@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | EE_Maintenance_Mode $maintenance_mode = null |
155 | 155 | ) { |
156 | 156 | // check if class object is instantiated |
157 | - if (! self::$_instance instanceof EE_System) { |
|
157 | + if ( ! self::$_instance instanceof EE_System) { |
|
158 | 158 | self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
159 | 159 | } |
160 | 160 | return self::$_instance; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
288 | 288 | add_action( |
289 | 289 | 'AHEE__EE_Capabilities__init_caps__before_initialization', |
290 | - function () { |
|
290 | + function() { |
|
291 | 291 | LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
292 | 292 | } |
293 | 293 | ); |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | { |
332 | 332 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
333 | 333 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
334 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
334 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | ); |
363 | 363 | static $brew; |
364 | 364 | if ($domain->isCaffeinated() && ! $brew instanceof EE_Brewing_Regular) { |
365 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
365 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
366 | 366 | /** @var EE_Brewing_Regular $brew */ |
367 | 367 | $brew = LoaderFactory::getLoader()->getShared(EE_Brewing_Regular::class); |
368 | 368 | $brew->initializePUE(); |
@@ -389,14 +389,14 @@ discard block |
||
389 | 389 | $load_callback, |
390 | 390 | $plugin_file_constant |
391 | 391 | ) { |
392 | - if (! defined($version_constant)) { |
|
392 | + if ( ! defined($version_constant)) { |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | $addon_version = constant($version_constant); |
396 | 396 | if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
397 | 397 | remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
398 | - if (! function_exists('deactivate_plugins')) { |
|
399 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
398 | + if ( ! function_exists('deactivate_plugins')) { |
|
399 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
400 | 400 | } |
401 | 401 | deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
402 | 402 | $this->request->unSetRequestParams(['activate', 'activate-multi'], true); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $min_version_required |
411 | 411 | ), |
412 | 412 | __FILE__, |
413 | - __FUNCTION__ . "({$addon_name})", |
|
413 | + __FUNCTION__."({$addon_name})", |
|
414 | 414 | __LINE__ |
415 | 415 | ); |
416 | 416 | EE_Error::get_notices(false, true); |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | true |
463 | 463 | ) |
464 | 464 | ) { |
465 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
465 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth/basic-auth.php'; |
|
466 | 466 | } |
467 | 467 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
468 | 468 | } |
@@ -564,11 +564,11 @@ discard block |
||
564 | 564 | private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
565 | 565 | { |
566 | 566 | do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
567 | - if (! $espresso_db_update) { |
|
567 | + if ( ! $espresso_db_update) { |
|
568 | 568 | $espresso_db_update = get_option('espresso_db_update'); |
569 | 569 | } |
570 | 570 | // check that option is an array |
571 | - if (! is_array($espresso_db_update)) { |
|
571 | + if ( ! is_array($espresso_db_update)) { |
|
572 | 572 | // if option is FALSE, then it never existed |
573 | 573 | if ($espresso_db_update === false) { |
574 | 574 | // make $espresso_db_update an array and save option with autoload OFF |
@@ -588,10 +588,10 @@ discard block |
||
588 | 588 | // so it must be numerically-indexed, where values are versions installed... |
589 | 589 | // fix it! |
590 | 590 | $version_string = $should_be_array; |
591 | - $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
591 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
592 | 592 | } else { |
593 | 593 | // ok it checks out |
594 | - $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
594 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
595 | 595 | } |
596 | 596 | } |
597 | 597 | $espresso_db_update = $corrected_db_update; |
@@ -675,13 +675,13 @@ discard block |
||
675 | 675 | */ |
676 | 676 | public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
677 | 677 | { |
678 | - if (! $version_history) { |
|
678 | + if ( ! $version_history) { |
|
679 | 679 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
680 | 680 | } |
681 | 681 | if ($current_version_to_add === null) { |
682 | 682 | $current_version_to_add = espresso_version(); |
683 | 683 | } |
684 | - $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
684 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
685 | 685 | // re-save |
686 | 686 | return update_option('espresso_db_update', $version_history); |
687 | 687 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | if ($activation_history_for_addon) { |
772 | 772 | // it exists, so this isn't a completely new install |
773 | 773 | // check if this version already in that list of previously installed versions |
774 | - if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
774 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
775 | 775 | // it a version we haven't seen before |
776 | 776 | if ($version_is_higher === 1) { |
777 | 777 | $req_type = EE_System::req_type_upgrade; |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | foreach ($activation_history as $version => $times_activated) { |
850 | 850 | // check there is a record of when this version was activated. Otherwise, |
851 | 851 | // mark it as unknown |
852 | - if (! $times_activated) { |
|
852 | + if ( ! $times_activated) { |
|
853 | 853 | $times_activated = array('unknown-date'); |
854 | 854 | } |
855 | 855 | if (is_string($times_activated)) { |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | private function _parse_model_names() |
953 | 953 | { |
954 | 954 | // get all the files in the EE_MODELS folder that end in .model.php |
955 | - $models = glob(EE_MODELS . '*.model.php'); |
|
955 | + $models = glob(EE_MODELS.'*.model.php'); |
|
956 | 956 | $model_names = array(); |
957 | 957 | $non_abstract_db_models = array(); |
958 | 958 | foreach ($models as $model) { |
@@ -961,9 +961,9 @@ discard block |
||
961 | 961 | $short_name = str_replace('EEM_', '', $classname); |
962 | 962 | $reflectionClass = new ReflectionClass($classname); |
963 | 963 | if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
964 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
964 | + $non_abstract_db_models[$short_name] = $classname; |
|
965 | 965 | } |
966 | - $model_names[ $short_name ] = $classname; |
|
966 | + $model_names[$short_name] = $classname; |
|
967 | 967 | } |
968 | 968 | $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
969 | 969 | $this->registry->non_abstract_db_models = apply_filters( |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
1051 | 1051 | 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
1052 | 1052 | ); |
1053 | - if (! empty($class_names)) { |
|
1053 | + if ( ! empty($class_names)) { |
|
1054 | 1054 | $msg = esc_html__( |
1055 | 1055 | 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
1056 | 1056 | 'event_espresso' |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
1063 | 1063 | '', |
1064 | 1064 | $class_name |
1065 | - ) . '</b></li>'; |
|
1065 | + ).'</b></li>'; |
|
1066 | 1066 | } |
1067 | 1067 | $msg .= '</ul>'; |
1068 | 1068 | $msg .= esc_html__( |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | private function _deactivate_incompatible_addons() |
1127 | 1127 | { |
1128 | 1128 | $incompatible_addons = get_option('ee_incompatible_addons', array()); |
1129 | - if (! empty($incompatible_addons)) { |
|
1129 | + if ( ! empty($incompatible_addons)) { |
|
1130 | 1130 | $active_plugins = get_option('active_plugins', array()); |
1131 | 1131 | foreach ($active_plugins as $active_plugin) { |
1132 | 1132 | foreach ($incompatible_addons as $incompatible_addon) { |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | do_action('AHEE__EE_System__core_loaded_and_ready'); |
1237 | 1237 | // always load template tags, because it's faster than checking if it's a front-end request, and many page |
1238 | 1238 | // builders require these even on the front-end |
1239 | - require_once EE_PUBLIC . 'template_tags.php'; |
|
1239 | + require_once EE_PUBLIC.'template_tags.php'; |
|
1240 | 1240 | do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
1241 | 1241 | } |
1242 | 1242 | |
@@ -1253,7 +1253,7 @@ discard block |
||
1253 | 1253 | do_action('AHEE__EE_System__initialize'); |
1254 | 1254 | add_filter( |
1255 | 1255 | 'safe_style_css', |
1256 | - function ($styles) { |
|
1256 | + function($styles) { |
|
1257 | 1257 | $styles[] = 'display'; |
1258 | 1258 | $styles[] = 'visibility'; |
1259 | 1259 | $styles[] = 'position'; |
@@ -1320,13 +1320,13 @@ discard block |
||
1320 | 1320 | public static function do_not_cache() |
1321 | 1321 | { |
1322 | 1322 | // set no cache constants |
1323 | - if (! defined('DONOTCACHEPAGE')) { |
|
1323 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
1324 | 1324 | define('DONOTCACHEPAGE', true); |
1325 | 1325 | } |
1326 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
1326 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
1327 | 1327 | define('DONOTCACHCEOBJECT', true); |
1328 | 1328 | } |
1329 | - if (! defined('DONOTCACHEDB')) { |
|
1329 | + if ( ! defined('DONOTCACHEDB')) { |
|
1330 | 1330 | define('DONOTCACHEDB', true); |
1331 | 1331 | } |
1332 | 1332 | // add no cache headers |
@@ -26,1370 +26,1370 @@ |
||
26 | 26 | */ |
27 | 27 | final class EE_System implements ResettableInterface |
28 | 28 | { |
29 | - /** |
|
30 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
31 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
32 | - */ |
|
33 | - const req_type_normal = 0; |
|
34 | - |
|
35 | - /** |
|
36 | - * Indicates this is a brand new installation of EE so we should install |
|
37 | - * tables and default data etc |
|
38 | - */ |
|
39 | - const req_type_new_activation = 1; |
|
40 | - |
|
41 | - /** |
|
42 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
43 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
44 | - * and that default data is setup too |
|
45 | - */ |
|
46 | - const req_type_reactivation = 2; |
|
47 | - |
|
48 | - /** |
|
49 | - * indicates that EE has been upgraded since its previous request. |
|
50 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
51 | - */ |
|
52 | - const req_type_upgrade = 3; |
|
53 | - |
|
54 | - /** |
|
55 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
56 | - */ |
|
57 | - const req_type_downgrade = 4; |
|
58 | - |
|
59 | - /** |
|
60 | - * @deprecated since version 4.6.0.dev.006 |
|
61 | - * Now whenever a new_activation is detected the request type is still just |
|
62 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
63 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
64 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
65 | - * (Specifically, when the migration manager indicates migrations are finished |
|
66 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
67 | - */ |
|
68 | - const req_type_activation_but_not_installed = 5; |
|
69 | - |
|
70 | - /** |
|
71 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
72 | - */ |
|
73 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var EE_System $_instance |
|
77 | - */ |
|
78 | - private static $_instance; |
|
79 | - |
|
80 | - /** |
|
81 | - * @var EE_Registry $registry |
|
82 | - */ |
|
83 | - private $registry; |
|
84 | - |
|
85 | - /** |
|
86 | - * @var LoaderInterface $loader |
|
87 | - */ |
|
88 | - private $loader; |
|
89 | - |
|
90 | - /** |
|
91 | - * @var EE_Capabilities $capabilities |
|
92 | - */ |
|
93 | - private $capabilities; |
|
94 | - |
|
95 | - /** |
|
96 | - * @var RequestInterface $request |
|
97 | - */ |
|
98 | - private $request; |
|
99 | - |
|
100 | - /** |
|
101 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
102 | - */ |
|
103 | - private $maintenance_mode; |
|
104 | - |
|
105 | - /** |
|
106 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
107 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
108 | - * |
|
109 | - * @var int $_req_type |
|
110 | - */ |
|
111 | - private $_req_type; |
|
112 | - |
|
113 | - /** |
|
114 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
115 | - * |
|
116 | - * @var boolean $_major_version_change |
|
117 | - */ |
|
118 | - private $_major_version_change = false; |
|
119 | - |
|
120 | - /** |
|
121 | - * A Context DTO dedicated solely to identifying the current request type. |
|
122 | - * |
|
123 | - * @var RequestTypeContextCheckerInterface $request_type |
|
124 | - */ |
|
125 | - private $request_type; |
|
126 | - |
|
127 | - /** |
|
128 | - * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes |
|
129 | - */ |
|
130 | - private $register_custom_post_types; |
|
131 | - |
|
132 | - /** |
|
133 | - * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies |
|
134 | - */ |
|
135 | - private $register_custom_taxonomies; |
|
136 | - |
|
137 | - /** |
|
138 | - * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms |
|
139 | - */ |
|
140 | - private $register_custom_taxonomy_terms; |
|
141 | - |
|
142 | - /** |
|
143 | - * @singleton method used to instantiate class object |
|
144 | - * @param EE_Registry|null $registry |
|
145 | - * @param LoaderInterface|null $loader |
|
146 | - * @param RequestInterface|null $request |
|
147 | - * @param EE_Maintenance_Mode|null $maintenance_mode |
|
148 | - * @return EE_System |
|
149 | - */ |
|
150 | - public static function instance( |
|
151 | - EE_Registry $registry = null, |
|
152 | - LoaderInterface $loader = null, |
|
153 | - RequestInterface $request = null, |
|
154 | - EE_Maintenance_Mode $maintenance_mode = null |
|
155 | - ) { |
|
156 | - // check if class object is instantiated |
|
157 | - if (! self::$_instance instanceof EE_System) { |
|
158 | - self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
|
159 | - } |
|
160 | - return self::$_instance; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * resets the instance and returns it |
|
166 | - * |
|
167 | - * @return EE_System |
|
168 | - */ |
|
169 | - public static function reset() |
|
170 | - { |
|
171 | - self::$_instance->_req_type = null; |
|
172 | - // make sure none of the old hooks are left hanging around |
|
173 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
174 | - // we need to reset the migration manager in order for it to detect DMSs properly |
|
175 | - EE_Data_Migration_Manager::reset(); |
|
176 | - self::instance()->detect_activations_or_upgrades(); |
|
177 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
178 | - return self::instance(); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * sets hooks for running rest of system |
|
184 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
185 | - * starting EE Addons from any other point may lead to problems |
|
186 | - * |
|
187 | - * @param EE_Registry $registry |
|
188 | - * @param LoaderInterface $loader |
|
189 | - * @param RequestInterface $request |
|
190 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
191 | - */ |
|
192 | - private function __construct( |
|
193 | - EE_Registry $registry, |
|
194 | - LoaderInterface $loader, |
|
195 | - RequestInterface $request, |
|
196 | - EE_Maintenance_Mode $maintenance_mode |
|
197 | - ) { |
|
198 | - $this->registry = $registry; |
|
199 | - $this->loader = $loader; |
|
200 | - $this->request = $request; |
|
201 | - $this->maintenance_mode = $maintenance_mode; |
|
202 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
203 | - add_action( |
|
204 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
205 | - array($this, 'loadCapabilities'), |
|
206 | - 5 |
|
207 | - ); |
|
208 | - add_action( |
|
209 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
210 | - array($this, 'loadCommandBus'), |
|
211 | - 7 |
|
212 | - ); |
|
213 | - add_action( |
|
214 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
215 | - array($this, 'loadPluginApi'), |
|
216 | - 9 |
|
217 | - ); |
|
218 | - // give caff stuff a chance to play during the activation process too. |
|
219 | - add_action( |
|
220 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
221 | - [$this, 'brewCaffeinated'], |
|
222 | - 9 |
|
223 | - ); |
|
224 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
225 | - add_action( |
|
226 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
227 | - array($this, 'load_espresso_addons') |
|
228 | - ); |
|
229 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
230 | - // because the newly-activated addon didn't get a chance to run at all |
|
231 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
232 | - // detect whether install or upgrade |
|
233 | - add_action( |
|
234 | - 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
235 | - array($this, 'detect_activations_or_upgrades'), |
|
236 | - 3 |
|
237 | - ); |
|
238 | - // load EE_Config, EE_Textdomain, etc |
|
239 | - add_action( |
|
240 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
241 | - array($this, 'load_core_configuration'), |
|
242 | - 5 |
|
243 | - ); |
|
244 | - // load specifications for matching routes to current request |
|
245 | - add_action( |
|
246 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
247 | - array($this, 'loadRouteMatchSpecifications') |
|
248 | - ); |
|
249 | - // load specifications for custom post types |
|
250 | - add_action( |
|
251 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
252 | - array($this, 'loadCustomPostTypes') |
|
253 | - ); |
|
254 | - // load EE_Config, EE_Textdomain, etc |
|
255 | - add_action( |
|
256 | - 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
257 | - array($this, 'register_shortcodes_modules_and_widgets'), |
|
258 | - 7 |
|
259 | - ); |
|
260 | - // you wanna get going? I wanna get going... let's get going! |
|
261 | - add_action( |
|
262 | - 'AHEE__EE_Bootstrap__brew_espresso', |
|
263 | - array($this, 'brew_espresso'), |
|
264 | - 9 |
|
265 | - ); |
|
266 | - // other housekeeping |
|
267 | - // exclude EE critical pages from wp_list_pages |
|
268 | - add_filter( |
|
269 | - 'wp_list_pages_excludes', |
|
270 | - array($this, 'remove_pages_from_wp_list_pages'), |
|
271 | - 10 |
|
272 | - ); |
|
273 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
274 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
275 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
276 | - } |
|
277 | - |
|
278 | - |
|
279 | - /** |
|
280 | - * load and setup EE_Capabilities |
|
281 | - * |
|
282 | - * @return void |
|
283 | - * @throws EE_Error |
|
284 | - */ |
|
285 | - public function loadCapabilities() |
|
286 | - { |
|
287 | - $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
288 | - add_action( |
|
289 | - 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
290 | - function () { |
|
291 | - LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
292 | - } |
|
293 | - ); |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * create and cache the CommandBus, and also add middleware |
|
299 | - * The CapChecker middleware requires the use of EE_Capabilities |
|
300 | - * which is why we need to load the CommandBus after Caps are set up |
|
301 | - * CommandBus middleware operate FIFO - First In First Out |
|
302 | - * so LocateMovedCommands will run first in order to return any new commands |
|
303 | - * |
|
304 | - * @return void |
|
305 | - * @throws EE_Error |
|
306 | - */ |
|
307 | - public function loadCommandBus() |
|
308 | - { |
|
309 | - $this->loader->getShared( |
|
310 | - 'CommandBusInterface', |
|
311 | - array( |
|
312 | - null, |
|
313 | - apply_filters( |
|
314 | - 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
315 | - array( |
|
316 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\LocateMovedCommands'), |
|
317 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
318 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
319 | - ) |
|
320 | - ), |
|
321 | - ) |
|
322 | - ); |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @return void |
|
328 | - * @throws EE_Error |
|
329 | - */ |
|
330 | - public function loadPluginApi() |
|
331 | - { |
|
332 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
333 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
334 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
340 | - * that need to be setup before our EE_System launches. |
|
341 | - * |
|
342 | - * @return void |
|
343 | - * @throws DomainException |
|
344 | - * @throws InvalidArgumentException |
|
345 | - * @throws InvalidDataTypeException |
|
346 | - * @throws InvalidInterfaceException |
|
347 | - * @throws InvalidClassException |
|
348 | - * @throws InvalidFilePathException |
|
349 | - * @throws EE_Error |
|
350 | - */ |
|
351 | - public function brewCaffeinated() |
|
352 | - { |
|
353 | - /** @var Domain $domain */ |
|
354 | - $domain = DomainFactory::getShared( |
|
355 | - new FullyQualifiedName( |
|
356 | - 'EventEspresso\core\domain\Domain' |
|
357 | - ), |
|
358 | - [ |
|
359 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
360 | - Version::fromString(espresso_version()), |
|
361 | - ] |
|
362 | - ); |
|
363 | - static $brew; |
|
364 | - if ($domain->isCaffeinated() && ! $brew instanceof EE_Brewing_Regular) { |
|
365 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
366 | - /** @var EE_Brewing_Regular $brew */ |
|
367 | - $brew = LoaderFactory::getLoader()->getShared(EE_Brewing_Regular::class); |
|
368 | - $brew->initializePUE(); |
|
369 | - add_action( |
|
370 | - 'AHEE__EE_System__load_core_configuration__begin', |
|
371 | - [$brew, 'caffeinated'] |
|
372 | - ); |
|
373 | - } |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * @param string $addon_name |
|
379 | - * @param string $version_constant |
|
380 | - * @param string $min_version_required |
|
381 | - * @param string $load_callback |
|
382 | - * @param string $plugin_file_constant |
|
383 | - * @return void |
|
384 | - */ |
|
385 | - private function deactivateIncompatibleAddon( |
|
386 | - $addon_name, |
|
387 | - $version_constant, |
|
388 | - $min_version_required, |
|
389 | - $load_callback, |
|
390 | - $plugin_file_constant |
|
391 | - ) { |
|
392 | - if (! defined($version_constant)) { |
|
393 | - return; |
|
394 | - } |
|
395 | - $addon_version = constant($version_constant); |
|
396 | - if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
397 | - remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
398 | - if (! function_exists('deactivate_plugins')) { |
|
399 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
400 | - } |
|
401 | - deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
402 | - $this->request->unSetRequestParams(['activate', 'activate-multi'], true); |
|
403 | - EE_Error::add_error( |
|
404 | - sprintf( |
|
405 | - esc_html__( |
|
406 | - 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
407 | - 'event_espresso' |
|
408 | - ), |
|
409 | - $addon_name, |
|
410 | - $min_version_required |
|
411 | - ), |
|
412 | - __FILE__, |
|
413 | - __FUNCTION__ . "({$addon_name})", |
|
414 | - __LINE__ |
|
415 | - ); |
|
416 | - EE_Error::get_notices(false, true); |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * load_espresso_addons |
|
423 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
424 | - * this is hooked into both: |
|
425 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
426 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
427 | - * and the WP 'activate_plugin' hook point |
|
428 | - * |
|
429 | - * @access public |
|
430 | - * @return void |
|
431 | - */ |
|
432 | - public function load_espresso_addons() |
|
433 | - { |
|
434 | - $this->deactivateIncompatibleAddon( |
|
435 | - 'Wait Lists', |
|
436 | - 'EE_WAIT_LISTS_VERSION', |
|
437 | - '1.0.0.beta.074', |
|
438 | - 'load_espresso_wait_lists', |
|
439 | - 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
440 | - ); |
|
441 | - $this->deactivateIncompatibleAddon( |
|
442 | - 'Automated Upcoming Event Notifications', |
|
443 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
444 | - '1.0.0.beta.091', |
|
445 | - 'load_espresso_automated_upcoming_event_notification', |
|
446 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
447 | - ); |
|
448 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
449 | - // if the WP API basic auth plugin isn't already loaded, load it now. |
|
450 | - // We want it for mobile apps. Just include the entire plugin |
|
451 | - // also, don't load the basic auth when a plugin is getting activated, because |
|
452 | - // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
453 | - // and causes a fatal error |
|
454 | - if ( |
|
455 | - ($this->request->isWordPressApi() || $this->request->isApi()) |
|
456 | - && $this->request->getRequestParam('activate') !== 'true' |
|
457 | - && ! function_exists('json_basic_auth_handler') |
|
458 | - && ! function_exists('json_basic_auth_error') |
|
459 | - && ! in_array( |
|
460 | - $this->request->getRequestParam('action'), |
|
461 | - array('activate', 'activate-selected'), |
|
462 | - true |
|
463 | - ) |
|
464 | - ) { |
|
465 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
466 | - } |
|
467 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
468 | - } |
|
469 | - |
|
470 | - |
|
471 | - /** |
|
472 | - * detect_activations_or_upgrades |
|
473 | - * Checks for activation or upgrade of core first; |
|
474 | - * then also checks if any registered addons have been activated or upgraded |
|
475 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
476 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
477 | - * |
|
478 | - * @access public |
|
479 | - * @return void |
|
480 | - */ |
|
481 | - public function detect_activations_or_upgrades() |
|
482 | - { |
|
483 | - // first off: let's make sure to handle core |
|
484 | - $this->detect_if_activation_or_upgrade(); |
|
485 | - foreach ($this->registry->addons as $addon) { |
|
486 | - if ($addon instanceof EE_Addon) { |
|
487 | - // detect teh request type for that addon |
|
488 | - $addon->detect_req_type(); |
|
489 | - } |
|
490 | - } |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * detect_if_activation_or_upgrade |
|
496 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
497 | - * and either setting up the DB or setting up maintenance mode etc. |
|
498 | - * |
|
499 | - * @access public |
|
500 | - * @return void |
|
501 | - */ |
|
502 | - public function detect_if_activation_or_upgrade() |
|
503 | - { |
|
504 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
505 | - // check if db has been updated, or if its a brand-new installation |
|
506 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
507 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
508 | - // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
509 | - switch ($request_type) { |
|
510 | - case EE_System::req_type_new_activation: |
|
511 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
512 | - $this->_handle_core_version_change($espresso_db_update); |
|
513 | - break; |
|
514 | - case EE_System::req_type_reactivation: |
|
515 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
516 | - $this->_handle_core_version_change($espresso_db_update); |
|
517 | - break; |
|
518 | - case EE_System::req_type_upgrade: |
|
519 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
520 | - // migrations may be required now that we've upgraded |
|
521 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
522 | - $this->_handle_core_version_change($espresso_db_update); |
|
523 | - break; |
|
524 | - case EE_System::req_type_downgrade: |
|
525 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
526 | - // its possible migrations are no longer required |
|
527 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
528 | - $this->_handle_core_version_change($espresso_db_update); |
|
529 | - break; |
|
530 | - case EE_System::req_type_normal: |
|
531 | - default: |
|
532 | - break; |
|
533 | - } |
|
534 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - /** |
|
539 | - * Updates the list of installed versions and sets hooks for |
|
540 | - * initializing the database later during the request |
|
541 | - * |
|
542 | - * @param array $espresso_db_update |
|
543 | - */ |
|
544 | - private function _handle_core_version_change($espresso_db_update) |
|
545 | - { |
|
546 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
547 | - // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
548 | - add_action( |
|
549 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
550 | - array($this, 'initialize_db_if_no_migrations_required') |
|
551 | - ); |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - /** |
|
556 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
557 | - * information about what versions of EE have been installed and activated, |
|
558 | - * NOT necessarily the state of the database |
|
559 | - * |
|
560 | - * @param mixed $espresso_db_update the value of the WordPress option. |
|
561 | - * If not supplied, fetches it from the options table |
|
562 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
563 | - */ |
|
564 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
565 | - { |
|
566 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
567 | - if (! $espresso_db_update) { |
|
568 | - $espresso_db_update = get_option('espresso_db_update'); |
|
569 | - } |
|
570 | - // check that option is an array |
|
571 | - if (! is_array($espresso_db_update)) { |
|
572 | - // if option is FALSE, then it never existed |
|
573 | - if ($espresso_db_update === false) { |
|
574 | - // make $espresso_db_update an array and save option with autoload OFF |
|
575 | - $espresso_db_update = array(); |
|
576 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
577 | - } else { |
|
578 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
579 | - $espresso_db_update = array($espresso_db_update => array()); |
|
580 | - update_option('espresso_db_update', $espresso_db_update); |
|
581 | - } |
|
582 | - } else { |
|
583 | - $corrected_db_update = array(); |
|
584 | - // if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
585 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
586 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
587 | - // the key is an int, and the value IS NOT an array |
|
588 | - // so it must be numerically-indexed, where values are versions installed... |
|
589 | - // fix it! |
|
590 | - $version_string = $should_be_array; |
|
591 | - $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
592 | - } else { |
|
593 | - // ok it checks out |
|
594 | - $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
595 | - } |
|
596 | - } |
|
597 | - $espresso_db_update = $corrected_db_update; |
|
598 | - update_option('espresso_db_update', $espresso_db_update); |
|
599 | - } |
|
600 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
601 | - return $espresso_db_update; |
|
602 | - } |
|
603 | - |
|
604 | - |
|
605 | - /** |
|
606 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
607 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
608 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
609 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
610 | - * so that it will be done when migrations are finished |
|
611 | - * |
|
612 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
613 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
614 | - * This is a resource-intensive job |
|
615 | - * so we prefer to only do it when necessary |
|
616 | - * @return void |
|
617 | - * @throws EE_Error |
|
618 | - */ |
|
619 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
620 | - { |
|
621 | - $request_type = $this->detect_req_type(); |
|
622 | - // only initialize system if we're not in maintenance mode. |
|
623 | - if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
624 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
625 | - $rewrite_rules = $this->loader->getShared( |
|
626 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
627 | - ); |
|
628 | - $rewrite_rules->flush(); |
|
629 | - if ($verify_schema) { |
|
630 | - EEH_Activation::initialize_db_and_folders(); |
|
631 | - } |
|
632 | - EEH_Activation::initialize_db_content(); |
|
633 | - EEH_Activation::system_initialization(); |
|
634 | - if ($initialize_addons_too) { |
|
635 | - $this->initialize_addons(); |
|
636 | - } |
|
637 | - } else { |
|
638 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
639 | - } |
|
640 | - if ( |
|
641 | - $request_type === EE_System::req_type_new_activation |
|
642 | - || $request_type === EE_System::req_type_reactivation |
|
643 | - || ( |
|
644 | - $request_type === EE_System::req_type_upgrade |
|
645 | - && $this->is_major_version_change() |
|
646 | - ) |
|
647 | - ) { |
|
648 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
649 | - } |
|
650 | - } |
|
651 | - |
|
652 | - |
|
653 | - /** |
|
654 | - * Initializes the db for all registered addons |
|
655 | - * |
|
656 | - * @throws EE_Error |
|
657 | - */ |
|
658 | - public function initialize_addons() |
|
659 | - { |
|
660 | - // foreach registered addon, make sure its db is up-to-date too |
|
661 | - foreach ($this->registry->addons as $addon) { |
|
662 | - if ($addon instanceof EE_Addon) { |
|
663 | - $addon->initialize_db_if_no_migrations_required(); |
|
664 | - } |
|
665 | - } |
|
666 | - } |
|
667 | - |
|
668 | - |
|
669 | - /** |
|
670 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
671 | - * |
|
672 | - * @param array $version_history |
|
673 | - * @param string $current_version_to_add version to be added to the version history |
|
674 | - * @return boolean success as to whether or not this option was changed |
|
675 | - */ |
|
676 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
677 | - { |
|
678 | - if (! $version_history) { |
|
679 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
680 | - } |
|
681 | - if ($current_version_to_add === null) { |
|
682 | - $current_version_to_add = espresso_version(); |
|
683 | - } |
|
684 | - $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
685 | - // re-save |
|
686 | - return update_option('espresso_db_update', $version_history); |
|
687 | - } |
|
688 | - |
|
689 | - |
|
690 | - /** |
|
691 | - * Detects if the current version indicated in the has existed in the list of |
|
692 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
693 | - * |
|
694 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
695 | - * If not supplied, fetches it from the options table. |
|
696 | - * Also, caches its result so later parts of the code can also know whether |
|
697 | - * there's been an update or not. This way we can add the current version to |
|
698 | - * espresso_db_update, but still know if this is a new install or not |
|
699 | - * @return int one of the constants on EE_System::req_type_ |
|
700 | - */ |
|
701 | - public function detect_req_type($espresso_db_update = null) |
|
702 | - { |
|
703 | - if ($this->_req_type === null) { |
|
704 | - $espresso_db_update = ! empty($espresso_db_update) |
|
705 | - ? $espresso_db_update |
|
706 | - : $this->fix_espresso_db_upgrade_option(); |
|
707 | - $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
708 | - $espresso_db_update, |
|
709 | - 'ee_espresso_activation', |
|
710 | - espresso_version() |
|
711 | - ); |
|
712 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
713 | - $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal); |
|
714 | - } |
|
715 | - return $this->_req_type; |
|
716 | - } |
|
717 | - |
|
718 | - |
|
719 | - /** |
|
720 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
721 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
722 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
723 | - * |
|
724 | - * @param $activation_history |
|
725 | - * @return bool |
|
726 | - */ |
|
727 | - private function _detect_major_version_change($activation_history) |
|
728 | - { |
|
729 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
730 | - $previous_version_parts = explode('.', $previous_version); |
|
731 | - $current_version_parts = explode('.', espresso_version()); |
|
732 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
733 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
734 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
735 | - ); |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * Returns true if either the major or minor version of EE changed during this request. |
|
741 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
742 | - * |
|
743 | - * @return bool |
|
744 | - */ |
|
745 | - public function is_major_version_change() |
|
746 | - { |
|
747 | - return $this->_major_version_change; |
|
748 | - } |
|
749 | - |
|
750 | - |
|
751 | - /** |
|
752 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
753 | - * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
754 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
755 | - * just activated to (for core that will always be espresso_version()) |
|
756 | - * |
|
757 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
758 | - * ee plugin. for core that's 'espresso_db_update' |
|
759 | - * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
760 | - * indicate that this plugin was just activated |
|
761 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
762 | - * espresso_version()) |
|
763 | - * @return int one of the constants on EE_System::req_type_* |
|
764 | - */ |
|
765 | - public static function detect_req_type_given_activation_history( |
|
766 | - $activation_history_for_addon, |
|
767 | - $activation_indicator_option_name, |
|
768 | - $version_to_upgrade_to |
|
769 | - ) { |
|
770 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
771 | - if ($activation_history_for_addon) { |
|
772 | - // it exists, so this isn't a completely new install |
|
773 | - // check if this version already in that list of previously installed versions |
|
774 | - if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
775 | - // it a version we haven't seen before |
|
776 | - if ($version_is_higher === 1) { |
|
777 | - $req_type = EE_System::req_type_upgrade; |
|
778 | - } else { |
|
779 | - $req_type = EE_System::req_type_downgrade; |
|
780 | - } |
|
781 | - delete_option($activation_indicator_option_name); |
|
782 | - } else { |
|
783 | - // its not an update. maybe a reactivation? |
|
784 | - if (get_option($activation_indicator_option_name, false)) { |
|
785 | - if ($version_is_higher === -1) { |
|
786 | - $req_type = EE_System::req_type_downgrade; |
|
787 | - } elseif ($version_is_higher === 0) { |
|
788 | - // we've seen this version before, but it's an activation. must be a reactivation |
|
789 | - $req_type = EE_System::req_type_reactivation; |
|
790 | - } else {// $version_is_higher === 1 |
|
791 | - $req_type = EE_System::req_type_upgrade; |
|
792 | - } |
|
793 | - delete_option($activation_indicator_option_name); |
|
794 | - } else { |
|
795 | - // we've seen this version before and the activation indicate doesn't show it was just activated |
|
796 | - if ($version_is_higher === -1) { |
|
797 | - $req_type = EE_System::req_type_downgrade; |
|
798 | - } elseif ($version_is_higher === 0) { |
|
799 | - // we've seen this version before and it's not an activation. its normal request |
|
800 | - $req_type = EE_System::req_type_normal; |
|
801 | - } else {// $version_is_higher === 1 |
|
802 | - $req_type = EE_System::req_type_upgrade; |
|
803 | - } |
|
804 | - } |
|
805 | - } |
|
806 | - } else { |
|
807 | - // brand new install |
|
808 | - $req_type = EE_System::req_type_new_activation; |
|
809 | - delete_option($activation_indicator_option_name); |
|
810 | - } |
|
811 | - return $req_type; |
|
812 | - } |
|
813 | - |
|
814 | - |
|
815 | - /** |
|
816 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
817 | - * the $activation_history_for_addon |
|
818 | - * |
|
819 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
820 | - * sometimes containing 'unknown-date' |
|
821 | - * @param string $version_to_upgrade_to (current version) |
|
822 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
823 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
824 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
825 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
826 | - */ |
|
827 | - private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
828 | - { |
|
829 | - // find the most recently-activated version |
|
830 | - $most_recently_active_version = |
|
831 | - EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
832 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
833 | - } |
|
834 | - |
|
835 | - |
|
836 | - /** |
|
837 | - * Gets the most recently active version listed in the activation history, |
|
838 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
839 | - * |
|
840 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
841 | - * sometimes containing 'unknown-date' |
|
842 | - * @return string |
|
843 | - */ |
|
844 | - private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
845 | - { |
|
846 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
847 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
848 | - if (is_array($activation_history)) { |
|
849 | - foreach ($activation_history as $version => $times_activated) { |
|
850 | - // check there is a record of when this version was activated. Otherwise, |
|
851 | - // mark it as unknown |
|
852 | - if (! $times_activated) { |
|
853 | - $times_activated = array('unknown-date'); |
|
854 | - } |
|
855 | - if (is_string($times_activated)) { |
|
856 | - $times_activated = array($times_activated); |
|
857 | - } |
|
858 | - foreach ($times_activated as $an_activation) { |
|
859 | - if ( |
|
860 | - $an_activation !== 'unknown-date' |
|
861 | - && $an_activation |
|
862 | - > $most_recently_active_version_activation |
|
863 | - ) { |
|
864 | - $most_recently_active_version = $version; |
|
865 | - $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
866 | - ? '1970-01-01 00:00:00' |
|
867 | - : $an_activation; |
|
868 | - } |
|
869 | - } |
|
870 | - } |
|
871 | - } |
|
872 | - return $most_recently_active_version; |
|
873 | - } |
|
874 | - |
|
875 | - |
|
876 | - /** |
|
877 | - * This redirects to the about EE page after activation |
|
878 | - * |
|
879 | - * @return void |
|
880 | - */ |
|
881 | - public function redirect_to_about_ee() |
|
882 | - { |
|
883 | - $notices = EE_Error::get_notices(false); |
|
884 | - // if current user is an admin and it's not an ajax or rest request |
|
885 | - if ( |
|
886 | - ! isset($notices['errors']) |
|
887 | - && $this->request->isAdmin() |
|
888 | - && apply_filters( |
|
889 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
890 | - $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
891 | - ) |
|
892 | - ) { |
|
893 | - $query_params = array('page' => 'espresso_about'); |
|
894 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
895 | - $query_params['new_activation'] = true; |
|
896 | - } |
|
897 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
898 | - $query_params['reactivation'] = true; |
|
899 | - } |
|
900 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
901 | - wp_safe_redirect($url); |
|
902 | - exit(); |
|
903 | - } |
|
904 | - } |
|
905 | - |
|
906 | - |
|
907 | - /** |
|
908 | - * load_core_configuration |
|
909 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
910 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
911 | - * |
|
912 | - * @return void |
|
913 | - * @throws ReflectionException |
|
914 | - * @throws Exception |
|
915 | - */ |
|
916 | - public function load_core_configuration() |
|
917 | - { |
|
918 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
919 | - $this->loader->getShared('EE_Load_Textdomain'); |
|
920 | - // load textdomain |
|
921 | - EE_Load_Textdomain::load_textdomain(); |
|
922 | - // load and setup EE_Config and EE_Network_Config |
|
923 | - $config = $this->loader->getShared('EE_Config'); |
|
924 | - $this->loader->getShared('EE_Network_Config'); |
|
925 | - // setup autoloaders |
|
926 | - // enable logging? |
|
927 | - $this->loader->getShared('EventEspresso\core\services\orm\TrashLogger'); |
|
928 | - if ($config->admin->use_remote_logging) { |
|
929 | - $this->loader->getShared('EE_Log'); |
|
930 | - } |
|
931 | - // check for activation errors |
|
932 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
933 | - if ($activation_errors) { |
|
934 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
935 | - update_option('ee_plugin_activation_errors', false); |
|
936 | - } |
|
937 | - // get model names |
|
938 | - $this->_parse_model_names(); |
|
939 | - // configure custom post type definitions |
|
940 | - $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'); |
|
941 | - $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'); |
|
942 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
943 | - } |
|
944 | - |
|
945 | - |
|
946 | - /** |
|
947 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
948 | - * |
|
949 | - * @return void |
|
950 | - * @throws ReflectionException |
|
951 | - */ |
|
952 | - private function _parse_model_names() |
|
953 | - { |
|
954 | - // get all the files in the EE_MODELS folder that end in .model.php |
|
955 | - $models = glob(EE_MODELS . '*.model.php'); |
|
956 | - $model_names = array(); |
|
957 | - $non_abstract_db_models = array(); |
|
958 | - foreach ($models as $model) { |
|
959 | - // get model classname |
|
960 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
961 | - $short_name = str_replace('EEM_', '', $classname); |
|
962 | - $reflectionClass = new ReflectionClass($classname); |
|
963 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
964 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
965 | - } |
|
966 | - $model_names[ $short_name ] = $classname; |
|
967 | - } |
|
968 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
969 | - $this->registry->non_abstract_db_models = apply_filters( |
|
970 | - 'FHEE__EE_System__parse_implemented_model_names', |
|
971 | - $non_abstract_db_models |
|
972 | - ); |
|
973 | - } |
|
974 | - |
|
975 | - |
|
976 | - /** |
|
977 | - * @since 4.9.71.p |
|
978 | - * @throws Exception |
|
979 | - */ |
|
980 | - public function loadRouteMatchSpecifications() |
|
981 | - { |
|
982 | - try { |
|
983 | - $this->loader->getShared( |
|
984 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' |
|
985 | - ); |
|
986 | - } catch (Exception $exception) { |
|
987 | - new ExceptionStackTraceDisplay($exception); |
|
988 | - } |
|
989 | - do_action('AHEE__EE_System__loadRouteMatchSpecifications'); |
|
990 | - } |
|
991 | - |
|
992 | - |
|
993 | - /** |
|
994 | - * loading CPT related classes earlier so that their definitions are available |
|
995 | - * but not performing any actual registration with WP core until load_CPTs_and_session() is called |
|
996 | - * |
|
997 | - * @since 4.10.21.p |
|
998 | - */ |
|
999 | - public function loadCustomPostTypes() |
|
1000 | - { |
|
1001 | - $this->register_custom_taxonomies = $this->loader->getShared( |
|
1002 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
1003 | - ); |
|
1004 | - $this->register_custom_post_types = $this->loader->getShared( |
|
1005 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
1006 | - ); |
|
1007 | - $this->register_custom_taxonomy_terms = $this->loader->getShared( |
|
1008 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
1009 | - ); |
|
1010 | - // integrate WP_Query with the EE models |
|
1011 | - $this->loader->getShared('EE_CPT_Strategy'); |
|
1012 | - // load legacy EE_Request_Handler in case add-ons still need it |
|
1013 | - $this->loader->getShared('EE_Request_Handler'); |
|
1014 | - } |
|
1015 | - |
|
1016 | - |
|
1017 | - /** |
|
1018 | - * register_shortcodes_modules_and_widgets |
|
1019 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
1020 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
1021 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
1022 | - * |
|
1023 | - * @access public |
|
1024 | - * @return void |
|
1025 | - * @throws Exception |
|
1026 | - */ |
|
1027 | - public function register_shortcodes_modules_and_widgets() |
|
1028 | - { |
|
1029 | - if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAjax()) { |
|
1030 | - // load, register, and add shortcodes the new way |
|
1031 | - $this->loader->getShared('EventEspresso\core\services\shortcodes\ShortcodesManager'); |
|
1032 | - } |
|
1033 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
1034 | - // check for addons using old hook point |
|
1035 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
1036 | - $this->_incompatible_addon_error(); |
|
1037 | - } |
|
1038 | - } |
|
1039 | - |
|
1040 | - |
|
1041 | - /** |
|
1042 | - * _incompatible_addon_error |
|
1043 | - * |
|
1044 | - * @access public |
|
1045 | - * @return void |
|
1046 | - */ |
|
1047 | - private function _incompatible_addon_error() |
|
1048 | - { |
|
1049 | - // get array of classes hooking into here |
|
1050 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
1051 | - 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
1052 | - ); |
|
1053 | - if (! empty($class_names)) { |
|
1054 | - $msg = esc_html__( |
|
1055 | - 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
1056 | - 'event_espresso' |
|
1057 | - ); |
|
1058 | - $msg .= '<ul>'; |
|
1059 | - foreach ($class_names as $class_name) { |
|
1060 | - $msg .= '<li><b>Event Espresso - ' |
|
1061 | - . str_replace( |
|
1062 | - array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
|
1063 | - '', |
|
1064 | - $class_name |
|
1065 | - ) . '</b></li>'; |
|
1066 | - } |
|
1067 | - $msg .= '</ul>'; |
|
1068 | - $msg .= esc_html__( |
|
1069 | - 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
1070 | - 'event_espresso' |
|
1071 | - ); |
|
1072 | - // save list of incompatible addons to wp-options for later use |
|
1073 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
1074 | - if (is_admin()) { |
|
1075 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1076 | - } |
|
1077 | - } |
|
1078 | - } |
|
1079 | - |
|
1080 | - |
|
1081 | - /** |
|
1082 | - * brew_espresso |
|
1083 | - * begins the process of setting hooks for initializing EE in the correct order |
|
1084 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
1085 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
1086 | - * |
|
1087 | - * @return void |
|
1088 | - */ |
|
1089 | - public function brew_espresso() |
|
1090 | - { |
|
1091 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
1092 | - // load some final core systems |
|
1093 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
1094 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
1095 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
1096 | - add_action('init', array($this, 'load_controllers'), 7); |
|
1097 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
1098 | - add_action('init', array($this, 'initialize'), 10); |
|
1099 | - add_action('init', array($this, 'initialize_last'), 100); |
|
1100 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
1101 | - } |
|
1102 | - |
|
1103 | - |
|
1104 | - /** |
|
1105 | - * set_hooks_for_core |
|
1106 | - * |
|
1107 | - * @access public |
|
1108 | - * @return void |
|
1109 | - * @throws EE_Error |
|
1110 | - */ |
|
1111 | - public function set_hooks_for_core() |
|
1112 | - { |
|
1113 | - $this->_deactivate_incompatible_addons(); |
|
1114 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
1115 | - $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan'); |
|
1116 | - // caps need to be initialized on every request so that capability maps are set. |
|
1117 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
1118 | - $this->registry->CAP->init_caps(); |
|
1119 | - } |
|
1120 | - |
|
1121 | - |
|
1122 | - /** |
|
1123 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
1124 | - * deactivates any addons considered incompatible with the current version of EE |
|
1125 | - */ |
|
1126 | - private function _deactivate_incompatible_addons() |
|
1127 | - { |
|
1128 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
1129 | - if (! empty($incompatible_addons)) { |
|
1130 | - $active_plugins = get_option('active_plugins', array()); |
|
1131 | - foreach ($active_plugins as $active_plugin) { |
|
1132 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
1133 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
1134 | - $this->request->unSetRequestParams(['activate'], true); |
|
1135 | - espresso_deactivate_plugin($active_plugin); |
|
1136 | - } |
|
1137 | - } |
|
1138 | - } |
|
1139 | - } |
|
1140 | - } |
|
1141 | - |
|
1142 | - |
|
1143 | - /** |
|
1144 | - * perform_activations_upgrades_and_migrations |
|
1145 | - * |
|
1146 | - * @access public |
|
1147 | - * @return void |
|
1148 | - */ |
|
1149 | - public function perform_activations_upgrades_and_migrations() |
|
1150 | - { |
|
1151 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
1152 | - } |
|
1153 | - |
|
1154 | - |
|
1155 | - /** |
|
1156 | - * @return void |
|
1157 | - * @throws DomainException |
|
1158 | - */ |
|
1159 | - public function load_CPTs_and_session() |
|
1160 | - { |
|
1161 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
1162 | - $this->register_custom_taxonomies->registerCustomTaxonomies(); |
|
1163 | - $this->register_custom_post_types->registerCustomPostTypes(); |
|
1164 | - $this->register_custom_taxonomy_terms->registerCustomTaxonomyTerms(); |
|
1165 | - // load legacy Custom Post Types and Taxonomies |
|
1166 | - $this->loader->getShared('EE_Register_CPTs'); |
|
1167 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
1168 | - } |
|
1169 | - |
|
1170 | - |
|
1171 | - /** |
|
1172 | - * load_controllers |
|
1173 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
1174 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
1175 | - * time |
|
1176 | - * |
|
1177 | - * @access public |
|
1178 | - * @return void |
|
1179 | - */ |
|
1180 | - public function load_controllers() |
|
1181 | - { |
|
1182 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
1183 | - // let's get it started |
|
1184 | - if ( |
|
1185 | - ! $this->maintenance_mode->level() |
|
1186 | - && ($this->request->isFrontend() || $this->request->isFrontAjax()) |
|
1187 | - ) { |
|
1188 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
1189 | - $this->loader->getShared('EE_Front_Controller'); |
|
1190 | - } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
1191 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
1192 | - $this->loader->getShared('EE_Admin'); |
|
1193 | - } elseif ($this->request->isWordPressHeartbeat()) { |
|
1194 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'); |
|
1195 | - } |
|
1196 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
1197 | - } |
|
1198 | - |
|
1199 | - |
|
1200 | - /** |
|
1201 | - * core_loaded_and_ready |
|
1202 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
1203 | - * |
|
1204 | - * @access public |
|
1205 | - * @return void |
|
1206 | - * @throws Exception |
|
1207 | - */ |
|
1208 | - public function core_loaded_and_ready() |
|
1209 | - { |
|
1210 | - if ( |
|
1211 | - $this->request->isAdmin() |
|
1212 | - || $this->request->isFrontend() |
|
1213 | - || $this->request->isIframe() |
|
1214 | - || $this->request->isWordPressApi() |
|
1215 | - ) { |
|
1216 | - try { |
|
1217 | - $this->loader->getShared('EventEspresso\core\services\assets\I18nRegistry', [[]]); |
|
1218 | - $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
1219 | - $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager'); |
|
1220 | - if ($this->canLoadBlocks()) { |
|
1221 | - $this->loader->getShared( |
|
1222 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
1223 | - ); |
|
1224 | - } |
|
1225 | - } catch (Exception $exception) { |
|
1226 | - new ExceptionStackTraceDisplay($exception); |
|
1227 | - } |
|
1228 | - } |
|
1229 | - if ( |
|
1230 | - $this->request->isAdmin() |
|
1231 | - || $this->request->isEeAjax() |
|
1232 | - || $this->request->isFrontend() |
|
1233 | - ) { |
|
1234 | - $this->loader->getShared('EE_Session'); |
|
1235 | - } |
|
1236 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
1237 | - // always load template tags, because it's faster than checking if it's a front-end request, and many page |
|
1238 | - // builders require these even on the front-end |
|
1239 | - require_once EE_PUBLIC . 'template_tags.php'; |
|
1240 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
1241 | - } |
|
1242 | - |
|
1243 | - |
|
1244 | - /** |
|
1245 | - * initialize |
|
1246 | - * this is the best place to begin initializing client code |
|
1247 | - * |
|
1248 | - * @access public |
|
1249 | - * @return void |
|
1250 | - */ |
|
1251 | - public function initialize() |
|
1252 | - { |
|
1253 | - do_action('AHEE__EE_System__initialize'); |
|
1254 | - add_filter( |
|
1255 | - 'safe_style_css', |
|
1256 | - function ($styles) { |
|
1257 | - $styles[] = 'display'; |
|
1258 | - $styles[] = 'visibility'; |
|
1259 | - $styles[] = 'position'; |
|
1260 | - $styles[] = 'top'; |
|
1261 | - $styles[] = 'right'; |
|
1262 | - $styles[] = 'bottom'; |
|
1263 | - $styles[] = 'left'; |
|
1264 | - $styles[] = 'resize'; |
|
1265 | - $styles[] = 'max-width'; |
|
1266 | - $styles[] = 'max-height'; |
|
1267 | - return $styles; |
|
1268 | - } |
|
1269 | - ); |
|
1270 | - } |
|
1271 | - |
|
1272 | - |
|
1273 | - /** |
|
1274 | - * initialize_last |
|
1275 | - * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
1276 | - * initialize has done so |
|
1277 | - * |
|
1278 | - * @access public |
|
1279 | - * @return void |
|
1280 | - */ |
|
1281 | - public function initialize_last() |
|
1282 | - { |
|
1283 | - do_action('AHEE__EE_System__initialize_last'); |
|
1284 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
1285 | - $rewrite_rules = $this->loader->getShared( |
|
1286 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
1287 | - ); |
|
1288 | - $rewrite_rules->flushRewriteRules(); |
|
1289 | - add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
1290 | - if ( |
|
1291 | - ($this->request->isAjax() || $this->request->isAdmin()) |
|
1292 | - && $this->maintenance_mode->models_can_query() |
|
1293 | - ) { |
|
1294 | - $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
1295 | - $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
1296 | - } |
|
1297 | - } |
|
1298 | - |
|
1299 | - |
|
1300 | - /** |
|
1301 | - * @return void |
|
1302 | - * @throws EE_Error |
|
1303 | - */ |
|
1304 | - public function addEspressoToolbar() |
|
1305 | - { |
|
1306 | - $this->loader->getShared( |
|
1307 | - 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
1308 | - array($this->registry->CAP) |
|
1309 | - ); |
|
1310 | - } |
|
1311 | - |
|
1312 | - |
|
1313 | - /** |
|
1314 | - * do_not_cache |
|
1315 | - * sets no cache headers and defines no cache constants for WP plugins |
|
1316 | - * |
|
1317 | - * @access public |
|
1318 | - * @return void |
|
1319 | - */ |
|
1320 | - public static function do_not_cache() |
|
1321 | - { |
|
1322 | - // set no cache constants |
|
1323 | - if (! defined('DONOTCACHEPAGE')) { |
|
1324 | - define('DONOTCACHEPAGE', true); |
|
1325 | - } |
|
1326 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
1327 | - define('DONOTCACHCEOBJECT', true); |
|
1328 | - } |
|
1329 | - if (! defined('DONOTCACHEDB')) { |
|
1330 | - define('DONOTCACHEDB', true); |
|
1331 | - } |
|
1332 | - // add no cache headers |
|
1333 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1334 | - // plus a little extra for nginx and Google Chrome |
|
1335 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1336 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1337 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1338 | - } |
|
1339 | - |
|
1340 | - |
|
1341 | - /** |
|
1342 | - * extra_nocache_headers |
|
1343 | - * |
|
1344 | - * @access public |
|
1345 | - * @param $headers |
|
1346 | - * @return array |
|
1347 | - */ |
|
1348 | - public static function extra_nocache_headers($headers) |
|
1349 | - { |
|
1350 | - // for NGINX |
|
1351 | - $headers['X-Accel-Expires'] = 0; |
|
1352 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1353 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1354 | - return $headers; |
|
1355 | - } |
|
1356 | - |
|
1357 | - |
|
1358 | - /** |
|
1359 | - * nocache_headers |
|
1360 | - * |
|
1361 | - * @access public |
|
1362 | - * @return void |
|
1363 | - */ |
|
1364 | - public static function nocache_headers() |
|
1365 | - { |
|
1366 | - nocache_headers(); |
|
1367 | - } |
|
1368 | - |
|
1369 | - |
|
1370 | - /** |
|
1371 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1372 | - * never returned with the function. |
|
1373 | - * |
|
1374 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
1375 | - * @return array |
|
1376 | - */ |
|
1377 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
1378 | - { |
|
1379 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1380 | - } |
|
1381 | - |
|
1382 | - |
|
1383 | - /** |
|
1384 | - * Return whether blocks can be registered/loaded or not. |
|
1385 | - * @return bool |
|
1386 | - */ |
|
1387 | - private function canLoadBlocks() |
|
1388 | - { |
|
1389 | - return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
1390 | - && function_exists('register_block_type') |
|
1391 | - // don't load blocks if in the Divi page builder editor context |
|
1392 | - // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
1393 | - && ! $this->request->getRequestParam('et_fb', false); |
|
1394 | - } |
|
29 | + /** |
|
30 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
31 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
32 | + */ |
|
33 | + const req_type_normal = 0; |
|
34 | + |
|
35 | + /** |
|
36 | + * Indicates this is a brand new installation of EE so we should install |
|
37 | + * tables and default data etc |
|
38 | + */ |
|
39 | + const req_type_new_activation = 1; |
|
40 | + |
|
41 | + /** |
|
42 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
43 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
44 | + * and that default data is setup too |
|
45 | + */ |
|
46 | + const req_type_reactivation = 2; |
|
47 | + |
|
48 | + /** |
|
49 | + * indicates that EE has been upgraded since its previous request. |
|
50 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
51 | + */ |
|
52 | + const req_type_upgrade = 3; |
|
53 | + |
|
54 | + /** |
|
55 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
56 | + */ |
|
57 | + const req_type_downgrade = 4; |
|
58 | + |
|
59 | + /** |
|
60 | + * @deprecated since version 4.6.0.dev.006 |
|
61 | + * Now whenever a new_activation is detected the request type is still just |
|
62 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
63 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
64 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
65 | + * (Specifically, when the migration manager indicates migrations are finished |
|
66 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
67 | + */ |
|
68 | + const req_type_activation_but_not_installed = 5; |
|
69 | + |
|
70 | + /** |
|
71 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
72 | + */ |
|
73 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var EE_System $_instance |
|
77 | + */ |
|
78 | + private static $_instance; |
|
79 | + |
|
80 | + /** |
|
81 | + * @var EE_Registry $registry |
|
82 | + */ |
|
83 | + private $registry; |
|
84 | + |
|
85 | + /** |
|
86 | + * @var LoaderInterface $loader |
|
87 | + */ |
|
88 | + private $loader; |
|
89 | + |
|
90 | + /** |
|
91 | + * @var EE_Capabilities $capabilities |
|
92 | + */ |
|
93 | + private $capabilities; |
|
94 | + |
|
95 | + /** |
|
96 | + * @var RequestInterface $request |
|
97 | + */ |
|
98 | + private $request; |
|
99 | + |
|
100 | + /** |
|
101 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
102 | + */ |
|
103 | + private $maintenance_mode; |
|
104 | + |
|
105 | + /** |
|
106 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
107 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
108 | + * |
|
109 | + * @var int $_req_type |
|
110 | + */ |
|
111 | + private $_req_type; |
|
112 | + |
|
113 | + /** |
|
114 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
115 | + * |
|
116 | + * @var boolean $_major_version_change |
|
117 | + */ |
|
118 | + private $_major_version_change = false; |
|
119 | + |
|
120 | + /** |
|
121 | + * A Context DTO dedicated solely to identifying the current request type. |
|
122 | + * |
|
123 | + * @var RequestTypeContextCheckerInterface $request_type |
|
124 | + */ |
|
125 | + private $request_type; |
|
126 | + |
|
127 | + /** |
|
128 | + * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes |
|
129 | + */ |
|
130 | + private $register_custom_post_types; |
|
131 | + |
|
132 | + /** |
|
133 | + * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies |
|
134 | + */ |
|
135 | + private $register_custom_taxonomies; |
|
136 | + |
|
137 | + /** |
|
138 | + * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms |
|
139 | + */ |
|
140 | + private $register_custom_taxonomy_terms; |
|
141 | + |
|
142 | + /** |
|
143 | + * @singleton method used to instantiate class object |
|
144 | + * @param EE_Registry|null $registry |
|
145 | + * @param LoaderInterface|null $loader |
|
146 | + * @param RequestInterface|null $request |
|
147 | + * @param EE_Maintenance_Mode|null $maintenance_mode |
|
148 | + * @return EE_System |
|
149 | + */ |
|
150 | + public static function instance( |
|
151 | + EE_Registry $registry = null, |
|
152 | + LoaderInterface $loader = null, |
|
153 | + RequestInterface $request = null, |
|
154 | + EE_Maintenance_Mode $maintenance_mode = null |
|
155 | + ) { |
|
156 | + // check if class object is instantiated |
|
157 | + if (! self::$_instance instanceof EE_System) { |
|
158 | + self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
|
159 | + } |
|
160 | + return self::$_instance; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * resets the instance and returns it |
|
166 | + * |
|
167 | + * @return EE_System |
|
168 | + */ |
|
169 | + public static function reset() |
|
170 | + { |
|
171 | + self::$_instance->_req_type = null; |
|
172 | + // make sure none of the old hooks are left hanging around |
|
173 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
174 | + // we need to reset the migration manager in order for it to detect DMSs properly |
|
175 | + EE_Data_Migration_Manager::reset(); |
|
176 | + self::instance()->detect_activations_or_upgrades(); |
|
177 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
178 | + return self::instance(); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * sets hooks for running rest of system |
|
184 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
185 | + * starting EE Addons from any other point may lead to problems |
|
186 | + * |
|
187 | + * @param EE_Registry $registry |
|
188 | + * @param LoaderInterface $loader |
|
189 | + * @param RequestInterface $request |
|
190 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
191 | + */ |
|
192 | + private function __construct( |
|
193 | + EE_Registry $registry, |
|
194 | + LoaderInterface $loader, |
|
195 | + RequestInterface $request, |
|
196 | + EE_Maintenance_Mode $maintenance_mode |
|
197 | + ) { |
|
198 | + $this->registry = $registry; |
|
199 | + $this->loader = $loader; |
|
200 | + $this->request = $request; |
|
201 | + $this->maintenance_mode = $maintenance_mode; |
|
202 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
203 | + add_action( |
|
204 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
205 | + array($this, 'loadCapabilities'), |
|
206 | + 5 |
|
207 | + ); |
|
208 | + add_action( |
|
209 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
210 | + array($this, 'loadCommandBus'), |
|
211 | + 7 |
|
212 | + ); |
|
213 | + add_action( |
|
214 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
215 | + array($this, 'loadPluginApi'), |
|
216 | + 9 |
|
217 | + ); |
|
218 | + // give caff stuff a chance to play during the activation process too. |
|
219 | + add_action( |
|
220 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
221 | + [$this, 'brewCaffeinated'], |
|
222 | + 9 |
|
223 | + ); |
|
224 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
225 | + add_action( |
|
226 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
227 | + array($this, 'load_espresso_addons') |
|
228 | + ); |
|
229 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
230 | + // because the newly-activated addon didn't get a chance to run at all |
|
231 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
232 | + // detect whether install or upgrade |
|
233 | + add_action( |
|
234 | + 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
235 | + array($this, 'detect_activations_or_upgrades'), |
|
236 | + 3 |
|
237 | + ); |
|
238 | + // load EE_Config, EE_Textdomain, etc |
|
239 | + add_action( |
|
240 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
241 | + array($this, 'load_core_configuration'), |
|
242 | + 5 |
|
243 | + ); |
|
244 | + // load specifications for matching routes to current request |
|
245 | + add_action( |
|
246 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
247 | + array($this, 'loadRouteMatchSpecifications') |
|
248 | + ); |
|
249 | + // load specifications for custom post types |
|
250 | + add_action( |
|
251 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
252 | + array($this, 'loadCustomPostTypes') |
|
253 | + ); |
|
254 | + // load EE_Config, EE_Textdomain, etc |
|
255 | + add_action( |
|
256 | + 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
257 | + array($this, 'register_shortcodes_modules_and_widgets'), |
|
258 | + 7 |
|
259 | + ); |
|
260 | + // you wanna get going? I wanna get going... let's get going! |
|
261 | + add_action( |
|
262 | + 'AHEE__EE_Bootstrap__brew_espresso', |
|
263 | + array($this, 'brew_espresso'), |
|
264 | + 9 |
|
265 | + ); |
|
266 | + // other housekeeping |
|
267 | + // exclude EE critical pages from wp_list_pages |
|
268 | + add_filter( |
|
269 | + 'wp_list_pages_excludes', |
|
270 | + array($this, 'remove_pages_from_wp_list_pages'), |
|
271 | + 10 |
|
272 | + ); |
|
273 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
274 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
275 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
276 | + } |
|
277 | + |
|
278 | + |
|
279 | + /** |
|
280 | + * load and setup EE_Capabilities |
|
281 | + * |
|
282 | + * @return void |
|
283 | + * @throws EE_Error |
|
284 | + */ |
|
285 | + public function loadCapabilities() |
|
286 | + { |
|
287 | + $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
288 | + add_action( |
|
289 | + 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
290 | + function () { |
|
291 | + LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
292 | + } |
|
293 | + ); |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * create and cache the CommandBus, and also add middleware |
|
299 | + * The CapChecker middleware requires the use of EE_Capabilities |
|
300 | + * which is why we need to load the CommandBus after Caps are set up |
|
301 | + * CommandBus middleware operate FIFO - First In First Out |
|
302 | + * so LocateMovedCommands will run first in order to return any new commands |
|
303 | + * |
|
304 | + * @return void |
|
305 | + * @throws EE_Error |
|
306 | + */ |
|
307 | + public function loadCommandBus() |
|
308 | + { |
|
309 | + $this->loader->getShared( |
|
310 | + 'CommandBusInterface', |
|
311 | + array( |
|
312 | + null, |
|
313 | + apply_filters( |
|
314 | + 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
315 | + array( |
|
316 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\LocateMovedCommands'), |
|
317 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
318 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
319 | + ) |
|
320 | + ), |
|
321 | + ) |
|
322 | + ); |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @return void |
|
328 | + * @throws EE_Error |
|
329 | + */ |
|
330 | + public function loadPluginApi() |
|
331 | + { |
|
332 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
333 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
334 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
340 | + * that need to be setup before our EE_System launches. |
|
341 | + * |
|
342 | + * @return void |
|
343 | + * @throws DomainException |
|
344 | + * @throws InvalidArgumentException |
|
345 | + * @throws InvalidDataTypeException |
|
346 | + * @throws InvalidInterfaceException |
|
347 | + * @throws InvalidClassException |
|
348 | + * @throws InvalidFilePathException |
|
349 | + * @throws EE_Error |
|
350 | + */ |
|
351 | + public function brewCaffeinated() |
|
352 | + { |
|
353 | + /** @var Domain $domain */ |
|
354 | + $domain = DomainFactory::getShared( |
|
355 | + new FullyQualifiedName( |
|
356 | + 'EventEspresso\core\domain\Domain' |
|
357 | + ), |
|
358 | + [ |
|
359 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
360 | + Version::fromString(espresso_version()), |
|
361 | + ] |
|
362 | + ); |
|
363 | + static $brew; |
|
364 | + if ($domain->isCaffeinated() && ! $brew instanceof EE_Brewing_Regular) { |
|
365 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
366 | + /** @var EE_Brewing_Regular $brew */ |
|
367 | + $brew = LoaderFactory::getLoader()->getShared(EE_Brewing_Regular::class); |
|
368 | + $brew->initializePUE(); |
|
369 | + add_action( |
|
370 | + 'AHEE__EE_System__load_core_configuration__begin', |
|
371 | + [$brew, 'caffeinated'] |
|
372 | + ); |
|
373 | + } |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * @param string $addon_name |
|
379 | + * @param string $version_constant |
|
380 | + * @param string $min_version_required |
|
381 | + * @param string $load_callback |
|
382 | + * @param string $plugin_file_constant |
|
383 | + * @return void |
|
384 | + */ |
|
385 | + private function deactivateIncompatibleAddon( |
|
386 | + $addon_name, |
|
387 | + $version_constant, |
|
388 | + $min_version_required, |
|
389 | + $load_callback, |
|
390 | + $plugin_file_constant |
|
391 | + ) { |
|
392 | + if (! defined($version_constant)) { |
|
393 | + return; |
|
394 | + } |
|
395 | + $addon_version = constant($version_constant); |
|
396 | + if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
397 | + remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
398 | + if (! function_exists('deactivate_plugins')) { |
|
399 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
400 | + } |
|
401 | + deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
402 | + $this->request->unSetRequestParams(['activate', 'activate-multi'], true); |
|
403 | + EE_Error::add_error( |
|
404 | + sprintf( |
|
405 | + esc_html__( |
|
406 | + 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
407 | + 'event_espresso' |
|
408 | + ), |
|
409 | + $addon_name, |
|
410 | + $min_version_required |
|
411 | + ), |
|
412 | + __FILE__, |
|
413 | + __FUNCTION__ . "({$addon_name})", |
|
414 | + __LINE__ |
|
415 | + ); |
|
416 | + EE_Error::get_notices(false, true); |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * load_espresso_addons |
|
423 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
424 | + * this is hooked into both: |
|
425 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
426 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
427 | + * and the WP 'activate_plugin' hook point |
|
428 | + * |
|
429 | + * @access public |
|
430 | + * @return void |
|
431 | + */ |
|
432 | + public function load_espresso_addons() |
|
433 | + { |
|
434 | + $this->deactivateIncompatibleAddon( |
|
435 | + 'Wait Lists', |
|
436 | + 'EE_WAIT_LISTS_VERSION', |
|
437 | + '1.0.0.beta.074', |
|
438 | + 'load_espresso_wait_lists', |
|
439 | + 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
440 | + ); |
|
441 | + $this->deactivateIncompatibleAddon( |
|
442 | + 'Automated Upcoming Event Notifications', |
|
443 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
444 | + '1.0.0.beta.091', |
|
445 | + 'load_espresso_automated_upcoming_event_notification', |
|
446 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
447 | + ); |
|
448 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
449 | + // if the WP API basic auth plugin isn't already loaded, load it now. |
|
450 | + // We want it for mobile apps. Just include the entire plugin |
|
451 | + // also, don't load the basic auth when a plugin is getting activated, because |
|
452 | + // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
453 | + // and causes a fatal error |
|
454 | + if ( |
|
455 | + ($this->request->isWordPressApi() || $this->request->isApi()) |
|
456 | + && $this->request->getRequestParam('activate') !== 'true' |
|
457 | + && ! function_exists('json_basic_auth_handler') |
|
458 | + && ! function_exists('json_basic_auth_error') |
|
459 | + && ! in_array( |
|
460 | + $this->request->getRequestParam('action'), |
|
461 | + array('activate', 'activate-selected'), |
|
462 | + true |
|
463 | + ) |
|
464 | + ) { |
|
465 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
466 | + } |
|
467 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
468 | + } |
|
469 | + |
|
470 | + |
|
471 | + /** |
|
472 | + * detect_activations_or_upgrades |
|
473 | + * Checks for activation or upgrade of core first; |
|
474 | + * then also checks if any registered addons have been activated or upgraded |
|
475 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
476 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
477 | + * |
|
478 | + * @access public |
|
479 | + * @return void |
|
480 | + */ |
|
481 | + public function detect_activations_or_upgrades() |
|
482 | + { |
|
483 | + // first off: let's make sure to handle core |
|
484 | + $this->detect_if_activation_or_upgrade(); |
|
485 | + foreach ($this->registry->addons as $addon) { |
|
486 | + if ($addon instanceof EE_Addon) { |
|
487 | + // detect teh request type for that addon |
|
488 | + $addon->detect_req_type(); |
|
489 | + } |
|
490 | + } |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * detect_if_activation_or_upgrade |
|
496 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
497 | + * and either setting up the DB or setting up maintenance mode etc. |
|
498 | + * |
|
499 | + * @access public |
|
500 | + * @return void |
|
501 | + */ |
|
502 | + public function detect_if_activation_or_upgrade() |
|
503 | + { |
|
504 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
505 | + // check if db has been updated, or if its a brand-new installation |
|
506 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
507 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
508 | + // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
509 | + switch ($request_type) { |
|
510 | + case EE_System::req_type_new_activation: |
|
511 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
512 | + $this->_handle_core_version_change($espresso_db_update); |
|
513 | + break; |
|
514 | + case EE_System::req_type_reactivation: |
|
515 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
516 | + $this->_handle_core_version_change($espresso_db_update); |
|
517 | + break; |
|
518 | + case EE_System::req_type_upgrade: |
|
519 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
520 | + // migrations may be required now that we've upgraded |
|
521 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
522 | + $this->_handle_core_version_change($espresso_db_update); |
|
523 | + break; |
|
524 | + case EE_System::req_type_downgrade: |
|
525 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
526 | + // its possible migrations are no longer required |
|
527 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
528 | + $this->_handle_core_version_change($espresso_db_update); |
|
529 | + break; |
|
530 | + case EE_System::req_type_normal: |
|
531 | + default: |
|
532 | + break; |
|
533 | + } |
|
534 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + /** |
|
539 | + * Updates the list of installed versions and sets hooks for |
|
540 | + * initializing the database later during the request |
|
541 | + * |
|
542 | + * @param array $espresso_db_update |
|
543 | + */ |
|
544 | + private function _handle_core_version_change($espresso_db_update) |
|
545 | + { |
|
546 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
547 | + // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
548 | + add_action( |
|
549 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
550 | + array($this, 'initialize_db_if_no_migrations_required') |
|
551 | + ); |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + /** |
|
556 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
557 | + * information about what versions of EE have been installed and activated, |
|
558 | + * NOT necessarily the state of the database |
|
559 | + * |
|
560 | + * @param mixed $espresso_db_update the value of the WordPress option. |
|
561 | + * If not supplied, fetches it from the options table |
|
562 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
563 | + */ |
|
564 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
565 | + { |
|
566 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
567 | + if (! $espresso_db_update) { |
|
568 | + $espresso_db_update = get_option('espresso_db_update'); |
|
569 | + } |
|
570 | + // check that option is an array |
|
571 | + if (! is_array($espresso_db_update)) { |
|
572 | + // if option is FALSE, then it never existed |
|
573 | + if ($espresso_db_update === false) { |
|
574 | + // make $espresso_db_update an array and save option with autoload OFF |
|
575 | + $espresso_db_update = array(); |
|
576 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
577 | + } else { |
|
578 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
579 | + $espresso_db_update = array($espresso_db_update => array()); |
|
580 | + update_option('espresso_db_update', $espresso_db_update); |
|
581 | + } |
|
582 | + } else { |
|
583 | + $corrected_db_update = array(); |
|
584 | + // if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
585 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
586 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
587 | + // the key is an int, and the value IS NOT an array |
|
588 | + // so it must be numerically-indexed, where values are versions installed... |
|
589 | + // fix it! |
|
590 | + $version_string = $should_be_array; |
|
591 | + $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
592 | + } else { |
|
593 | + // ok it checks out |
|
594 | + $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
595 | + } |
|
596 | + } |
|
597 | + $espresso_db_update = $corrected_db_update; |
|
598 | + update_option('espresso_db_update', $espresso_db_update); |
|
599 | + } |
|
600 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
601 | + return $espresso_db_update; |
|
602 | + } |
|
603 | + |
|
604 | + |
|
605 | + /** |
|
606 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
607 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
608 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
609 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
610 | + * so that it will be done when migrations are finished |
|
611 | + * |
|
612 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
613 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
614 | + * This is a resource-intensive job |
|
615 | + * so we prefer to only do it when necessary |
|
616 | + * @return void |
|
617 | + * @throws EE_Error |
|
618 | + */ |
|
619 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
620 | + { |
|
621 | + $request_type = $this->detect_req_type(); |
|
622 | + // only initialize system if we're not in maintenance mode. |
|
623 | + if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
624 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
625 | + $rewrite_rules = $this->loader->getShared( |
|
626 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
627 | + ); |
|
628 | + $rewrite_rules->flush(); |
|
629 | + if ($verify_schema) { |
|
630 | + EEH_Activation::initialize_db_and_folders(); |
|
631 | + } |
|
632 | + EEH_Activation::initialize_db_content(); |
|
633 | + EEH_Activation::system_initialization(); |
|
634 | + if ($initialize_addons_too) { |
|
635 | + $this->initialize_addons(); |
|
636 | + } |
|
637 | + } else { |
|
638 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
639 | + } |
|
640 | + if ( |
|
641 | + $request_type === EE_System::req_type_new_activation |
|
642 | + || $request_type === EE_System::req_type_reactivation |
|
643 | + || ( |
|
644 | + $request_type === EE_System::req_type_upgrade |
|
645 | + && $this->is_major_version_change() |
|
646 | + ) |
|
647 | + ) { |
|
648 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
649 | + } |
|
650 | + } |
|
651 | + |
|
652 | + |
|
653 | + /** |
|
654 | + * Initializes the db for all registered addons |
|
655 | + * |
|
656 | + * @throws EE_Error |
|
657 | + */ |
|
658 | + public function initialize_addons() |
|
659 | + { |
|
660 | + // foreach registered addon, make sure its db is up-to-date too |
|
661 | + foreach ($this->registry->addons as $addon) { |
|
662 | + if ($addon instanceof EE_Addon) { |
|
663 | + $addon->initialize_db_if_no_migrations_required(); |
|
664 | + } |
|
665 | + } |
|
666 | + } |
|
667 | + |
|
668 | + |
|
669 | + /** |
|
670 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
671 | + * |
|
672 | + * @param array $version_history |
|
673 | + * @param string $current_version_to_add version to be added to the version history |
|
674 | + * @return boolean success as to whether or not this option was changed |
|
675 | + */ |
|
676 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
677 | + { |
|
678 | + if (! $version_history) { |
|
679 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
680 | + } |
|
681 | + if ($current_version_to_add === null) { |
|
682 | + $current_version_to_add = espresso_version(); |
|
683 | + } |
|
684 | + $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
685 | + // re-save |
|
686 | + return update_option('espresso_db_update', $version_history); |
|
687 | + } |
|
688 | + |
|
689 | + |
|
690 | + /** |
|
691 | + * Detects if the current version indicated in the has existed in the list of |
|
692 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
693 | + * |
|
694 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
695 | + * If not supplied, fetches it from the options table. |
|
696 | + * Also, caches its result so later parts of the code can also know whether |
|
697 | + * there's been an update or not. This way we can add the current version to |
|
698 | + * espresso_db_update, but still know if this is a new install or not |
|
699 | + * @return int one of the constants on EE_System::req_type_ |
|
700 | + */ |
|
701 | + public function detect_req_type($espresso_db_update = null) |
|
702 | + { |
|
703 | + if ($this->_req_type === null) { |
|
704 | + $espresso_db_update = ! empty($espresso_db_update) |
|
705 | + ? $espresso_db_update |
|
706 | + : $this->fix_espresso_db_upgrade_option(); |
|
707 | + $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
708 | + $espresso_db_update, |
|
709 | + 'ee_espresso_activation', |
|
710 | + espresso_version() |
|
711 | + ); |
|
712 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
713 | + $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal); |
|
714 | + } |
|
715 | + return $this->_req_type; |
|
716 | + } |
|
717 | + |
|
718 | + |
|
719 | + /** |
|
720 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
721 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
722 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
723 | + * |
|
724 | + * @param $activation_history |
|
725 | + * @return bool |
|
726 | + */ |
|
727 | + private function _detect_major_version_change($activation_history) |
|
728 | + { |
|
729 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
730 | + $previous_version_parts = explode('.', $previous_version); |
|
731 | + $current_version_parts = explode('.', espresso_version()); |
|
732 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
733 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
734 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
735 | + ); |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * Returns true if either the major or minor version of EE changed during this request. |
|
741 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
742 | + * |
|
743 | + * @return bool |
|
744 | + */ |
|
745 | + public function is_major_version_change() |
|
746 | + { |
|
747 | + return $this->_major_version_change; |
|
748 | + } |
|
749 | + |
|
750 | + |
|
751 | + /** |
|
752 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
753 | + * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
754 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
755 | + * just activated to (for core that will always be espresso_version()) |
|
756 | + * |
|
757 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
758 | + * ee plugin. for core that's 'espresso_db_update' |
|
759 | + * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
760 | + * indicate that this plugin was just activated |
|
761 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
762 | + * espresso_version()) |
|
763 | + * @return int one of the constants on EE_System::req_type_* |
|
764 | + */ |
|
765 | + public static function detect_req_type_given_activation_history( |
|
766 | + $activation_history_for_addon, |
|
767 | + $activation_indicator_option_name, |
|
768 | + $version_to_upgrade_to |
|
769 | + ) { |
|
770 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
771 | + if ($activation_history_for_addon) { |
|
772 | + // it exists, so this isn't a completely new install |
|
773 | + // check if this version already in that list of previously installed versions |
|
774 | + if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
775 | + // it a version we haven't seen before |
|
776 | + if ($version_is_higher === 1) { |
|
777 | + $req_type = EE_System::req_type_upgrade; |
|
778 | + } else { |
|
779 | + $req_type = EE_System::req_type_downgrade; |
|
780 | + } |
|
781 | + delete_option($activation_indicator_option_name); |
|
782 | + } else { |
|
783 | + // its not an update. maybe a reactivation? |
|
784 | + if (get_option($activation_indicator_option_name, false)) { |
|
785 | + if ($version_is_higher === -1) { |
|
786 | + $req_type = EE_System::req_type_downgrade; |
|
787 | + } elseif ($version_is_higher === 0) { |
|
788 | + // we've seen this version before, but it's an activation. must be a reactivation |
|
789 | + $req_type = EE_System::req_type_reactivation; |
|
790 | + } else {// $version_is_higher === 1 |
|
791 | + $req_type = EE_System::req_type_upgrade; |
|
792 | + } |
|
793 | + delete_option($activation_indicator_option_name); |
|
794 | + } else { |
|
795 | + // we've seen this version before and the activation indicate doesn't show it was just activated |
|
796 | + if ($version_is_higher === -1) { |
|
797 | + $req_type = EE_System::req_type_downgrade; |
|
798 | + } elseif ($version_is_higher === 0) { |
|
799 | + // we've seen this version before and it's not an activation. its normal request |
|
800 | + $req_type = EE_System::req_type_normal; |
|
801 | + } else {// $version_is_higher === 1 |
|
802 | + $req_type = EE_System::req_type_upgrade; |
|
803 | + } |
|
804 | + } |
|
805 | + } |
|
806 | + } else { |
|
807 | + // brand new install |
|
808 | + $req_type = EE_System::req_type_new_activation; |
|
809 | + delete_option($activation_indicator_option_name); |
|
810 | + } |
|
811 | + return $req_type; |
|
812 | + } |
|
813 | + |
|
814 | + |
|
815 | + /** |
|
816 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
817 | + * the $activation_history_for_addon |
|
818 | + * |
|
819 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
820 | + * sometimes containing 'unknown-date' |
|
821 | + * @param string $version_to_upgrade_to (current version) |
|
822 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
823 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
824 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
825 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
826 | + */ |
|
827 | + private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
828 | + { |
|
829 | + // find the most recently-activated version |
|
830 | + $most_recently_active_version = |
|
831 | + EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
832 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
833 | + } |
|
834 | + |
|
835 | + |
|
836 | + /** |
|
837 | + * Gets the most recently active version listed in the activation history, |
|
838 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
839 | + * |
|
840 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
841 | + * sometimes containing 'unknown-date' |
|
842 | + * @return string |
|
843 | + */ |
|
844 | + private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
845 | + { |
|
846 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
847 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
848 | + if (is_array($activation_history)) { |
|
849 | + foreach ($activation_history as $version => $times_activated) { |
|
850 | + // check there is a record of when this version was activated. Otherwise, |
|
851 | + // mark it as unknown |
|
852 | + if (! $times_activated) { |
|
853 | + $times_activated = array('unknown-date'); |
|
854 | + } |
|
855 | + if (is_string($times_activated)) { |
|
856 | + $times_activated = array($times_activated); |
|
857 | + } |
|
858 | + foreach ($times_activated as $an_activation) { |
|
859 | + if ( |
|
860 | + $an_activation !== 'unknown-date' |
|
861 | + && $an_activation |
|
862 | + > $most_recently_active_version_activation |
|
863 | + ) { |
|
864 | + $most_recently_active_version = $version; |
|
865 | + $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
866 | + ? '1970-01-01 00:00:00' |
|
867 | + : $an_activation; |
|
868 | + } |
|
869 | + } |
|
870 | + } |
|
871 | + } |
|
872 | + return $most_recently_active_version; |
|
873 | + } |
|
874 | + |
|
875 | + |
|
876 | + /** |
|
877 | + * This redirects to the about EE page after activation |
|
878 | + * |
|
879 | + * @return void |
|
880 | + */ |
|
881 | + public function redirect_to_about_ee() |
|
882 | + { |
|
883 | + $notices = EE_Error::get_notices(false); |
|
884 | + // if current user is an admin and it's not an ajax or rest request |
|
885 | + if ( |
|
886 | + ! isset($notices['errors']) |
|
887 | + && $this->request->isAdmin() |
|
888 | + && apply_filters( |
|
889 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
890 | + $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
891 | + ) |
|
892 | + ) { |
|
893 | + $query_params = array('page' => 'espresso_about'); |
|
894 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
895 | + $query_params['new_activation'] = true; |
|
896 | + } |
|
897 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
898 | + $query_params['reactivation'] = true; |
|
899 | + } |
|
900 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
901 | + wp_safe_redirect($url); |
|
902 | + exit(); |
|
903 | + } |
|
904 | + } |
|
905 | + |
|
906 | + |
|
907 | + /** |
|
908 | + * load_core_configuration |
|
909 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
910 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
911 | + * |
|
912 | + * @return void |
|
913 | + * @throws ReflectionException |
|
914 | + * @throws Exception |
|
915 | + */ |
|
916 | + public function load_core_configuration() |
|
917 | + { |
|
918 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
919 | + $this->loader->getShared('EE_Load_Textdomain'); |
|
920 | + // load textdomain |
|
921 | + EE_Load_Textdomain::load_textdomain(); |
|
922 | + // load and setup EE_Config and EE_Network_Config |
|
923 | + $config = $this->loader->getShared('EE_Config'); |
|
924 | + $this->loader->getShared('EE_Network_Config'); |
|
925 | + // setup autoloaders |
|
926 | + // enable logging? |
|
927 | + $this->loader->getShared('EventEspresso\core\services\orm\TrashLogger'); |
|
928 | + if ($config->admin->use_remote_logging) { |
|
929 | + $this->loader->getShared('EE_Log'); |
|
930 | + } |
|
931 | + // check for activation errors |
|
932 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
933 | + if ($activation_errors) { |
|
934 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
935 | + update_option('ee_plugin_activation_errors', false); |
|
936 | + } |
|
937 | + // get model names |
|
938 | + $this->_parse_model_names(); |
|
939 | + // configure custom post type definitions |
|
940 | + $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'); |
|
941 | + $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'); |
|
942 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
943 | + } |
|
944 | + |
|
945 | + |
|
946 | + /** |
|
947 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
948 | + * |
|
949 | + * @return void |
|
950 | + * @throws ReflectionException |
|
951 | + */ |
|
952 | + private function _parse_model_names() |
|
953 | + { |
|
954 | + // get all the files in the EE_MODELS folder that end in .model.php |
|
955 | + $models = glob(EE_MODELS . '*.model.php'); |
|
956 | + $model_names = array(); |
|
957 | + $non_abstract_db_models = array(); |
|
958 | + foreach ($models as $model) { |
|
959 | + // get model classname |
|
960 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
961 | + $short_name = str_replace('EEM_', '', $classname); |
|
962 | + $reflectionClass = new ReflectionClass($classname); |
|
963 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
964 | + $non_abstract_db_models[ $short_name ] = $classname; |
|
965 | + } |
|
966 | + $model_names[ $short_name ] = $classname; |
|
967 | + } |
|
968 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
969 | + $this->registry->non_abstract_db_models = apply_filters( |
|
970 | + 'FHEE__EE_System__parse_implemented_model_names', |
|
971 | + $non_abstract_db_models |
|
972 | + ); |
|
973 | + } |
|
974 | + |
|
975 | + |
|
976 | + /** |
|
977 | + * @since 4.9.71.p |
|
978 | + * @throws Exception |
|
979 | + */ |
|
980 | + public function loadRouteMatchSpecifications() |
|
981 | + { |
|
982 | + try { |
|
983 | + $this->loader->getShared( |
|
984 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' |
|
985 | + ); |
|
986 | + } catch (Exception $exception) { |
|
987 | + new ExceptionStackTraceDisplay($exception); |
|
988 | + } |
|
989 | + do_action('AHEE__EE_System__loadRouteMatchSpecifications'); |
|
990 | + } |
|
991 | + |
|
992 | + |
|
993 | + /** |
|
994 | + * loading CPT related classes earlier so that their definitions are available |
|
995 | + * but not performing any actual registration with WP core until load_CPTs_and_session() is called |
|
996 | + * |
|
997 | + * @since 4.10.21.p |
|
998 | + */ |
|
999 | + public function loadCustomPostTypes() |
|
1000 | + { |
|
1001 | + $this->register_custom_taxonomies = $this->loader->getShared( |
|
1002 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
1003 | + ); |
|
1004 | + $this->register_custom_post_types = $this->loader->getShared( |
|
1005 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
1006 | + ); |
|
1007 | + $this->register_custom_taxonomy_terms = $this->loader->getShared( |
|
1008 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
1009 | + ); |
|
1010 | + // integrate WP_Query with the EE models |
|
1011 | + $this->loader->getShared('EE_CPT_Strategy'); |
|
1012 | + // load legacy EE_Request_Handler in case add-ons still need it |
|
1013 | + $this->loader->getShared('EE_Request_Handler'); |
|
1014 | + } |
|
1015 | + |
|
1016 | + |
|
1017 | + /** |
|
1018 | + * register_shortcodes_modules_and_widgets |
|
1019 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
1020 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
1021 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
1022 | + * |
|
1023 | + * @access public |
|
1024 | + * @return void |
|
1025 | + * @throws Exception |
|
1026 | + */ |
|
1027 | + public function register_shortcodes_modules_and_widgets() |
|
1028 | + { |
|
1029 | + if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAjax()) { |
|
1030 | + // load, register, and add shortcodes the new way |
|
1031 | + $this->loader->getShared('EventEspresso\core\services\shortcodes\ShortcodesManager'); |
|
1032 | + } |
|
1033 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
1034 | + // check for addons using old hook point |
|
1035 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
1036 | + $this->_incompatible_addon_error(); |
|
1037 | + } |
|
1038 | + } |
|
1039 | + |
|
1040 | + |
|
1041 | + /** |
|
1042 | + * _incompatible_addon_error |
|
1043 | + * |
|
1044 | + * @access public |
|
1045 | + * @return void |
|
1046 | + */ |
|
1047 | + private function _incompatible_addon_error() |
|
1048 | + { |
|
1049 | + // get array of classes hooking into here |
|
1050 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
1051 | + 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
1052 | + ); |
|
1053 | + if (! empty($class_names)) { |
|
1054 | + $msg = esc_html__( |
|
1055 | + 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
1056 | + 'event_espresso' |
|
1057 | + ); |
|
1058 | + $msg .= '<ul>'; |
|
1059 | + foreach ($class_names as $class_name) { |
|
1060 | + $msg .= '<li><b>Event Espresso - ' |
|
1061 | + . str_replace( |
|
1062 | + array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
|
1063 | + '', |
|
1064 | + $class_name |
|
1065 | + ) . '</b></li>'; |
|
1066 | + } |
|
1067 | + $msg .= '</ul>'; |
|
1068 | + $msg .= esc_html__( |
|
1069 | + 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
1070 | + 'event_espresso' |
|
1071 | + ); |
|
1072 | + // save list of incompatible addons to wp-options for later use |
|
1073 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
1074 | + if (is_admin()) { |
|
1075 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1076 | + } |
|
1077 | + } |
|
1078 | + } |
|
1079 | + |
|
1080 | + |
|
1081 | + /** |
|
1082 | + * brew_espresso |
|
1083 | + * begins the process of setting hooks for initializing EE in the correct order |
|
1084 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
1085 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
1086 | + * |
|
1087 | + * @return void |
|
1088 | + */ |
|
1089 | + public function brew_espresso() |
|
1090 | + { |
|
1091 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
1092 | + // load some final core systems |
|
1093 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
1094 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
1095 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
1096 | + add_action('init', array($this, 'load_controllers'), 7); |
|
1097 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
1098 | + add_action('init', array($this, 'initialize'), 10); |
|
1099 | + add_action('init', array($this, 'initialize_last'), 100); |
|
1100 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
1101 | + } |
|
1102 | + |
|
1103 | + |
|
1104 | + /** |
|
1105 | + * set_hooks_for_core |
|
1106 | + * |
|
1107 | + * @access public |
|
1108 | + * @return void |
|
1109 | + * @throws EE_Error |
|
1110 | + */ |
|
1111 | + public function set_hooks_for_core() |
|
1112 | + { |
|
1113 | + $this->_deactivate_incompatible_addons(); |
|
1114 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
1115 | + $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan'); |
|
1116 | + // caps need to be initialized on every request so that capability maps are set. |
|
1117 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
1118 | + $this->registry->CAP->init_caps(); |
|
1119 | + } |
|
1120 | + |
|
1121 | + |
|
1122 | + /** |
|
1123 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
1124 | + * deactivates any addons considered incompatible with the current version of EE |
|
1125 | + */ |
|
1126 | + private function _deactivate_incompatible_addons() |
|
1127 | + { |
|
1128 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
1129 | + if (! empty($incompatible_addons)) { |
|
1130 | + $active_plugins = get_option('active_plugins', array()); |
|
1131 | + foreach ($active_plugins as $active_plugin) { |
|
1132 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
1133 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
1134 | + $this->request->unSetRequestParams(['activate'], true); |
|
1135 | + espresso_deactivate_plugin($active_plugin); |
|
1136 | + } |
|
1137 | + } |
|
1138 | + } |
|
1139 | + } |
|
1140 | + } |
|
1141 | + |
|
1142 | + |
|
1143 | + /** |
|
1144 | + * perform_activations_upgrades_and_migrations |
|
1145 | + * |
|
1146 | + * @access public |
|
1147 | + * @return void |
|
1148 | + */ |
|
1149 | + public function perform_activations_upgrades_and_migrations() |
|
1150 | + { |
|
1151 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
1152 | + } |
|
1153 | + |
|
1154 | + |
|
1155 | + /** |
|
1156 | + * @return void |
|
1157 | + * @throws DomainException |
|
1158 | + */ |
|
1159 | + public function load_CPTs_and_session() |
|
1160 | + { |
|
1161 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
1162 | + $this->register_custom_taxonomies->registerCustomTaxonomies(); |
|
1163 | + $this->register_custom_post_types->registerCustomPostTypes(); |
|
1164 | + $this->register_custom_taxonomy_terms->registerCustomTaxonomyTerms(); |
|
1165 | + // load legacy Custom Post Types and Taxonomies |
|
1166 | + $this->loader->getShared('EE_Register_CPTs'); |
|
1167 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
1168 | + } |
|
1169 | + |
|
1170 | + |
|
1171 | + /** |
|
1172 | + * load_controllers |
|
1173 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
1174 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
1175 | + * time |
|
1176 | + * |
|
1177 | + * @access public |
|
1178 | + * @return void |
|
1179 | + */ |
|
1180 | + public function load_controllers() |
|
1181 | + { |
|
1182 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
1183 | + // let's get it started |
|
1184 | + if ( |
|
1185 | + ! $this->maintenance_mode->level() |
|
1186 | + && ($this->request->isFrontend() || $this->request->isFrontAjax()) |
|
1187 | + ) { |
|
1188 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
1189 | + $this->loader->getShared('EE_Front_Controller'); |
|
1190 | + } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
1191 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
1192 | + $this->loader->getShared('EE_Admin'); |
|
1193 | + } elseif ($this->request->isWordPressHeartbeat()) { |
|
1194 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'); |
|
1195 | + } |
|
1196 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
1197 | + } |
|
1198 | + |
|
1199 | + |
|
1200 | + /** |
|
1201 | + * core_loaded_and_ready |
|
1202 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
1203 | + * |
|
1204 | + * @access public |
|
1205 | + * @return void |
|
1206 | + * @throws Exception |
|
1207 | + */ |
|
1208 | + public function core_loaded_and_ready() |
|
1209 | + { |
|
1210 | + if ( |
|
1211 | + $this->request->isAdmin() |
|
1212 | + || $this->request->isFrontend() |
|
1213 | + || $this->request->isIframe() |
|
1214 | + || $this->request->isWordPressApi() |
|
1215 | + ) { |
|
1216 | + try { |
|
1217 | + $this->loader->getShared('EventEspresso\core\services\assets\I18nRegistry', [[]]); |
|
1218 | + $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
1219 | + $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager'); |
|
1220 | + if ($this->canLoadBlocks()) { |
|
1221 | + $this->loader->getShared( |
|
1222 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
1223 | + ); |
|
1224 | + } |
|
1225 | + } catch (Exception $exception) { |
|
1226 | + new ExceptionStackTraceDisplay($exception); |
|
1227 | + } |
|
1228 | + } |
|
1229 | + if ( |
|
1230 | + $this->request->isAdmin() |
|
1231 | + || $this->request->isEeAjax() |
|
1232 | + || $this->request->isFrontend() |
|
1233 | + ) { |
|
1234 | + $this->loader->getShared('EE_Session'); |
|
1235 | + } |
|
1236 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
1237 | + // always load template tags, because it's faster than checking if it's a front-end request, and many page |
|
1238 | + // builders require these even on the front-end |
|
1239 | + require_once EE_PUBLIC . 'template_tags.php'; |
|
1240 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
1241 | + } |
|
1242 | + |
|
1243 | + |
|
1244 | + /** |
|
1245 | + * initialize |
|
1246 | + * this is the best place to begin initializing client code |
|
1247 | + * |
|
1248 | + * @access public |
|
1249 | + * @return void |
|
1250 | + */ |
|
1251 | + public function initialize() |
|
1252 | + { |
|
1253 | + do_action('AHEE__EE_System__initialize'); |
|
1254 | + add_filter( |
|
1255 | + 'safe_style_css', |
|
1256 | + function ($styles) { |
|
1257 | + $styles[] = 'display'; |
|
1258 | + $styles[] = 'visibility'; |
|
1259 | + $styles[] = 'position'; |
|
1260 | + $styles[] = 'top'; |
|
1261 | + $styles[] = 'right'; |
|
1262 | + $styles[] = 'bottom'; |
|
1263 | + $styles[] = 'left'; |
|
1264 | + $styles[] = 'resize'; |
|
1265 | + $styles[] = 'max-width'; |
|
1266 | + $styles[] = 'max-height'; |
|
1267 | + return $styles; |
|
1268 | + } |
|
1269 | + ); |
|
1270 | + } |
|
1271 | + |
|
1272 | + |
|
1273 | + /** |
|
1274 | + * initialize_last |
|
1275 | + * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
1276 | + * initialize has done so |
|
1277 | + * |
|
1278 | + * @access public |
|
1279 | + * @return void |
|
1280 | + */ |
|
1281 | + public function initialize_last() |
|
1282 | + { |
|
1283 | + do_action('AHEE__EE_System__initialize_last'); |
|
1284 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
1285 | + $rewrite_rules = $this->loader->getShared( |
|
1286 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
1287 | + ); |
|
1288 | + $rewrite_rules->flushRewriteRules(); |
|
1289 | + add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
1290 | + if ( |
|
1291 | + ($this->request->isAjax() || $this->request->isAdmin()) |
|
1292 | + && $this->maintenance_mode->models_can_query() |
|
1293 | + ) { |
|
1294 | + $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
1295 | + $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
1296 | + } |
|
1297 | + } |
|
1298 | + |
|
1299 | + |
|
1300 | + /** |
|
1301 | + * @return void |
|
1302 | + * @throws EE_Error |
|
1303 | + */ |
|
1304 | + public function addEspressoToolbar() |
|
1305 | + { |
|
1306 | + $this->loader->getShared( |
|
1307 | + 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
1308 | + array($this->registry->CAP) |
|
1309 | + ); |
|
1310 | + } |
|
1311 | + |
|
1312 | + |
|
1313 | + /** |
|
1314 | + * do_not_cache |
|
1315 | + * sets no cache headers and defines no cache constants for WP plugins |
|
1316 | + * |
|
1317 | + * @access public |
|
1318 | + * @return void |
|
1319 | + */ |
|
1320 | + public static function do_not_cache() |
|
1321 | + { |
|
1322 | + // set no cache constants |
|
1323 | + if (! defined('DONOTCACHEPAGE')) { |
|
1324 | + define('DONOTCACHEPAGE', true); |
|
1325 | + } |
|
1326 | + if (! defined('DONOTCACHCEOBJECT')) { |
|
1327 | + define('DONOTCACHCEOBJECT', true); |
|
1328 | + } |
|
1329 | + if (! defined('DONOTCACHEDB')) { |
|
1330 | + define('DONOTCACHEDB', true); |
|
1331 | + } |
|
1332 | + // add no cache headers |
|
1333 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1334 | + // plus a little extra for nginx and Google Chrome |
|
1335 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1336 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1337 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1338 | + } |
|
1339 | + |
|
1340 | + |
|
1341 | + /** |
|
1342 | + * extra_nocache_headers |
|
1343 | + * |
|
1344 | + * @access public |
|
1345 | + * @param $headers |
|
1346 | + * @return array |
|
1347 | + */ |
|
1348 | + public static function extra_nocache_headers($headers) |
|
1349 | + { |
|
1350 | + // for NGINX |
|
1351 | + $headers['X-Accel-Expires'] = 0; |
|
1352 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1353 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1354 | + return $headers; |
|
1355 | + } |
|
1356 | + |
|
1357 | + |
|
1358 | + /** |
|
1359 | + * nocache_headers |
|
1360 | + * |
|
1361 | + * @access public |
|
1362 | + * @return void |
|
1363 | + */ |
|
1364 | + public static function nocache_headers() |
|
1365 | + { |
|
1366 | + nocache_headers(); |
|
1367 | + } |
|
1368 | + |
|
1369 | + |
|
1370 | + /** |
|
1371 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1372 | + * never returned with the function. |
|
1373 | + * |
|
1374 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
1375 | + * @return array |
|
1376 | + */ |
|
1377 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
1378 | + { |
|
1379 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1380 | + } |
|
1381 | + |
|
1382 | + |
|
1383 | + /** |
|
1384 | + * Return whether blocks can be registered/loaded or not. |
|
1385 | + * @return bool |
|
1386 | + */ |
|
1387 | + private function canLoadBlocks() |
|
1388 | + { |
|
1389 | + return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
1390 | + && function_exists('register_block_type') |
|
1391 | + // don't load blocks if in the Divi page builder editor context |
|
1392 | + // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
1393 | + && ! $this->request->getRequestParam('et_fb', false); |
|
1394 | + } |
|
1395 | 1395 | } |
@@ -19,1156 +19,1156 @@ |
||
19 | 19 | */ |
20 | 20 | class EE_Dependency_Map |
21 | 21 | { |
22 | - /** |
|
23 | - * This means that the requested class dependency is not present in the dependency map |
|
24 | - */ |
|
25 | - const not_registered = 0; |
|
26 | - |
|
27 | - /** |
|
28 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
29 | - */ |
|
30 | - const load_new_object = 1; |
|
31 | - |
|
32 | - /** |
|
33 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
34 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
35 | - */ |
|
36 | - const load_from_cache = 2; |
|
37 | - |
|
38 | - /** |
|
39 | - * When registering a dependency, |
|
40 | - * this indicates to keep any existing dependencies that already exist, |
|
41 | - * and simply discard any new dependencies declared in the incoming data |
|
42 | - */ |
|
43 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
44 | - |
|
45 | - /** |
|
46 | - * When registering a dependency, |
|
47 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
48 | - */ |
|
49 | - const OVERWRITE_DEPENDENCIES = 1; |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @type EE_Dependency_Map $_instance |
|
54 | - */ |
|
55 | - protected static $_instance; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var ClassInterfaceCache $class_cache |
|
59 | - */ |
|
60 | - private $class_cache; |
|
61 | - |
|
62 | - /** |
|
63 | - * @type RequestInterface $request |
|
64 | - */ |
|
65 | - protected $request; |
|
66 | - |
|
67 | - /** |
|
68 | - * @type LegacyRequestInterface $legacy_request |
|
69 | - */ |
|
70 | - protected $legacy_request; |
|
71 | - |
|
72 | - /** |
|
73 | - * @type ResponseInterface $response |
|
74 | - */ |
|
75 | - protected $response; |
|
76 | - |
|
77 | - /** |
|
78 | - * @type LoaderInterface $loader |
|
79 | - */ |
|
80 | - protected $loader; |
|
81 | - |
|
82 | - /** |
|
83 | - * @type array $_dependency_map |
|
84 | - */ |
|
85 | - protected $_dependency_map = []; |
|
86 | - |
|
87 | - /** |
|
88 | - * @type array $_class_loaders |
|
89 | - */ |
|
90 | - protected $_class_loaders = []; |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * EE_Dependency_Map constructor. |
|
95 | - * |
|
96 | - * @param ClassInterfaceCache $class_cache |
|
97 | - */ |
|
98 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
99 | - { |
|
100 | - $this->class_cache = $class_cache; |
|
101 | - do_action('EE_Dependency_Map____construct', $this); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return void |
|
107 | - */ |
|
108 | - public function initialize() |
|
109 | - { |
|
110 | - $this->_register_core_dependencies(); |
|
111 | - $this->_register_core_class_loaders(); |
|
112 | - $this->_register_core_aliases(); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @singleton method used to instantiate class object |
|
118 | - * @param ClassInterfaceCache|null $class_cache |
|
119 | - * @return EE_Dependency_Map |
|
120 | - */ |
|
121 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
122 | - { |
|
123 | - // check if class object is instantiated, and instantiated properly |
|
124 | - if ( |
|
125 | - ! self::$_instance instanceof EE_Dependency_Map |
|
126 | - && $class_cache instanceof ClassInterfaceCache |
|
127 | - ) { |
|
128 | - self::$_instance = new EE_Dependency_Map($class_cache); |
|
129 | - } |
|
130 | - return self::$_instance; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param RequestInterface $request |
|
136 | - */ |
|
137 | - public function setRequest(RequestInterface $request) |
|
138 | - { |
|
139 | - $this->request = $request; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @param LegacyRequestInterface $legacy_request |
|
145 | - */ |
|
146 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
147 | - { |
|
148 | - $this->legacy_request = $legacy_request; |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @param ResponseInterface $response |
|
154 | - */ |
|
155 | - public function setResponse(ResponseInterface $response) |
|
156 | - { |
|
157 | - $this->response = $response; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param LoaderInterface $loader |
|
163 | - */ |
|
164 | - public function setLoader(LoaderInterface $loader) |
|
165 | - { |
|
166 | - $this->loader = $loader; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @param string $class |
|
172 | - * @param array $dependencies |
|
173 | - * @param int $overwrite |
|
174 | - * @return bool |
|
175 | - */ |
|
176 | - public static function register_dependencies( |
|
177 | - $class, |
|
178 | - array $dependencies, |
|
179 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
180 | - ) { |
|
181 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
187 | - * to the class specified by the first parameter. |
|
188 | - * IMPORTANT !!! |
|
189 | - * The order of elements in the incoming $dependencies array MUST match |
|
190 | - * the order of the constructor parameters for the class in question. |
|
191 | - * This is especially important when overriding any existing dependencies that are registered. |
|
192 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
193 | - * |
|
194 | - * @param string $class |
|
195 | - * @param array $dependencies |
|
196 | - * @param int $overwrite |
|
197 | - * @return bool |
|
198 | - */ |
|
199 | - public function registerDependencies( |
|
200 | - $class, |
|
201 | - array $dependencies, |
|
202 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
203 | - ) { |
|
204 | - $class = trim($class, '\\'); |
|
205 | - $registered = false; |
|
206 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
207 | - self::$_instance->_dependency_map[ $class ] = []; |
|
208 | - } |
|
209 | - // we need to make sure that any aliases used when registering a dependency |
|
210 | - // get resolved to the correct class name |
|
211 | - foreach ($dependencies as $dependency => $load_source) { |
|
212 | - $alias = self::$_instance->getFqnForAlias($dependency); |
|
213 | - if ( |
|
214 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
215 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
216 | - ) { |
|
217 | - unset($dependencies[ $dependency ]); |
|
218 | - $dependencies[ $alias ] = $load_source; |
|
219 | - $registered = true; |
|
220 | - } |
|
221 | - } |
|
222 | - // now add our two lists of dependencies together. |
|
223 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
224 | - // so $dependencies is NOT overwritten because it is listed first |
|
225 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
226 | - // Union is way faster than array_merge() but should be used with caution... |
|
227 | - // especially with numerically indexed arrays |
|
228 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
229 | - // now we need to ensure that the resulting dependencies |
|
230 | - // array only has the entries that are required for the class |
|
231 | - // so first count how many dependencies were originally registered for the class |
|
232 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
233 | - // if that count is non-zero (meaning dependencies were already registered) |
|
234 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
235 | - // then truncate the final array to match that count |
|
236 | - ? array_slice($dependencies, 0, $dependency_count) |
|
237 | - // otherwise just take the incoming array because nothing previously existed |
|
238 | - : $dependencies; |
|
239 | - return $registered; |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * @param string $class_name |
|
245 | - * @param string $loader |
|
246 | - * @param bool $overwrite |
|
247 | - * @return bool |
|
248 | - * @throws DomainException |
|
249 | - */ |
|
250 | - public static function register_class_loader($class_name, $loader = 'load_core', $overwrite = false) |
|
251 | - { |
|
252 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
253 | - throw new DomainException( |
|
254 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
255 | - ); |
|
256 | - } |
|
257 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
258 | - if ( |
|
259 | - ! is_callable($loader) |
|
260 | - && ( |
|
261 | - strpos($loader, 'load_') !== 0 |
|
262 | - || ! method_exists('EE_Registry', $loader) |
|
263 | - ) |
|
264 | - ) { |
|
265 | - throw new DomainException( |
|
266 | - sprintf( |
|
267 | - esc_html__( |
|
268 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
269 | - 'event_espresso' |
|
270 | - ), |
|
271 | - $loader |
|
272 | - ) |
|
273 | - ); |
|
274 | - } |
|
275 | - $class_name = self::$_instance->getFqnForAlias($class_name); |
|
276 | - if ($overwrite || ! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
277 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
278 | - return true; |
|
279 | - } |
|
280 | - return false; |
|
281 | - } |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * @return array |
|
286 | - */ |
|
287 | - public function dependency_map() |
|
288 | - { |
|
289 | - return $this->_dependency_map; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
295 | - * |
|
296 | - * @param string $class_name |
|
297 | - * @return boolean |
|
298 | - */ |
|
299 | - public function has($class_name = '') |
|
300 | - { |
|
301 | - // all legacy models have the same dependencies |
|
302 | - if (strpos($class_name, 'EEM_') === 0) { |
|
303 | - $class_name = 'LEGACY_MODELS'; |
|
304 | - } |
|
305 | - return isset($this->_dependency_map[ $class_name ]); |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
311 | - * |
|
312 | - * @param string $class_name |
|
313 | - * @param string $dependency |
|
314 | - * @return bool |
|
315 | - */ |
|
316 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
317 | - { |
|
318 | - // all legacy models have the same dependencies |
|
319 | - if (strpos($class_name, 'EEM_') === 0) { |
|
320 | - $class_name = 'LEGACY_MODELS'; |
|
321 | - } |
|
322 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
323 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
329 | - * |
|
330 | - * @param string $class_name |
|
331 | - * @param string $dependency |
|
332 | - * @return int |
|
333 | - */ |
|
334 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
335 | - { |
|
336 | - // all legacy models have the same dependencies |
|
337 | - if (strpos($class_name, 'EEM_') === 0) { |
|
338 | - $class_name = 'LEGACY_MODELS'; |
|
339 | - } |
|
340 | - $dependency = $this->getFqnForAlias($dependency); |
|
341 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
342 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
343 | - : EE_Dependency_Map::not_registered; |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * @param string $class_name |
|
349 | - * @return string | Closure |
|
350 | - */ |
|
351 | - public function class_loader($class_name) |
|
352 | - { |
|
353 | - // all legacy models use load_model() |
|
354 | - if (strpos($class_name, 'EEM_') === 0) { |
|
355 | - return 'load_model'; |
|
356 | - } |
|
357 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
358 | - // perform strpos() first to avoid loading regex every time we load a class |
|
359 | - if ( |
|
360 | - strpos($class_name, 'EE_CPT_') === 0 |
|
361 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
362 | - ) { |
|
363 | - return 'load_core'; |
|
364 | - } |
|
365 | - $class_name = $this->getFqnForAlias($class_name); |
|
366 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
367 | - } |
|
368 | - |
|
369 | - |
|
370 | - /** |
|
371 | - * @return array |
|
372 | - */ |
|
373 | - public function class_loaders() |
|
374 | - { |
|
375 | - return $this->_class_loaders; |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * adds an alias for a classname |
|
381 | - * |
|
382 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
383 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
384 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
385 | - */ |
|
386 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
387 | - { |
|
388 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
389 | - } |
|
390 | - |
|
391 | - |
|
392 | - /** |
|
393 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
394 | - * WHY? |
|
395 | - * Because if a class is type hinting for a concretion, |
|
396 | - * then why would we need to find another class to supply it? |
|
397 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
398 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
399 | - * Don't go looking for some substitute. |
|
400 | - * Whereas if a class is type hinting for an interface... |
|
401 | - * then we need to find an actual class to use. |
|
402 | - * So the interface IS the alias for some other FQN, |
|
403 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
404 | - * represents some other class. |
|
405 | - * |
|
406 | - * @param string $fqn |
|
407 | - * @param string $for_class |
|
408 | - * @return bool |
|
409 | - */ |
|
410 | - public function isAlias($fqn = '', $for_class = '') |
|
411 | - { |
|
412 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - /** |
|
417 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
418 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
419 | - * for example: |
|
420 | - * if the following two entries were added to the _aliases array: |
|
421 | - * array( |
|
422 | - * 'interface_alias' => 'some\namespace\interface' |
|
423 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
424 | - * ) |
|
425 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
426 | - * to load an instance of 'some\namespace\classname' |
|
427 | - * |
|
428 | - * @param string $alias |
|
429 | - * @param string $for_class |
|
430 | - * @return string |
|
431 | - */ |
|
432 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
433 | - { |
|
434 | - return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
435 | - } |
|
436 | - |
|
437 | - |
|
438 | - /** |
|
439 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
440 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
441 | - * This is done by using the following class constants: |
|
442 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
443 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
444 | - */ |
|
445 | - protected function _register_core_dependencies() |
|
446 | - { |
|
447 | - $this->_dependency_map = [ |
|
448 | - 'EE_Admin' => [ |
|
449 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
450 | - ], |
|
451 | - 'EE_Request_Handler' => [ |
|
452 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
453 | - 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
454 | - ], |
|
455 | - 'EE_System' => [ |
|
456 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
457 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
458 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
459 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
460 | - ], |
|
461 | - 'EE_Session' => [ |
|
462 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
463 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
464 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
465 | - 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
466 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
467 | - ], |
|
468 | - 'EE_Cart' => [ |
|
469 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
470 | - ], |
|
471 | - 'EE_Front_Controller' => [ |
|
472 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
473 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
474 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
475 | - ], |
|
476 | - 'EE_Messenger_Collection_Loader' => [ |
|
477 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
478 | - ], |
|
479 | - 'EE_Message_Type_Collection_Loader' => [ |
|
480 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
481 | - ], |
|
482 | - 'EE_Message_Resource_Manager' => [ |
|
483 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
484 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
485 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
486 | - ], |
|
487 | - 'EE_Message_Factory' => [ |
|
488 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
489 | - ], |
|
490 | - 'EE_messages' => [ |
|
491 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
492 | - ], |
|
493 | - 'EE_Messages_Generator' => [ |
|
494 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
495 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
496 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
497 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
498 | - ], |
|
499 | - 'EE_Messages_Processor' => [ |
|
500 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
501 | - ], |
|
502 | - 'EE_Messages_Queue' => [ |
|
503 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
504 | - ], |
|
505 | - 'EE_Messages_Template_Defaults' => [ |
|
506 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
507 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
508 | - ], |
|
509 | - 'EE_Message_To_Generate_From_Request' => [ |
|
510 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
511 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
512 | - ], |
|
513 | - 'EventEspresso\core\services\commands\CommandBus' => [ |
|
514 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
515 | - ], |
|
516 | - 'EventEspresso\services\commands\CommandHandler' => [ |
|
517 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
518 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
519 | - ], |
|
520 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
521 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
522 | - ], |
|
523 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
524 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
525 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
526 | - ], |
|
527 | - 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
528 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
529 | - ], |
|
530 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
531 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
532 | - ], |
|
533 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
534 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
535 | - ], |
|
536 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
537 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
538 | - ], |
|
539 | - 'EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
540 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
541 | - ], |
|
542 | - 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
543 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
544 | - ], |
|
545 | - 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
546 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
547 | - ], |
|
548 | - 'EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
549 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
550 | - ], |
|
551 | - 'EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
552 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
553 | - ], |
|
554 | - 'EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
555 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
556 | - ], |
|
557 | - 'EventEspresso\core\domain\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
558 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
559 | - ], |
|
560 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
561 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
562 | - ], |
|
563 | - 'EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
564 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
565 | - ], |
|
566 | - 'EventEspresso\core\services\database\TableManager' => [ |
|
567 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
568 | - ], |
|
569 | - 'EE_Data_Migration_Class_Base' => [ |
|
570 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
571 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
572 | - ], |
|
573 | - 'EE_DMS_Core_4_1_0' => [ |
|
574 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
575 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
576 | - ], |
|
577 | - 'EE_DMS_Core_4_2_0' => [ |
|
578 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
580 | - ], |
|
581 | - 'EE_DMS_Core_4_3_0' => [ |
|
582 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
583 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
584 | - ], |
|
585 | - 'EE_DMS_Core_4_4_0' => [ |
|
586 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
587 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
588 | - ], |
|
589 | - 'EE_DMS_Core_4_5_0' => [ |
|
590 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
591 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
592 | - ], |
|
593 | - 'EE_DMS_Core_4_6_0' => [ |
|
594 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
595 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
596 | - ], |
|
597 | - 'EE_DMS_Core_4_7_0' => [ |
|
598 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
599 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
600 | - ], |
|
601 | - 'EE_DMS_Core_4_8_0' => [ |
|
602 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
603 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
604 | - ], |
|
605 | - 'EE_DMS_Core_4_9_0' => [ |
|
606 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
607 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
608 | - ], |
|
609 | - 'EE_DMS_Core_4_10_0' => [ |
|
610 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
611 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
612 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
613 | - ], |
|
614 | - 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
615 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
616 | - ], |
|
617 | - 'EventEspresso\core\services\assets\Registry' => [ |
|
618 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
619 | - 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
620 | - ], |
|
621 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
622 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
623 | - ], |
|
624 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
625 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
626 | - ], |
|
627 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
628 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
629 | - ], |
|
630 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
631 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
632 | - ], |
|
633 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
634 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
635 | - ], |
|
636 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
637 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
638 | - ], |
|
639 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
640 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
641 | - ], |
|
642 | - 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
643 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
644 | - ], |
|
645 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
646 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
647 | - ], |
|
648 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
649 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
650 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
651 | - ], |
|
652 | - 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
653 | - null, |
|
654 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
655 | - ], |
|
656 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
657 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
658 | - ], |
|
659 | - 'LEGACY_MODELS' => [ |
|
660 | - null, |
|
661 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
662 | - ], |
|
663 | - 'EE_Module_Request_Router' => [ |
|
664 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
665 | - ], |
|
666 | - 'EE_Registration_Processor' => [ |
|
667 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
668 | - ], |
|
669 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
670 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
671 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
672 | - ], |
|
673 | - 'EE_Admin_Transactions_List_Table' => [ |
|
674 | - null, |
|
675 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
676 | - ], |
|
677 | - 'EventEspresso\core\domain\services\admin\ExitModal' => [ |
|
678 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
679 | - ], |
|
680 | - 'EventEspresso\core\domain\services\admin\PluginUpsells' => [ |
|
681 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
682 | - ], |
|
683 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
684 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
685 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
686 | - ], |
|
687 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => [ |
|
688 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
689 | - ], |
|
690 | - 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
691 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
692 | - 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
693 | - ], |
|
694 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
695 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
696 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
697 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
698 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
699 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
700 | - ], |
|
701 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
702 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
703 | - ], |
|
704 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
705 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
706 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
707 | - ], |
|
708 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
709 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
710 | - ], |
|
711 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
712 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
713 | - ], |
|
714 | - 'EE_CPT_Strategy' => [ |
|
715 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
716 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
717 | - ], |
|
718 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
719 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
720 | - ], |
|
721 | - 'EventEspresso\core\domain\services\assets\CoreAssetManager' => [ |
|
722 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
723 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
724 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
725 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
726 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
727 | - ], |
|
728 | - 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => [ |
|
729 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
730 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
731 | - ], |
|
732 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => [ |
|
733 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
734 | - ], |
|
735 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => [ |
|
736 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
737 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
738 | - ], |
|
739 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => [ |
|
740 | - 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
741 | - ], |
|
742 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => [ |
|
743 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
744 | - ], |
|
745 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => [ |
|
746 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
747 | - ], |
|
748 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => [ |
|
749 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
750 | - ], |
|
751 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => [ |
|
752 | - 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
753 | - 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
754 | - ], |
|
755 | - 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
756 | - null, |
|
757 | - null, |
|
758 | - null, |
|
759 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
760 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
761 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
762 | - ], |
|
763 | - 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => [ |
|
764 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
765 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
766 | - ], |
|
767 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' => [ |
|
768 | - 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
769 | - 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
770 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
771 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
772 | - ], |
|
773 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => [ |
|
774 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
775 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
776 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
777 | - ], |
|
778 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => [ |
|
779 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
780 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
781 | - ], |
|
782 | - 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => [ |
|
783 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
784 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
785 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
786 | - ], |
|
787 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => [ |
|
788 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
789 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
790 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
791 | - ], |
|
792 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => [ |
|
793 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
794 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
795 | - ], |
|
796 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => [ |
|
797 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
798 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
799 | - ], |
|
800 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => [ |
|
801 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache, |
|
802 | - ], |
|
803 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => [ |
|
804 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
805 | - ], |
|
806 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => [ |
|
807 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache, |
|
808 | - ], |
|
809 | - 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => [ |
|
810 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
811 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
812 | - ], |
|
813 | - 'EventEspresso\core\libraries\rest_api\calculations\Event' => [ |
|
814 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
815 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
816 | - ], |
|
817 | - 'EventEspresso\core\libraries\rest_api\calculations\Registration' => [ |
|
818 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
819 | - ], |
|
820 | - 'EventEspresso\core\services\session\SessionStartHandler' => [ |
|
821 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
822 | - ], |
|
823 | - 'EE_URL_Validation_Strategy' => [ |
|
824 | - null, |
|
825 | - null, |
|
826 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
827 | - ], |
|
828 | - 'EventEspresso\admin_pages\general_settings\OrganizationSettings' => [ |
|
829 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
830 | - 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
831 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
832 | - 'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
833 | - 'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache, |
|
834 | - ], |
|
835 | - 'EventEspresso\core\services\address\CountrySubRegionDao' => [ |
|
836 | - 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
837 | - 'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache, |
|
838 | - ], |
|
839 | - 'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => [ |
|
840 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
841 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
842 | - ], |
|
843 | - 'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => [ |
|
844 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
845 | - 'EE_Environment_Config' => EE_Dependency_Map::load_from_cache, |
|
846 | - ], |
|
847 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
848 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
849 | - ], |
|
850 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
851 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
852 | - ], |
|
853 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [ |
|
854 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
855 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
856 | - null, |
|
857 | - ], |
|
858 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [ |
|
859 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
860 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
861 | - ], |
|
862 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [ |
|
863 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
864 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
865 | - ], |
|
866 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [ |
|
867 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
868 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
869 | - ], |
|
870 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [ |
|
871 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
872 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
873 | - ], |
|
874 | - 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
875 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
876 | - ], |
|
877 | - 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
878 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
879 | - ], |
|
880 | - 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
881 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
882 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
883 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
884 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
885 | - ], |
|
886 | - 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
887 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
888 | - ], |
|
889 | - 'EventEspresso\core\services\request\CurrentPage' => [ |
|
890 | - 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
891 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
892 | - ], |
|
893 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
894 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
895 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
896 | - ], |
|
897 | - 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
898 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
899 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
900 | - ], |
|
901 | - 'EE_Brewing_Regular' => [ |
|
902 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
903 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
904 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
905 | - ], |
|
906 | - ]; |
|
907 | - } |
|
908 | - |
|
909 | - |
|
910 | - /** |
|
911 | - * Registers how core classes are loaded. |
|
912 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
913 | - * 'EE_Request_Handler' => 'load_core' |
|
914 | - * 'EE_Messages_Queue' => 'load_lib' |
|
915 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
916 | - * or, if greater control is required, by providing a custom closure. For example: |
|
917 | - * 'Some_Class' => function () { |
|
918 | - * return new Some_Class(); |
|
919 | - * }, |
|
920 | - * This is required for instantiating dependencies |
|
921 | - * where an interface has been type hinted in a class constructor. For example: |
|
922 | - * 'Required_Interface' => function () { |
|
923 | - * return new A_Class_That_Implements_Required_Interface(); |
|
924 | - * }, |
|
925 | - */ |
|
926 | - protected function _register_core_class_loaders() |
|
927 | - { |
|
928 | - $this->_class_loaders = [ |
|
929 | - // load_core |
|
930 | - 'EE_Dependency_Map' => function () { |
|
931 | - return $this; |
|
932 | - }, |
|
933 | - 'EE_Capabilities' => 'load_core', |
|
934 | - 'EE_Encryption' => 'load_core', |
|
935 | - 'EE_Front_Controller' => 'load_core', |
|
936 | - 'EE_Module_Request_Router' => 'load_core', |
|
937 | - 'EE_Registry' => 'load_core', |
|
938 | - 'EE_Request' => function () { |
|
939 | - return $this->legacy_request; |
|
940 | - }, |
|
941 | - 'EventEspresso\core\services\request\Request' => function () { |
|
942 | - return $this->request; |
|
943 | - }, |
|
944 | - 'EventEspresso\core\services\request\Response' => function () { |
|
945 | - return $this->response; |
|
946 | - }, |
|
947 | - 'EE_Base' => 'load_core', |
|
948 | - 'EE_Request_Handler' => 'load_core', |
|
949 | - 'EE_Session' => 'load_core', |
|
950 | - 'EE_Cron_Tasks' => 'load_core', |
|
951 | - 'EE_System' => 'load_core', |
|
952 | - 'EE_Maintenance_Mode' => 'load_core', |
|
953 | - 'EE_Register_CPTs' => 'load_core', |
|
954 | - 'EE_Admin' => 'load_core', |
|
955 | - 'EE_CPT_Strategy' => 'load_core', |
|
956 | - // load_class |
|
957 | - 'EE_Registration_Processor' => 'load_class', |
|
958 | - // load_lib |
|
959 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
960 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
961 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
962 | - 'EE_Messenger_Collection' => 'load_lib', |
|
963 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
964 | - 'EE_Messages_Processor' => 'load_lib', |
|
965 | - 'EE_Message_Repository' => 'load_lib', |
|
966 | - 'EE_Messages_Queue' => 'load_lib', |
|
967 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
968 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
969 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
970 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
971 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
972 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
973 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
974 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
975 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
976 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
977 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
978 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
979 | - 'EE_Messages_Generator' => function () { |
|
980 | - return EE_Registry::instance()->load_lib( |
|
981 | - 'Messages_Generator', |
|
982 | - [], |
|
983 | - false, |
|
984 | - false |
|
985 | - ); |
|
986 | - }, |
|
987 | - 'EE_Messages_Template_Defaults' => function ($arguments = []) { |
|
988 | - return EE_Registry::instance()->load_lib( |
|
989 | - 'Messages_Template_Defaults', |
|
990 | - $arguments, |
|
991 | - false, |
|
992 | - false |
|
993 | - ); |
|
994 | - }, |
|
995 | - // load_helper |
|
996 | - 'EEH_Parse_Shortcodes' => function () { |
|
997 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
998 | - return new EEH_Parse_Shortcodes(); |
|
999 | - } |
|
1000 | - return null; |
|
1001 | - }, |
|
1002 | - 'EE_Template_Config' => function () { |
|
1003 | - return EE_Config::instance()->template_settings; |
|
1004 | - }, |
|
1005 | - 'EE_Currency_Config' => function () { |
|
1006 | - return EE_Config::instance()->currency; |
|
1007 | - }, |
|
1008 | - 'EE_Registration_Config' => function () { |
|
1009 | - return EE_Config::instance()->registration; |
|
1010 | - }, |
|
1011 | - 'EE_Core_Config' => function () { |
|
1012 | - return EE_Config::instance()->core; |
|
1013 | - }, |
|
1014 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
1015 | - return LoaderFactory::getLoader(); |
|
1016 | - }, |
|
1017 | - 'EE_Network_Config' => function () { |
|
1018 | - return EE_Network_Config::instance(); |
|
1019 | - }, |
|
1020 | - 'EE_Config' => function () { |
|
1021 | - return EE_Config::instance(); |
|
1022 | - }, |
|
1023 | - 'EventEspresso\core\domain\Domain' => function () { |
|
1024 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
1025 | - }, |
|
1026 | - 'EE_Admin_Config' => function () { |
|
1027 | - return EE_Config::instance()->admin; |
|
1028 | - }, |
|
1029 | - 'EE_Organization_Config' => function () { |
|
1030 | - return EE_Config::instance()->organization; |
|
1031 | - }, |
|
1032 | - 'EE_Network_Core_Config' => function () { |
|
1033 | - return EE_Network_Config::instance()->core; |
|
1034 | - }, |
|
1035 | - 'EE_Environment_Config' => function () { |
|
1036 | - return EE_Config::instance()->environment; |
|
1037 | - }, |
|
1038 | - 'EE_Ticket_Selector_Config' => function () { |
|
1039 | - return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
1040 | - }, |
|
1041 | - ]; |
|
1042 | - } |
|
1043 | - |
|
1044 | - |
|
1045 | - /** |
|
1046 | - * can be used for supplying alternate names for classes, |
|
1047 | - * or for connecting interface names to instantiable classes |
|
1048 | - */ |
|
1049 | - protected function _register_core_aliases() |
|
1050 | - { |
|
1051 | - $aliases = [ |
|
1052 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
1053 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
1054 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
1055 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
1056 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
1057 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
1058 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1059 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
1060 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1061 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1062 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommand', |
|
1063 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1064 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1065 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1066 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1067 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommand', |
|
1068 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\domain\services\commands\transaction\CreateTransactionCommandHandler', |
|
1069 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1070 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1071 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1072 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1073 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1074 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1075 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1076 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1077 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1078 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1079 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1080 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1081 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1082 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1083 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1084 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1085 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1086 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1087 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1088 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1089 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
1090 | - ]; |
|
1091 | - foreach ($aliases as $alias => $fqn) { |
|
1092 | - if (is_array($fqn)) { |
|
1093 | - foreach ($fqn as $class => $for_class) { |
|
1094 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
1095 | - } |
|
1096 | - continue; |
|
1097 | - } |
|
1098 | - $this->class_cache->addAlias($fqn, $alias); |
|
1099 | - } |
|
1100 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1101 | - $this->class_cache->addAlias( |
|
1102 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1103 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1104 | - ); |
|
1105 | - } |
|
1106 | - } |
|
1107 | - |
|
1108 | - |
|
1109 | - public function debug($for_class = '') |
|
1110 | - { |
|
1111 | - $this->class_cache->debug($for_class); |
|
1112 | - } |
|
1113 | - |
|
1114 | - |
|
1115 | - /** |
|
1116 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1117 | - * request Primarily used by unit tests. |
|
1118 | - */ |
|
1119 | - public function reset() |
|
1120 | - { |
|
1121 | - $this->_register_core_class_loaders(); |
|
1122 | - $this->_register_core_dependencies(); |
|
1123 | - } |
|
1124 | - |
|
1125 | - |
|
1126 | - /** |
|
1127 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
1128 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
1129 | - * WHY? |
|
1130 | - * Because if a class is type hinting for a concretion, |
|
1131 | - * then why would we need to find another class to supply it? |
|
1132 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1133 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1134 | - * Don't go looking for some substitute. |
|
1135 | - * Whereas if a class is type hinting for an interface... |
|
1136 | - * then we need to find an actual class to use. |
|
1137 | - * So the interface IS the alias for some other FQN, |
|
1138 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1139 | - * represents some other class. |
|
1140 | - * |
|
1141 | - * @param string $fqn |
|
1142 | - * @param string $for_class |
|
1143 | - * @return bool |
|
1144 | - * @deprecated 4.9.62.p |
|
1145 | - */ |
|
1146 | - public function has_alias($fqn = '', $for_class = '') |
|
1147 | - { |
|
1148 | - return $this->isAlias($fqn, $for_class); |
|
1149 | - } |
|
1150 | - |
|
1151 | - |
|
1152 | - /** |
|
1153 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1154 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1155 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1156 | - * for example: |
|
1157 | - * if the following two entries were added to the _aliases array: |
|
1158 | - * array( |
|
1159 | - * 'interface_alias' => 'some\namespace\interface' |
|
1160 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
1161 | - * ) |
|
1162 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1163 | - * to load an instance of 'some\namespace\classname' |
|
1164 | - * |
|
1165 | - * @param string $alias |
|
1166 | - * @param string $for_class |
|
1167 | - * @return string |
|
1168 | - * @deprecated 4.9.62.p |
|
1169 | - */ |
|
1170 | - public function get_alias($alias = '', $for_class = '') |
|
1171 | - { |
|
1172 | - return $this->getFqnForAlias($alias, $for_class); |
|
1173 | - } |
|
22 | + /** |
|
23 | + * This means that the requested class dependency is not present in the dependency map |
|
24 | + */ |
|
25 | + const not_registered = 0; |
|
26 | + |
|
27 | + /** |
|
28 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
29 | + */ |
|
30 | + const load_new_object = 1; |
|
31 | + |
|
32 | + /** |
|
33 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
34 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
35 | + */ |
|
36 | + const load_from_cache = 2; |
|
37 | + |
|
38 | + /** |
|
39 | + * When registering a dependency, |
|
40 | + * this indicates to keep any existing dependencies that already exist, |
|
41 | + * and simply discard any new dependencies declared in the incoming data |
|
42 | + */ |
|
43 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
44 | + |
|
45 | + /** |
|
46 | + * When registering a dependency, |
|
47 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
48 | + */ |
|
49 | + const OVERWRITE_DEPENDENCIES = 1; |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @type EE_Dependency_Map $_instance |
|
54 | + */ |
|
55 | + protected static $_instance; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var ClassInterfaceCache $class_cache |
|
59 | + */ |
|
60 | + private $class_cache; |
|
61 | + |
|
62 | + /** |
|
63 | + * @type RequestInterface $request |
|
64 | + */ |
|
65 | + protected $request; |
|
66 | + |
|
67 | + /** |
|
68 | + * @type LegacyRequestInterface $legacy_request |
|
69 | + */ |
|
70 | + protected $legacy_request; |
|
71 | + |
|
72 | + /** |
|
73 | + * @type ResponseInterface $response |
|
74 | + */ |
|
75 | + protected $response; |
|
76 | + |
|
77 | + /** |
|
78 | + * @type LoaderInterface $loader |
|
79 | + */ |
|
80 | + protected $loader; |
|
81 | + |
|
82 | + /** |
|
83 | + * @type array $_dependency_map |
|
84 | + */ |
|
85 | + protected $_dependency_map = []; |
|
86 | + |
|
87 | + /** |
|
88 | + * @type array $_class_loaders |
|
89 | + */ |
|
90 | + protected $_class_loaders = []; |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * EE_Dependency_Map constructor. |
|
95 | + * |
|
96 | + * @param ClassInterfaceCache $class_cache |
|
97 | + */ |
|
98 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
99 | + { |
|
100 | + $this->class_cache = $class_cache; |
|
101 | + do_action('EE_Dependency_Map____construct', $this); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return void |
|
107 | + */ |
|
108 | + public function initialize() |
|
109 | + { |
|
110 | + $this->_register_core_dependencies(); |
|
111 | + $this->_register_core_class_loaders(); |
|
112 | + $this->_register_core_aliases(); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @singleton method used to instantiate class object |
|
118 | + * @param ClassInterfaceCache|null $class_cache |
|
119 | + * @return EE_Dependency_Map |
|
120 | + */ |
|
121 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
122 | + { |
|
123 | + // check if class object is instantiated, and instantiated properly |
|
124 | + if ( |
|
125 | + ! self::$_instance instanceof EE_Dependency_Map |
|
126 | + && $class_cache instanceof ClassInterfaceCache |
|
127 | + ) { |
|
128 | + self::$_instance = new EE_Dependency_Map($class_cache); |
|
129 | + } |
|
130 | + return self::$_instance; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param RequestInterface $request |
|
136 | + */ |
|
137 | + public function setRequest(RequestInterface $request) |
|
138 | + { |
|
139 | + $this->request = $request; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @param LegacyRequestInterface $legacy_request |
|
145 | + */ |
|
146 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
147 | + { |
|
148 | + $this->legacy_request = $legacy_request; |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @param ResponseInterface $response |
|
154 | + */ |
|
155 | + public function setResponse(ResponseInterface $response) |
|
156 | + { |
|
157 | + $this->response = $response; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param LoaderInterface $loader |
|
163 | + */ |
|
164 | + public function setLoader(LoaderInterface $loader) |
|
165 | + { |
|
166 | + $this->loader = $loader; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @param string $class |
|
172 | + * @param array $dependencies |
|
173 | + * @param int $overwrite |
|
174 | + * @return bool |
|
175 | + */ |
|
176 | + public static function register_dependencies( |
|
177 | + $class, |
|
178 | + array $dependencies, |
|
179 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
180 | + ) { |
|
181 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
187 | + * to the class specified by the first parameter. |
|
188 | + * IMPORTANT !!! |
|
189 | + * The order of elements in the incoming $dependencies array MUST match |
|
190 | + * the order of the constructor parameters for the class in question. |
|
191 | + * This is especially important when overriding any existing dependencies that are registered. |
|
192 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
193 | + * |
|
194 | + * @param string $class |
|
195 | + * @param array $dependencies |
|
196 | + * @param int $overwrite |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | + public function registerDependencies( |
|
200 | + $class, |
|
201 | + array $dependencies, |
|
202 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
203 | + ) { |
|
204 | + $class = trim($class, '\\'); |
|
205 | + $registered = false; |
|
206 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
207 | + self::$_instance->_dependency_map[ $class ] = []; |
|
208 | + } |
|
209 | + // we need to make sure that any aliases used when registering a dependency |
|
210 | + // get resolved to the correct class name |
|
211 | + foreach ($dependencies as $dependency => $load_source) { |
|
212 | + $alias = self::$_instance->getFqnForAlias($dependency); |
|
213 | + if ( |
|
214 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
215 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
216 | + ) { |
|
217 | + unset($dependencies[ $dependency ]); |
|
218 | + $dependencies[ $alias ] = $load_source; |
|
219 | + $registered = true; |
|
220 | + } |
|
221 | + } |
|
222 | + // now add our two lists of dependencies together. |
|
223 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
224 | + // so $dependencies is NOT overwritten because it is listed first |
|
225 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
226 | + // Union is way faster than array_merge() but should be used with caution... |
|
227 | + // especially with numerically indexed arrays |
|
228 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
229 | + // now we need to ensure that the resulting dependencies |
|
230 | + // array only has the entries that are required for the class |
|
231 | + // so first count how many dependencies were originally registered for the class |
|
232 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
233 | + // if that count is non-zero (meaning dependencies were already registered) |
|
234 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
235 | + // then truncate the final array to match that count |
|
236 | + ? array_slice($dependencies, 0, $dependency_count) |
|
237 | + // otherwise just take the incoming array because nothing previously existed |
|
238 | + : $dependencies; |
|
239 | + return $registered; |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * @param string $class_name |
|
245 | + * @param string $loader |
|
246 | + * @param bool $overwrite |
|
247 | + * @return bool |
|
248 | + * @throws DomainException |
|
249 | + */ |
|
250 | + public static function register_class_loader($class_name, $loader = 'load_core', $overwrite = false) |
|
251 | + { |
|
252 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
253 | + throw new DomainException( |
|
254 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
255 | + ); |
|
256 | + } |
|
257 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
258 | + if ( |
|
259 | + ! is_callable($loader) |
|
260 | + && ( |
|
261 | + strpos($loader, 'load_') !== 0 |
|
262 | + || ! method_exists('EE_Registry', $loader) |
|
263 | + ) |
|
264 | + ) { |
|
265 | + throw new DomainException( |
|
266 | + sprintf( |
|
267 | + esc_html__( |
|
268 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
269 | + 'event_espresso' |
|
270 | + ), |
|
271 | + $loader |
|
272 | + ) |
|
273 | + ); |
|
274 | + } |
|
275 | + $class_name = self::$_instance->getFqnForAlias($class_name); |
|
276 | + if ($overwrite || ! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
277 | + self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
278 | + return true; |
|
279 | + } |
|
280 | + return false; |
|
281 | + } |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * @return array |
|
286 | + */ |
|
287 | + public function dependency_map() |
|
288 | + { |
|
289 | + return $this->_dependency_map; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
295 | + * |
|
296 | + * @param string $class_name |
|
297 | + * @return boolean |
|
298 | + */ |
|
299 | + public function has($class_name = '') |
|
300 | + { |
|
301 | + // all legacy models have the same dependencies |
|
302 | + if (strpos($class_name, 'EEM_') === 0) { |
|
303 | + $class_name = 'LEGACY_MODELS'; |
|
304 | + } |
|
305 | + return isset($this->_dependency_map[ $class_name ]); |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
311 | + * |
|
312 | + * @param string $class_name |
|
313 | + * @param string $dependency |
|
314 | + * @return bool |
|
315 | + */ |
|
316 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
317 | + { |
|
318 | + // all legacy models have the same dependencies |
|
319 | + if (strpos($class_name, 'EEM_') === 0) { |
|
320 | + $class_name = 'LEGACY_MODELS'; |
|
321 | + } |
|
322 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
323 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
329 | + * |
|
330 | + * @param string $class_name |
|
331 | + * @param string $dependency |
|
332 | + * @return int |
|
333 | + */ |
|
334 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
335 | + { |
|
336 | + // all legacy models have the same dependencies |
|
337 | + if (strpos($class_name, 'EEM_') === 0) { |
|
338 | + $class_name = 'LEGACY_MODELS'; |
|
339 | + } |
|
340 | + $dependency = $this->getFqnForAlias($dependency); |
|
341 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
342 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
343 | + : EE_Dependency_Map::not_registered; |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * @param string $class_name |
|
349 | + * @return string | Closure |
|
350 | + */ |
|
351 | + public function class_loader($class_name) |
|
352 | + { |
|
353 | + // all legacy models use load_model() |
|
354 | + if (strpos($class_name, 'EEM_') === 0) { |
|
355 | + return 'load_model'; |
|
356 | + } |
|
357 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
358 | + // perform strpos() first to avoid loading regex every time we load a class |
|
359 | + if ( |
|
360 | + strpos($class_name, 'EE_CPT_') === 0 |
|
361 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
362 | + ) { |
|
363 | + return 'load_core'; |
|
364 | + } |
|
365 | + $class_name = $this->getFqnForAlias($class_name); |
|
366 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + /** |
|
371 | + * @return array |
|
372 | + */ |
|
373 | + public function class_loaders() |
|
374 | + { |
|
375 | + return $this->_class_loaders; |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * adds an alias for a classname |
|
381 | + * |
|
382 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
383 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
384 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
385 | + */ |
|
386 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
387 | + { |
|
388 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
389 | + } |
|
390 | + |
|
391 | + |
|
392 | + /** |
|
393 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
394 | + * WHY? |
|
395 | + * Because if a class is type hinting for a concretion, |
|
396 | + * then why would we need to find another class to supply it? |
|
397 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
398 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
399 | + * Don't go looking for some substitute. |
|
400 | + * Whereas if a class is type hinting for an interface... |
|
401 | + * then we need to find an actual class to use. |
|
402 | + * So the interface IS the alias for some other FQN, |
|
403 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
404 | + * represents some other class. |
|
405 | + * |
|
406 | + * @param string $fqn |
|
407 | + * @param string $for_class |
|
408 | + * @return bool |
|
409 | + */ |
|
410 | + public function isAlias($fqn = '', $for_class = '') |
|
411 | + { |
|
412 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + /** |
|
417 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
418 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
419 | + * for example: |
|
420 | + * if the following two entries were added to the _aliases array: |
|
421 | + * array( |
|
422 | + * 'interface_alias' => 'some\namespace\interface' |
|
423 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
424 | + * ) |
|
425 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
426 | + * to load an instance of 'some\namespace\classname' |
|
427 | + * |
|
428 | + * @param string $alias |
|
429 | + * @param string $for_class |
|
430 | + * @return string |
|
431 | + */ |
|
432 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
433 | + { |
|
434 | + return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
435 | + } |
|
436 | + |
|
437 | + |
|
438 | + /** |
|
439 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
440 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
441 | + * This is done by using the following class constants: |
|
442 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
443 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
444 | + */ |
|
445 | + protected function _register_core_dependencies() |
|
446 | + { |
|
447 | + $this->_dependency_map = [ |
|
448 | + 'EE_Admin' => [ |
|
449 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
450 | + ], |
|
451 | + 'EE_Request_Handler' => [ |
|
452 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
453 | + 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
454 | + ], |
|
455 | + 'EE_System' => [ |
|
456 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
457 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
458 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
459 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
460 | + ], |
|
461 | + 'EE_Session' => [ |
|
462 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
463 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
464 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
465 | + 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
466 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
467 | + ], |
|
468 | + 'EE_Cart' => [ |
|
469 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
470 | + ], |
|
471 | + 'EE_Front_Controller' => [ |
|
472 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
473 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
474 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
475 | + ], |
|
476 | + 'EE_Messenger_Collection_Loader' => [ |
|
477 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
478 | + ], |
|
479 | + 'EE_Message_Type_Collection_Loader' => [ |
|
480 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
481 | + ], |
|
482 | + 'EE_Message_Resource_Manager' => [ |
|
483 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
484 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
485 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
486 | + ], |
|
487 | + 'EE_Message_Factory' => [ |
|
488 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
489 | + ], |
|
490 | + 'EE_messages' => [ |
|
491 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
492 | + ], |
|
493 | + 'EE_Messages_Generator' => [ |
|
494 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
495 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
496 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
497 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
498 | + ], |
|
499 | + 'EE_Messages_Processor' => [ |
|
500 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
501 | + ], |
|
502 | + 'EE_Messages_Queue' => [ |
|
503 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
504 | + ], |
|
505 | + 'EE_Messages_Template_Defaults' => [ |
|
506 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
507 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
508 | + ], |
|
509 | + 'EE_Message_To_Generate_From_Request' => [ |
|
510 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
511 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
512 | + ], |
|
513 | + 'EventEspresso\core\services\commands\CommandBus' => [ |
|
514 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
515 | + ], |
|
516 | + 'EventEspresso\services\commands\CommandHandler' => [ |
|
517 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
518 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
519 | + ], |
|
520 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
521 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
522 | + ], |
|
523 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
524 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
525 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
526 | + ], |
|
527 | + 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
528 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
529 | + ], |
|
530 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
531 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
532 | + ], |
|
533 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
534 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
535 | + ], |
|
536 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
537 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
538 | + ], |
|
539 | + 'EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
540 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
541 | + ], |
|
542 | + 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
543 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
544 | + ], |
|
545 | + 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
546 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
547 | + ], |
|
548 | + 'EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
549 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
550 | + ], |
|
551 | + 'EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
552 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
553 | + ], |
|
554 | + 'EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
555 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
556 | + ], |
|
557 | + 'EventEspresso\core\domain\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
558 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
559 | + ], |
|
560 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
561 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
562 | + ], |
|
563 | + 'EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
564 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
565 | + ], |
|
566 | + 'EventEspresso\core\services\database\TableManager' => [ |
|
567 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
568 | + ], |
|
569 | + 'EE_Data_Migration_Class_Base' => [ |
|
570 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
571 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
572 | + ], |
|
573 | + 'EE_DMS_Core_4_1_0' => [ |
|
574 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
575 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
576 | + ], |
|
577 | + 'EE_DMS_Core_4_2_0' => [ |
|
578 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
580 | + ], |
|
581 | + 'EE_DMS_Core_4_3_0' => [ |
|
582 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
583 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
584 | + ], |
|
585 | + 'EE_DMS_Core_4_4_0' => [ |
|
586 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
587 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
588 | + ], |
|
589 | + 'EE_DMS_Core_4_5_0' => [ |
|
590 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
591 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
592 | + ], |
|
593 | + 'EE_DMS_Core_4_6_0' => [ |
|
594 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
595 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
596 | + ], |
|
597 | + 'EE_DMS_Core_4_7_0' => [ |
|
598 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
599 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
600 | + ], |
|
601 | + 'EE_DMS_Core_4_8_0' => [ |
|
602 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
603 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
604 | + ], |
|
605 | + 'EE_DMS_Core_4_9_0' => [ |
|
606 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
607 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
608 | + ], |
|
609 | + 'EE_DMS_Core_4_10_0' => [ |
|
610 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
611 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
612 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
613 | + ], |
|
614 | + 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
615 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
616 | + ], |
|
617 | + 'EventEspresso\core\services\assets\Registry' => [ |
|
618 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
619 | + 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
620 | + ], |
|
621 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
622 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
623 | + ], |
|
624 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
625 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
626 | + ], |
|
627 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
628 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
629 | + ], |
|
630 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
631 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
632 | + ], |
|
633 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
634 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
635 | + ], |
|
636 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
637 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
638 | + ], |
|
639 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
640 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
641 | + ], |
|
642 | + 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
643 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
644 | + ], |
|
645 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
646 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
647 | + ], |
|
648 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
649 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
650 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
651 | + ], |
|
652 | + 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
653 | + null, |
|
654 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
655 | + ], |
|
656 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
657 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
658 | + ], |
|
659 | + 'LEGACY_MODELS' => [ |
|
660 | + null, |
|
661 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
662 | + ], |
|
663 | + 'EE_Module_Request_Router' => [ |
|
664 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
665 | + ], |
|
666 | + 'EE_Registration_Processor' => [ |
|
667 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
668 | + ], |
|
669 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
670 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
671 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
672 | + ], |
|
673 | + 'EE_Admin_Transactions_List_Table' => [ |
|
674 | + null, |
|
675 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
676 | + ], |
|
677 | + 'EventEspresso\core\domain\services\admin\ExitModal' => [ |
|
678 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
679 | + ], |
|
680 | + 'EventEspresso\core\domain\services\admin\PluginUpsells' => [ |
|
681 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
682 | + ], |
|
683 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
684 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
685 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
686 | + ], |
|
687 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => [ |
|
688 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
689 | + ], |
|
690 | + 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
691 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
692 | + 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
693 | + ], |
|
694 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
695 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
696 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
697 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
698 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
699 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
700 | + ], |
|
701 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
702 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
703 | + ], |
|
704 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
705 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
706 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
707 | + ], |
|
708 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
709 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
710 | + ], |
|
711 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
712 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
713 | + ], |
|
714 | + 'EE_CPT_Strategy' => [ |
|
715 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
716 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
717 | + ], |
|
718 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
719 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
720 | + ], |
|
721 | + 'EventEspresso\core\domain\services\assets\CoreAssetManager' => [ |
|
722 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
723 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
724 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
725 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
726 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
727 | + ], |
|
728 | + 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => [ |
|
729 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
730 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
731 | + ], |
|
732 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => [ |
|
733 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
734 | + ], |
|
735 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => [ |
|
736 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
737 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
738 | + ], |
|
739 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => [ |
|
740 | + 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
741 | + ], |
|
742 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => [ |
|
743 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
744 | + ], |
|
745 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => [ |
|
746 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
747 | + ], |
|
748 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => [ |
|
749 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
750 | + ], |
|
751 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => [ |
|
752 | + 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
753 | + 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
754 | + ], |
|
755 | + 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
756 | + null, |
|
757 | + null, |
|
758 | + null, |
|
759 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
760 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
761 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
762 | + ], |
|
763 | + 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => [ |
|
764 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
765 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
766 | + ], |
|
767 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' => [ |
|
768 | + 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
769 | + 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
770 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
771 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
772 | + ], |
|
773 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => [ |
|
774 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
775 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
776 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
777 | + ], |
|
778 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => [ |
|
779 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
780 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
781 | + ], |
|
782 | + 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => [ |
|
783 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
784 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
785 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
786 | + ], |
|
787 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => [ |
|
788 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
789 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
790 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
791 | + ], |
|
792 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => [ |
|
793 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
794 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
795 | + ], |
|
796 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => [ |
|
797 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
798 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
799 | + ], |
|
800 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => [ |
|
801 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache, |
|
802 | + ], |
|
803 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => [ |
|
804 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
805 | + ], |
|
806 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => [ |
|
807 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache, |
|
808 | + ], |
|
809 | + 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => [ |
|
810 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
811 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
812 | + ], |
|
813 | + 'EventEspresso\core\libraries\rest_api\calculations\Event' => [ |
|
814 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
815 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
816 | + ], |
|
817 | + 'EventEspresso\core\libraries\rest_api\calculations\Registration' => [ |
|
818 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
819 | + ], |
|
820 | + 'EventEspresso\core\services\session\SessionStartHandler' => [ |
|
821 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
822 | + ], |
|
823 | + 'EE_URL_Validation_Strategy' => [ |
|
824 | + null, |
|
825 | + null, |
|
826 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
827 | + ], |
|
828 | + 'EventEspresso\admin_pages\general_settings\OrganizationSettings' => [ |
|
829 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
830 | + 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
831 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
832 | + 'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
833 | + 'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache, |
|
834 | + ], |
|
835 | + 'EventEspresso\core\services\address\CountrySubRegionDao' => [ |
|
836 | + 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
837 | + 'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache, |
|
838 | + ], |
|
839 | + 'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => [ |
|
840 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
841 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
842 | + ], |
|
843 | + 'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => [ |
|
844 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
845 | + 'EE_Environment_Config' => EE_Dependency_Map::load_from_cache, |
|
846 | + ], |
|
847 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
848 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
849 | + ], |
|
850 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
851 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
852 | + ], |
|
853 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [ |
|
854 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
855 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
856 | + null, |
|
857 | + ], |
|
858 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [ |
|
859 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
860 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
861 | + ], |
|
862 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [ |
|
863 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
864 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
865 | + ], |
|
866 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [ |
|
867 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
868 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
869 | + ], |
|
870 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [ |
|
871 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
872 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
873 | + ], |
|
874 | + 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
875 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
876 | + ], |
|
877 | + 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
878 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
879 | + ], |
|
880 | + 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
881 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
882 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
883 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
884 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
885 | + ], |
|
886 | + 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
887 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
888 | + ], |
|
889 | + 'EventEspresso\core\services\request\CurrentPage' => [ |
|
890 | + 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
891 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
892 | + ], |
|
893 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
894 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
895 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
896 | + ], |
|
897 | + 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
898 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
899 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
900 | + ], |
|
901 | + 'EE_Brewing_Regular' => [ |
|
902 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
903 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
904 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
905 | + ], |
|
906 | + ]; |
|
907 | + } |
|
908 | + |
|
909 | + |
|
910 | + /** |
|
911 | + * Registers how core classes are loaded. |
|
912 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
913 | + * 'EE_Request_Handler' => 'load_core' |
|
914 | + * 'EE_Messages_Queue' => 'load_lib' |
|
915 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
916 | + * or, if greater control is required, by providing a custom closure. For example: |
|
917 | + * 'Some_Class' => function () { |
|
918 | + * return new Some_Class(); |
|
919 | + * }, |
|
920 | + * This is required for instantiating dependencies |
|
921 | + * where an interface has been type hinted in a class constructor. For example: |
|
922 | + * 'Required_Interface' => function () { |
|
923 | + * return new A_Class_That_Implements_Required_Interface(); |
|
924 | + * }, |
|
925 | + */ |
|
926 | + protected function _register_core_class_loaders() |
|
927 | + { |
|
928 | + $this->_class_loaders = [ |
|
929 | + // load_core |
|
930 | + 'EE_Dependency_Map' => function () { |
|
931 | + return $this; |
|
932 | + }, |
|
933 | + 'EE_Capabilities' => 'load_core', |
|
934 | + 'EE_Encryption' => 'load_core', |
|
935 | + 'EE_Front_Controller' => 'load_core', |
|
936 | + 'EE_Module_Request_Router' => 'load_core', |
|
937 | + 'EE_Registry' => 'load_core', |
|
938 | + 'EE_Request' => function () { |
|
939 | + return $this->legacy_request; |
|
940 | + }, |
|
941 | + 'EventEspresso\core\services\request\Request' => function () { |
|
942 | + return $this->request; |
|
943 | + }, |
|
944 | + 'EventEspresso\core\services\request\Response' => function () { |
|
945 | + return $this->response; |
|
946 | + }, |
|
947 | + 'EE_Base' => 'load_core', |
|
948 | + 'EE_Request_Handler' => 'load_core', |
|
949 | + 'EE_Session' => 'load_core', |
|
950 | + 'EE_Cron_Tasks' => 'load_core', |
|
951 | + 'EE_System' => 'load_core', |
|
952 | + 'EE_Maintenance_Mode' => 'load_core', |
|
953 | + 'EE_Register_CPTs' => 'load_core', |
|
954 | + 'EE_Admin' => 'load_core', |
|
955 | + 'EE_CPT_Strategy' => 'load_core', |
|
956 | + // load_class |
|
957 | + 'EE_Registration_Processor' => 'load_class', |
|
958 | + // load_lib |
|
959 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
960 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
961 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
962 | + 'EE_Messenger_Collection' => 'load_lib', |
|
963 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
964 | + 'EE_Messages_Processor' => 'load_lib', |
|
965 | + 'EE_Message_Repository' => 'load_lib', |
|
966 | + 'EE_Messages_Queue' => 'load_lib', |
|
967 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
968 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
969 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
970 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
971 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
972 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
973 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
974 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
975 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
976 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
977 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
978 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
979 | + 'EE_Messages_Generator' => function () { |
|
980 | + return EE_Registry::instance()->load_lib( |
|
981 | + 'Messages_Generator', |
|
982 | + [], |
|
983 | + false, |
|
984 | + false |
|
985 | + ); |
|
986 | + }, |
|
987 | + 'EE_Messages_Template_Defaults' => function ($arguments = []) { |
|
988 | + return EE_Registry::instance()->load_lib( |
|
989 | + 'Messages_Template_Defaults', |
|
990 | + $arguments, |
|
991 | + false, |
|
992 | + false |
|
993 | + ); |
|
994 | + }, |
|
995 | + // load_helper |
|
996 | + 'EEH_Parse_Shortcodes' => function () { |
|
997 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
998 | + return new EEH_Parse_Shortcodes(); |
|
999 | + } |
|
1000 | + return null; |
|
1001 | + }, |
|
1002 | + 'EE_Template_Config' => function () { |
|
1003 | + return EE_Config::instance()->template_settings; |
|
1004 | + }, |
|
1005 | + 'EE_Currency_Config' => function () { |
|
1006 | + return EE_Config::instance()->currency; |
|
1007 | + }, |
|
1008 | + 'EE_Registration_Config' => function () { |
|
1009 | + return EE_Config::instance()->registration; |
|
1010 | + }, |
|
1011 | + 'EE_Core_Config' => function () { |
|
1012 | + return EE_Config::instance()->core; |
|
1013 | + }, |
|
1014 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
1015 | + return LoaderFactory::getLoader(); |
|
1016 | + }, |
|
1017 | + 'EE_Network_Config' => function () { |
|
1018 | + return EE_Network_Config::instance(); |
|
1019 | + }, |
|
1020 | + 'EE_Config' => function () { |
|
1021 | + return EE_Config::instance(); |
|
1022 | + }, |
|
1023 | + 'EventEspresso\core\domain\Domain' => function () { |
|
1024 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
1025 | + }, |
|
1026 | + 'EE_Admin_Config' => function () { |
|
1027 | + return EE_Config::instance()->admin; |
|
1028 | + }, |
|
1029 | + 'EE_Organization_Config' => function () { |
|
1030 | + return EE_Config::instance()->organization; |
|
1031 | + }, |
|
1032 | + 'EE_Network_Core_Config' => function () { |
|
1033 | + return EE_Network_Config::instance()->core; |
|
1034 | + }, |
|
1035 | + 'EE_Environment_Config' => function () { |
|
1036 | + return EE_Config::instance()->environment; |
|
1037 | + }, |
|
1038 | + 'EE_Ticket_Selector_Config' => function () { |
|
1039 | + return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
1040 | + }, |
|
1041 | + ]; |
|
1042 | + } |
|
1043 | + |
|
1044 | + |
|
1045 | + /** |
|
1046 | + * can be used for supplying alternate names for classes, |
|
1047 | + * or for connecting interface names to instantiable classes |
|
1048 | + */ |
|
1049 | + protected function _register_core_aliases() |
|
1050 | + { |
|
1051 | + $aliases = [ |
|
1052 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
1053 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
1054 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
1055 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
1056 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
1057 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
1058 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1059 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
1060 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1061 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1062 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommand', |
|
1063 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1064 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1065 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1066 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1067 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommand', |
|
1068 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\domain\services\commands\transaction\CreateTransactionCommandHandler', |
|
1069 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1070 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1071 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1072 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1073 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1074 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1075 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1076 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1077 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1078 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1079 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1080 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1081 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1082 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1083 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1084 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1085 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1086 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1087 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1088 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1089 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
1090 | + ]; |
|
1091 | + foreach ($aliases as $alias => $fqn) { |
|
1092 | + if (is_array($fqn)) { |
|
1093 | + foreach ($fqn as $class => $for_class) { |
|
1094 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
1095 | + } |
|
1096 | + continue; |
|
1097 | + } |
|
1098 | + $this->class_cache->addAlias($fqn, $alias); |
|
1099 | + } |
|
1100 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1101 | + $this->class_cache->addAlias( |
|
1102 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1103 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1104 | + ); |
|
1105 | + } |
|
1106 | + } |
|
1107 | + |
|
1108 | + |
|
1109 | + public function debug($for_class = '') |
|
1110 | + { |
|
1111 | + $this->class_cache->debug($for_class); |
|
1112 | + } |
|
1113 | + |
|
1114 | + |
|
1115 | + /** |
|
1116 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1117 | + * request Primarily used by unit tests. |
|
1118 | + */ |
|
1119 | + public function reset() |
|
1120 | + { |
|
1121 | + $this->_register_core_class_loaders(); |
|
1122 | + $this->_register_core_dependencies(); |
|
1123 | + } |
|
1124 | + |
|
1125 | + |
|
1126 | + /** |
|
1127 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
1128 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
1129 | + * WHY? |
|
1130 | + * Because if a class is type hinting for a concretion, |
|
1131 | + * then why would we need to find another class to supply it? |
|
1132 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1133 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1134 | + * Don't go looking for some substitute. |
|
1135 | + * Whereas if a class is type hinting for an interface... |
|
1136 | + * then we need to find an actual class to use. |
|
1137 | + * So the interface IS the alias for some other FQN, |
|
1138 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1139 | + * represents some other class. |
|
1140 | + * |
|
1141 | + * @param string $fqn |
|
1142 | + * @param string $for_class |
|
1143 | + * @return bool |
|
1144 | + * @deprecated 4.9.62.p |
|
1145 | + */ |
|
1146 | + public function has_alias($fqn = '', $for_class = '') |
|
1147 | + { |
|
1148 | + return $this->isAlias($fqn, $for_class); |
|
1149 | + } |
|
1150 | + |
|
1151 | + |
|
1152 | + /** |
|
1153 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1154 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1155 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1156 | + * for example: |
|
1157 | + * if the following two entries were added to the _aliases array: |
|
1158 | + * array( |
|
1159 | + * 'interface_alias' => 'some\namespace\interface' |
|
1160 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
1161 | + * ) |
|
1162 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1163 | + * to load an instance of 'some\namespace\classname' |
|
1164 | + * |
|
1165 | + * @param string $alias |
|
1166 | + * @param string $for_class |
|
1167 | + * @return string |
|
1168 | + * @deprecated 4.9.62.p |
|
1169 | + */ |
|
1170 | + public function get_alias($alias = '', $for_class = '') |
|
1171 | + { |
|
1172 | + return $this->getFqnForAlias($alias, $for_class); |
|
1173 | + } |
|
1174 | 1174 | } |
@@ -21,28 +21,28 @@ discard block |
||
21 | 21 | use EventEspresso\modules\ticket_selector\TicketDetails; |
22 | 22 | |
23 | 23 | $event_date_label = apply_filters( |
24 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
25 | - esc_html__('Event Date ', 'event_espresso') |
|
24 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
25 | + esc_html__('Event Date ', 'event_espresso') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | $sold_label = apply_filters( |
29 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
30 | - esc_html__('Sold', 'event_espresso') |
|
29 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
30 | + esc_html__('Sold', 'event_espresso') |
|
31 | 31 | ); |
32 | 32 | |
33 | 33 | $remaining_label = apply_filters( |
34 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
35 | - esc_html__('Remaining', 'event_espresso') |
|
34 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
35 | + esc_html__('Remaining', 'event_espresso') |
|
36 | 36 | ); |
37 | 37 | |
38 | 38 | $total_sold_label = apply_filters( |
39 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
40 | - esc_html__('Total Sold', 'event_espresso') |
|
39 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
40 | + esc_html__('Total Sold', 'event_espresso') |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | $spaces_left_label = apply_filters( |
44 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
45 | - esc_html__('Total Spaces Left', 'event_espresso') |
|
44 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
45 | + esc_html__('Total Spaces Left', 'event_espresso') |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | ?> |
@@ -56,32 +56,32 @@ discard block |
||
56 | 56 | <p><?php echo wp_kses($ticket->description(), AllowedTags::getAllowedTags()); ?></p> |
57 | 57 | |
58 | 58 | <?php |
59 | - do_action( |
|
60 | - 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
61 | - $ticket, |
|
62 | - $ticket_price, |
|
63 | - $display_ticket_price |
|
64 | - ); |
|
65 | - ?> |
|
59 | + do_action( |
|
60 | + 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
61 | + $ticket, |
|
62 | + $ticket_price, |
|
63 | + $display_ticket_price |
|
64 | + ); |
|
65 | + ?> |
|
66 | 66 | <section class="tckt-slctr-tkt-sale-dates-sctn"> |
67 | 67 | <h5> |
68 | 68 | <?php echo apply_filters( |
69 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
70 | - esc_html__('Sale Dates', 'event_espresso') |
|
71 | - ); ?> |
|
69 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
70 | + esc_html__('Sale Dates', 'event_espresso') |
|
71 | + ); ?> |
|
72 | 72 | </h5> |
73 | 73 | <span class="drk-grey-text small-text no-bold"> - |
74 | 74 | <?php echo apply_filters( |
75 | - 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
76 | - esc_html__('The dates when this option is available for purchase.', 'event_espresso') |
|
77 | - ); ?> |
|
75 | + 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
76 | + esc_html__('The dates when this option is available for purchase.', 'event_espresso') |
|
77 | + ); ?> |
|
78 | 78 | </span> |
79 | 79 | <br /> |
80 | 80 | <span class="ticket-details-label-spn drk-grey-text"> |
81 | 81 | <?php echo apply_filters( |
82 | - 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
83 | - esc_html__('Goes On Sale:', 'event_espresso') |
|
84 | - ); ?> |
|
82 | + 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
83 | + esc_html__('Goes On Sale:', 'event_espresso') |
|
84 | + ); ?> |
|
85 | 85 | </span> |
86 | 86 | <span class="dashicons dashicons-calendar"></span> |
87 | 87 | <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)) . ' '; ?> |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | <br /> |
91 | 91 | <span class="ticket-details-label-spn drk-grey-text"> |
92 | 92 | <?php echo apply_filters( |
93 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
94 | - esc_html__('Sales End:', 'event_espresso') |
|
95 | - ); ?> |
|
93 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
94 | + esc_html__('Sales End:', 'event_espresso') |
|
95 | + ); ?> |
|
96 | 96 | </span> |
97 | 97 | <span class="dashicons dashicons-calendar"></span> |
98 | 98 | <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)) . ' '; ?> |
@@ -108,55 +108,55 @@ discard block |
||
108 | 108 | <section class="tckt-slctr-tkt-quantities-sctn"> |
109 | 109 | <h5> |
110 | 110 | <?php echo apply_filters( |
111 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
112 | - esc_html__('Purchasable Quantities', 'event_espresso') |
|
113 | - ); ?> |
|
111 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
112 | + esc_html__('Purchasable Quantities', 'event_espresso') |
|
113 | + ); ?> |
|
114 | 114 | </h5> |
115 | 115 | <span class="drk-grey-text small-text no-bold"> - |
116 | 116 | <?php echo apply_filters( |
117 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
118 | - esc_html__( |
|
119 | - 'The number of tickets that can be purchased per transaction (if available).', |
|
120 | - 'event_espresso' |
|
121 | - ) |
|
122 | - ); ?> |
|
117 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
118 | + esc_html__( |
|
119 | + 'The number of tickets that can be purchased per transaction (if available).', |
|
120 | + 'event_espresso' |
|
121 | + ) |
|
122 | + ); ?> |
|
123 | 123 | </span> |
124 | 124 | <br /> |
125 | 125 | <span class="ticket-details-label-spn drk-grey-text"> |
126 | 126 | <?php echo apply_filters( |
127 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
128 | - esc_html__('Minimum Qty:', 'event_espresso') |
|
129 | - ); ?> |
|
127 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
128 | + esc_html__('Minimum Qty:', 'event_espresso') |
|
129 | + ); ?> |
|
130 | 130 | </span> |
131 | 131 | <?php |
132 | - echo esc_html($ticket->min() > 0 ? $ticket->min() : 0); |
|
132 | + echo esc_html($ticket->min() > 0 ? $ticket->min() : 0); |
|
133 | 133 | |
134 | - if ($ticket->min() > $remaining) { |
|
135 | - ?> |
|
134 | + if ($ticket->min() > $remaining) { |
|
135 | + ?> |
|
136 | 136 | <span class="important-notice small-text"> |
137 | 137 | <?php echo apply_filters( |
138 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
139 | - esc_html__( |
|
140 | - 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
141 | - 'event_espresso' |
|
142 | - ) |
|
143 | - ); ?> |
|
138 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
139 | + esc_html__( |
|
140 | + 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
141 | + 'event_espresso' |
|
142 | + ) |
|
143 | + ); ?> |
|
144 | 144 | </span> |
145 | 145 | <?php } ?> |
146 | 146 | <br /> |
147 | 147 | <?php // $max = min( $max, $max_atndz );?> |
148 | 148 | <span class="ticket-details-label-spn drk-grey-text"> |
149 | 149 | <?php echo apply_filters( |
150 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
151 | - esc_html__('Maximum Qty:', 'event_espresso') |
|
152 | - ); ?> |
|
150 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
151 | + esc_html__('Maximum Qty:', 'event_espresso') |
|
152 | + ); ?> |
|
153 | 153 | </span> |
154 | 154 | <?php echo esc_html( |
155 | - $ticket->max() === EE_INF |
|
156 | - ? __('no limit', 'event_espresso') |
|
157 | - : max($ticket->max(), 1) |
|
158 | - ); |
|
159 | - ?> |
|
155 | + $ticket->max() === EE_INF |
|
156 | + ? __('no limit', 'event_espresso') |
|
157 | + : max($ticket->max(), 1) |
|
158 | + ); |
|
159 | + ?> |
|
160 | 160 | <br /> |
161 | 161 | </section> |
162 | 162 | <br /> |
@@ -166,31 +166,31 @@ discard block |
||
166 | 166 | <section class="tckt-slctr-tkt-uses-sctn"> |
167 | 167 | <h5> |
168 | 168 | <?php echo apply_filters( |
169 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
170 | - esc_html__('Event Date Ticket Uses', 'event_espresso') |
|
171 | - ); ?> |
|
169 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
170 | + esc_html__('Event Date Ticket Uses', 'event_espresso') |
|
171 | + ); ?> |
|
172 | 172 | </h5> |
173 | 173 | <span class="drk-grey-text small-text no-bold"> - |
174 | 174 | <?php echo apply_filters( |
175 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
176 | - sprintf( |
|
177 | - esc_html__( |
|
178 | - 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
179 | - 'event_espresso' |
|
180 | - ), |
|
181 | - '<br/>', |
|
182 | - '<strong>', |
|
183 | - '</strong>' |
|
184 | - ) |
|
185 | - ); |
|
186 | - ?> |
|
175 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
176 | + sprintf( |
|
177 | + esc_html__( |
|
178 | + 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
179 | + 'event_espresso' |
|
180 | + ), |
|
181 | + '<br/>', |
|
182 | + '<strong>', |
|
183 | + '</strong>' |
|
184 | + ) |
|
185 | + ); |
|
186 | + ?> |
|
187 | 187 | </span> |
188 | 188 | <br /> |
189 | 189 | <span class="ticket-details-label-spn drk-grey-text"> |
190 | 190 | <?php echo apply_filters( |
191 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
192 | - esc_html__('# Datetimes:', 'event_espresso') |
|
193 | - ); ?> |
|
191 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
192 | + esc_html__('# Datetimes:', 'event_espresso') |
|
193 | + ); ?> |
|
194 | 194 | </span> |
195 | 195 | <?php echo wp_kses($ticket->uses(), AllowedTags::getAllowedTags()); ?> |
196 | 196 | <br /> |
@@ -198,24 +198,24 @@ discard block |
||
198 | 198 | <?php } ?> |
199 | 199 | |
200 | 200 | <?php |
201 | - $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
|
202 | - $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
203 | - if (! empty($datetimes)) { ?> |
|
201 | + $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
|
202 | + $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
203 | + if (! empty($datetimes)) { ?> |
|
204 | 204 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
205 | 205 | <h5> |
206 | 206 | <?php echo apply_filters( |
207 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
208 | - esc_html__('Access', 'event_espresso') |
|
209 | - ); ?> |
|
207 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
208 | + esc_html__('Access', 'event_espresso') |
|
209 | + ); ?> |
|
210 | 210 | </h5> |
211 | 211 | <span class="drk-grey-text small-text no-bold"> - |
212 | 212 | <?php echo apply_filters( |
213 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
214 | - esc_html__( |
|
215 | - 'This option allows access to the following dates and times.', |
|
216 | - 'event_espresso' |
|
217 | - ) |
|
218 | - ); ?> |
|
213 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
214 | + esc_html__( |
|
215 | + 'This option allows access to the following dates and times.', |
|
216 | + 'event_espresso' |
|
217 | + ) |
|
218 | + ); ?> |
|
219 | 219 | </span> |
220 | 220 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
221 | 221 | <table class="tckt-slctr-tkt-details-tbl"> |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | <span class="dashicons dashicons-calendar"></span> |
226 | 226 | <span class="small-text"> |
227 | 227 | <?php echo apply_filters( |
228 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
229 | - esc_html__('Date ', 'event_espresso') |
|
230 | - ); ?> |
|
228 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
229 | + esc_html__('Date ', 'event_espresso') |
|
230 | + ); ?> |
|
231 | 231 | </span> |
232 | 232 | </th> |
233 | 233 | <th class="tckt-slctr-tkt-details-time-th <?php echo esc_attr($chart_column_width); ?>"> |
@@ -240,33 +240,33 @@ discard block |
||
240 | 240 | <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr"> |
241 | 241 | <span class="smaller-text"> |
242 | 242 | <?php echo apply_filters( |
243 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
244 | - sprintf(esc_html__('Sold', 'event_espresso'), '<br/>') |
|
245 | - ); ?> |
|
243 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
244 | + sprintf(esc_html__('Sold', 'event_espresso'), '<br/>') |
|
245 | + ); ?> |
|
246 | 246 | </span> |
247 | 247 | </th> |
248 | 248 | <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr"> |
249 | 249 | <span class="smaller-text"> |
250 | 250 | <?php echo apply_filters( |
251 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
252 | - sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>') |
|
253 | - ); ?> |
|
251 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
252 | + sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>') |
|
253 | + ); ?> |
|
254 | 254 | </span> |
255 | 255 | </th> |
256 | 256 | <th class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr"> |
257 | 257 | <span class="smaller-text"> |
258 | 258 | <?php echo apply_filters( |
259 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
260 | - sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>') |
|
261 | - ); ?> |
|
259 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
260 | + sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>') |
|
261 | + ); ?> |
|
262 | 262 | </span> |
263 | 263 | </th> |
264 | 264 | <th class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr"> |
265 | 265 | <span class="smaller-text"> |
266 | 266 | <?php echo apply_filters( |
267 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
268 | - sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>') |
|
269 | - ); ?> |
|
267 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
268 | + sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>') |
|
269 | + ); ?> |
|
270 | 270 | </span> |
271 | 271 | </th> |
272 | 272 | <?php endif; // end $show_ticket_sale_columns conditional ?> |
@@ -274,25 +274,25 @@ discard block |
||
274 | 274 | </thead> |
275 | 275 | <tbody> |
276 | 276 | <?php foreach ($datetimes as $datetime) { |
277 | - if ($datetime instanceof EE_Datetime) { ?> |
|
277 | + if ($datetime instanceof EE_Datetime) { ?> |
|
278 | 278 | <tr> |
279 | 279 | <td data-th="<?php echo esc_attr($event_date_label); ?>" class="small-text"> |
280 | 280 | <?php $datetime_name = $datetime->name(); ?> |
281 | 281 | <?php echo ! empty($datetime_name) |
282 | - ? '<b>' . esc_html($datetime_name) . '</b><br/>' |
|
283 | - : ''; ?> |
|
282 | + ? '<b>' . esc_html($datetime_name) . '</b><br/>' |
|
283 | + : ''; ?> |
|
284 | 284 | <?php echo esc_html($datetime->date_range( |
285 | - $date_format, |
|
286 | - esc_html__(' to ', 'event_espresso') |
|
287 | - )); ?> |
|
285 | + $date_format, |
|
286 | + esc_html__(' to ', 'event_espresso') |
|
287 | + )); ?> |
|
288 | 288 | </td> |
289 | 289 | <td data-th="<?php esc_html_e('Time ', 'event_espresso'); ?>" |
290 | 290 | class="cntr small-text" |
291 | 291 | > |
292 | 292 | <?php echo esc_html($datetime->time_range( |
293 | - $time_format, |
|
294 | - esc_html__(' to ', 'event_espresso') |
|
295 | - )); ?> |
|
293 | + $time_format, |
|
294 | + esc_html__(' to ', 'event_espresso') |
|
295 | + )); ?> |
|
296 | 296 | </td> |
297 | 297 | <?php if ($show_ticket_sale_columns) : ?> |
298 | 298 | <td data-th="<?php echo esc_attr($sold_label); ?>" class="cntr small-text"> |
@@ -300,31 +300,31 @@ discard block |
||
300 | 300 | </td> |
301 | 301 | <td data-th="<?php echo esc_attr($remaining_label); ?>" class="cntr small-text"> |
302 | 302 | <?php echo wp_kses( |
303 | - $remaining === EE_INF |
|
304 | - ? '<span class="smaller-text">' |
|
305 | - . esc_html__('unlimited ', 'event_espresso') |
|
306 | - . '</span>' |
|
307 | - : $remaining, |
|
308 | - AllowedTags::getAllowedTags() |
|
309 | - ); ?> |
|
303 | + $remaining === EE_INF |
|
304 | + ? '<span class="smaller-text">' |
|
305 | + . esc_html__('unlimited ', 'event_espresso') |
|
306 | + . '</span>' |
|
307 | + : $remaining, |
|
308 | + AllowedTags::getAllowedTags() |
|
309 | + ); ?> |
|
310 | 310 | </td> |
311 | 311 | <td data-th="<?php echo esc_attr($total_sold_label); ?>" class="cntr small-text"> |
312 | 312 | <?php echo esc_html($datetime->sold()); ?> |
313 | 313 | </td> |
314 | 314 | <?php $tkts_left = $datetime->sold_out() |
315 | - ? '<span class="sold-out smaller-text">' |
|
316 | - . esc_html__('Sold Out', 'event_espresso') |
|
317 | - . '</span>' |
|
318 | - : $datetime->spaces_remaining(); ?> |
|
315 | + ? '<span class="sold-out smaller-text">' |
|
316 | + . esc_html__('Sold Out', 'event_espresso') |
|
317 | + . '</span>' |
|
318 | + : $datetime->spaces_remaining(); ?> |
|
319 | 319 | <td data-th="<?php echo esc_attr($spaces_left_label); ?>" class="cntr small-text"> |
320 | 320 | <?php echo wp_kses( |
321 | - $tkts_left === EE_INF |
|
322 | - ? '<span class="smaller-text">' |
|
323 | - . esc_html__('unlimited ', 'event_espresso') |
|
324 | - . '</span>' |
|
325 | - : $tkts_left, |
|
326 | - AllowedTags::getAllowedTags() |
|
327 | - ); ?> |
|
321 | + $tkts_left === EE_INF |
|
322 | + ? '<span class="smaller-text">' |
|
323 | + . esc_html__('unlimited ', 'event_espresso') |
|
324 | + . '</span>' |
|
325 | + : $tkts_left, |
|
326 | + AllowedTags::getAllowedTags() |
|
327 | + ); ?> |
|
328 | 328 | </td> |
329 | 329 | <?php endif; // end $show_ticket_sale_columns conditional ?> |
330 | 330 | </tr> |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | </thead> |
77 | 77 | <tbody> |
78 | 78 | <?php |
79 | - /** |
|
80 | - * Recursive function for traversing all the sub-items of each line item |
|
81 | - * and displaying them in the table |
|
82 | - * |
|
83 | - * @param EE_Line_Item $line_item |
|
84 | - * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
85 | - */ |
|
86 | - function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
87 | - { |
|
88 | - switch ($line_item->type()) { |
|
89 | - case EEM_Line_Item::type_total: |
|
90 | - foreach ($line_item->children() as $child_line_item) { |
|
91 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
92 | - } ?> |
|
79 | + /** |
|
80 | + * Recursive function for traversing all the sub-items of each line item |
|
81 | + * and displaying them in the table |
|
82 | + * |
|
83 | + * @param EE_Line_Item $line_item |
|
84 | + * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
85 | + */ |
|
86 | + function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
87 | + { |
|
88 | + switch ($line_item->type()) { |
|
89 | + case EEM_Line_Item::type_total: |
|
90 | + foreach ($line_item->children() as $child_line_item) { |
|
91 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
92 | + } ?> |
|
93 | 93 | <tr> |
94 | 94 | <td colspan="<?php echo esc_attr($show_line_item_description ? 5 : 4); ?>"> |
95 | 95 | <hr> |
@@ -101,50 +101,50 @@ discard block |
||
101 | 101 | <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
102 | 102 | </tr> |
103 | 103 | <?php |
104 | - break; |
|
104 | + break; |
|
105 | 105 | |
106 | 106 | |
107 | - case EEM_Line_Item::type_sub_total: |
|
108 | - foreach ($line_item->children() as $child_line_item) { |
|
109 | - // $odd = !$odd; |
|
110 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
111 | - } ?> |
|
107 | + case EEM_Line_Item::type_sub_total: |
|
108 | + foreach ($line_item->children() as $child_line_item) { |
|
109 | + // $odd = !$odd; |
|
110 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
111 | + } ?> |
|
112 | 112 | <tr class="total_tr odd"> |
113 | 113 | <td colspan="<?php echo esc_attr($show_line_item_description ? 2 : 1); ?>"> </td> |
114 | 114 | <td colspan="2" class="total" id="total_currency"> |
115 | 115 | <?php esc_html_e( |
116 | - 'Sub-Total', |
|
117 | - 'event_espresso' |
|
118 | - ); ?></td> |
|
116 | + 'Sub-Total', |
|
117 | + 'event_espresso' |
|
118 | + ); ?></td> |
|
119 | 119 | <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
120 | 120 | </tr> |
121 | 121 | <?php |
122 | - break; |
|
122 | + break; |
|
123 | 123 | |
124 | 124 | |
125 | - case EEM_Line_Item::type_tax_sub_total: |
|
126 | - foreach ($line_item->children() as $child_line_item) { |
|
127 | - $odd = ! $odd; |
|
128 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
129 | - } ?> |
|
125 | + case EEM_Line_Item::type_tax_sub_total: |
|
126 | + foreach ($line_item->children() as $child_line_item) { |
|
127 | + $odd = ! $odd; |
|
128 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
129 | + } ?> |
|
130 | 130 | <tr class="total_tr odd"> |
131 | 131 | <td colspan="<?php echo esc_attr($show_line_item_description ? 2 : 1); ?>"> </td> |
132 | 132 | <td colspan="2" class="total" id="total_currency"> |
133 | 133 | <?php esc_html_e( |
134 | - 'Tax Total', |
|
135 | - 'event_espresso' |
|
136 | - ); ?></td> |
|
134 | + 'Tax Total', |
|
135 | + 'event_espresso' |
|
136 | + ); ?></td> |
|
137 | 137 | <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
138 | 138 | </tr> |
139 | 139 | <?php |
140 | - break; |
|
140 | + break; |
|
141 | 141 | |
142 | 142 | |
143 | - case EEM_Line_Item::type_line_item: |
|
144 | - $subitems = $line_item->children(); |
|
145 | - $has_subitems = count($subitems) > 1; |
|
146 | - if ($has_subitems) { |
|
147 | - ?> |
|
143 | + case EEM_Line_Item::type_line_item: |
|
144 | + $subitems = $line_item->children(); |
|
145 | + $has_subitems = count($subitems) > 1; |
|
146 | + if ($has_subitems) { |
|
147 | + ?> |
|
148 | 148 | <tr class="item <?php echo sanitize_html_class($odd ? 'odd' : ''); ?>"> |
149 | 149 | <td class="item_l"><?php echo esc_html($line_item->name()) ?></td> |
150 | 150 | <?php if ($show_line_item_description) { ?> |
@@ -155,18 +155,18 @@ discard block |
||
155 | 155 | <td class="item_c"><?php echo esc_html($line_item->unit_price_no_code()) ?></td> |
156 | 156 | |
157 | 157 | <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); |
158 | - echo esc_html($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
158 | + echo esc_html($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
159 | 159 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
160 | - ?> |
|
160 | + ?> |
|
161 | 161 | </tr> |
162 | 162 | <?php |
163 | - if ($has_subitems) { |
|
164 | - foreach ($line_item->children() as $child_line_item) { |
|
165 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
166 | - } |
|
167 | - } |
|
168 | - } else {// no subitems - just show this line item |
|
169 | - ?> |
|
163 | + if ($has_subitems) { |
|
164 | + foreach ($line_item->children() as $child_line_item) { |
|
165 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
166 | + } |
|
167 | + } |
|
168 | + } else {// no subitems - just show this line item |
|
169 | + ?> |
|
170 | 170 | <tr class="item <?php echo sanitize_html_class($odd ? 'odd' : ''); ?>"> |
171 | 171 | <td class="item_l"><?php echo esc_html($line_item->name()); ?></td> |
172 | 172 | <?php if ($show_line_item_description) { ?> |
@@ -175,15 +175,15 @@ discard block |
||
175 | 175 | <td class="item_l"><?php echo esc_html($line_item->quantity()); ?></td> |
176 | 176 | <td class="item_c"><?php echo wp_kses($line_item->unit_price_no_code(), AllowedTags::getAllowedTags()); ?></td> |
177 | 177 | <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); |
178 | - echo esc_html($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
178 | + echo esc_html($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
179 | 179 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
180 | - ?> |
|
180 | + ?> |
|
181 | 181 | </tr> |
182 | 182 | <?php } |
183 | 183 | |
184 | - break; |
|
185 | - case EEM_Line_Item::type_sub_line_item: |
|
186 | - ?> |
|
184 | + break; |
|
185 | + case EEM_Line_Item::type_sub_line_item: |
|
186 | + ?> |
|
187 | 187 | <tr class="item subitem-row"> |
188 | 188 | <td class="item_l subitem"><?php echo esc_html($line_item->name()); ?></td> |
189 | 189 | <?php if ($show_line_item_description) { ?> |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
200 | 200 | </tr> |
201 | 201 | <?php |
202 | - break; |
|
203 | - case EEM_Line_Item::type_tax: |
|
204 | - ?> |
|
202 | + break; |
|
203 | + case EEM_Line_Item::type_tax: |
|
204 | + ?> |
|
205 | 205 | <tr class="item sub-item tax-total"> |
206 | 206 | <td class="item_l"><?php echo esc_html($line_item->name()); ?></td> |
207 | 207 | <?php if ($show_line_item_description) { ?> |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | |
212 | 212 | <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
213 | 213 | </tr><?php |
214 | - break; |
|
215 | - } |
|
216 | - } |
|
214 | + break; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | - $c = false; |
|
219 | - /* @var $transaction EE_Transaction */ |
|
220 | - $total_line_item = $transaction->total_line_item(); |
|
221 | - ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
222 | - ?> |
|
218 | + $c = false; |
|
219 | + /* @var $transaction EE_Transaction */ |
|
220 | + $total_line_item = $transaction->total_line_item(); |
|
221 | + ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
222 | + ?> |
|
223 | 223 | </tbody> |
224 | 224 | |
225 | 225 | </table> |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | </thead> |
239 | 239 | <tbody> |
240 | 240 | <?php |
241 | - $c = false; |
|
242 | - if (! empty($payments)) { |
|
243 | - foreach ($payments as $payment) { |
|
244 | - /* @var $payment EE_Payment */ |
|
245 | - ?> |
|
241 | + $c = false; |
|
242 | + if (! empty($payments)) { |
|
243 | + foreach ($payments as $payment) { |
|
244 | + /* @var $payment EE_Payment */ |
|
245 | + ?> |
|
246 | 246 | <tr class='item <?php echo(($c = ! $c) ? ' odd' : '') ?>'> |
247 | 247 | <td><?php $payment->e('PAY_gateway') ?></td> |
248 | 248 | <td><?php echo esc_html($payment->timestamp('D M j, Y')); ?></td> |
@@ -251,23 +251,23 @@ discard block |
||
251 | 251 | <td><?php $payment->e_pretty_status() ?></td> |
252 | 252 | <td class='item_r'> |
253 | 253 | <?php echo wp_kses( |
254 | - EEH_Template::format_currency($payment->amount()), |
|
255 | - AllowedTags::getAllowedTags() |
|
256 | - ); ?> |
|
254 | + EEH_Template::format_currency($payment->amount()), |
|
255 | + AllowedTags::getAllowedTags() |
|
256 | + ); ?> |
|
257 | 257 | </td> |
258 | 258 | </tr> |
259 | 259 | <?php } |
260 | - } else { |
|
261 | - ?> |
|
260 | + } else { |
|
261 | + ?> |
|
262 | 262 | <tr class='item'> |
263 | 263 | <td class='aln-cntr' colspan=6> |
264 | 264 | <?php esc_html_e( |
265 | - "No approved payments have been received", |
|
266 | - 'event_espresso' |
|
267 | - ) ?></td> |
|
265 | + "No approved payments have been received", |
|
266 | + 'event_espresso' |
|
267 | + ) ?></td> |
|
268 | 268 | </tr> |
269 | 269 | <?php } |
270 | - ?> |
|
270 | + ?> |
|
271 | 271 | </tbody> |
272 | 272 | <tfoot> |
273 | 273 | <tr class='total_tr'> |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | <td class="item_r"><?php esc_html_e('Total Paid', 'event_espresso') ?></td> |
276 | 276 | <td class="item_r"> |
277 | 277 | <?php echo wp_kses( |
278 | - EEH_Template::format_currency($amount_pd), |
|
279 | - AllowedTags::getAllowedTags() |
|
280 | - ); ?> |
|
278 | + EEH_Template::format_currency($amount_pd), |
|
279 | + AllowedTags::getAllowedTags() |
|
280 | + ); ?> |
|
281 | 281 | </td> |
282 | 282 | </tr> |
283 | 283 | <tr class="total_tr"> |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | <td class="total" id="total_currency"><?php esc_html_e('Amount Owed', 'event_espresso'); ?></td> |
286 | 286 | <td class="total"> |
287 | 287 | <?php echo wp_kses( |
288 | - EEH_Template::format_currency($total_cost - $amount_pd), |
|
289 | - AllowedTags::getAllowedTags() |
|
290 | - ); ?> |
|
288 | + EEH_Template::format_currency($total_cost - $amount_pd), |
|
289 | + AllowedTags::getAllowedTags() |
|
290 | + ); ?> |
|
291 | 291 | </td> |
292 | 292 | </tr> |
293 | 293 | </tfoot> |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | <h3 class="section-title event-name"> |
65 | 65 | <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>"> |
66 | 66 | <?php |
67 | - esc_html_e( |
|
68 | - "Event Name:", |
|
69 | - "event_espresso" |
|
70 | - ) ?> |
|
67 | + esc_html_e( |
|
68 | + "Event Name:", |
|
69 | + "event_espresso" |
|
70 | + ) ?> |
|
71 | 71 | <span class="plain-text"><?php echo wp_kses($event->name(), AllowedTags::getAllowedTags()); ?></span> |
72 | 72 | <span class="small-text link"> |
73 | 73 | [ <a href='<?php echo esc_url_raw($event->get_permalink()) ?>'><?php esc_html_e('view', 'event_espresso'); ?></a> ] |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | <?php } ?> |
79 | 79 | <ul class="tickets-per-event"> |
80 | 80 | <?php |
81 | - foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
82 | - $ticket = $line_item->ticket(); |
|
83 | - $taxable_html = $ticket->taxable() |
|
84 | - ? '*' |
|
85 | - : ''; |
|
86 | - $subitems = $line_item->children(); |
|
87 | - $ticket_uses = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso")); |
|
88 | - ?> |
|
81 | + foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
82 | + $ticket = $line_item->ticket(); |
|
83 | + $taxable_html = $ticket->taxable() |
|
84 | + ? '*' |
|
85 | + : ''; |
|
86 | + $subitems = $line_item->children(); |
|
87 | + $ticket_uses = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso")); |
|
88 | + ?> |
|
89 | 89 | <li class="event-ticket"> |
90 | 90 | <div class="ticket-details"> |
91 | 91 | <table class="invoice-amount"> |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | <th class="name-column"><?php esc_html_e("Ticket", "event_espresso"); ?></th> |
95 | 95 | <th colspan="2" class="desc-column"> |
96 | 96 | <?php |
97 | - esc_html_e( |
|
98 | - "Description", |
|
99 | - "event_espresso" |
|
100 | - ); ?></th> |
|
97 | + esc_html_e( |
|
98 | + "Description", |
|
99 | + "event_espresso" |
|
100 | + ); ?></th> |
|
101 | 101 | <th class="number-column item_c"><?php esc_html_e("Quantity", "event_espresso"); ?></th> |
102 | 102 | <th class="number-column item_c"><?php esc_html_e("Price", "event_espresso"); ?></th> |
103 | 103 | <th class="number-column item_r"><?php esc_html_e("Total", "event_espresso"); ?></th> |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | </thead> |
106 | 106 | <tbody> |
107 | 107 | <?php |
108 | - if (count($subitems) < 2) { ?> |
|
108 | + if (count($subitems) < 2) { ?> |
|
109 | 109 | <tr class="item"> |
110 | 110 | <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td> |
111 | 111 | <td colspan="2"> |
112 | 112 | <?php echo esc_html($line_item->desc()); ?> |
113 | 113 | <p class="ticket-note"> |
114 | 114 | <?php |
115 | - echo sprintf( |
|
116 | - esc_html__( |
|
117 | - 'This ticket can be used once at %s of the dates/times below.', |
|
118 | - 'event_espresso' |
|
119 | - ), |
|
120 | - $ticket_uses |
|
121 | - ); ?> |
|
115 | + echo sprintf( |
|
116 | + esc_html__( |
|
117 | + 'This ticket can be used once at %s of the dates/times below.', |
|
118 | + 'event_espresso' |
|
119 | + ), |
|
120 | + $ticket_uses |
|
121 | + ); ?> |
|
122 | 122 | </p> |
123 | 123 | </td> |
124 | 124 | <td class="item_c"><?php echo esc_html($line_item->quantity()); ?></td> |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
127 | 127 | </tr> |
128 | 128 | <?php |
129 | - } else { ?> |
|
129 | + } else { ?> |
|
130 | 130 | <tr class="item"> |
131 | 131 | <td class="aln-left"> |
132 | 132 | <?php echo esc_html($line_item->name() . $taxable_html); ?> |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | <td colspan="2"><?php echo esc_html($line_item->desc()); ?> |
135 | 135 | <p class="ticket-note"> |
136 | 136 | <?php |
137 | - echo sprintf( |
|
138 | - esc_html__( |
|
139 | - 'This ticket can be used once at %s of the dates/times below.', |
|
140 | - 'event_espresso' |
|
141 | - ), |
|
142 | - $ticket_uses |
|
143 | - ); ?> |
|
137 | + echo sprintf( |
|
138 | + esc_html__( |
|
139 | + 'This ticket can be used once at %s of the dates/times below.', |
|
140 | + 'event_espresso' |
|
141 | + ), |
|
142 | + $ticket_uses |
|
143 | + ); ?> |
|
144 | 144 | </p> |
145 | 145 | </td> |
146 | 146 | <td class="item_c"> |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | </td> |
155 | 155 | </tr> |
156 | 156 | <?php |
157 | - foreach ($subitems as $sub_line_item) { |
|
158 | - $is_percent = $sub_line_item->is_percent(); ?> |
|
157 | + foreach ($subitems as $sub_line_item) { |
|
158 | + $is_percent = $sub_line_item->is_percent(); ?> |
|
159 | 159 | <tr class="subitem-row"> |
160 | 160 | <td class="subitem"> |
161 | 161 | <?php echo esc_html($sub_line_item->name()); ?> |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | </td> |
168 | 168 | <td class="item_c"> |
169 | 169 | <?php echo wp_kses( |
170 | - $is_percent |
|
171 | - ? $sub_line_item->percent() . "%" |
|
172 | - : $sub_line_item->unit_price_no_code(), |
|
173 | - AllowedTags::getAllowedTags() |
|
174 | - ); ?> |
|
170 | + $is_percent |
|
171 | + ? $sub_line_item->percent() . "%" |
|
172 | + : $sub_line_item->unit_price_no_code(), |
|
173 | + AllowedTags::getAllowedTags() |
|
174 | + ); ?> |
|
175 | 175 | </td> |
176 | 176 | <td class="item_r"> |
177 | 177 | <?php echo wp_kses( |
178 | - $sub_line_item->total_no_code(), |
|
179 | - AllowedTags::getAllowedTags() |
|
180 | - ); ?> |
|
178 | + $sub_line_item->total_no_code(), |
|
179 | + AllowedTags::getAllowedTags() |
|
180 | + ); ?> |
|
181 | 181 | </td> |
182 | 182 | </tr> |
183 | 183 | <?php |
184 | - } ?> |
|
184 | + } ?> |
|
185 | 185 | <tr class="total_tr odd"> |
186 | 186 | <td colspan="4"></td> |
187 | 187 | <td class="total" nowrap="nowrap"> |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | </td> |
193 | 193 | </tr> |
194 | 194 | <?php |
195 | - } ?> |
|
195 | + } ?> |
|
196 | 196 | </tbody> |
197 | 197 | </table> |
198 | 198 | |
@@ -203,56 +203,56 @@ discard block |
||
203 | 203 | <h4 class="sub-section-title no-bottom-margin"> |
204 | 204 | <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>"> |
205 | 205 | <?php |
206 | - echo _n( |
|
207 | - "Date/Time:", |
|
208 | - "Dates/Times:", |
|
209 | - count($ticket->datetimes()), |
|
210 | - "event_espresso" |
|
211 | - ); ?></h4> |
|
206 | + echo _n( |
|
207 | + "Date/Time:", |
|
208 | + "Dates/Times:", |
|
209 | + count($ticket->datetimes()), |
|
210 | + "event_espresso" |
|
211 | + ); ?></h4> |
|
212 | 212 | <ul class="event-dates"> |
213 | 213 | <?php |
214 | - foreach ($ticket->datetimes_ordered() as $datetime) { |
|
215 | - /* @var $datetime EE_Datetime */ ?> |
|
214 | + foreach ($ticket->datetimes_ordered() as $datetime) { |
|
215 | + /* @var $datetime EE_Datetime */ ?> |
|
216 | 216 | <li><?php |
217 | - echo wp_kses( |
|
218 | - $datetime->name() |
|
219 | - ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
220 | - : '', |
|
221 | - AllowedTags::getAllowedTags() |
|
222 | - ); |
|
223 | - echo sprintf( |
|
224 | - esc_html__("%s - %s (%s)", "event_espresso"), |
|
225 | - $datetime->start_date_and_time(), |
|
226 | - $datetime->end_date_and_time(), |
|
227 | - $datetime->get_timezone() |
|
228 | - ); |
|
229 | - echo wp_kses( |
|
230 | - $datetime->description() |
|
231 | - ? '<p class="ticket-note">' . $datetime->description() . '</p>' |
|
232 | - : '', |
|
233 | - AllowedTags::getAllowedTags() |
|
234 | - ); ?> |
|
217 | + echo wp_kses( |
|
218 | + $datetime->name() |
|
219 | + ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
220 | + : '', |
|
221 | + AllowedTags::getAllowedTags() |
|
222 | + ); |
|
223 | + echo sprintf( |
|
224 | + esc_html__("%s - %s (%s)", "event_espresso"), |
|
225 | + $datetime->start_date_and_time(), |
|
226 | + $datetime->end_date_and_time(), |
|
227 | + $datetime->get_timezone() |
|
228 | + ); |
|
229 | + echo wp_kses( |
|
230 | + $datetime->description() |
|
231 | + ? '<p class="ticket-note">' . $datetime->description() . '</p>' |
|
232 | + : '', |
|
233 | + AllowedTags::getAllowedTags() |
|
234 | + ); ?> |
|
235 | 235 | </li> |
236 | 236 | <?php |
237 | - } ?> |
|
237 | + } ?> |
|
238 | 238 | </ul> |
239 | 239 | </div> |
240 | 240 | <?php |
241 | - if ($event->venues()) { ?> |
|
241 | + if ($event->venues()) { ?> |
|
242 | 242 | <div class="ticket-place-details"> |
243 | 243 | <h4 class="sub-section-title no-bottom-margin"> |
244 | 244 | <img class="icon" src="<?php |
245 | - echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
245 | + echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
246 | 246 | <?php |
247 | - echo _n( |
|
248 | - "Venue:", |
|
249 | - "Venues:", |
|
250 | - count($event->venues()), |
|
251 | - "event_espresso" |
|
252 | - ); ?></h4> |
|
247 | + echo _n( |
|
248 | + "Venue:", |
|
249 | + "Venues:", |
|
250 | + count($event->venues()), |
|
251 | + "event_espresso" |
|
252 | + ); ?></h4> |
|
253 | 253 | <ul class="event-venues"> |
254 | 254 | <?php |
255 | - foreach ($event->venues() as $venue) { ?> |
|
255 | + foreach ($event->venues() as $venue) { ?> |
|
256 | 256 | <li><?php echo esc_html($venue->name()) ?> |
257 | 257 | <span class="small-text"> |
258 | 258 | [ |
@@ -263,18 +263,18 @@ discard block |
||
263 | 263 | </span> |
264 | 264 | </li> |
265 | 265 | <?php |
266 | - } ?> |
|
266 | + } ?> |
|
267 | 267 | </ul> |
268 | 268 | </div> |
269 | 269 | <?php |
270 | - } ?> |
|
270 | + } ?> |
|
271 | 271 | </div> |
272 | 272 | <div class="ticket-registrations-area"> |
273 | 273 | <h4 class="sub-section-title"> |
274 | 274 | <img class="icon" src="<?php |
275 | - echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
275 | + echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
276 | 276 | <?php |
277 | - echo esc_html__("Registration Details", "event_espresso"); ?> |
|
277 | + echo esc_html__("Registration Details", "event_espresso"); ?> |
|
278 | 278 | <span class="small-text link">[ |
279 | 279 | <a class="print_button noPrint" href="<?php echo esc_url_raw($edit_reg_info_url); ?>"> |
280 | 280 | <?php esc_html_e('edit', 'event_espresso'); ?> |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | </h4> |
285 | 285 | <ul class="ticket-registrations-list"> |
286 | 286 | <?php |
287 | - foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
288 | - /* @var $registration EE_Registration */ |
|
289 | - $attendee = $registration->attendee(); |
|
290 | - $answers = $registration->answers( |
|
291 | - ['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']] |
|
292 | - ); ?> |
|
287 | + foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
288 | + /* @var $registration EE_Registration */ |
|
289 | + $attendee = $registration->attendee(); |
|
290 | + $answers = $registration->answers( |
|
291 | + ['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']] |
|
292 | + ); ?> |
|
293 | 293 | <li class="ticket-registration"> |
294 | 294 | <table class="registration-details"> |
295 | 295 | <tr class="odd"> |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | </td> |
305 | 305 | </tr> |
306 | 306 | <?php |
307 | - foreach ($event->question_groups() as $question_group) { ?> |
|
307 | + foreach ($event->question_groups() as $question_group) { ?> |
|
308 | 308 | <tr> |
309 | 309 | <th> |
310 | 310 | <?php $question_group->e('QSG_name'); ?> |
@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | <td></td> |
313 | 313 | </tr> |
314 | 314 | <?php $has_personal_info = false; |
315 | - foreach ($question_group->questions() as $question) { |
|
316 | - if (in_array($question->system_ID(), $questions_to_skip)) { |
|
317 | - $has_personal_info = true; |
|
318 | - continue; |
|
319 | - } |
|
320 | - ?> |
|
315 | + foreach ($question_group->questions() as $question) { |
|
316 | + if (in_array($question->system_ID(), $questions_to_skip)) { |
|
317 | + $has_personal_info = true; |
|
318 | + continue; |
|
319 | + } |
|
320 | + ?> |
|
321 | 321 | <tr> |
322 | 322 | <th> |
323 | 323 | <?php echo wp_kses($question->display_text(), AllowedTags::getAllowedTags()); ?> |
@@ -327,26 +327,26 @@ discard block |
||
327 | 327 | </td> |
328 | 328 | </tr> |
329 | 329 | <?php } |
330 | - if ($has_personal_info) { ?> |
|
330 | + if ($has_personal_info) { ?> |
|
331 | 331 | <tr> |
332 | 332 | <th><?php esc_html_e('Attendee', 'event_espresso'); ?></th> |
333 | 333 | <td> |
334 | 334 | <?php |
335 | - echo sprintf( |
|
336 | - esc_html__('%s (%s)', "event_espresso"), |
|
337 | - esc_html($attendee->full_name()), |
|
338 | - sanitize_email($attendee->email()) |
|
339 | - ) ?> |
|
335 | + echo sprintf( |
|
336 | + esc_html__('%s (%s)', "event_espresso"), |
|
337 | + esc_html($attendee->full_name()), |
|
338 | + sanitize_email($attendee->email()) |
|
339 | + ) ?> |
|
340 | 340 | </td> |
341 | 341 | </tr> |
342 | 342 | <?php |
343 | - } |
|
344 | - } |
|
345 | - ?> |
|
343 | + } |
|
344 | + } |
|
345 | + ?> |
|
346 | 346 | </table> |
347 | 347 | </li> |
348 | 348 | <?php |
349 | - } ?> |
|
349 | + } ?> |
|
350 | 350 | </ul> |
351 | 351 | </div> |
352 | 352 | </div> |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | <div class="grand-total-dv"> |
391 | 391 | <h2 class="grand-total"> |
392 | 392 | <?php |
393 | - printf( |
|
394 | - esc_html__("Grand Total: %s", "event_espresso"), |
|
395 | - EEH_Template::format_currency($total_cost) |
|
396 | - ); ?> |
|
393 | + printf( |
|
394 | + esc_html__("Grand Total: %s", "event_espresso"), |
|
395 | + EEH_Template::format_currency($total_cost) |
|
396 | + ); ?> |
|
397 | 397 | </h2> |
398 | 398 | </div> |
399 | 399 | <div class="payment-dv"> |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | </thead> |
413 | 413 | <tbody> |
414 | 414 | <?php |
415 | - $c = false; |
|
416 | - if (! empty($payments)) { |
|
417 | - foreach ($payments as $payment) { |
|
418 | - /* @var $payment EE_Payment */ ?> |
|
415 | + $c = false; |
|
416 | + if (! empty($payments)) { |
|
417 | + foreach ($payments as $payment) { |
|
418 | + /* @var $payment EE_Payment */ ?> |
|
419 | 419 | <tr class='item <?php echo(($c = ! $c) |
420 | - ? ' odd' |
|
421 | - : '') ?>'> |
|
420 | + ? ' odd' |
|
421 | + : '') ?>'> |
|
422 | 422 | <td><?php $payment->e('PAY_gateway') ?></td> |
423 | 423 | <td><?php echo esc_html($payment->timestamp()); ?></td> |
424 | 424 | <td><?php $payment->e('PAY_txn_id_chq_nmbr') ?></td> |
@@ -427,14 +427,14 @@ discard block |
||
427 | 427 | <td class='item_r'><?php echo wp_kses($payment->amount_no_code(), AllowedTags::getAllowedTags()); ?></td> |
428 | 428 | </tr> |
429 | 429 | <?php } |
430 | - } else { ?> |
|
430 | + } else { ?> |
|
431 | 431 | <tr class='item'> |
432 | 432 | <td class='aln-cntr' colspan="6"> |
433 | 433 | <?php |
434 | - esc_html_e( |
|
435 | - "No approved payments have been received.", |
|
436 | - 'event_espresso' |
|
437 | - ) ?> |
|
434 | + esc_html_e( |
|
435 | + "No approved payments have been received.", |
|
436 | + 'event_espresso' |
|
437 | + ) ?> |
|
438 | 438 | </td> |
439 | 439 | </tr> |
440 | 440 | <?php } ?> |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | <td class="item_r"><?php esc_html_e('Total Paid', 'event_espresso') ?></td> |
455 | 455 | <td class="item_r"> |
456 | 456 | <?php echo wp_kses( |
457 | - EEH_Template::format_currency($amount_pd, false, false), |
|
458 | - AllowedTags::getAllowedTags() |
|
459 | - ); ?> |
|
457 | + EEH_Template::format_currency($amount_pd, false, false), |
|
458 | + AllowedTags::getAllowedTags() |
|
459 | + ); ?> |
|
460 | 460 | </td> |
461 | 461 | </tr> |
462 | 462 | <tr class="total_tr odd"> |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | <td class="total" id="total_currency"><?php esc_html_e('Amount Owed:', 'event_espresso'); ?></td> |
465 | 465 | <td class="total"> |
466 | 466 | <?php echo wp_kses( |
467 | - EEH_Template::format_currency($amount_owed), |
|
468 | - AllowedTags::getAllowedTags() |
|
469 | - ); ?> |
|
467 | + EEH_Template::format_currency($amount_owed), |
|
468 | + AllowedTags::getAllowedTags() |
|
469 | + ); ?> |
|
470 | 470 | </td> |
471 | 471 | </tr> |
472 | 472 | </tfoot> |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | <?php if ($venues_for_events) { ?> |
479 | 479 | <h2> |
480 | 480 | <?php |
481 | - echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?> |
|
481 | + echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?> |
|
482 | 482 | </h2> |
483 | 483 | <table class="venue-list"> |
484 | 484 | <?php foreach ($venues_for_events as $venue) { ?> |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | <div class="events"> |
63 | 63 | <?php foreach ($events_for_txn as $event_id => $event) { ?> |
64 | 64 | <h3 class="section-title event-name"> |
65 | - <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>"> |
|
65 | + <img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png'; ?>"> |
|
66 | 66 | <?php |
67 | 67 | esc_html_e( |
68 | 68 | "Event Name:", |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | <?php } ?> |
79 | 79 | <ul class="tickets-per-event"> |
80 | 80 | <?php |
81 | - foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
81 | + foreach ($ticket_line_items_per_event[$event_id] as $line_item_id => $line_item) { |
|
82 | 82 | $ticket = $line_item->ticket(); |
83 | 83 | $taxable_html = $ticket->taxable() |
84 | 84 | ? '*' |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | <?php |
108 | 108 | if (count($subitems) < 2) { ?> |
109 | 109 | <tr class="item"> |
110 | - <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td> |
|
110 | + <td><?php echo esc_html($line_item->name().$taxable_html); ?></td> |
|
111 | 111 | <td colspan="2"> |
112 | 112 | <?php echo esc_html($line_item->desc()); ?> |
113 | 113 | <p class="ticket-note"> |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | </td> |
124 | 124 | <td class="item_c"><?php echo esc_html($line_item->quantity()); ?></td> |
125 | 125 | <td class="item_c"><?php echo wp_kses($line_item->unit_price_no_code(), AllowedTags::getAllowedTags()); ?></td> |
126 | - <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
|
126 | + <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
|
127 | 127 | </tr> |
128 | 128 | <?php |
129 | 129 | } else { ?> |
130 | 130 | <tr class="item"> |
131 | 131 | <td class="aln-left"> |
132 | - <?php echo esc_html($line_item->name() . $taxable_html); ?> |
|
132 | + <?php echo esc_html($line_item->name().$taxable_html); ?> |
|
133 | 133 | </td> |
134 | 134 | <td colspan="2"><?php echo esc_html($line_item->desc()); ?> |
135 | 135 | <p class="ticket-note"> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | <td class="item_c"> |
169 | 169 | <?php echo wp_kses( |
170 | 170 | $is_percent |
171 | - ? $sub_line_item->percent() . "%" |
|
171 | + ? $sub_line_item->percent()."%" |
|
172 | 172 | : $sub_line_item->unit_price_no_code(), |
173 | 173 | AllowedTags::getAllowedTags() |
174 | 174 | ); ?> |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | <div class="ticket-time-and-place-details"> |
202 | 202 | <div class="ticket-time-details"> |
203 | 203 | <h4 class="sub-section-title no-bottom-margin"> |
204 | - <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>"> |
|
204 | + <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL.'clock-16x16.png'); ?>"> |
|
205 | 205 | <?php |
206 | 206 | echo _n( |
207 | 207 | "Date/Time:", |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | <li><?php |
217 | 217 | echo wp_kses( |
218 | 218 | $datetime->name() |
219 | - ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
219 | + ? '<b>'.esc_html($datetime->name()).' </b>' |
|
220 | 220 | : '', |
221 | 221 | AllowedTags::getAllowedTags() |
222 | 222 | ); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | ); |
229 | 229 | echo wp_kses( |
230 | 230 | $datetime->description() |
231 | - ? '<p class="ticket-note">' . $datetime->description() . '</p>' |
|
231 | + ? '<p class="ticket-note">'.$datetime->description().'</p>' |
|
232 | 232 | : '', |
233 | 233 | AllowedTags::getAllowedTags() |
234 | 234 | ); ?> |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | <div class="ticket-place-details"> |
243 | 243 | <h4 class="sub-section-title no-bottom-margin"> |
244 | 244 | <img class="icon" src="<?php |
245 | - echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
245 | + echo esc_url_raw(EE_IMAGES_URL.'location-pin-16x16.png'); ?>"> |
|
246 | 246 | <?php |
247 | 247 | echo _n( |
248 | 248 | "Venue:", |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | <div class="ticket-registrations-area"> |
273 | 273 | <h4 class="sub-section-title"> |
274 | 274 | <img class="icon" src="<?php |
275 | - echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
275 | + echo esc_url_raw(EE_IMAGES_URL.'users-16x16.png'); ?>"> |
|
276 | 276 | <?php |
277 | 277 | echo esc_html__("Registration Details", "event_espresso"); ?> |
278 | 278 | <span class="small-text link">[ |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | </h4> |
285 | 285 | <ul class="ticket-registrations-list"> |
286 | 286 | <?php |
287 | - foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
287 | + foreach ($registrations_per_line_item[$line_item_id] as $registration) { |
|
288 | 288 | /* @var $registration EE_Registration */ |
289 | 289 | $attendee = $registration->attendee(); |
290 | 290 | $answers = $registration->answers( |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | <tbody> |
414 | 414 | <?php |
415 | 415 | $c = false; |
416 | - if (! empty($payments)) { |
|
416 | + if ( ! empty($payments)) { |
|
417 | 417 | foreach ($payments as $payment) { |
418 | 418 | /* @var $payment EE_Payment */ ?> |
419 | 419 | <tr class='item <?php echo(($c = ! $c) |
@@ -14,400 +14,400 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_SPCO_JSON_Response |
16 | 16 | { |
17 | - /** |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - protected $_errors = ''; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $_unexpected_errors = ''; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected $_attention = ''; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - protected $_success = ''; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - protected $_plz_select_method_of_payment = ''; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - protected $_redirect_url = ''; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var string |
|
49 | - */ |
|
50 | - protected $_registration_time_limit = ''; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var string |
|
54 | - */ |
|
55 | - protected $_redirect_form = ''; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - protected $_reg_step_html = ''; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var string |
|
64 | - */ |
|
65 | - protected $_method_of_payment = ''; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var float |
|
69 | - */ |
|
70 | - protected $_payment_amount; |
|
71 | - |
|
72 | - /** |
|
73 | - * @var array |
|
74 | - */ |
|
75 | - protected $_return_data = array(); |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @var array |
|
80 | - */ |
|
81 | - protected $_validation_rules = array(); |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * class constructor |
|
86 | - */ |
|
87 | - public function __construct() |
|
88 | - { |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * __toString |
|
94 | - * |
|
95 | - * allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a JSON encoded string |
|
96 | - * |
|
97 | - * @access public |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - public function __toString() |
|
101 | - { |
|
102 | - $JSON_response = array(); |
|
103 | - // grab notices |
|
104 | - $notices = EE_Error::get_notices(false); |
|
105 | - $this->set_attention(isset($notices['attention']) ? $notices['attention'] : ''); |
|
106 | - $this->set_errors(isset($notices['errors']) ? $notices['errors'] : ''); |
|
107 | - $this->set_success(isset($notices['success']) ? $notices['success'] : ''); |
|
108 | - // add notices to JSON response, but only if they exist |
|
109 | - if ($this->attention()) { |
|
110 | - $JSON_response['attention'] = $this->attention(); |
|
111 | - } |
|
112 | - if ($this->errors()) { |
|
113 | - $JSON_response['errors'] = $this->errors(); |
|
114 | - } |
|
115 | - if ($this->unexpected_errors()) { |
|
116 | - $JSON_response['unexpected_errors'] = $this->unexpected_errors(); |
|
117 | - } |
|
118 | - if ($this->success()) { |
|
119 | - $JSON_response['success'] = $this->success(); |
|
120 | - } |
|
121 | - // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked |
|
122 | - if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) { |
|
123 | - $JSON_response['success'] = null; |
|
124 | - } |
|
125 | - // set redirect_url, IF it exists |
|
126 | - if ($this->redirect_url()) { |
|
127 | - $JSON_response['redirect_url'] = $this->redirect_url(); |
|
128 | - } |
|
129 | - // set registration_time_limit, IF it exists |
|
130 | - if ($this->registration_time_limit()) { |
|
131 | - $JSON_response['registration_time_limit'] = $this->registration_time_limit(); |
|
132 | - } |
|
133 | - // set payment_amount, IF it exists |
|
134 | - if ($this->payment_amount() !== null) { |
|
135 | - $JSON_response['payment_amount'] = $this->payment_amount(); |
|
136 | - } |
|
137 | - // grab generic return data |
|
138 | - $return_data = $this->return_data(); |
|
139 | - // add billing form validation rules |
|
140 | - if ($this->validation_rules()) { |
|
141 | - $return_data['validation_rules'] = $this->validation_rules(); |
|
142 | - } |
|
143 | - // set reg_step_html, IF it exists |
|
144 | - if ($this->reg_step_html()) { |
|
145 | - $return_data['reg_step_html'] = $this->reg_step_html(); |
|
146 | - } |
|
147 | - // set method of payment, IF it exists |
|
148 | - if ($this->method_of_payment()) { |
|
149 | - $return_data['method_of_payment'] = $this->method_of_payment(); |
|
150 | - } |
|
151 | - // set "plz_select_method_of_payment" message, IF it exists |
|
152 | - if ($this->plz_select_method_of_payment()) { |
|
153 | - $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment(); |
|
154 | - } |
|
155 | - // set redirect_form, IF it exists |
|
156 | - if ($this->redirect_form()) { |
|
157 | - $return_data['redirect_form'] = $this->redirect_form(); |
|
158 | - } |
|
159 | - // and finally, add return_data array to main JSON response array, IF it contains anything |
|
160 | - // why did we add some of the above properties to the return data array? |
|
161 | - // because it is easier and cleaner in the Javascript to deal with this way |
|
162 | - if (! empty($return_data)) { |
|
163 | - $JSON_response['return_data'] = $return_data; |
|
164 | - } |
|
165 | - // filter final array |
|
166 | - $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response); |
|
167 | - // return encoded array |
|
168 | - return (string) wp_json_encode($JSON_response); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * @param string $attention |
|
174 | - */ |
|
175 | - public function set_attention($attention) |
|
176 | - { |
|
177 | - $this->_attention = $attention; |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - public function attention() |
|
185 | - { |
|
186 | - return $this->_attention; |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * @param string $errors |
|
192 | - */ |
|
193 | - public function set_errors($errors) |
|
194 | - { |
|
195 | - $this->_errors = $errors; |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public function errors() |
|
203 | - { |
|
204 | - return $this->_errors; |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - public function unexpected_errors() |
|
212 | - { |
|
213 | - return $this->_unexpected_errors; |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * @param string $unexpected_errors |
|
219 | - */ |
|
220 | - public function set_unexpected_errors($unexpected_errors) |
|
221 | - { |
|
222 | - $this->_unexpected_errors = $unexpected_errors; |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * @param string $success |
|
228 | - */ |
|
229 | - public function set_success($success) |
|
230 | - { |
|
231 | - $this->_success = $success; |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * @return string |
|
237 | - */ |
|
238 | - public function success() |
|
239 | - { |
|
240 | - return $this->_success; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * @param string $method_of_payment |
|
246 | - */ |
|
247 | - public function set_method_of_payment($method_of_payment) |
|
248 | - { |
|
249 | - $this->_method_of_payment = $method_of_payment; |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * @return string |
|
255 | - */ |
|
256 | - public function method_of_payment() |
|
257 | - { |
|
258 | - return $this->_method_of_payment; |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * @return float |
|
264 | - */ |
|
265 | - public function payment_amount() |
|
266 | - { |
|
267 | - return $this->_payment_amount; |
|
268 | - } |
|
269 | - |
|
270 | - |
|
271 | - /** |
|
272 | - * @param float $payment_amount |
|
273 | - * @throws EE_Error |
|
274 | - */ |
|
275 | - public function set_payment_amount($payment_amount) |
|
276 | - { |
|
277 | - $this->_payment_amount = (float) $payment_amount; |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * @param string $next_step_html |
|
283 | - */ |
|
284 | - public function set_reg_step_html($next_step_html) |
|
285 | - { |
|
286 | - $this->_reg_step_html = $next_step_html; |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * @return string |
|
292 | - */ |
|
293 | - public function reg_step_html() |
|
294 | - { |
|
295 | - return $this->_reg_step_html; |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * @param string $redirect_form |
|
301 | - */ |
|
302 | - public function set_redirect_form($redirect_form) |
|
303 | - { |
|
304 | - $this->_redirect_form = $redirect_form; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * @return string |
|
310 | - */ |
|
311 | - public function redirect_form() |
|
312 | - { |
|
313 | - return ! empty($this->_redirect_form) ? $this->_redirect_form : false; |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * @param string $plz_select_method_of_payment |
|
319 | - */ |
|
320 | - public function set_plz_select_method_of_payment($plz_select_method_of_payment) |
|
321 | - { |
|
322 | - $this->_plz_select_method_of_payment = $plz_select_method_of_payment; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @return string |
|
328 | - */ |
|
329 | - public function plz_select_method_of_payment() |
|
330 | - { |
|
331 | - return $this->_plz_select_method_of_payment; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * @param string $redirect_url |
|
337 | - */ |
|
338 | - public function set_redirect_url($redirect_url) |
|
339 | - { |
|
340 | - $this->_redirect_url = $redirect_url; |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * @return string |
|
346 | - */ |
|
347 | - public function redirect_url() |
|
348 | - { |
|
349 | - return $this->_redirect_url; |
|
350 | - } |
|
351 | - |
|
352 | - |
|
353 | - /** |
|
354 | - * @return string |
|
355 | - */ |
|
356 | - public function registration_time_limit() |
|
357 | - { |
|
358 | - return $this->_registration_time_limit; |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * @param string $registration_time_limit |
|
364 | - */ |
|
365 | - public function set_registration_time_limit($registration_time_limit) |
|
366 | - { |
|
367 | - $this->_registration_time_limit = $registration_time_limit; |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * @param array $return_data |
|
373 | - */ |
|
374 | - public function set_return_data($return_data) |
|
375 | - { |
|
376 | - $this->_return_data = array_merge($this->_return_data, $return_data); |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * @return array |
|
382 | - */ |
|
383 | - public function return_data() |
|
384 | - { |
|
385 | - return $this->_return_data; |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * @param array $validation_rules |
|
391 | - */ |
|
392 | - public function add_validation_rules(array $validation_rules = array()) |
|
393 | - { |
|
394 | - if (is_array($validation_rules) && ! empty($validation_rules)) { |
|
395 | - $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules); |
|
396 | - } |
|
397 | - } |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * @return array | bool |
|
402 | - */ |
|
403 | - public function validation_rules() |
|
404 | - { |
|
405 | - return ! empty($this->_validation_rules) ? $this->_validation_rules : false; |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - public function echoAndExit() |
|
410 | - { |
|
411 | - exit($this->__toString()); |
|
412 | - } |
|
17 | + /** |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + protected $_errors = ''; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $_unexpected_errors = ''; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected $_attention = ''; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + protected $_success = ''; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + protected $_plz_select_method_of_payment = ''; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + protected $_redirect_url = ''; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var string |
|
49 | + */ |
|
50 | + protected $_registration_time_limit = ''; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var string |
|
54 | + */ |
|
55 | + protected $_redirect_form = ''; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + protected $_reg_step_html = ''; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var string |
|
64 | + */ |
|
65 | + protected $_method_of_payment = ''; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var float |
|
69 | + */ |
|
70 | + protected $_payment_amount; |
|
71 | + |
|
72 | + /** |
|
73 | + * @var array |
|
74 | + */ |
|
75 | + protected $_return_data = array(); |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @var array |
|
80 | + */ |
|
81 | + protected $_validation_rules = array(); |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * class constructor |
|
86 | + */ |
|
87 | + public function __construct() |
|
88 | + { |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * __toString |
|
94 | + * |
|
95 | + * allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a JSON encoded string |
|
96 | + * |
|
97 | + * @access public |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + public function __toString() |
|
101 | + { |
|
102 | + $JSON_response = array(); |
|
103 | + // grab notices |
|
104 | + $notices = EE_Error::get_notices(false); |
|
105 | + $this->set_attention(isset($notices['attention']) ? $notices['attention'] : ''); |
|
106 | + $this->set_errors(isset($notices['errors']) ? $notices['errors'] : ''); |
|
107 | + $this->set_success(isset($notices['success']) ? $notices['success'] : ''); |
|
108 | + // add notices to JSON response, but only if they exist |
|
109 | + if ($this->attention()) { |
|
110 | + $JSON_response['attention'] = $this->attention(); |
|
111 | + } |
|
112 | + if ($this->errors()) { |
|
113 | + $JSON_response['errors'] = $this->errors(); |
|
114 | + } |
|
115 | + if ($this->unexpected_errors()) { |
|
116 | + $JSON_response['unexpected_errors'] = $this->unexpected_errors(); |
|
117 | + } |
|
118 | + if ($this->success()) { |
|
119 | + $JSON_response['success'] = $this->success(); |
|
120 | + } |
|
121 | + // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked |
|
122 | + if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) { |
|
123 | + $JSON_response['success'] = null; |
|
124 | + } |
|
125 | + // set redirect_url, IF it exists |
|
126 | + if ($this->redirect_url()) { |
|
127 | + $JSON_response['redirect_url'] = $this->redirect_url(); |
|
128 | + } |
|
129 | + // set registration_time_limit, IF it exists |
|
130 | + if ($this->registration_time_limit()) { |
|
131 | + $JSON_response['registration_time_limit'] = $this->registration_time_limit(); |
|
132 | + } |
|
133 | + // set payment_amount, IF it exists |
|
134 | + if ($this->payment_amount() !== null) { |
|
135 | + $JSON_response['payment_amount'] = $this->payment_amount(); |
|
136 | + } |
|
137 | + // grab generic return data |
|
138 | + $return_data = $this->return_data(); |
|
139 | + // add billing form validation rules |
|
140 | + if ($this->validation_rules()) { |
|
141 | + $return_data['validation_rules'] = $this->validation_rules(); |
|
142 | + } |
|
143 | + // set reg_step_html, IF it exists |
|
144 | + if ($this->reg_step_html()) { |
|
145 | + $return_data['reg_step_html'] = $this->reg_step_html(); |
|
146 | + } |
|
147 | + // set method of payment, IF it exists |
|
148 | + if ($this->method_of_payment()) { |
|
149 | + $return_data['method_of_payment'] = $this->method_of_payment(); |
|
150 | + } |
|
151 | + // set "plz_select_method_of_payment" message, IF it exists |
|
152 | + if ($this->plz_select_method_of_payment()) { |
|
153 | + $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment(); |
|
154 | + } |
|
155 | + // set redirect_form, IF it exists |
|
156 | + if ($this->redirect_form()) { |
|
157 | + $return_data['redirect_form'] = $this->redirect_form(); |
|
158 | + } |
|
159 | + // and finally, add return_data array to main JSON response array, IF it contains anything |
|
160 | + // why did we add some of the above properties to the return data array? |
|
161 | + // because it is easier and cleaner in the Javascript to deal with this way |
|
162 | + if (! empty($return_data)) { |
|
163 | + $JSON_response['return_data'] = $return_data; |
|
164 | + } |
|
165 | + // filter final array |
|
166 | + $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response); |
|
167 | + // return encoded array |
|
168 | + return (string) wp_json_encode($JSON_response); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * @param string $attention |
|
174 | + */ |
|
175 | + public function set_attention($attention) |
|
176 | + { |
|
177 | + $this->_attention = $attention; |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + public function attention() |
|
185 | + { |
|
186 | + return $this->_attention; |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * @param string $errors |
|
192 | + */ |
|
193 | + public function set_errors($errors) |
|
194 | + { |
|
195 | + $this->_errors = $errors; |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public function errors() |
|
203 | + { |
|
204 | + return $this->_errors; |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + public function unexpected_errors() |
|
212 | + { |
|
213 | + return $this->_unexpected_errors; |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * @param string $unexpected_errors |
|
219 | + */ |
|
220 | + public function set_unexpected_errors($unexpected_errors) |
|
221 | + { |
|
222 | + $this->_unexpected_errors = $unexpected_errors; |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * @param string $success |
|
228 | + */ |
|
229 | + public function set_success($success) |
|
230 | + { |
|
231 | + $this->_success = $success; |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * @return string |
|
237 | + */ |
|
238 | + public function success() |
|
239 | + { |
|
240 | + return $this->_success; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * @param string $method_of_payment |
|
246 | + */ |
|
247 | + public function set_method_of_payment($method_of_payment) |
|
248 | + { |
|
249 | + $this->_method_of_payment = $method_of_payment; |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * @return string |
|
255 | + */ |
|
256 | + public function method_of_payment() |
|
257 | + { |
|
258 | + return $this->_method_of_payment; |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * @return float |
|
264 | + */ |
|
265 | + public function payment_amount() |
|
266 | + { |
|
267 | + return $this->_payment_amount; |
|
268 | + } |
|
269 | + |
|
270 | + |
|
271 | + /** |
|
272 | + * @param float $payment_amount |
|
273 | + * @throws EE_Error |
|
274 | + */ |
|
275 | + public function set_payment_amount($payment_amount) |
|
276 | + { |
|
277 | + $this->_payment_amount = (float) $payment_amount; |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * @param string $next_step_html |
|
283 | + */ |
|
284 | + public function set_reg_step_html($next_step_html) |
|
285 | + { |
|
286 | + $this->_reg_step_html = $next_step_html; |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * @return string |
|
292 | + */ |
|
293 | + public function reg_step_html() |
|
294 | + { |
|
295 | + return $this->_reg_step_html; |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * @param string $redirect_form |
|
301 | + */ |
|
302 | + public function set_redirect_form($redirect_form) |
|
303 | + { |
|
304 | + $this->_redirect_form = $redirect_form; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * @return string |
|
310 | + */ |
|
311 | + public function redirect_form() |
|
312 | + { |
|
313 | + return ! empty($this->_redirect_form) ? $this->_redirect_form : false; |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * @param string $plz_select_method_of_payment |
|
319 | + */ |
|
320 | + public function set_plz_select_method_of_payment($plz_select_method_of_payment) |
|
321 | + { |
|
322 | + $this->_plz_select_method_of_payment = $plz_select_method_of_payment; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @return string |
|
328 | + */ |
|
329 | + public function plz_select_method_of_payment() |
|
330 | + { |
|
331 | + return $this->_plz_select_method_of_payment; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * @param string $redirect_url |
|
337 | + */ |
|
338 | + public function set_redirect_url($redirect_url) |
|
339 | + { |
|
340 | + $this->_redirect_url = $redirect_url; |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * @return string |
|
346 | + */ |
|
347 | + public function redirect_url() |
|
348 | + { |
|
349 | + return $this->_redirect_url; |
|
350 | + } |
|
351 | + |
|
352 | + |
|
353 | + /** |
|
354 | + * @return string |
|
355 | + */ |
|
356 | + public function registration_time_limit() |
|
357 | + { |
|
358 | + return $this->_registration_time_limit; |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * @param string $registration_time_limit |
|
364 | + */ |
|
365 | + public function set_registration_time_limit($registration_time_limit) |
|
366 | + { |
|
367 | + $this->_registration_time_limit = $registration_time_limit; |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * @param array $return_data |
|
373 | + */ |
|
374 | + public function set_return_data($return_data) |
|
375 | + { |
|
376 | + $this->_return_data = array_merge($this->_return_data, $return_data); |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * @return array |
|
382 | + */ |
|
383 | + public function return_data() |
|
384 | + { |
|
385 | + return $this->_return_data; |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * @param array $validation_rules |
|
391 | + */ |
|
392 | + public function add_validation_rules(array $validation_rules = array()) |
|
393 | + { |
|
394 | + if (is_array($validation_rules) && ! empty($validation_rules)) { |
|
395 | + $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules); |
|
396 | + } |
|
397 | + } |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * @return array | bool |
|
402 | + */ |
|
403 | + public function validation_rules() |
|
404 | + { |
|
405 | + return ! empty($this->_validation_rules) ? $this->_validation_rules : false; |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + public function echoAndExit() |
|
410 | + { |
|
411 | + exit($this->__toString()); |
|
412 | + } |
|
413 | 413 | } |
@@ -19,1791 +19,1791 @@ |
||
19 | 19 | */ |
20 | 20 | class EED_Single_Page_Checkout extends EED_Module |
21 | 21 | { |
22 | - /** |
|
23 | - * $_initialized - has the SPCO controller already been initialized ? |
|
24 | - * |
|
25 | - * @var bool $_initialized |
|
26 | - */ |
|
27 | - private static $_initialized = false; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
32 | - * |
|
33 | - * @var bool $_valid_checkout |
|
34 | - */ |
|
35 | - private static $_checkout_verified = true; |
|
36 | - |
|
37 | - /** |
|
38 | - * $_reg_steps_array - holds initial array of reg steps |
|
39 | - * |
|
40 | - * @var array $_reg_steps_array |
|
41 | - */ |
|
42 | - private static $_reg_steps_array = array(); |
|
43 | - |
|
44 | - /** |
|
45 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
46 | - * |
|
47 | - * @var EE_Checkout $checkout |
|
48 | - */ |
|
49 | - public $checkout; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var RequestInterface $request |
|
53 | - */ |
|
54 | - protected $request; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * @return EED_Single_Page_Checkout|EED_Module |
|
59 | - * @throws EE_Error |
|
60 | - * @throws ReflectionException |
|
61 | - */ |
|
62 | - public static function instance() |
|
63 | - { |
|
64 | - add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
65 | - return parent::get_instance(__CLASS__); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @return EE_CART |
|
71 | - */ |
|
72 | - public function cart() |
|
73 | - { |
|
74 | - return $this->checkout->cart; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @return RequestInterface |
|
80 | - * @since 4.10.14.p |
|
81 | - */ |
|
82 | - public static function getRequest() |
|
83 | - { |
|
84 | - return LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @return EE_Transaction |
|
90 | - */ |
|
91 | - public function transaction() |
|
92 | - { |
|
93 | - return $this->checkout->transaction; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
99 | - * |
|
100 | - * @return void |
|
101 | - * @throws EE_Error |
|
102 | - */ |
|
103 | - public static function set_hooks() |
|
104 | - { |
|
105 | - EED_Single_Page_Checkout::set_definitions(); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
111 | - * |
|
112 | - * @return void |
|
113 | - * @throws EE_Error |
|
114 | - */ |
|
115 | - public static function set_hooks_admin() |
|
116 | - { |
|
117 | - EED_Single_Page_Checkout::set_definitions(); |
|
118 | - if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
119 | - return; |
|
120 | - } |
|
121 | - // going to start an output buffer in case anything gets accidentally output |
|
122 | - // that might disrupt our JSON response |
|
123 | - ob_start(); |
|
124 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
125 | - // set ajax hooks |
|
126 | - add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
127 | - add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
128 | - add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
129 | - add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
130 | - add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
131 | - add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * process ajax request |
|
137 | - * |
|
138 | - * @param string $ajax_action |
|
139 | - * @throws EE_Error |
|
140 | - * @throws ReflectionException |
|
141 | - */ |
|
142 | - public static function process_ajax_request($ajax_action) |
|
143 | - { |
|
144 | - $request = EED_Single_Page_Checkout::getRequest(); |
|
145 | - $request->setRequestParam('action', $ajax_action); |
|
146 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * ajax display registration step |
|
152 | - * |
|
153 | - * @throws EE_Error |
|
154 | - * @throws ReflectionException |
|
155 | - */ |
|
156 | - public static function display_reg_step() |
|
157 | - { |
|
158 | - EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * ajax process registration step |
|
164 | - * |
|
165 | - * @throws EE_Error |
|
166 | - * @throws ReflectionException |
|
167 | - */ |
|
168 | - public static function process_reg_step() |
|
169 | - { |
|
170 | - EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * ajax process registration step |
|
176 | - * |
|
177 | - * @throws EE_Error |
|
178 | - * @throws ReflectionException |
|
179 | - */ |
|
180 | - public static function update_reg_step() |
|
181 | - { |
|
182 | - EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * update_checkout |
|
188 | - * |
|
189 | - * @return void |
|
190 | - * @throws ReflectionException |
|
191 | - * @throws EE_Error |
|
192 | - */ |
|
193 | - public static function update_checkout() |
|
194 | - { |
|
195 | - EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * @return void |
|
201 | - * @deprecated 4.10.14.p |
|
202 | - */ |
|
203 | - public static function load_request_handler() |
|
204 | - { |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * set_definitions |
|
210 | - * |
|
211 | - * @return void |
|
212 | - * @throws EE_Error |
|
213 | - */ |
|
214 | - public static function set_definitions() |
|
215 | - { |
|
216 | - if (defined('SPCO_BASE_PATH')) { |
|
217 | - return; |
|
218 | - } |
|
219 | - define( |
|
220 | - 'SPCO_BASE_PATH', |
|
221 | - rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
222 | - ); |
|
223 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/'); |
|
224 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/'); |
|
225 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/'); |
|
226 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/'); |
|
227 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/'); |
|
228 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/'); |
|
229 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
230 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
231 | - ); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * load_reg_steps |
|
237 | - * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
238 | - * |
|
239 | - * @throws EE_Error |
|
240 | - */ |
|
241 | - public static function load_reg_steps() |
|
242 | - { |
|
243 | - static $reg_steps_loaded = false; |
|
244 | - if ($reg_steps_loaded) { |
|
245 | - return; |
|
246 | - } |
|
247 | - // filter list of reg_steps |
|
248 | - $reg_steps_to_load = (array) apply_filters( |
|
249 | - 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
250 | - EED_Single_Page_Checkout::get_reg_steps() |
|
251 | - ); |
|
252 | - // sort by key (order) |
|
253 | - ksort($reg_steps_to_load); |
|
254 | - // loop through folders |
|
255 | - foreach ($reg_steps_to_load as $order => $reg_step) { |
|
256 | - // we need a |
|
257 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
258 | - // copy over to the reg_steps_array |
|
259 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
260 | - // register custom key route for each reg step |
|
261 | - // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
262 | - EE_Config::register_route( |
|
263 | - $reg_step['slug'], |
|
264 | - 'EED_Single_Page_Checkout', |
|
265 | - 'run', |
|
266 | - 'step' |
|
267 | - ); |
|
268 | - // add AJAX or other hooks |
|
269 | - if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
270 | - // setup autoloaders if necessary |
|
271 | - if (! class_exists($reg_step['class_name'])) { |
|
272 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
273 | - $reg_step['file_path'], |
|
274 | - true |
|
275 | - ); |
|
276 | - } |
|
277 | - if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
278 | - call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
279 | - } |
|
280 | - } |
|
281 | - } |
|
282 | - } |
|
283 | - $reg_steps_loaded = true; |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * get_reg_steps |
|
289 | - * |
|
290 | - * @return array |
|
291 | - */ |
|
292 | - public static function get_reg_steps() |
|
293 | - { |
|
294 | - $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
295 | - if (empty($reg_steps)) { |
|
296 | - $reg_steps = array( |
|
297 | - 10 => array( |
|
298 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
299 | - 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
300 | - 'slug' => 'attendee_information', |
|
301 | - 'has_hooks' => false, |
|
302 | - ), |
|
303 | - 30 => array( |
|
304 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
305 | - 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
306 | - 'slug' => 'payment_options', |
|
307 | - 'has_hooks' => true, |
|
308 | - ), |
|
309 | - 999 => array( |
|
310 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
311 | - 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
312 | - 'slug' => 'finalize_registration', |
|
313 | - 'has_hooks' => false, |
|
314 | - ), |
|
315 | - ); |
|
316 | - } |
|
317 | - return $reg_steps; |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - /** |
|
322 | - * registration_checkout_for_admin |
|
323 | - * |
|
324 | - * @return string |
|
325 | - * @throws EE_Error |
|
326 | - * @throws ReflectionException |
|
327 | - */ |
|
328 | - public static function registration_checkout_for_admin() |
|
329 | - { |
|
330 | - $request = EED_Single_Page_Checkout::getRequest(); |
|
331 | - $request->setRequestParam('step', 'attendee_information'); |
|
332 | - $request->setRequestParam('action', 'display_spco_reg_step'); |
|
333 | - $request->setRequestParam('process_form_submission', false); |
|
334 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
335 | - EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
336 | - return EED_Single_Page_Checkout::getResponse()->getOutput(); |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - /** |
|
341 | - * process_registration_from_admin |
|
342 | - * |
|
343 | - * @return EE_Transaction |
|
344 | - * @throws EE_Error |
|
345 | - * @throws ReflectionException |
|
346 | - */ |
|
347 | - public static function process_registration_from_admin() |
|
348 | - { |
|
349 | - $request = EED_Single_Page_Checkout::getRequest(); |
|
350 | - $request->setRequestParam('step', 'attendee_information'); |
|
351 | - $request->setRequestParam('action', 'process_reg_step'); |
|
352 | - $request->setRequestParam('process_form_submission', true); |
|
353 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
354 | - if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
355 | - $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
356 | - if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
357 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
358 | - if ($final_reg_step->process_reg_step()) { |
|
359 | - $final_reg_step->set_completed(); |
|
360 | - EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
361 | - return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
362 | - } |
|
363 | - } |
|
364 | - } |
|
365 | - return null; |
|
366 | - } |
|
367 | - |
|
368 | - |
|
369 | - /** |
|
370 | - * run |
|
371 | - * |
|
372 | - * @param WP_Query $WP |
|
373 | - * @return void |
|
374 | - */ |
|
375 | - public function run($WP) |
|
376 | - { |
|
377 | - if ( |
|
378 | - $WP instanceof WP_Query |
|
379 | - && $WP->is_main_query() |
|
380 | - && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
381 | - && $this->_is_reg_checkout() |
|
382 | - ) { |
|
383 | - $this->_initialize(); |
|
384 | - } |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * determines whether current url matches reg page url |
|
390 | - * |
|
391 | - * @return bool |
|
392 | - */ |
|
393 | - protected function _is_reg_checkout() |
|
394 | - { |
|
395 | - // get current permalink for reg page without any extra query args |
|
396 | - $reg_page_url = get_permalink(EE_Config::instance()->core->reg_page_id); |
|
397 | - // get request URI for current request, but without the scheme or host |
|
398 | - $current_request_uri = EEH_URL::filter_input_server_url(); |
|
399 | - $current_request_uri = html_entity_decode($current_request_uri); |
|
400 | - // get array of query args from the current request URI |
|
401 | - $query_args = EEH_URL::get_query_string($current_request_uri); |
|
402 | - // grab page id if it is set |
|
403 | - $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
404 | - // and remove the page id from the query args (we will re-add it later) |
|
405 | - unset($query_args['page_id']); |
|
406 | - // now strip all query args from current request URI |
|
407 | - $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
408 | - // and re-add the page id if it was set |
|
409 | - if ($page_id) { |
|
410 | - $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
411 | - } |
|
412 | - // remove slashes and ? |
|
413 | - $current_request_uri = trim($current_request_uri, '?/'); |
|
414 | - // is current request URI part of the known full reg page URL ? |
|
415 | - return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * @param WP_Query $wp_query |
|
421 | - * @return void |
|
422 | - * @throws EE_Error |
|
423 | - * @throws ReflectionException |
|
424 | - */ |
|
425 | - public static function init($wp_query) |
|
426 | - { |
|
427 | - EED_Single_Page_Checkout::instance()->run($wp_query); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * _initialize - initial module setup |
|
433 | - * |
|
434 | - * @return void |
|
435 | - */ |
|
436 | - private function _initialize() |
|
437 | - { |
|
438 | - // ensure SPCO doesn't run twice |
|
439 | - if (EED_Single_Page_Checkout::$_initialized) { |
|
440 | - return; |
|
441 | - } |
|
442 | - try { |
|
443 | - $this->request = EED_Single_Page_Checkout::getRequest(); |
|
444 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
445 | - $this->_verify_session(); |
|
446 | - // setup the EE_Checkout object |
|
447 | - $this->checkout = $this->_initialize_checkout(); |
|
448 | - // filter checkout |
|
449 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
450 | - // get the $_GET |
|
451 | - $this->_get_request_vars(); |
|
452 | - if ($this->_block_bots()) { |
|
453 | - return; |
|
454 | - } |
|
455 | - // filter continue_reg |
|
456 | - $this->checkout->continue_reg = apply_filters( |
|
457 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
458 | - true, |
|
459 | - $this->checkout |
|
460 | - ); |
|
461 | - // load the reg steps array |
|
462 | - if (! $this->_load_and_instantiate_reg_steps()) { |
|
463 | - EED_Single_Page_Checkout::$_initialized = true; |
|
464 | - return; |
|
465 | - } |
|
466 | - // set the current step |
|
467 | - $this->checkout->set_current_step($this->checkout->step); |
|
468 | - // and the next step |
|
469 | - $this->checkout->set_next_step(); |
|
470 | - // verify that everything has been setup correctly |
|
471 | - if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
472 | - EED_Single_Page_Checkout::$_initialized = true; |
|
473 | - return; |
|
474 | - } |
|
475 | - // lock the transaction |
|
476 | - $this->checkout->transaction->lock(); |
|
477 | - // make sure all of our cached objects are added to their respective model entity mappers |
|
478 | - $this->checkout->refresh_all_entities(); |
|
479 | - // set amount owing |
|
480 | - $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
481 | - // initialize each reg step, which gives them the chance to potentially alter the process |
|
482 | - $this->_initialize_reg_steps(); |
|
483 | - // DEBUG LOG |
|
484 | - // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
485 | - // get reg form |
|
486 | - if (! $this->_check_form_submission()) { |
|
487 | - EED_Single_Page_Checkout::$_initialized = true; |
|
488 | - return; |
|
489 | - } |
|
490 | - // checkout the action!!! |
|
491 | - $this->_process_form_action(); |
|
492 | - // add some style and make it dance |
|
493 | - $this->add_styles_and_scripts($this); |
|
494 | - // kk... SPCO has successfully run |
|
495 | - EED_Single_Page_Checkout::$_initialized = true; |
|
496 | - // set no cache headers and constants |
|
497 | - EE_System::do_not_cache(); |
|
498 | - // add anchor |
|
499 | - add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
500 | - // remove transaction lock |
|
501 | - add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
502 | - } catch (Exception $e) { |
|
503 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
504 | - } |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - /** |
|
509 | - * _verify_session |
|
510 | - * checks that the session is valid and not expired |
|
511 | - * |
|
512 | - * @throws EE_Error |
|
513 | - * @throws ReflectionException |
|
514 | - */ |
|
515 | - private function _verify_session() |
|
516 | - { |
|
517 | - if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
518 | - throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
519 | - } |
|
520 | - $clear_session_requested = $this->request->getRequestParam('clear_session', false, 'bool'); |
|
521 | - // is session still valid ? |
|
522 | - if ( |
|
523 | - $clear_session_requested |
|
524 | - || ( |
|
525 | - EE_Registry::instance()->SSN->expired() |
|
526 | - && $this->request->getRequestParam('e_reg_url_link') === '' |
|
527 | - ) |
|
528 | - ) { |
|
529 | - $this->checkout = new EE_Checkout(); |
|
530 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
531 | - // EE_Registry::instance()->SSN->reset_cart(); |
|
532 | - // EE_Registry::instance()->SSN->reset_checkout(); |
|
533 | - // EE_Registry::instance()->SSN->reset_transaction(); |
|
534 | - if (! $clear_session_requested) { |
|
535 | - EE_Error::add_attention( |
|
536 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
537 | - __FILE__, |
|
538 | - __FUNCTION__, |
|
539 | - __LINE__ |
|
540 | - ); |
|
541 | - } |
|
542 | - // EE_Registry::instance()->SSN->reset_expired(); |
|
543 | - } |
|
544 | - } |
|
545 | - |
|
546 | - |
|
547 | - /** |
|
548 | - * _initialize_checkout |
|
549 | - * loads and instantiates EE_Checkout |
|
550 | - * |
|
551 | - * @return EE_Checkout |
|
552 | - * @throws EE_Error |
|
553 | - * @throws ReflectionException |
|
554 | - */ |
|
555 | - private function _initialize_checkout() |
|
556 | - { |
|
557 | - // look in session for existing checkout |
|
558 | - /** @type EE_Checkout $checkout */ |
|
559 | - $checkout = EE_Registry::instance()->SSN->checkout(); |
|
560 | - // verify |
|
561 | - if (! $checkout instanceof EE_Checkout) { |
|
562 | - // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
563 | - $checkout = EE_Registry::instance()->load_file( |
|
564 | - SPCO_INC_PATH, |
|
565 | - 'EE_Checkout', |
|
566 | - 'class', |
|
567 | - array(), |
|
568 | - false |
|
569 | - ); |
|
570 | - } else { |
|
571 | - if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
572 | - $this->unlock_transaction(); |
|
573 | - wp_safe_redirect($checkout->redirect_url); |
|
574 | - exit(); |
|
575 | - } |
|
576 | - } |
|
577 | - $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
578 | - // verify again |
|
579 | - if (! $checkout instanceof EE_Checkout) { |
|
580 | - throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
581 | - } |
|
582 | - // reset anything that needs a clean slate for each request |
|
583 | - $checkout->reset_for_current_request(); |
|
584 | - return $checkout; |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - /** |
|
589 | - * _get_request_vars |
|
590 | - * |
|
591 | - * @return void |
|
592 | - */ |
|
593 | - private function _get_request_vars() |
|
594 | - { |
|
595 | - // make sure this request is marked as belonging to EE |
|
596 | - /** @var CurrentPage $current_page */ |
|
597 | - $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class); |
|
598 | - $current_page->setEspressoPage(true); |
|
599 | - // which step is being requested ? |
|
600 | - $this->checkout->step = $this->request->getRequestParam('step', $this->_get_first_step()); |
|
601 | - // which step is being edited ? |
|
602 | - $this->checkout->edit_step = $this->request->getRequestParam('edit_step'); |
|
603 | - // and what we're doing on the current step |
|
604 | - $this->checkout->action = $this->request->getRequestParam('action', 'display_spco_reg_step'); |
|
605 | - // timestamp |
|
606 | - $this->checkout->uts = $this->request->getRequestParam('uts', 0, 'int'); |
|
607 | - // returning to edit ? |
|
608 | - $this->checkout->reg_url_link = $this->request->getRequestParam('e_reg_url_link'); |
|
609 | - // add reg url link to registration query params |
|
610 | - if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
611 | - $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
612 | - } |
|
613 | - // or some other kind of revisit ? |
|
614 | - $this->checkout->revisit = $this->request->getRequestParam('revisit', false, 'bool'); |
|
615 | - // and whether or not to generate a reg form for this request |
|
616 | - $this->checkout->generate_reg_form = $this->request->getRequestParam('generate_reg_form', true, 'bool'); |
|
617 | - // and whether or not to process a reg form submission for this request |
|
618 | - $this->checkout->process_form_submission = $this->request->getRequestParam( |
|
619 | - 'process_form_submission', |
|
620 | - $this->checkout->action === 'process_reg_step', |
|
621 | - 'bool' |
|
622 | - ); |
|
623 | - $this->checkout->process_form_submission = filter_var( |
|
624 | - $this->checkout->action !== 'display_spco_reg_step' |
|
625 | - ? $this->checkout->process_form_submission |
|
626 | - : false, |
|
627 | - FILTER_VALIDATE_BOOLEAN |
|
628 | - ); |
|
629 | - // $this->_display_request_vars(); |
|
630 | - } |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * _display_request_vars |
|
635 | - * |
|
636 | - * @return void |
|
637 | - */ |
|
638 | - protected function _display_request_vars() |
|
639 | - { |
|
640 | - if (! WP_DEBUG) { |
|
641 | - return; |
|
642 | - } |
|
643 | - EEH_Debug_Tools::printr($this->request->requestParams(), 'requestParams', __FILE__, __LINE__); |
|
644 | - EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
645 | - EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
646 | - EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
647 | - EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
648 | - EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
649 | - EEH_Debug_Tools::printr( |
|
650 | - $this->checkout->generate_reg_form, |
|
651 | - '$this->checkout->generate_reg_form', |
|
652 | - __FILE__, |
|
653 | - __LINE__ |
|
654 | - ); |
|
655 | - EEH_Debug_Tools::printr( |
|
656 | - $this->checkout->process_form_submission, |
|
657 | - '$this->checkout->process_form_submission', |
|
658 | - __FILE__, |
|
659 | - __LINE__ |
|
660 | - ); |
|
661 | - } |
|
662 | - |
|
663 | - |
|
664 | - /** |
|
665 | - * _block_bots |
|
666 | - * checks that the incoming request has either of the following set: |
|
667 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
668 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
669 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
670 | - * then where you coming from man? |
|
671 | - * |
|
672 | - * @return boolean |
|
673 | - */ |
|
674 | - private function _block_bots() |
|
675 | - { |
|
676 | - $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
677 | - if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
678 | - return true; |
|
679 | - } |
|
680 | - return false; |
|
681 | - } |
|
682 | - |
|
683 | - |
|
684 | - /** |
|
685 | - * _get_first_step |
|
686 | - * gets slug for first step in $_reg_steps_array |
|
687 | - * |
|
688 | - * @return string |
|
689 | - */ |
|
690 | - private function _get_first_step() |
|
691 | - { |
|
692 | - $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
693 | - return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
694 | - } |
|
695 | - |
|
696 | - |
|
697 | - /** |
|
698 | - * instantiates each reg step based on the loaded reg_steps array |
|
699 | - * |
|
700 | - * @return bool |
|
701 | - * @throws EE_Error |
|
702 | - * @throws InvalidArgumentException |
|
703 | - * @throws InvalidDataTypeException |
|
704 | - * @throws InvalidInterfaceException |
|
705 | - * @throws ReflectionException |
|
706 | - */ |
|
707 | - private function _load_and_instantiate_reg_steps() |
|
708 | - { |
|
709 | - do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
710 | - // have reg_steps already been instantiated ? |
|
711 | - if ( |
|
712 | - empty($this->checkout->reg_steps) |
|
713 | - || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
714 | - ) { |
|
715 | - // if not, then loop through raw reg steps array |
|
716 | - foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
717 | - if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
718 | - return false; |
|
719 | - } |
|
720 | - } |
|
721 | - if (isset($this->checkout->reg_steps['registration_confirmation'])) { |
|
722 | - // skip the registration_confirmation page ? |
|
723 | - if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
724 | - // just remove it from the reg steps array |
|
725 | - $this->checkout->remove_reg_step('registration_confirmation', false); |
|
726 | - } elseif ( |
|
727 | - EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
728 | - ) { |
|
729 | - // set the order to something big like 100 |
|
730 | - $this->checkout->set_reg_step_order('registration_confirmation'); |
|
731 | - } |
|
732 | - } |
|
733 | - // filter the array for good luck |
|
734 | - $this->checkout->reg_steps = apply_filters( |
|
735 | - 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
736 | - $this->checkout->reg_steps |
|
737 | - ); |
|
738 | - // finally re-sort based on the reg step class order properties |
|
739 | - $this->checkout->sort_reg_steps(); |
|
740 | - } else { |
|
741 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
742 | - // set all current step stati to FALSE |
|
743 | - $reg_step->set_is_current_step(false); |
|
744 | - } |
|
745 | - } |
|
746 | - if (empty($this->checkout->reg_steps)) { |
|
747 | - EE_Error::add_error( |
|
748 | - esc_html__('No Reg Steps were loaded..', 'event_espresso'), |
|
749 | - __FILE__, |
|
750 | - __FUNCTION__, |
|
751 | - __LINE__ |
|
752 | - ); |
|
753 | - return false; |
|
754 | - } |
|
755 | - // make reg step details available to JS |
|
756 | - $this->checkout->set_reg_step_JSON_info(); |
|
757 | - return true; |
|
758 | - } |
|
759 | - |
|
760 | - |
|
761 | - /** |
|
762 | - * _load_and_instantiate_reg_step |
|
763 | - * |
|
764 | - * @param array $reg_step |
|
765 | - * @param int $order |
|
766 | - * @return bool |
|
767 | - * @throws EE_Error |
|
768 | - * @throws ReflectionException |
|
769 | - */ |
|
770 | - private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
771 | - { |
|
772 | - // we need a file_path, class_name, and slug to add a reg step |
|
773 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
774 | - // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
775 | - if ( |
|
776 | - $this->checkout->reg_url_link |
|
777 | - && $this->checkout->step !== $reg_step['slug'] |
|
778 | - && $reg_step['slug'] !== 'finalize_registration' |
|
779 | - // normally at this point we would NOT load the reg step, but this filter can change that |
|
780 | - && apply_filters( |
|
781 | - 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
782 | - true, |
|
783 | - $reg_step, |
|
784 | - $this->checkout |
|
785 | - ) |
|
786 | - ) { |
|
787 | - return true; |
|
788 | - } |
|
789 | - |
|
790 | - // instantiate step class using file path and class name |
|
791 | - $reg_step_obj = EE_Registry::instance()->load_file( |
|
792 | - $reg_step['file_path'], |
|
793 | - $reg_step['class_name'], |
|
794 | - 'class', |
|
795 | - [$this->checkout], |
|
796 | - false |
|
797 | - ); |
|
798 | - // did we gets the goods ? |
|
799 | - if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
800 | - // set reg step order based on config |
|
801 | - $reg_step_obj->set_order($order); |
|
802 | - // add instantiated reg step object to the master reg steps array |
|
803 | - $this->checkout->add_reg_step($reg_step_obj); |
|
804 | - } else { |
|
805 | - EE_Error::add_error( |
|
806 | - esc_html__('The current step could not be set.', 'event_espresso'), |
|
807 | - __FILE__, |
|
808 | - __FUNCTION__, |
|
809 | - __LINE__ |
|
810 | - ); |
|
811 | - return false; |
|
812 | - } |
|
813 | - } else { |
|
814 | - if (WP_DEBUG) { |
|
815 | - EE_Error::add_error( |
|
816 | - sprintf( |
|
817 | - esc_html__( |
|
818 | - 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
819 | - 'event_espresso' |
|
820 | - ), |
|
821 | - isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
822 | - isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
823 | - isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
824 | - '<ul>', |
|
825 | - '<li>', |
|
826 | - '</li>', |
|
827 | - '</ul>' |
|
828 | - ), |
|
829 | - __FILE__, |
|
830 | - __FUNCTION__, |
|
831 | - __LINE__ |
|
832 | - ); |
|
833 | - } |
|
834 | - return false; |
|
835 | - } |
|
836 | - return true; |
|
837 | - } |
|
838 | - |
|
839 | - |
|
840 | - /** |
|
841 | - * _verify_transaction_and_get_registrations |
|
842 | - * |
|
843 | - * @return bool |
|
844 | - * @throws EE_Error |
|
845 | - * @throws ReflectionException |
|
846 | - */ |
|
847 | - private function _verify_transaction_and_get_registrations() |
|
848 | - { |
|
849 | - // was there already a valid transaction in the checkout from the session ? |
|
850 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
851 | - // get transaction from db or session |
|
852 | - $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
853 | - ? $this->_get_transaction_and_cart_for_previous_visit() |
|
854 | - : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
855 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
856 | - EE_Error::add_error( |
|
857 | - esc_html__( |
|
858 | - 'Your Registration and Transaction information could not be retrieved from the db.', |
|
859 | - 'event_espresso' |
|
860 | - ), |
|
861 | - __FILE__, |
|
862 | - __FUNCTION__, |
|
863 | - __LINE__ |
|
864 | - ); |
|
865 | - $this->checkout->transaction = EE_Transaction::new_instance(); |
|
866 | - // add some style and make it dance |
|
867 | - $this->add_styles_and_scripts($this); |
|
868 | - EED_Single_Page_Checkout::$_initialized = true; |
|
869 | - return false; |
|
870 | - } |
|
871 | - // and the registrations for the transaction |
|
872 | - $this->_get_registrations($this->checkout->transaction); |
|
873 | - } |
|
874 | - return true; |
|
875 | - } |
|
876 | - |
|
877 | - |
|
878 | - /** |
|
879 | - * _get_transaction_and_cart_for_previous_visit |
|
880 | - * |
|
881 | - * @return EE_Transaction|null |
|
882 | - * @throws EE_Error |
|
883 | - * @throws ReflectionException |
|
884 | - */ |
|
885 | - private function _get_transaction_and_cart_for_previous_visit() |
|
886 | - { |
|
887 | - /** @var $TXN_model EEM_Transaction */ |
|
888 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
889 | - // because the reg_url_link is present in the request, |
|
890 | - // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
891 | - $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
892 | - // verify transaction |
|
893 | - if ($transaction instanceof EE_Transaction) { |
|
894 | - // and get the cart that was used for that transaction |
|
895 | - $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
896 | - return $transaction; |
|
897 | - } |
|
898 | - EE_Error::add_error( |
|
899 | - esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
900 | - __FILE__, |
|
901 | - __FUNCTION__, |
|
902 | - __LINE__ |
|
903 | - ); |
|
904 | - return null; |
|
905 | - } |
|
906 | - |
|
907 | - |
|
908 | - /** |
|
909 | - * _get_cart_for_transaction |
|
910 | - * |
|
911 | - * @param EE_Transaction $transaction |
|
912 | - * @return EE_Cart |
|
913 | - */ |
|
914 | - private function _get_cart_for_transaction($transaction) |
|
915 | - { |
|
916 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
917 | - } |
|
918 | - |
|
919 | - |
|
920 | - /** |
|
921 | - * get_cart_for_transaction |
|
922 | - * |
|
923 | - * @param EE_Transaction $transaction |
|
924 | - * @return EE_Cart |
|
925 | - */ |
|
926 | - public function get_cart_for_transaction(EE_Transaction $transaction) |
|
927 | - { |
|
928 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
929 | - } |
|
930 | - |
|
931 | - |
|
932 | - /** |
|
933 | - * _get_transaction_and_cart_for_current_session |
|
934 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
935 | - * |
|
936 | - * @return EE_Transaction |
|
937 | - * @throws EE_Error |
|
938 | - * @throws ReflectionException |
|
939 | - */ |
|
940 | - private function _get_cart_for_current_session_and_setup_new_transaction() |
|
941 | - { |
|
942 | - // if there's no transaction, then this is the FIRST visit to SPCO |
|
943 | - // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
944 | - $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
945 | - // and then create a new transaction |
|
946 | - $transaction = $this->_initialize_transaction(); |
|
947 | - // verify transaction |
|
948 | - if ($transaction instanceof EE_Transaction) { |
|
949 | - // save it so that we have an ID for other objects to use |
|
950 | - $transaction->save(); |
|
951 | - // and save TXN data to the cart |
|
952 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
953 | - } else { |
|
954 | - EE_Error::add_error( |
|
955 | - esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
956 | - __FILE__, |
|
957 | - __FUNCTION__, |
|
958 | - __LINE__ |
|
959 | - ); |
|
960 | - } |
|
961 | - return $transaction; |
|
962 | - } |
|
963 | - |
|
964 | - |
|
965 | - /** |
|
966 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
967 | - * |
|
968 | - * @return EE_Transaction|null |
|
969 | - */ |
|
970 | - private function _initialize_transaction() |
|
971 | - { |
|
972 | - try { |
|
973 | - // ensure cart totals have been calculated |
|
974 | - $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
975 | - // grab the cart grand total |
|
976 | - $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
977 | - // create new TXN |
|
978 | - $transaction = EE_Transaction::new_instance( |
|
979 | - array( |
|
980 | - 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
981 | - 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
982 | - 'TXN_paid' => 0, |
|
983 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
984 | - ) |
|
985 | - ); |
|
986 | - // save it so that we have an ID for other objects to use |
|
987 | - $transaction->save(); |
|
988 | - // set cron job for following up on TXNs after their session has expired |
|
989 | - EE_Cron_Tasks::schedule_expired_transaction_check( |
|
990 | - EE_Registry::instance()->SSN->expiration() + 1, |
|
991 | - $transaction->ID() |
|
992 | - ); |
|
993 | - return $transaction; |
|
994 | - } catch (Exception $e) { |
|
995 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
996 | - } |
|
997 | - return null; |
|
998 | - } |
|
999 | - |
|
1000 | - |
|
1001 | - /** |
|
1002 | - * _get_registrations |
|
1003 | - * |
|
1004 | - * @param EE_Transaction $transaction |
|
1005 | - * @return void |
|
1006 | - * @throws EE_Error |
|
1007 | - * @throws ReflectionException |
|
1008 | - */ |
|
1009 | - private function _get_registrations(EE_Transaction $transaction) |
|
1010 | - { |
|
1011 | - // first step: grab the registrants { : o |
|
1012 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params); |
|
1013 | - $this->checkout->total_ticket_count = count($registrations); |
|
1014 | - // verify registrations have been set |
|
1015 | - if (empty($registrations)) { |
|
1016 | - // if no cached registrations, then check the db |
|
1017 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params); |
|
1018 | - // still nothing ? well as long as this isn't a revisit |
|
1019 | - if (empty($registrations) && ! $this->checkout->revisit) { |
|
1020 | - // generate new registrations from scratch |
|
1021 | - $registrations = $this->_initialize_registrations($transaction); |
|
1022 | - } |
|
1023 | - } |
|
1024 | - // sort by their original registration order |
|
1025 | - usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1026 | - // then loop thru the array |
|
1027 | - foreach ($registrations as $registration) { |
|
1028 | - // verify each registration |
|
1029 | - if ($registration instanceof EE_Registration) { |
|
1030 | - // we display all attendee info for the primary registrant |
|
1031 | - if ( |
|
1032 | - $this->checkout->reg_url_link === $registration->reg_url_link() |
|
1033 | - && $registration->is_primary_registrant() |
|
1034 | - ) { |
|
1035 | - $this->checkout->primary_revisit = true; |
|
1036 | - break; |
|
1037 | - } |
|
1038 | - if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
1039 | - // but hide info if it doesn't belong to you |
|
1040 | - $transaction->clear_cache('Registration', $registration->ID()); |
|
1041 | - $this->checkout->total_ticket_count--; |
|
1042 | - } |
|
1043 | - $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1044 | - } |
|
1045 | - } |
|
1046 | - } |
|
1047 | - |
|
1048 | - |
|
1049 | - /** |
|
1050 | - * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1051 | - * |
|
1052 | - * @param EE_Transaction $transaction |
|
1053 | - * @return array |
|
1054 | - * @throws EE_Error |
|
1055 | - * @throws ReflectionException |
|
1056 | - */ |
|
1057 | - private function _initialize_registrations(EE_Transaction $transaction) |
|
1058 | - { |
|
1059 | - $att_nmbr = 0; |
|
1060 | - $registrations = array(); |
|
1061 | - if ($transaction instanceof EE_Transaction) { |
|
1062 | - /** @type EE_Registration_Processor $registration_processor */ |
|
1063 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1064 | - $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1065 | - // now let's add the cart items to the $transaction |
|
1066 | - foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1067 | - // do the following for each ticket of this type they selected |
|
1068 | - for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1069 | - $att_nmbr++; |
|
1070 | - /** @var CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1071 | - $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
1072 | - CreateRegistrationCommand::class, |
|
1073 | - [ |
|
1074 | - $transaction, |
|
1075 | - $line_item, |
|
1076 | - $att_nmbr, |
|
1077 | - $this->checkout->total_ticket_count, |
|
1078 | - ] |
|
1079 | - ); |
|
1080 | - // override capabilities for frontend registrations |
|
1081 | - if ($this->request->isFrontend()) { |
|
1082 | - $CreateRegistrationCommand->setCapCheck( |
|
1083 | - new PublicCapabilities('', 'create_new_registration') |
|
1084 | - ); |
|
1085 | - } |
|
1086 | - $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1087 | - if (! $registration instanceof EE_Registration) { |
|
1088 | - throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1089 | - } |
|
1090 | - $registrations[ $registration->ID() ] = $registration; |
|
1091 | - } |
|
1092 | - } |
|
1093 | - $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1094 | - } |
|
1095 | - return $registrations; |
|
1096 | - } |
|
1097 | - |
|
1098 | - |
|
1099 | - /** |
|
1100 | - * sorts registrations by REG_count |
|
1101 | - * |
|
1102 | - * @param EE_Registration $reg_A |
|
1103 | - * @param EE_Registration $reg_B |
|
1104 | - * @return int |
|
1105 | - */ |
|
1106 | - public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1107 | - { |
|
1108 | - // this shouldn't ever happen within the same TXN, but oh well |
|
1109 | - if ($reg_A->count() === $reg_B->count()) { |
|
1110 | - return 0; |
|
1111 | - } |
|
1112 | - return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1113 | - } |
|
1114 | - |
|
1115 | - |
|
1116 | - /** |
|
1117 | - * _final_verifications |
|
1118 | - * just makes sure that everything is set up correctly before proceeding |
|
1119 | - * |
|
1120 | - * @return bool |
|
1121 | - * @throws EE_Error |
|
1122 | - * @throws ReflectionException |
|
1123 | - */ |
|
1124 | - private function _final_verifications() |
|
1125 | - { |
|
1126 | - // filter checkout |
|
1127 | - $this->checkout = apply_filters( |
|
1128 | - 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
1129 | - $this->checkout |
|
1130 | - ); |
|
1131 | - // verify that current step is still set correctly |
|
1132 | - if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1133 | - EE_Error::add_error( |
|
1134 | - esc_html__( |
|
1135 | - 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
|
1136 | - 'event_espresso' |
|
1137 | - ), |
|
1138 | - __FILE__, |
|
1139 | - __FUNCTION__, |
|
1140 | - __LINE__ |
|
1141 | - ); |
|
1142 | - return false; |
|
1143 | - } |
|
1144 | - // if returning to SPCO, then verify that primary registrant is set |
|
1145 | - if (! empty($this->checkout->reg_url_link)) { |
|
1146 | - $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1147 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1148 | - EE_Error::add_error( |
|
1149 | - esc_html__( |
|
1150 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
|
1151 | - 'event_espresso' |
|
1152 | - ), |
|
1153 | - __FILE__, |
|
1154 | - __FUNCTION__, |
|
1155 | - __LINE__ |
|
1156 | - ); |
|
1157 | - return false; |
|
1158 | - } |
|
1159 | - $valid_registrant = null; |
|
1160 | - foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1161 | - if ( |
|
1162 | - $registration instanceof EE_Registration |
|
1163 | - && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1164 | - ) { |
|
1165 | - $valid_registrant = $registration; |
|
1166 | - } |
|
1167 | - } |
|
1168 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1169 | - // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1170 | - if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1171 | - // clear the session, mark the checkout as unverified, and try again |
|
1172 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1173 | - EED_Single_Page_Checkout::$_initialized = false; |
|
1174 | - EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1175 | - $this->_initialize(); |
|
1176 | - EE_Error::reset_notices(); |
|
1177 | - return false; |
|
1178 | - } |
|
1179 | - EE_Error::add_error( |
|
1180 | - esc_html__( |
|
1181 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
1182 | - 'event_espresso' |
|
1183 | - ), |
|
1184 | - __FILE__, |
|
1185 | - __FUNCTION__, |
|
1186 | - __LINE__ |
|
1187 | - ); |
|
1188 | - return false; |
|
1189 | - } |
|
1190 | - } |
|
1191 | - // now that things have been kinda sufficiently verified, |
|
1192 | - // let's add the checkout to the session so that it's available to other systems |
|
1193 | - EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1194 | - return true; |
|
1195 | - } |
|
1196 | - |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * _initialize_reg_steps |
|
1200 | - * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1201 | - * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1202 | - * |
|
1203 | - * @param bool $reinitializing |
|
1204 | - * @throws EE_Error |
|
1205 | - */ |
|
1206 | - private function _initialize_reg_steps($reinitializing = false) |
|
1207 | - { |
|
1208 | - $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1209 | - // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1210 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
1211 | - if (! $reg_step->initialize_reg_step()) { |
|
1212 | - // if not initialized then maybe this step is being removed... |
|
1213 | - if (! $reinitializing && $reg_step->is_current_step()) { |
|
1214 | - // if it was the current step, then we need to start over here |
|
1215 | - $this->_initialize_reg_steps(true); |
|
1216 | - return; |
|
1217 | - } |
|
1218 | - continue; |
|
1219 | - } |
|
1220 | - // add css and JS for current step |
|
1221 | - $this->add_styles_and_scripts($reg_step); |
|
1222 | - if ($reg_step->is_current_step()) { |
|
1223 | - // the text that appears on the reg step form submit button |
|
1224 | - $reg_step->set_submit_button_text(); |
|
1225 | - } |
|
1226 | - } |
|
1227 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1228 | - do_action( |
|
1229 | - "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
1230 | - $this->checkout->current_step |
|
1231 | - ); |
|
1232 | - } |
|
1233 | - |
|
1234 | - |
|
1235 | - /** |
|
1236 | - * _check_form_submission |
|
1237 | - * |
|
1238 | - * @return boolean |
|
1239 | - * @throws EE_Error |
|
1240 | - * @throws ReflectionException |
|
1241 | - */ |
|
1242 | - private function _check_form_submission() |
|
1243 | - { |
|
1244 | - // does this request require the reg form to be generated ? |
|
1245 | - if ($this->checkout->generate_reg_form) { |
|
1246 | - // ever heard that song by Blue Rodeo ? |
|
1247 | - try { |
|
1248 | - $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1249 | - // if not displaying a form, then check for form submission |
|
1250 | - if ( |
|
1251 | - $this->checkout->process_form_submission |
|
1252 | - && $this->checkout->current_step->reg_form->was_submitted() |
|
1253 | - ) { |
|
1254 | - // clear out any old data in case this step is being run again |
|
1255 | - $this->checkout->current_step->set_valid_data(array()); |
|
1256 | - // capture submitted form data |
|
1257 | - $request_data = $this->request->requestParams(); |
|
1258 | - $this->checkout->current_step->reg_form->receive_form_submission( |
|
1259 | - (array) apply_filters( |
|
1260 | - 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1261 | - $request_data, |
|
1262 | - $this->checkout |
|
1263 | - ) |
|
1264 | - ); |
|
1265 | - // validate submitted form data |
|
1266 | - if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1267 | - // thou shall not pass !!! |
|
1268 | - $this->checkout->continue_reg = false; |
|
1269 | - // any form validation errors? |
|
1270 | - if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1271 | - EE_Error::add_error( |
|
1272 | - $this->checkout->current_step->reg_form->submission_error_message(), |
|
1273 | - __FILE__, |
|
1274 | - __FUNCTION__, |
|
1275 | - __LINE__ |
|
1276 | - ); |
|
1277 | - } |
|
1278 | - // well not really... what will happen is |
|
1279 | - // we'll just get redirected back to redo the current step |
|
1280 | - $this->go_to_next_step(); |
|
1281 | - return false; |
|
1282 | - } |
|
1283 | - } |
|
1284 | - } catch (EE_Error $e) { |
|
1285 | - $e->get_error(); |
|
1286 | - } |
|
1287 | - } |
|
1288 | - return true; |
|
1289 | - } |
|
1290 | - |
|
1291 | - |
|
1292 | - /** |
|
1293 | - * _process_action |
|
1294 | - * |
|
1295 | - * @return void |
|
1296 | - * @throws EE_Error |
|
1297 | - * @throws ReflectionException |
|
1298 | - */ |
|
1299 | - private function _process_form_action() |
|
1300 | - { |
|
1301 | - // what cha wanna do? |
|
1302 | - switch ($this->checkout->action) { |
|
1303 | - // AJAX next step reg form |
|
1304 | - case 'display_spco_reg_step': |
|
1305 | - $this->checkout->redirect = false; |
|
1306 | - if ($this->request->isAjax()) { |
|
1307 | - $this->checkout->json_response->set_reg_step_html( |
|
1308 | - $this->checkout->current_step->display_reg_form() |
|
1309 | - ); |
|
1310 | - } |
|
1311 | - break; |
|
1312 | - default: |
|
1313 | - // meh... do one of those other steps first |
|
1314 | - if ( |
|
1315 | - ! empty($this->checkout->action) |
|
1316 | - && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
1317 | - ) { |
|
1318 | - // dynamically creates hook point like: |
|
1319 | - // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1320 | - do_action( |
|
1321 | - "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1322 | - $this->checkout->current_step |
|
1323 | - ); |
|
1324 | - $process_reg_step = apply_filters( |
|
1325 | - "AHEE__Single_Page_Checkout__process_reg_step__{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1326 | - true, |
|
1327 | - $this->checkout->current_step, |
|
1328 | - $this |
|
1329 | - ); |
|
1330 | - // call action on current step |
|
1331 | - if ($process_reg_step && call_user_func([$this->checkout->current_step, $this->checkout->action])) { |
|
1332 | - // good registrant, you get to proceed |
|
1333 | - if ( |
|
1334 | - $this->checkout->current_step->success_message() !== '' |
|
1335 | - && apply_filters( |
|
1336 | - 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1337 | - false |
|
1338 | - ) |
|
1339 | - ) { |
|
1340 | - EE_Error::add_success( |
|
1341 | - $this->checkout->current_step->success_message() |
|
1342 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1343 | - ); |
|
1344 | - } |
|
1345 | - // pack it up, pack it in... |
|
1346 | - $this->_setup_redirect(); |
|
1347 | - } |
|
1348 | - // dynamically creates hook point like: |
|
1349 | - // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1350 | - do_action( |
|
1351 | - "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1352 | - $this->checkout->current_step |
|
1353 | - ); |
|
1354 | - } else { |
|
1355 | - EE_Error::add_error( |
|
1356 | - sprintf( |
|
1357 | - esc_html__( |
|
1358 | - 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
1359 | - 'event_espresso' |
|
1360 | - ), |
|
1361 | - $this->checkout->action, |
|
1362 | - $this->checkout->current_step->name() |
|
1363 | - ), |
|
1364 | - __FILE__, |
|
1365 | - __FUNCTION__, |
|
1366 | - __LINE__ |
|
1367 | - ); |
|
1368 | - } |
|
1369 | - // end default |
|
1370 | - } |
|
1371 | - // store our progress so far |
|
1372 | - $this->checkout->stash_transaction_and_checkout(); |
|
1373 | - // advance to the next step! If you pass GO, collect $200 |
|
1374 | - $this->go_to_next_step(); |
|
1375 | - } |
|
1376 | - |
|
1377 | - |
|
1378 | - /** |
|
1379 | - * @param EED_Single_Page_Checkout|EE_SPCO_Reg_Step $target an object with the method `translate_js_strings` and |
|
1380 | - * `enqueue_styles_and_scripts`. |
|
1381 | - * @return void |
|
1382 | - */ |
|
1383 | - public function add_styles_and_scripts($target) |
|
1384 | - { |
|
1385 | - // i18n |
|
1386 | - $target->translate_js_strings(); |
|
1387 | - if ($this->checkout->admin_request) { |
|
1388 | - add_action('admin_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10); |
|
1389 | - } else { |
|
1390 | - add_action('wp_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10); |
|
1391 | - } |
|
1392 | - } |
|
1393 | - |
|
1394 | - /** |
|
1395 | - * translate_js_strings |
|
1396 | - * |
|
1397 | - * @return void |
|
1398 | - */ |
|
1399 | - public function translate_js_strings() |
|
1400 | - { |
|
1401 | - EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1402 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1403 | - EE_Registry::$i18n_js_strings['server_error'] = esc_html__( |
|
1404 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1405 | - 'event_espresso' |
|
1406 | - ); |
|
1407 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__( |
|
1408 | - 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1409 | - 'event_espresso' |
|
1410 | - ); |
|
1411 | - EE_Registry::$i18n_js_strings['validation_error'] = esc_html__( |
|
1412 | - 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
1413 | - 'event_espresso' |
|
1414 | - ); |
|
1415 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
1416 | - 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
1417 | - 'event_espresso' |
|
1418 | - ); |
|
1419 | - EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__( |
|
1420 | - 'This registration step could not be completed. Please refresh the page and try again.', |
|
1421 | - 'event_espresso' |
|
1422 | - ); |
|
1423 | - EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__( |
|
1424 | - 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
1425 | - 'event_espresso' |
|
1426 | - ); |
|
1427 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1428 | - esc_html__( |
|
1429 | - 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
1430 | - 'event_espresso' |
|
1431 | - ), |
|
1432 | - '<br/>', |
|
1433 | - '<br/>' |
|
1434 | - ); |
|
1435 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1436 | - EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1437 | - EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1438 | - EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1439 | - EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso'); |
|
1440 | - EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso'); |
|
1441 | - EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso'); |
|
1442 | - EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso'); |
|
1443 | - EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso'); |
|
1444 | - EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso'); |
|
1445 | - EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso'); |
|
1446 | - EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso'); |
|
1447 | - EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso'); |
|
1448 | - EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso'); |
|
1449 | - EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso'); |
|
1450 | - EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso'); |
|
1451 | - EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso'); |
|
1452 | - EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso'); |
|
1453 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
1454 | - ); |
|
1455 | - EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
1456 | - 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
1457 | - true |
|
1458 | - ); |
|
1459 | - EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1460 | - apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1461 | - ); |
|
1462 | - EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1463 | - 'M d, Y H:i:s', |
|
1464 | - EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1465 | - ); |
|
1466 | - } |
|
1467 | - |
|
1468 | - |
|
1469 | - /** |
|
1470 | - * enqueue_styles_and_scripts |
|
1471 | - * |
|
1472 | - * @return void |
|
1473 | - * @throws EE_Error |
|
1474 | - */ |
|
1475 | - public function enqueue_styles_and_scripts() |
|
1476 | - { |
|
1477 | - // load css |
|
1478 | - wp_register_style( |
|
1479 | - 'single_page_checkout', |
|
1480 | - SPCO_CSS_URL . 'single_page_checkout.css', |
|
1481 | - array('espresso_default'), |
|
1482 | - EVENT_ESPRESSO_VERSION |
|
1483 | - ); |
|
1484 | - wp_enqueue_style('single_page_checkout'); |
|
1485 | - // load JS |
|
1486 | - wp_register_script( |
|
1487 | - 'jquery_plugin', |
|
1488 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.plugin.min.js', |
|
1489 | - array('jquery'), |
|
1490 | - '1.0.1', |
|
1491 | - true |
|
1492 | - ); |
|
1493 | - wp_register_script( |
|
1494 | - 'jquery_countdown', |
|
1495 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.countdown.min.js', |
|
1496 | - array('jquery_plugin'), |
|
1497 | - '2.1.0', |
|
1498 | - true |
|
1499 | - ); |
|
1500 | - wp_register_script( |
|
1501 | - 'single_page_checkout', |
|
1502 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
1503 | - array('espresso_core', 'underscore', 'ee_form_section_validation'), |
|
1504 | - EVENT_ESPRESSO_VERSION, |
|
1505 | - true |
|
1506 | - ); |
|
1507 | - if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1508 | - $this->checkout->registration_form->enqueue_js(); |
|
1509 | - } |
|
1510 | - if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1511 | - $this->checkout->current_step->reg_form->enqueue_js(); |
|
1512 | - } |
|
1513 | - wp_enqueue_script('single_page_checkout'); |
|
1514 | - if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) { |
|
1515 | - wp_enqueue_script('jquery_countdown'); |
|
1516 | - } |
|
1517 | - /** |
|
1518 | - * global action hook for enqueueing styles and scripts with |
|
1519 | - * spco calls. |
|
1520 | - */ |
|
1521 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1522 | - /** |
|
1523 | - * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1524 | - * The hook will end up being something like: |
|
1525 | - * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1526 | - */ |
|
1527 | - do_action( |
|
1528 | - 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1529 | - $this |
|
1530 | - ); |
|
1531 | - } |
|
1532 | - |
|
1533 | - |
|
1534 | - /** |
|
1535 | - * display the Registration Single Page Checkout Form |
|
1536 | - * |
|
1537 | - * @return void |
|
1538 | - * @throws EE_Error |
|
1539 | - * @throws ReflectionException |
|
1540 | - */ |
|
1541 | - private function _display_spco_reg_form() |
|
1542 | - { |
|
1543 | - // if registering via the admin, just display the reg form for the current step |
|
1544 | - if ($this->checkout->admin_request) { |
|
1545 | - EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->current_step->display_reg_form()); |
|
1546 | - } else { |
|
1547 | - // add powered by EE msg |
|
1548 | - add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1549 | - $empty_cart = count( |
|
1550 | - $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) |
|
1551 | - ) < 1; |
|
1552 | - EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1553 | - $cookies_not_set_msg = ''; |
|
1554 | - if ($empty_cart) { |
|
1555 | - $cookies_not_set_msg = apply_filters( |
|
1556 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1557 | - sprintf( |
|
1558 | - esc_html__( |
|
1559 | - '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
1560 | - 'event_espresso' |
|
1561 | - ), |
|
1562 | - '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
1563 | - '</div>', |
|
1564 | - '<h6 class="important-notice">', |
|
1565 | - '</h6>', |
|
1566 | - '<p>', |
|
1567 | - '</p>', |
|
1568 | - '<br />', |
|
1569 | - '<a href="https://www.whatismybrowser.com/guides/how-to-enable-cookies/" target="_blank" rel="noopener noreferrer">', |
|
1570 | - '</a>' |
|
1571 | - ) |
|
1572 | - ); |
|
1573 | - } |
|
1574 | - $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1575 | - array( |
|
1576 | - 'name' => 'single-page-checkout', |
|
1577 | - 'html_id' => 'ee-single-page-checkout-dv', |
|
1578 | - 'layout_strategy' => |
|
1579 | - new EE_Template_Layout( |
|
1580 | - array( |
|
1581 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1582 | - 'template_args' => array( |
|
1583 | - 'empty_cart' => $empty_cart, |
|
1584 | - 'revisit' => $this->checkout->revisit, |
|
1585 | - 'reg_steps' => $this->checkout->reg_steps, |
|
1586 | - 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1587 | - ? $this->checkout->next_step->slug() |
|
1588 | - : '', |
|
1589 | - 'empty_msg' => apply_filters( |
|
1590 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1591 | - sprintf( |
|
1592 | - esc_html__( |
|
1593 | - 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1594 | - 'event_espresso' |
|
1595 | - ), |
|
1596 | - '<a href="' |
|
1597 | - . get_post_type_archive_link('espresso_events') |
|
1598 | - . '" title="', |
|
1599 | - '">', |
|
1600 | - '</a>' |
|
1601 | - ) |
|
1602 | - ), |
|
1603 | - 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1604 | - 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1605 | - 'session_expiration' => gmdate( |
|
1606 | - 'M d, Y H:i:s', |
|
1607 | - EE_Registry::instance()->SSN->expiration() |
|
1608 | - + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1609 | - ), |
|
1610 | - ), |
|
1611 | - ) |
|
1612 | - ), |
|
1613 | - ) |
|
1614 | - ); |
|
1615 | - // load template and add to output sent that gets filtered into the_content() |
|
1616 | - EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->registration_form->get_html()); |
|
1617 | - } |
|
1618 | - } |
|
1619 | - |
|
1620 | - |
|
1621 | - /** |
|
1622 | - * add_extra_finalize_registration_inputs |
|
1623 | - * |
|
1624 | - * @param $next_step |
|
1625 | - * @internal param string $label |
|
1626 | - * @return void |
|
1627 | - */ |
|
1628 | - public function add_extra_finalize_registration_inputs($next_step) |
|
1629 | - { |
|
1630 | - if ($next_step === 'finalize_registration') { |
|
1631 | - echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1632 | - } |
|
1633 | - } |
|
1634 | - |
|
1635 | - |
|
1636 | - /** |
|
1637 | - * display_registration_footer |
|
1638 | - * |
|
1639 | - * @return string |
|
1640 | - */ |
|
1641 | - public static function display_registration_footer() |
|
1642 | - { |
|
1643 | - if ( |
|
1644 | - apply_filters( |
|
1645 | - 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1646 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1647 | - ) |
|
1648 | - ) { |
|
1649 | - add_filter( |
|
1650 | - 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1651 | - function ($url) { |
|
1652 | - return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1653 | - } |
|
1654 | - ); |
|
1655 | - echo apply_filters( |
|
1656 | - 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1657 | - EEH_Template::powered_by_event_espresso( |
|
1658 | - '', |
|
1659 | - 'espresso-registration-footer-dv', |
|
1660 | - array('utm_content' => 'registration_checkout') |
|
1661 | - ) |
|
1662 | - ); |
|
1663 | - } |
|
1664 | - return ''; |
|
1665 | - } |
|
1666 | - |
|
1667 | - |
|
1668 | - /** |
|
1669 | - * unlock_transaction |
|
1670 | - * |
|
1671 | - * @return void |
|
1672 | - * @throws EE_Error |
|
1673 | - * @throws ReflectionException |
|
1674 | - */ |
|
1675 | - public function unlock_transaction() |
|
1676 | - { |
|
1677 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1678 | - $this->checkout->transaction->unlock(); |
|
1679 | - } |
|
1680 | - } |
|
1681 | - |
|
1682 | - |
|
1683 | - /** |
|
1684 | - * _setup_redirect |
|
1685 | - * |
|
1686 | - * @return void |
|
1687 | - */ |
|
1688 | - private function _setup_redirect() |
|
1689 | - { |
|
1690 | - if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1691 | - $this->checkout->redirect = true; |
|
1692 | - if (empty($this->checkout->redirect_url)) { |
|
1693 | - $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1694 | - } |
|
1695 | - $this->checkout->redirect_url = apply_filters( |
|
1696 | - 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1697 | - $this->checkout->redirect_url, |
|
1698 | - $this->checkout |
|
1699 | - ); |
|
1700 | - } |
|
1701 | - } |
|
1702 | - |
|
1703 | - |
|
1704 | - /** |
|
1705 | - * handle ajax message responses and redirects |
|
1706 | - * |
|
1707 | - * @return void |
|
1708 | - * @throws EE_Error |
|
1709 | - * @throws ReflectionException |
|
1710 | - */ |
|
1711 | - public function go_to_next_step() |
|
1712 | - { |
|
1713 | - if ($this->request->isAjax()) { |
|
1714 | - // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1715 | - $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1716 | - } |
|
1717 | - $this->unlock_transaction(); |
|
1718 | - // just return for these conditions |
|
1719 | - if ( |
|
1720 | - $this->checkout->admin_request |
|
1721 | - || $this->checkout->action === 'redirect_form' |
|
1722 | - || $this->checkout->action === 'update_checkout' |
|
1723 | - ) { |
|
1724 | - return; |
|
1725 | - } |
|
1726 | - // AJAX response |
|
1727 | - $this->_handle_json_response(); |
|
1728 | - // redirect to next step or the Thank You page |
|
1729 | - $this->_handle_html_redirects(); |
|
1730 | - // hmmm... must be something wrong, so let's just display the form again ! |
|
1731 | - $this->_display_spco_reg_form(); |
|
1732 | - } |
|
1733 | - |
|
1734 | - |
|
1735 | - /** |
|
1736 | - * _handle_json_response |
|
1737 | - * |
|
1738 | - * @return void |
|
1739 | - * @throws EE_Error |
|
1740 | - */ |
|
1741 | - protected function _handle_json_response() |
|
1742 | - { |
|
1743 | - // if this is an ajax request |
|
1744 | - if ($this->request->isAjax()) { |
|
1745 | - $this->checkout->json_response->set_registration_time_limit( |
|
1746 | - $this->checkout->get_registration_time_limit() |
|
1747 | - ); |
|
1748 | - $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1749 | - // just send the ajax ( |
|
1750 | - $json_response = apply_filters( |
|
1751 | - 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1752 | - $this->checkout->json_response |
|
1753 | - ); |
|
1754 | - exit($json_response); |
|
1755 | - } |
|
1756 | - } |
|
1757 | - |
|
1758 | - |
|
1759 | - /** |
|
1760 | - * _handle_redirects |
|
1761 | - * |
|
1762 | - * @return void |
|
1763 | - */ |
|
1764 | - protected function _handle_html_redirects() |
|
1765 | - { |
|
1766 | - // going somewhere ? |
|
1767 | - if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1768 | - // store notices in a transient |
|
1769 | - EE_Error::get_notices(false, true); |
|
1770 | - wp_safe_redirect($this->checkout->redirect_url); |
|
1771 | - exit(); |
|
1772 | - } |
|
1773 | - } |
|
1774 | - |
|
1775 | - |
|
1776 | - /** |
|
1777 | - * set_checkout_anchor |
|
1778 | - * |
|
1779 | - * @return void |
|
1780 | - */ |
|
1781 | - public function set_checkout_anchor() |
|
1782 | - { |
|
1783 | - echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1784 | - } |
|
1785 | - |
|
1786 | - /** |
|
1787 | - * getRegistrationExpirationNotice |
|
1788 | - * |
|
1789 | - * @since 4.9.59.p |
|
1790 | - * @return string |
|
1791 | - */ |
|
1792 | - public static function getRegistrationExpirationNotice() |
|
1793 | - { |
|
1794 | - return sprintf( |
|
1795 | - esc_html__( |
|
1796 | - '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
1797 | - 'event_espresso' |
|
1798 | - ), |
|
1799 | - '<h4 class="important-notice">', |
|
1800 | - '</h4>', |
|
1801 | - '<br />', |
|
1802 | - '<p>', |
|
1803 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1804 | - '">', |
|
1805 | - '</a>', |
|
1806 | - '</p>' |
|
1807 | - ); |
|
1808 | - } |
|
22 | + /** |
|
23 | + * $_initialized - has the SPCO controller already been initialized ? |
|
24 | + * |
|
25 | + * @var bool $_initialized |
|
26 | + */ |
|
27 | + private static $_initialized = false; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
32 | + * |
|
33 | + * @var bool $_valid_checkout |
|
34 | + */ |
|
35 | + private static $_checkout_verified = true; |
|
36 | + |
|
37 | + /** |
|
38 | + * $_reg_steps_array - holds initial array of reg steps |
|
39 | + * |
|
40 | + * @var array $_reg_steps_array |
|
41 | + */ |
|
42 | + private static $_reg_steps_array = array(); |
|
43 | + |
|
44 | + /** |
|
45 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
46 | + * |
|
47 | + * @var EE_Checkout $checkout |
|
48 | + */ |
|
49 | + public $checkout; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var RequestInterface $request |
|
53 | + */ |
|
54 | + protected $request; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * @return EED_Single_Page_Checkout|EED_Module |
|
59 | + * @throws EE_Error |
|
60 | + * @throws ReflectionException |
|
61 | + */ |
|
62 | + public static function instance() |
|
63 | + { |
|
64 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
65 | + return parent::get_instance(__CLASS__); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @return EE_CART |
|
71 | + */ |
|
72 | + public function cart() |
|
73 | + { |
|
74 | + return $this->checkout->cart; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @return RequestInterface |
|
80 | + * @since 4.10.14.p |
|
81 | + */ |
|
82 | + public static function getRequest() |
|
83 | + { |
|
84 | + return LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @return EE_Transaction |
|
90 | + */ |
|
91 | + public function transaction() |
|
92 | + { |
|
93 | + return $this->checkout->transaction; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
99 | + * |
|
100 | + * @return void |
|
101 | + * @throws EE_Error |
|
102 | + */ |
|
103 | + public static function set_hooks() |
|
104 | + { |
|
105 | + EED_Single_Page_Checkout::set_definitions(); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
111 | + * |
|
112 | + * @return void |
|
113 | + * @throws EE_Error |
|
114 | + */ |
|
115 | + public static function set_hooks_admin() |
|
116 | + { |
|
117 | + EED_Single_Page_Checkout::set_definitions(); |
|
118 | + if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
119 | + return; |
|
120 | + } |
|
121 | + // going to start an output buffer in case anything gets accidentally output |
|
122 | + // that might disrupt our JSON response |
|
123 | + ob_start(); |
|
124 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
125 | + // set ajax hooks |
|
126 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
127 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
128 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
129 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
130 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
131 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * process ajax request |
|
137 | + * |
|
138 | + * @param string $ajax_action |
|
139 | + * @throws EE_Error |
|
140 | + * @throws ReflectionException |
|
141 | + */ |
|
142 | + public static function process_ajax_request($ajax_action) |
|
143 | + { |
|
144 | + $request = EED_Single_Page_Checkout::getRequest(); |
|
145 | + $request->setRequestParam('action', $ajax_action); |
|
146 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * ajax display registration step |
|
152 | + * |
|
153 | + * @throws EE_Error |
|
154 | + * @throws ReflectionException |
|
155 | + */ |
|
156 | + public static function display_reg_step() |
|
157 | + { |
|
158 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * ajax process registration step |
|
164 | + * |
|
165 | + * @throws EE_Error |
|
166 | + * @throws ReflectionException |
|
167 | + */ |
|
168 | + public static function process_reg_step() |
|
169 | + { |
|
170 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * ajax process registration step |
|
176 | + * |
|
177 | + * @throws EE_Error |
|
178 | + * @throws ReflectionException |
|
179 | + */ |
|
180 | + public static function update_reg_step() |
|
181 | + { |
|
182 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * update_checkout |
|
188 | + * |
|
189 | + * @return void |
|
190 | + * @throws ReflectionException |
|
191 | + * @throws EE_Error |
|
192 | + */ |
|
193 | + public static function update_checkout() |
|
194 | + { |
|
195 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * @return void |
|
201 | + * @deprecated 4.10.14.p |
|
202 | + */ |
|
203 | + public static function load_request_handler() |
|
204 | + { |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * set_definitions |
|
210 | + * |
|
211 | + * @return void |
|
212 | + * @throws EE_Error |
|
213 | + */ |
|
214 | + public static function set_definitions() |
|
215 | + { |
|
216 | + if (defined('SPCO_BASE_PATH')) { |
|
217 | + return; |
|
218 | + } |
|
219 | + define( |
|
220 | + 'SPCO_BASE_PATH', |
|
221 | + rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
222 | + ); |
|
223 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/'); |
|
224 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/'); |
|
225 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/'); |
|
226 | + define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/'); |
|
227 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/'); |
|
228 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/'); |
|
229 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
230 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
231 | + ); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * load_reg_steps |
|
237 | + * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
238 | + * |
|
239 | + * @throws EE_Error |
|
240 | + */ |
|
241 | + public static function load_reg_steps() |
|
242 | + { |
|
243 | + static $reg_steps_loaded = false; |
|
244 | + if ($reg_steps_loaded) { |
|
245 | + return; |
|
246 | + } |
|
247 | + // filter list of reg_steps |
|
248 | + $reg_steps_to_load = (array) apply_filters( |
|
249 | + 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
250 | + EED_Single_Page_Checkout::get_reg_steps() |
|
251 | + ); |
|
252 | + // sort by key (order) |
|
253 | + ksort($reg_steps_to_load); |
|
254 | + // loop through folders |
|
255 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
256 | + // we need a |
|
257 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
258 | + // copy over to the reg_steps_array |
|
259 | + EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
260 | + // register custom key route for each reg step |
|
261 | + // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
262 | + EE_Config::register_route( |
|
263 | + $reg_step['slug'], |
|
264 | + 'EED_Single_Page_Checkout', |
|
265 | + 'run', |
|
266 | + 'step' |
|
267 | + ); |
|
268 | + // add AJAX or other hooks |
|
269 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
270 | + // setup autoloaders if necessary |
|
271 | + if (! class_exists($reg_step['class_name'])) { |
|
272 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
273 | + $reg_step['file_path'], |
|
274 | + true |
|
275 | + ); |
|
276 | + } |
|
277 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
278 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
279 | + } |
|
280 | + } |
|
281 | + } |
|
282 | + } |
|
283 | + $reg_steps_loaded = true; |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * get_reg_steps |
|
289 | + * |
|
290 | + * @return array |
|
291 | + */ |
|
292 | + public static function get_reg_steps() |
|
293 | + { |
|
294 | + $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
295 | + if (empty($reg_steps)) { |
|
296 | + $reg_steps = array( |
|
297 | + 10 => array( |
|
298 | + 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
299 | + 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
300 | + 'slug' => 'attendee_information', |
|
301 | + 'has_hooks' => false, |
|
302 | + ), |
|
303 | + 30 => array( |
|
304 | + 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
305 | + 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
306 | + 'slug' => 'payment_options', |
|
307 | + 'has_hooks' => true, |
|
308 | + ), |
|
309 | + 999 => array( |
|
310 | + 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
311 | + 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
312 | + 'slug' => 'finalize_registration', |
|
313 | + 'has_hooks' => false, |
|
314 | + ), |
|
315 | + ); |
|
316 | + } |
|
317 | + return $reg_steps; |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + /** |
|
322 | + * registration_checkout_for_admin |
|
323 | + * |
|
324 | + * @return string |
|
325 | + * @throws EE_Error |
|
326 | + * @throws ReflectionException |
|
327 | + */ |
|
328 | + public static function registration_checkout_for_admin() |
|
329 | + { |
|
330 | + $request = EED_Single_Page_Checkout::getRequest(); |
|
331 | + $request->setRequestParam('step', 'attendee_information'); |
|
332 | + $request->setRequestParam('action', 'display_spco_reg_step'); |
|
333 | + $request->setRequestParam('process_form_submission', false); |
|
334 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
335 | + EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
336 | + return EED_Single_Page_Checkout::getResponse()->getOutput(); |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + /** |
|
341 | + * process_registration_from_admin |
|
342 | + * |
|
343 | + * @return EE_Transaction |
|
344 | + * @throws EE_Error |
|
345 | + * @throws ReflectionException |
|
346 | + */ |
|
347 | + public static function process_registration_from_admin() |
|
348 | + { |
|
349 | + $request = EED_Single_Page_Checkout::getRequest(); |
|
350 | + $request->setRequestParam('step', 'attendee_information'); |
|
351 | + $request->setRequestParam('action', 'process_reg_step'); |
|
352 | + $request->setRequestParam('process_form_submission', true); |
|
353 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
354 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
355 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
356 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
357 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
358 | + if ($final_reg_step->process_reg_step()) { |
|
359 | + $final_reg_step->set_completed(); |
|
360 | + EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
361 | + return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
362 | + } |
|
363 | + } |
|
364 | + } |
|
365 | + return null; |
|
366 | + } |
|
367 | + |
|
368 | + |
|
369 | + /** |
|
370 | + * run |
|
371 | + * |
|
372 | + * @param WP_Query $WP |
|
373 | + * @return void |
|
374 | + */ |
|
375 | + public function run($WP) |
|
376 | + { |
|
377 | + if ( |
|
378 | + $WP instanceof WP_Query |
|
379 | + && $WP->is_main_query() |
|
380 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
381 | + && $this->_is_reg_checkout() |
|
382 | + ) { |
|
383 | + $this->_initialize(); |
|
384 | + } |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * determines whether current url matches reg page url |
|
390 | + * |
|
391 | + * @return bool |
|
392 | + */ |
|
393 | + protected function _is_reg_checkout() |
|
394 | + { |
|
395 | + // get current permalink for reg page without any extra query args |
|
396 | + $reg_page_url = get_permalink(EE_Config::instance()->core->reg_page_id); |
|
397 | + // get request URI for current request, but without the scheme or host |
|
398 | + $current_request_uri = EEH_URL::filter_input_server_url(); |
|
399 | + $current_request_uri = html_entity_decode($current_request_uri); |
|
400 | + // get array of query args from the current request URI |
|
401 | + $query_args = EEH_URL::get_query_string($current_request_uri); |
|
402 | + // grab page id if it is set |
|
403 | + $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
404 | + // and remove the page id from the query args (we will re-add it later) |
|
405 | + unset($query_args['page_id']); |
|
406 | + // now strip all query args from current request URI |
|
407 | + $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
408 | + // and re-add the page id if it was set |
|
409 | + if ($page_id) { |
|
410 | + $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
411 | + } |
|
412 | + // remove slashes and ? |
|
413 | + $current_request_uri = trim($current_request_uri, '?/'); |
|
414 | + // is current request URI part of the known full reg page URL ? |
|
415 | + return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * @param WP_Query $wp_query |
|
421 | + * @return void |
|
422 | + * @throws EE_Error |
|
423 | + * @throws ReflectionException |
|
424 | + */ |
|
425 | + public static function init($wp_query) |
|
426 | + { |
|
427 | + EED_Single_Page_Checkout::instance()->run($wp_query); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * _initialize - initial module setup |
|
433 | + * |
|
434 | + * @return void |
|
435 | + */ |
|
436 | + private function _initialize() |
|
437 | + { |
|
438 | + // ensure SPCO doesn't run twice |
|
439 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
440 | + return; |
|
441 | + } |
|
442 | + try { |
|
443 | + $this->request = EED_Single_Page_Checkout::getRequest(); |
|
444 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
445 | + $this->_verify_session(); |
|
446 | + // setup the EE_Checkout object |
|
447 | + $this->checkout = $this->_initialize_checkout(); |
|
448 | + // filter checkout |
|
449 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
450 | + // get the $_GET |
|
451 | + $this->_get_request_vars(); |
|
452 | + if ($this->_block_bots()) { |
|
453 | + return; |
|
454 | + } |
|
455 | + // filter continue_reg |
|
456 | + $this->checkout->continue_reg = apply_filters( |
|
457 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
458 | + true, |
|
459 | + $this->checkout |
|
460 | + ); |
|
461 | + // load the reg steps array |
|
462 | + if (! $this->_load_and_instantiate_reg_steps()) { |
|
463 | + EED_Single_Page_Checkout::$_initialized = true; |
|
464 | + return; |
|
465 | + } |
|
466 | + // set the current step |
|
467 | + $this->checkout->set_current_step($this->checkout->step); |
|
468 | + // and the next step |
|
469 | + $this->checkout->set_next_step(); |
|
470 | + // verify that everything has been setup correctly |
|
471 | + if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
472 | + EED_Single_Page_Checkout::$_initialized = true; |
|
473 | + return; |
|
474 | + } |
|
475 | + // lock the transaction |
|
476 | + $this->checkout->transaction->lock(); |
|
477 | + // make sure all of our cached objects are added to their respective model entity mappers |
|
478 | + $this->checkout->refresh_all_entities(); |
|
479 | + // set amount owing |
|
480 | + $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
481 | + // initialize each reg step, which gives them the chance to potentially alter the process |
|
482 | + $this->_initialize_reg_steps(); |
|
483 | + // DEBUG LOG |
|
484 | + // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
485 | + // get reg form |
|
486 | + if (! $this->_check_form_submission()) { |
|
487 | + EED_Single_Page_Checkout::$_initialized = true; |
|
488 | + return; |
|
489 | + } |
|
490 | + // checkout the action!!! |
|
491 | + $this->_process_form_action(); |
|
492 | + // add some style and make it dance |
|
493 | + $this->add_styles_and_scripts($this); |
|
494 | + // kk... SPCO has successfully run |
|
495 | + EED_Single_Page_Checkout::$_initialized = true; |
|
496 | + // set no cache headers and constants |
|
497 | + EE_System::do_not_cache(); |
|
498 | + // add anchor |
|
499 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
500 | + // remove transaction lock |
|
501 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
502 | + } catch (Exception $e) { |
|
503 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
504 | + } |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + /** |
|
509 | + * _verify_session |
|
510 | + * checks that the session is valid and not expired |
|
511 | + * |
|
512 | + * @throws EE_Error |
|
513 | + * @throws ReflectionException |
|
514 | + */ |
|
515 | + private function _verify_session() |
|
516 | + { |
|
517 | + if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
518 | + throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
519 | + } |
|
520 | + $clear_session_requested = $this->request->getRequestParam('clear_session', false, 'bool'); |
|
521 | + // is session still valid ? |
|
522 | + if ( |
|
523 | + $clear_session_requested |
|
524 | + || ( |
|
525 | + EE_Registry::instance()->SSN->expired() |
|
526 | + && $this->request->getRequestParam('e_reg_url_link') === '' |
|
527 | + ) |
|
528 | + ) { |
|
529 | + $this->checkout = new EE_Checkout(); |
|
530 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
531 | + // EE_Registry::instance()->SSN->reset_cart(); |
|
532 | + // EE_Registry::instance()->SSN->reset_checkout(); |
|
533 | + // EE_Registry::instance()->SSN->reset_transaction(); |
|
534 | + if (! $clear_session_requested) { |
|
535 | + EE_Error::add_attention( |
|
536 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
537 | + __FILE__, |
|
538 | + __FUNCTION__, |
|
539 | + __LINE__ |
|
540 | + ); |
|
541 | + } |
|
542 | + // EE_Registry::instance()->SSN->reset_expired(); |
|
543 | + } |
|
544 | + } |
|
545 | + |
|
546 | + |
|
547 | + /** |
|
548 | + * _initialize_checkout |
|
549 | + * loads and instantiates EE_Checkout |
|
550 | + * |
|
551 | + * @return EE_Checkout |
|
552 | + * @throws EE_Error |
|
553 | + * @throws ReflectionException |
|
554 | + */ |
|
555 | + private function _initialize_checkout() |
|
556 | + { |
|
557 | + // look in session for existing checkout |
|
558 | + /** @type EE_Checkout $checkout */ |
|
559 | + $checkout = EE_Registry::instance()->SSN->checkout(); |
|
560 | + // verify |
|
561 | + if (! $checkout instanceof EE_Checkout) { |
|
562 | + // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
563 | + $checkout = EE_Registry::instance()->load_file( |
|
564 | + SPCO_INC_PATH, |
|
565 | + 'EE_Checkout', |
|
566 | + 'class', |
|
567 | + array(), |
|
568 | + false |
|
569 | + ); |
|
570 | + } else { |
|
571 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
572 | + $this->unlock_transaction(); |
|
573 | + wp_safe_redirect($checkout->redirect_url); |
|
574 | + exit(); |
|
575 | + } |
|
576 | + } |
|
577 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
578 | + // verify again |
|
579 | + if (! $checkout instanceof EE_Checkout) { |
|
580 | + throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
581 | + } |
|
582 | + // reset anything that needs a clean slate for each request |
|
583 | + $checkout->reset_for_current_request(); |
|
584 | + return $checkout; |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + /** |
|
589 | + * _get_request_vars |
|
590 | + * |
|
591 | + * @return void |
|
592 | + */ |
|
593 | + private function _get_request_vars() |
|
594 | + { |
|
595 | + // make sure this request is marked as belonging to EE |
|
596 | + /** @var CurrentPage $current_page */ |
|
597 | + $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class); |
|
598 | + $current_page->setEspressoPage(true); |
|
599 | + // which step is being requested ? |
|
600 | + $this->checkout->step = $this->request->getRequestParam('step', $this->_get_first_step()); |
|
601 | + // which step is being edited ? |
|
602 | + $this->checkout->edit_step = $this->request->getRequestParam('edit_step'); |
|
603 | + // and what we're doing on the current step |
|
604 | + $this->checkout->action = $this->request->getRequestParam('action', 'display_spco_reg_step'); |
|
605 | + // timestamp |
|
606 | + $this->checkout->uts = $this->request->getRequestParam('uts', 0, 'int'); |
|
607 | + // returning to edit ? |
|
608 | + $this->checkout->reg_url_link = $this->request->getRequestParam('e_reg_url_link'); |
|
609 | + // add reg url link to registration query params |
|
610 | + if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
611 | + $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
612 | + } |
|
613 | + // or some other kind of revisit ? |
|
614 | + $this->checkout->revisit = $this->request->getRequestParam('revisit', false, 'bool'); |
|
615 | + // and whether or not to generate a reg form for this request |
|
616 | + $this->checkout->generate_reg_form = $this->request->getRequestParam('generate_reg_form', true, 'bool'); |
|
617 | + // and whether or not to process a reg form submission for this request |
|
618 | + $this->checkout->process_form_submission = $this->request->getRequestParam( |
|
619 | + 'process_form_submission', |
|
620 | + $this->checkout->action === 'process_reg_step', |
|
621 | + 'bool' |
|
622 | + ); |
|
623 | + $this->checkout->process_form_submission = filter_var( |
|
624 | + $this->checkout->action !== 'display_spco_reg_step' |
|
625 | + ? $this->checkout->process_form_submission |
|
626 | + : false, |
|
627 | + FILTER_VALIDATE_BOOLEAN |
|
628 | + ); |
|
629 | + // $this->_display_request_vars(); |
|
630 | + } |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * _display_request_vars |
|
635 | + * |
|
636 | + * @return void |
|
637 | + */ |
|
638 | + protected function _display_request_vars() |
|
639 | + { |
|
640 | + if (! WP_DEBUG) { |
|
641 | + return; |
|
642 | + } |
|
643 | + EEH_Debug_Tools::printr($this->request->requestParams(), 'requestParams', __FILE__, __LINE__); |
|
644 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
645 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
646 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
647 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
648 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
649 | + EEH_Debug_Tools::printr( |
|
650 | + $this->checkout->generate_reg_form, |
|
651 | + '$this->checkout->generate_reg_form', |
|
652 | + __FILE__, |
|
653 | + __LINE__ |
|
654 | + ); |
|
655 | + EEH_Debug_Tools::printr( |
|
656 | + $this->checkout->process_form_submission, |
|
657 | + '$this->checkout->process_form_submission', |
|
658 | + __FILE__, |
|
659 | + __LINE__ |
|
660 | + ); |
|
661 | + } |
|
662 | + |
|
663 | + |
|
664 | + /** |
|
665 | + * _block_bots |
|
666 | + * checks that the incoming request has either of the following set: |
|
667 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
668 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
669 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
670 | + * then where you coming from man? |
|
671 | + * |
|
672 | + * @return boolean |
|
673 | + */ |
|
674 | + private function _block_bots() |
|
675 | + { |
|
676 | + $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
677 | + if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
678 | + return true; |
|
679 | + } |
|
680 | + return false; |
|
681 | + } |
|
682 | + |
|
683 | + |
|
684 | + /** |
|
685 | + * _get_first_step |
|
686 | + * gets slug for first step in $_reg_steps_array |
|
687 | + * |
|
688 | + * @return string |
|
689 | + */ |
|
690 | + private function _get_first_step() |
|
691 | + { |
|
692 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
693 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
694 | + } |
|
695 | + |
|
696 | + |
|
697 | + /** |
|
698 | + * instantiates each reg step based on the loaded reg_steps array |
|
699 | + * |
|
700 | + * @return bool |
|
701 | + * @throws EE_Error |
|
702 | + * @throws InvalidArgumentException |
|
703 | + * @throws InvalidDataTypeException |
|
704 | + * @throws InvalidInterfaceException |
|
705 | + * @throws ReflectionException |
|
706 | + */ |
|
707 | + private function _load_and_instantiate_reg_steps() |
|
708 | + { |
|
709 | + do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
710 | + // have reg_steps already been instantiated ? |
|
711 | + if ( |
|
712 | + empty($this->checkout->reg_steps) |
|
713 | + || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
714 | + ) { |
|
715 | + // if not, then loop through raw reg steps array |
|
716 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
717 | + if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
718 | + return false; |
|
719 | + } |
|
720 | + } |
|
721 | + if (isset($this->checkout->reg_steps['registration_confirmation'])) { |
|
722 | + // skip the registration_confirmation page ? |
|
723 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
724 | + // just remove it from the reg steps array |
|
725 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
726 | + } elseif ( |
|
727 | + EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
728 | + ) { |
|
729 | + // set the order to something big like 100 |
|
730 | + $this->checkout->set_reg_step_order('registration_confirmation'); |
|
731 | + } |
|
732 | + } |
|
733 | + // filter the array for good luck |
|
734 | + $this->checkout->reg_steps = apply_filters( |
|
735 | + 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
736 | + $this->checkout->reg_steps |
|
737 | + ); |
|
738 | + // finally re-sort based on the reg step class order properties |
|
739 | + $this->checkout->sort_reg_steps(); |
|
740 | + } else { |
|
741 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
742 | + // set all current step stati to FALSE |
|
743 | + $reg_step->set_is_current_step(false); |
|
744 | + } |
|
745 | + } |
|
746 | + if (empty($this->checkout->reg_steps)) { |
|
747 | + EE_Error::add_error( |
|
748 | + esc_html__('No Reg Steps were loaded..', 'event_espresso'), |
|
749 | + __FILE__, |
|
750 | + __FUNCTION__, |
|
751 | + __LINE__ |
|
752 | + ); |
|
753 | + return false; |
|
754 | + } |
|
755 | + // make reg step details available to JS |
|
756 | + $this->checkout->set_reg_step_JSON_info(); |
|
757 | + return true; |
|
758 | + } |
|
759 | + |
|
760 | + |
|
761 | + /** |
|
762 | + * _load_and_instantiate_reg_step |
|
763 | + * |
|
764 | + * @param array $reg_step |
|
765 | + * @param int $order |
|
766 | + * @return bool |
|
767 | + * @throws EE_Error |
|
768 | + * @throws ReflectionException |
|
769 | + */ |
|
770 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
771 | + { |
|
772 | + // we need a file_path, class_name, and slug to add a reg step |
|
773 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
774 | + // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
775 | + if ( |
|
776 | + $this->checkout->reg_url_link |
|
777 | + && $this->checkout->step !== $reg_step['slug'] |
|
778 | + && $reg_step['slug'] !== 'finalize_registration' |
|
779 | + // normally at this point we would NOT load the reg step, but this filter can change that |
|
780 | + && apply_filters( |
|
781 | + 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
782 | + true, |
|
783 | + $reg_step, |
|
784 | + $this->checkout |
|
785 | + ) |
|
786 | + ) { |
|
787 | + return true; |
|
788 | + } |
|
789 | + |
|
790 | + // instantiate step class using file path and class name |
|
791 | + $reg_step_obj = EE_Registry::instance()->load_file( |
|
792 | + $reg_step['file_path'], |
|
793 | + $reg_step['class_name'], |
|
794 | + 'class', |
|
795 | + [$this->checkout], |
|
796 | + false |
|
797 | + ); |
|
798 | + // did we gets the goods ? |
|
799 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
800 | + // set reg step order based on config |
|
801 | + $reg_step_obj->set_order($order); |
|
802 | + // add instantiated reg step object to the master reg steps array |
|
803 | + $this->checkout->add_reg_step($reg_step_obj); |
|
804 | + } else { |
|
805 | + EE_Error::add_error( |
|
806 | + esc_html__('The current step could not be set.', 'event_espresso'), |
|
807 | + __FILE__, |
|
808 | + __FUNCTION__, |
|
809 | + __LINE__ |
|
810 | + ); |
|
811 | + return false; |
|
812 | + } |
|
813 | + } else { |
|
814 | + if (WP_DEBUG) { |
|
815 | + EE_Error::add_error( |
|
816 | + sprintf( |
|
817 | + esc_html__( |
|
818 | + 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
819 | + 'event_espresso' |
|
820 | + ), |
|
821 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
822 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
823 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
824 | + '<ul>', |
|
825 | + '<li>', |
|
826 | + '</li>', |
|
827 | + '</ul>' |
|
828 | + ), |
|
829 | + __FILE__, |
|
830 | + __FUNCTION__, |
|
831 | + __LINE__ |
|
832 | + ); |
|
833 | + } |
|
834 | + return false; |
|
835 | + } |
|
836 | + return true; |
|
837 | + } |
|
838 | + |
|
839 | + |
|
840 | + /** |
|
841 | + * _verify_transaction_and_get_registrations |
|
842 | + * |
|
843 | + * @return bool |
|
844 | + * @throws EE_Error |
|
845 | + * @throws ReflectionException |
|
846 | + */ |
|
847 | + private function _verify_transaction_and_get_registrations() |
|
848 | + { |
|
849 | + // was there already a valid transaction in the checkout from the session ? |
|
850 | + if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
851 | + // get transaction from db or session |
|
852 | + $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
853 | + ? $this->_get_transaction_and_cart_for_previous_visit() |
|
854 | + : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
855 | + if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
856 | + EE_Error::add_error( |
|
857 | + esc_html__( |
|
858 | + 'Your Registration and Transaction information could not be retrieved from the db.', |
|
859 | + 'event_espresso' |
|
860 | + ), |
|
861 | + __FILE__, |
|
862 | + __FUNCTION__, |
|
863 | + __LINE__ |
|
864 | + ); |
|
865 | + $this->checkout->transaction = EE_Transaction::new_instance(); |
|
866 | + // add some style and make it dance |
|
867 | + $this->add_styles_and_scripts($this); |
|
868 | + EED_Single_Page_Checkout::$_initialized = true; |
|
869 | + return false; |
|
870 | + } |
|
871 | + // and the registrations for the transaction |
|
872 | + $this->_get_registrations($this->checkout->transaction); |
|
873 | + } |
|
874 | + return true; |
|
875 | + } |
|
876 | + |
|
877 | + |
|
878 | + /** |
|
879 | + * _get_transaction_and_cart_for_previous_visit |
|
880 | + * |
|
881 | + * @return EE_Transaction|null |
|
882 | + * @throws EE_Error |
|
883 | + * @throws ReflectionException |
|
884 | + */ |
|
885 | + private function _get_transaction_and_cart_for_previous_visit() |
|
886 | + { |
|
887 | + /** @var $TXN_model EEM_Transaction */ |
|
888 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
889 | + // because the reg_url_link is present in the request, |
|
890 | + // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
891 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
892 | + // verify transaction |
|
893 | + if ($transaction instanceof EE_Transaction) { |
|
894 | + // and get the cart that was used for that transaction |
|
895 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
896 | + return $transaction; |
|
897 | + } |
|
898 | + EE_Error::add_error( |
|
899 | + esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
900 | + __FILE__, |
|
901 | + __FUNCTION__, |
|
902 | + __LINE__ |
|
903 | + ); |
|
904 | + return null; |
|
905 | + } |
|
906 | + |
|
907 | + |
|
908 | + /** |
|
909 | + * _get_cart_for_transaction |
|
910 | + * |
|
911 | + * @param EE_Transaction $transaction |
|
912 | + * @return EE_Cart |
|
913 | + */ |
|
914 | + private function _get_cart_for_transaction($transaction) |
|
915 | + { |
|
916 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
917 | + } |
|
918 | + |
|
919 | + |
|
920 | + /** |
|
921 | + * get_cart_for_transaction |
|
922 | + * |
|
923 | + * @param EE_Transaction $transaction |
|
924 | + * @return EE_Cart |
|
925 | + */ |
|
926 | + public function get_cart_for_transaction(EE_Transaction $transaction) |
|
927 | + { |
|
928 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
929 | + } |
|
930 | + |
|
931 | + |
|
932 | + /** |
|
933 | + * _get_transaction_and_cart_for_current_session |
|
934 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
935 | + * |
|
936 | + * @return EE_Transaction |
|
937 | + * @throws EE_Error |
|
938 | + * @throws ReflectionException |
|
939 | + */ |
|
940 | + private function _get_cart_for_current_session_and_setup_new_transaction() |
|
941 | + { |
|
942 | + // if there's no transaction, then this is the FIRST visit to SPCO |
|
943 | + // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
944 | + $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
945 | + // and then create a new transaction |
|
946 | + $transaction = $this->_initialize_transaction(); |
|
947 | + // verify transaction |
|
948 | + if ($transaction instanceof EE_Transaction) { |
|
949 | + // save it so that we have an ID for other objects to use |
|
950 | + $transaction->save(); |
|
951 | + // and save TXN data to the cart |
|
952 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
953 | + } else { |
|
954 | + EE_Error::add_error( |
|
955 | + esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
956 | + __FILE__, |
|
957 | + __FUNCTION__, |
|
958 | + __LINE__ |
|
959 | + ); |
|
960 | + } |
|
961 | + return $transaction; |
|
962 | + } |
|
963 | + |
|
964 | + |
|
965 | + /** |
|
966 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
967 | + * |
|
968 | + * @return EE_Transaction|null |
|
969 | + */ |
|
970 | + private function _initialize_transaction() |
|
971 | + { |
|
972 | + try { |
|
973 | + // ensure cart totals have been calculated |
|
974 | + $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
975 | + // grab the cart grand total |
|
976 | + $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
977 | + // create new TXN |
|
978 | + $transaction = EE_Transaction::new_instance( |
|
979 | + array( |
|
980 | + 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
981 | + 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
982 | + 'TXN_paid' => 0, |
|
983 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
984 | + ) |
|
985 | + ); |
|
986 | + // save it so that we have an ID for other objects to use |
|
987 | + $transaction->save(); |
|
988 | + // set cron job for following up on TXNs after their session has expired |
|
989 | + EE_Cron_Tasks::schedule_expired_transaction_check( |
|
990 | + EE_Registry::instance()->SSN->expiration() + 1, |
|
991 | + $transaction->ID() |
|
992 | + ); |
|
993 | + return $transaction; |
|
994 | + } catch (Exception $e) { |
|
995 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
996 | + } |
|
997 | + return null; |
|
998 | + } |
|
999 | + |
|
1000 | + |
|
1001 | + /** |
|
1002 | + * _get_registrations |
|
1003 | + * |
|
1004 | + * @param EE_Transaction $transaction |
|
1005 | + * @return void |
|
1006 | + * @throws EE_Error |
|
1007 | + * @throws ReflectionException |
|
1008 | + */ |
|
1009 | + private function _get_registrations(EE_Transaction $transaction) |
|
1010 | + { |
|
1011 | + // first step: grab the registrants { : o |
|
1012 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params); |
|
1013 | + $this->checkout->total_ticket_count = count($registrations); |
|
1014 | + // verify registrations have been set |
|
1015 | + if (empty($registrations)) { |
|
1016 | + // if no cached registrations, then check the db |
|
1017 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params); |
|
1018 | + // still nothing ? well as long as this isn't a revisit |
|
1019 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
1020 | + // generate new registrations from scratch |
|
1021 | + $registrations = $this->_initialize_registrations($transaction); |
|
1022 | + } |
|
1023 | + } |
|
1024 | + // sort by their original registration order |
|
1025 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1026 | + // then loop thru the array |
|
1027 | + foreach ($registrations as $registration) { |
|
1028 | + // verify each registration |
|
1029 | + if ($registration instanceof EE_Registration) { |
|
1030 | + // we display all attendee info for the primary registrant |
|
1031 | + if ( |
|
1032 | + $this->checkout->reg_url_link === $registration->reg_url_link() |
|
1033 | + && $registration->is_primary_registrant() |
|
1034 | + ) { |
|
1035 | + $this->checkout->primary_revisit = true; |
|
1036 | + break; |
|
1037 | + } |
|
1038 | + if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
1039 | + // but hide info if it doesn't belong to you |
|
1040 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
1041 | + $this->checkout->total_ticket_count--; |
|
1042 | + } |
|
1043 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1044 | + } |
|
1045 | + } |
|
1046 | + } |
|
1047 | + |
|
1048 | + |
|
1049 | + /** |
|
1050 | + * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1051 | + * |
|
1052 | + * @param EE_Transaction $transaction |
|
1053 | + * @return array |
|
1054 | + * @throws EE_Error |
|
1055 | + * @throws ReflectionException |
|
1056 | + */ |
|
1057 | + private function _initialize_registrations(EE_Transaction $transaction) |
|
1058 | + { |
|
1059 | + $att_nmbr = 0; |
|
1060 | + $registrations = array(); |
|
1061 | + if ($transaction instanceof EE_Transaction) { |
|
1062 | + /** @type EE_Registration_Processor $registration_processor */ |
|
1063 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1064 | + $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1065 | + // now let's add the cart items to the $transaction |
|
1066 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1067 | + // do the following for each ticket of this type they selected |
|
1068 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1069 | + $att_nmbr++; |
|
1070 | + /** @var CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1071 | + $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
1072 | + CreateRegistrationCommand::class, |
|
1073 | + [ |
|
1074 | + $transaction, |
|
1075 | + $line_item, |
|
1076 | + $att_nmbr, |
|
1077 | + $this->checkout->total_ticket_count, |
|
1078 | + ] |
|
1079 | + ); |
|
1080 | + // override capabilities for frontend registrations |
|
1081 | + if ($this->request->isFrontend()) { |
|
1082 | + $CreateRegistrationCommand->setCapCheck( |
|
1083 | + new PublicCapabilities('', 'create_new_registration') |
|
1084 | + ); |
|
1085 | + } |
|
1086 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1087 | + if (! $registration instanceof EE_Registration) { |
|
1088 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1089 | + } |
|
1090 | + $registrations[ $registration->ID() ] = $registration; |
|
1091 | + } |
|
1092 | + } |
|
1093 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1094 | + } |
|
1095 | + return $registrations; |
|
1096 | + } |
|
1097 | + |
|
1098 | + |
|
1099 | + /** |
|
1100 | + * sorts registrations by REG_count |
|
1101 | + * |
|
1102 | + * @param EE_Registration $reg_A |
|
1103 | + * @param EE_Registration $reg_B |
|
1104 | + * @return int |
|
1105 | + */ |
|
1106 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1107 | + { |
|
1108 | + // this shouldn't ever happen within the same TXN, but oh well |
|
1109 | + if ($reg_A->count() === $reg_B->count()) { |
|
1110 | + return 0; |
|
1111 | + } |
|
1112 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1113 | + } |
|
1114 | + |
|
1115 | + |
|
1116 | + /** |
|
1117 | + * _final_verifications |
|
1118 | + * just makes sure that everything is set up correctly before proceeding |
|
1119 | + * |
|
1120 | + * @return bool |
|
1121 | + * @throws EE_Error |
|
1122 | + * @throws ReflectionException |
|
1123 | + */ |
|
1124 | + private function _final_verifications() |
|
1125 | + { |
|
1126 | + // filter checkout |
|
1127 | + $this->checkout = apply_filters( |
|
1128 | + 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
1129 | + $this->checkout |
|
1130 | + ); |
|
1131 | + // verify that current step is still set correctly |
|
1132 | + if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1133 | + EE_Error::add_error( |
|
1134 | + esc_html__( |
|
1135 | + 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
|
1136 | + 'event_espresso' |
|
1137 | + ), |
|
1138 | + __FILE__, |
|
1139 | + __FUNCTION__, |
|
1140 | + __LINE__ |
|
1141 | + ); |
|
1142 | + return false; |
|
1143 | + } |
|
1144 | + // if returning to SPCO, then verify that primary registrant is set |
|
1145 | + if (! empty($this->checkout->reg_url_link)) { |
|
1146 | + $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1147 | + if (! $valid_registrant instanceof EE_Registration) { |
|
1148 | + EE_Error::add_error( |
|
1149 | + esc_html__( |
|
1150 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
|
1151 | + 'event_espresso' |
|
1152 | + ), |
|
1153 | + __FILE__, |
|
1154 | + __FUNCTION__, |
|
1155 | + __LINE__ |
|
1156 | + ); |
|
1157 | + return false; |
|
1158 | + } |
|
1159 | + $valid_registrant = null; |
|
1160 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1161 | + if ( |
|
1162 | + $registration instanceof EE_Registration |
|
1163 | + && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1164 | + ) { |
|
1165 | + $valid_registrant = $registration; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if (! $valid_registrant instanceof EE_Registration) { |
|
1169 | + // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1170 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1171 | + // clear the session, mark the checkout as unverified, and try again |
|
1172 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1173 | + EED_Single_Page_Checkout::$_initialized = false; |
|
1174 | + EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1175 | + $this->_initialize(); |
|
1176 | + EE_Error::reset_notices(); |
|
1177 | + return false; |
|
1178 | + } |
|
1179 | + EE_Error::add_error( |
|
1180 | + esc_html__( |
|
1181 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
1182 | + 'event_espresso' |
|
1183 | + ), |
|
1184 | + __FILE__, |
|
1185 | + __FUNCTION__, |
|
1186 | + __LINE__ |
|
1187 | + ); |
|
1188 | + return false; |
|
1189 | + } |
|
1190 | + } |
|
1191 | + // now that things have been kinda sufficiently verified, |
|
1192 | + // let's add the checkout to the session so that it's available to other systems |
|
1193 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1194 | + return true; |
|
1195 | + } |
|
1196 | + |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * _initialize_reg_steps |
|
1200 | + * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1201 | + * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1202 | + * |
|
1203 | + * @param bool $reinitializing |
|
1204 | + * @throws EE_Error |
|
1205 | + */ |
|
1206 | + private function _initialize_reg_steps($reinitializing = false) |
|
1207 | + { |
|
1208 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1209 | + // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1210 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
1211 | + if (! $reg_step->initialize_reg_step()) { |
|
1212 | + // if not initialized then maybe this step is being removed... |
|
1213 | + if (! $reinitializing && $reg_step->is_current_step()) { |
|
1214 | + // if it was the current step, then we need to start over here |
|
1215 | + $this->_initialize_reg_steps(true); |
|
1216 | + return; |
|
1217 | + } |
|
1218 | + continue; |
|
1219 | + } |
|
1220 | + // add css and JS for current step |
|
1221 | + $this->add_styles_and_scripts($reg_step); |
|
1222 | + if ($reg_step->is_current_step()) { |
|
1223 | + // the text that appears on the reg step form submit button |
|
1224 | + $reg_step->set_submit_button_text(); |
|
1225 | + } |
|
1226 | + } |
|
1227 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1228 | + do_action( |
|
1229 | + "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
1230 | + $this->checkout->current_step |
|
1231 | + ); |
|
1232 | + } |
|
1233 | + |
|
1234 | + |
|
1235 | + /** |
|
1236 | + * _check_form_submission |
|
1237 | + * |
|
1238 | + * @return boolean |
|
1239 | + * @throws EE_Error |
|
1240 | + * @throws ReflectionException |
|
1241 | + */ |
|
1242 | + private function _check_form_submission() |
|
1243 | + { |
|
1244 | + // does this request require the reg form to be generated ? |
|
1245 | + if ($this->checkout->generate_reg_form) { |
|
1246 | + // ever heard that song by Blue Rodeo ? |
|
1247 | + try { |
|
1248 | + $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1249 | + // if not displaying a form, then check for form submission |
|
1250 | + if ( |
|
1251 | + $this->checkout->process_form_submission |
|
1252 | + && $this->checkout->current_step->reg_form->was_submitted() |
|
1253 | + ) { |
|
1254 | + // clear out any old data in case this step is being run again |
|
1255 | + $this->checkout->current_step->set_valid_data(array()); |
|
1256 | + // capture submitted form data |
|
1257 | + $request_data = $this->request->requestParams(); |
|
1258 | + $this->checkout->current_step->reg_form->receive_form_submission( |
|
1259 | + (array) apply_filters( |
|
1260 | + 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1261 | + $request_data, |
|
1262 | + $this->checkout |
|
1263 | + ) |
|
1264 | + ); |
|
1265 | + // validate submitted form data |
|
1266 | + if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1267 | + // thou shall not pass !!! |
|
1268 | + $this->checkout->continue_reg = false; |
|
1269 | + // any form validation errors? |
|
1270 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1271 | + EE_Error::add_error( |
|
1272 | + $this->checkout->current_step->reg_form->submission_error_message(), |
|
1273 | + __FILE__, |
|
1274 | + __FUNCTION__, |
|
1275 | + __LINE__ |
|
1276 | + ); |
|
1277 | + } |
|
1278 | + // well not really... what will happen is |
|
1279 | + // we'll just get redirected back to redo the current step |
|
1280 | + $this->go_to_next_step(); |
|
1281 | + return false; |
|
1282 | + } |
|
1283 | + } |
|
1284 | + } catch (EE_Error $e) { |
|
1285 | + $e->get_error(); |
|
1286 | + } |
|
1287 | + } |
|
1288 | + return true; |
|
1289 | + } |
|
1290 | + |
|
1291 | + |
|
1292 | + /** |
|
1293 | + * _process_action |
|
1294 | + * |
|
1295 | + * @return void |
|
1296 | + * @throws EE_Error |
|
1297 | + * @throws ReflectionException |
|
1298 | + */ |
|
1299 | + private function _process_form_action() |
|
1300 | + { |
|
1301 | + // what cha wanna do? |
|
1302 | + switch ($this->checkout->action) { |
|
1303 | + // AJAX next step reg form |
|
1304 | + case 'display_spco_reg_step': |
|
1305 | + $this->checkout->redirect = false; |
|
1306 | + if ($this->request->isAjax()) { |
|
1307 | + $this->checkout->json_response->set_reg_step_html( |
|
1308 | + $this->checkout->current_step->display_reg_form() |
|
1309 | + ); |
|
1310 | + } |
|
1311 | + break; |
|
1312 | + default: |
|
1313 | + // meh... do one of those other steps first |
|
1314 | + if ( |
|
1315 | + ! empty($this->checkout->action) |
|
1316 | + && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
1317 | + ) { |
|
1318 | + // dynamically creates hook point like: |
|
1319 | + // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1320 | + do_action( |
|
1321 | + "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1322 | + $this->checkout->current_step |
|
1323 | + ); |
|
1324 | + $process_reg_step = apply_filters( |
|
1325 | + "AHEE__Single_Page_Checkout__process_reg_step__{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1326 | + true, |
|
1327 | + $this->checkout->current_step, |
|
1328 | + $this |
|
1329 | + ); |
|
1330 | + // call action on current step |
|
1331 | + if ($process_reg_step && call_user_func([$this->checkout->current_step, $this->checkout->action])) { |
|
1332 | + // good registrant, you get to proceed |
|
1333 | + if ( |
|
1334 | + $this->checkout->current_step->success_message() !== '' |
|
1335 | + && apply_filters( |
|
1336 | + 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1337 | + false |
|
1338 | + ) |
|
1339 | + ) { |
|
1340 | + EE_Error::add_success( |
|
1341 | + $this->checkout->current_step->success_message() |
|
1342 | + . '<br />' . $this->checkout->next_step->_instructions() |
|
1343 | + ); |
|
1344 | + } |
|
1345 | + // pack it up, pack it in... |
|
1346 | + $this->_setup_redirect(); |
|
1347 | + } |
|
1348 | + // dynamically creates hook point like: |
|
1349 | + // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1350 | + do_action( |
|
1351 | + "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1352 | + $this->checkout->current_step |
|
1353 | + ); |
|
1354 | + } else { |
|
1355 | + EE_Error::add_error( |
|
1356 | + sprintf( |
|
1357 | + esc_html__( |
|
1358 | + 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
1359 | + 'event_espresso' |
|
1360 | + ), |
|
1361 | + $this->checkout->action, |
|
1362 | + $this->checkout->current_step->name() |
|
1363 | + ), |
|
1364 | + __FILE__, |
|
1365 | + __FUNCTION__, |
|
1366 | + __LINE__ |
|
1367 | + ); |
|
1368 | + } |
|
1369 | + // end default |
|
1370 | + } |
|
1371 | + // store our progress so far |
|
1372 | + $this->checkout->stash_transaction_and_checkout(); |
|
1373 | + // advance to the next step! If you pass GO, collect $200 |
|
1374 | + $this->go_to_next_step(); |
|
1375 | + } |
|
1376 | + |
|
1377 | + |
|
1378 | + /** |
|
1379 | + * @param EED_Single_Page_Checkout|EE_SPCO_Reg_Step $target an object with the method `translate_js_strings` and |
|
1380 | + * `enqueue_styles_and_scripts`. |
|
1381 | + * @return void |
|
1382 | + */ |
|
1383 | + public function add_styles_and_scripts($target) |
|
1384 | + { |
|
1385 | + // i18n |
|
1386 | + $target->translate_js_strings(); |
|
1387 | + if ($this->checkout->admin_request) { |
|
1388 | + add_action('admin_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10); |
|
1389 | + } else { |
|
1390 | + add_action('wp_enqueue_scripts', array($target, 'enqueue_styles_and_scripts'), 10); |
|
1391 | + } |
|
1392 | + } |
|
1393 | + |
|
1394 | + /** |
|
1395 | + * translate_js_strings |
|
1396 | + * |
|
1397 | + * @return void |
|
1398 | + */ |
|
1399 | + public function translate_js_strings() |
|
1400 | + { |
|
1401 | + EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1402 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1403 | + EE_Registry::$i18n_js_strings['server_error'] = esc_html__( |
|
1404 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1405 | + 'event_espresso' |
|
1406 | + ); |
|
1407 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__( |
|
1408 | + 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1409 | + 'event_espresso' |
|
1410 | + ); |
|
1411 | + EE_Registry::$i18n_js_strings['validation_error'] = esc_html__( |
|
1412 | + 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
1413 | + 'event_espresso' |
|
1414 | + ); |
|
1415 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
1416 | + 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
1417 | + 'event_espresso' |
|
1418 | + ); |
|
1419 | + EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__( |
|
1420 | + 'This registration step could not be completed. Please refresh the page and try again.', |
|
1421 | + 'event_espresso' |
|
1422 | + ); |
|
1423 | + EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__( |
|
1424 | + 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
1425 | + 'event_espresso' |
|
1426 | + ); |
|
1427 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1428 | + esc_html__( |
|
1429 | + 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
1430 | + 'event_espresso' |
|
1431 | + ), |
|
1432 | + '<br/>', |
|
1433 | + '<br/>' |
|
1434 | + ); |
|
1435 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1436 | + EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1437 | + EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1438 | + EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1439 | + EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso'); |
|
1440 | + EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso'); |
|
1441 | + EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso'); |
|
1442 | + EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso'); |
|
1443 | + EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso'); |
|
1444 | + EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso'); |
|
1445 | + EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso'); |
|
1446 | + EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso'); |
|
1447 | + EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso'); |
|
1448 | + EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso'); |
|
1449 | + EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso'); |
|
1450 | + EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso'); |
|
1451 | + EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso'); |
|
1452 | + EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso'); |
|
1453 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
1454 | + ); |
|
1455 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
1456 | + 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
1457 | + true |
|
1458 | + ); |
|
1459 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1460 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1461 | + ); |
|
1462 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1463 | + 'M d, Y H:i:s', |
|
1464 | + EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1465 | + ); |
|
1466 | + } |
|
1467 | + |
|
1468 | + |
|
1469 | + /** |
|
1470 | + * enqueue_styles_and_scripts |
|
1471 | + * |
|
1472 | + * @return void |
|
1473 | + * @throws EE_Error |
|
1474 | + */ |
|
1475 | + public function enqueue_styles_and_scripts() |
|
1476 | + { |
|
1477 | + // load css |
|
1478 | + wp_register_style( |
|
1479 | + 'single_page_checkout', |
|
1480 | + SPCO_CSS_URL . 'single_page_checkout.css', |
|
1481 | + array('espresso_default'), |
|
1482 | + EVENT_ESPRESSO_VERSION |
|
1483 | + ); |
|
1484 | + wp_enqueue_style('single_page_checkout'); |
|
1485 | + // load JS |
|
1486 | + wp_register_script( |
|
1487 | + 'jquery_plugin', |
|
1488 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.plugin.min.js', |
|
1489 | + array('jquery'), |
|
1490 | + '1.0.1', |
|
1491 | + true |
|
1492 | + ); |
|
1493 | + wp_register_script( |
|
1494 | + 'jquery_countdown', |
|
1495 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.countdown.min.js', |
|
1496 | + array('jquery_plugin'), |
|
1497 | + '2.1.0', |
|
1498 | + true |
|
1499 | + ); |
|
1500 | + wp_register_script( |
|
1501 | + 'single_page_checkout', |
|
1502 | + SPCO_JS_URL . 'single_page_checkout.js', |
|
1503 | + array('espresso_core', 'underscore', 'ee_form_section_validation'), |
|
1504 | + EVENT_ESPRESSO_VERSION, |
|
1505 | + true |
|
1506 | + ); |
|
1507 | + if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1508 | + $this->checkout->registration_form->enqueue_js(); |
|
1509 | + } |
|
1510 | + if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1511 | + $this->checkout->current_step->reg_form->enqueue_js(); |
|
1512 | + } |
|
1513 | + wp_enqueue_script('single_page_checkout'); |
|
1514 | + if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) { |
|
1515 | + wp_enqueue_script('jquery_countdown'); |
|
1516 | + } |
|
1517 | + /** |
|
1518 | + * global action hook for enqueueing styles and scripts with |
|
1519 | + * spco calls. |
|
1520 | + */ |
|
1521 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1522 | + /** |
|
1523 | + * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1524 | + * The hook will end up being something like: |
|
1525 | + * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1526 | + */ |
|
1527 | + do_action( |
|
1528 | + 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1529 | + $this |
|
1530 | + ); |
|
1531 | + } |
|
1532 | + |
|
1533 | + |
|
1534 | + /** |
|
1535 | + * display the Registration Single Page Checkout Form |
|
1536 | + * |
|
1537 | + * @return void |
|
1538 | + * @throws EE_Error |
|
1539 | + * @throws ReflectionException |
|
1540 | + */ |
|
1541 | + private function _display_spco_reg_form() |
|
1542 | + { |
|
1543 | + // if registering via the admin, just display the reg form for the current step |
|
1544 | + if ($this->checkout->admin_request) { |
|
1545 | + EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->current_step->display_reg_form()); |
|
1546 | + } else { |
|
1547 | + // add powered by EE msg |
|
1548 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1549 | + $empty_cart = count( |
|
1550 | + $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) |
|
1551 | + ) < 1; |
|
1552 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1553 | + $cookies_not_set_msg = ''; |
|
1554 | + if ($empty_cart) { |
|
1555 | + $cookies_not_set_msg = apply_filters( |
|
1556 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1557 | + sprintf( |
|
1558 | + esc_html__( |
|
1559 | + '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
1560 | + 'event_espresso' |
|
1561 | + ), |
|
1562 | + '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
1563 | + '</div>', |
|
1564 | + '<h6 class="important-notice">', |
|
1565 | + '</h6>', |
|
1566 | + '<p>', |
|
1567 | + '</p>', |
|
1568 | + '<br />', |
|
1569 | + '<a href="https://www.whatismybrowser.com/guides/how-to-enable-cookies/" target="_blank" rel="noopener noreferrer">', |
|
1570 | + '</a>' |
|
1571 | + ) |
|
1572 | + ); |
|
1573 | + } |
|
1574 | + $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1575 | + array( |
|
1576 | + 'name' => 'single-page-checkout', |
|
1577 | + 'html_id' => 'ee-single-page-checkout-dv', |
|
1578 | + 'layout_strategy' => |
|
1579 | + new EE_Template_Layout( |
|
1580 | + array( |
|
1581 | + 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1582 | + 'template_args' => array( |
|
1583 | + 'empty_cart' => $empty_cart, |
|
1584 | + 'revisit' => $this->checkout->revisit, |
|
1585 | + 'reg_steps' => $this->checkout->reg_steps, |
|
1586 | + 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1587 | + ? $this->checkout->next_step->slug() |
|
1588 | + : '', |
|
1589 | + 'empty_msg' => apply_filters( |
|
1590 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1591 | + sprintf( |
|
1592 | + esc_html__( |
|
1593 | + 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1594 | + 'event_espresso' |
|
1595 | + ), |
|
1596 | + '<a href="' |
|
1597 | + . get_post_type_archive_link('espresso_events') |
|
1598 | + . '" title="', |
|
1599 | + '">', |
|
1600 | + '</a>' |
|
1601 | + ) |
|
1602 | + ), |
|
1603 | + 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1604 | + 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1605 | + 'session_expiration' => gmdate( |
|
1606 | + 'M d, Y H:i:s', |
|
1607 | + EE_Registry::instance()->SSN->expiration() |
|
1608 | + + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1609 | + ), |
|
1610 | + ), |
|
1611 | + ) |
|
1612 | + ), |
|
1613 | + ) |
|
1614 | + ); |
|
1615 | + // load template and add to output sent that gets filtered into the_content() |
|
1616 | + EED_Single_Page_Checkout::getResponse()->addOutput($this->checkout->registration_form->get_html()); |
|
1617 | + } |
|
1618 | + } |
|
1619 | + |
|
1620 | + |
|
1621 | + /** |
|
1622 | + * add_extra_finalize_registration_inputs |
|
1623 | + * |
|
1624 | + * @param $next_step |
|
1625 | + * @internal param string $label |
|
1626 | + * @return void |
|
1627 | + */ |
|
1628 | + public function add_extra_finalize_registration_inputs($next_step) |
|
1629 | + { |
|
1630 | + if ($next_step === 'finalize_registration') { |
|
1631 | + echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1632 | + } |
|
1633 | + } |
|
1634 | + |
|
1635 | + |
|
1636 | + /** |
|
1637 | + * display_registration_footer |
|
1638 | + * |
|
1639 | + * @return string |
|
1640 | + */ |
|
1641 | + public static function display_registration_footer() |
|
1642 | + { |
|
1643 | + if ( |
|
1644 | + apply_filters( |
|
1645 | + 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1646 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1647 | + ) |
|
1648 | + ) { |
|
1649 | + add_filter( |
|
1650 | + 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1651 | + function ($url) { |
|
1652 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1653 | + } |
|
1654 | + ); |
|
1655 | + echo apply_filters( |
|
1656 | + 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1657 | + EEH_Template::powered_by_event_espresso( |
|
1658 | + '', |
|
1659 | + 'espresso-registration-footer-dv', |
|
1660 | + array('utm_content' => 'registration_checkout') |
|
1661 | + ) |
|
1662 | + ); |
|
1663 | + } |
|
1664 | + return ''; |
|
1665 | + } |
|
1666 | + |
|
1667 | + |
|
1668 | + /** |
|
1669 | + * unlock_transaction |
|
1670 | + * |
|
1671 | + * @return void |
|
1672 | + * @throws EE_Error |
|
1673 | + * @throws ReflectionException |
|
1674 | + */ |
|
1675 | + public function unlock_transaction() |
|
1676 | + { |
|
1677 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1678 | + $this->checkout->transaction->unlock(); |
|
1679 | + } |
|
1680 | + } |
|
1681 | + |
|
1682 | + |
|
1683 | + /** |
|
1684 | + * _setup_redirect |
|
1685 | + * |
|
1686 | + * @return void |
|
1687 | + */ |
|
1688 | + private function _setup_redirect() |
|
1689 | + { |
|
1690 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1691 | + $this->checkout->redirect = true; |
|
1692 | + if (empty($this->checkout->redirect_url)) { |
|
1693 | + $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1694 | + } |
|
1695 | + $this->checkout->redirect_url = apply_filters( |
|
1696 | + 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1697 | + $this->checkout->redirect_url, |
|
1698 | + $this->checkout |
|
1699 | + ); |
|
1700 | + } |
|
1701 | + } |
|
1702 | + |
|
1703 | + |
|
1704 | + /** |
|
1705 | + * handle ajax message responses and redirects |
|
1706 | + * |
|
1707 | + * @return void |
|
1708 | + * @throws EE_Error |
|
1709 | + * @throws ReflectionException |
|
1710 | + */ |
|
1711 | + public function go_to_next_step() |
|
1712 | + { |
|
1713 | + if ($this->request->isAjax()) { |
|
1714 | + // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1715 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1716 | + } |
|
1717 | + $this->unlock_transaction(); |
|
1718 | + // just return for these conditions |
|
1719 | + if ( |
|
1720 | + $this->checkout->admin_request |
|
1721 | + || $this->checkout->action === 'redirect_form' |
|
1722 | + || $this->checkout->action === 'update_checkout' |
|
1723 | + ) { |
|
1724 | + return; |
|
1725 | + } |
|
1726 | + // AJAX response |
|
1727 | + $this->_handle_json_response(); |
|
1728 | + // redirect to next step or the Thank You page |
|
1729 | + $this->_handle_html_redirects(); |
|
1730 | + // hmmm... must be something wrong, so let's just display the form again ! |
|
1731 | + $this->_display_spco_reg_form(); |
|
1732 | + } |
|
1733 | + |
|
1734 | + |
|
1735 | + /** |
|
1736 | + * _handle_json_response |
|
1737 | + * |
|
1738 | + * @return void |
|
1739 | + * @throws EE_Error |
|
1740 | + */ |
|
1741 | + protected function _handle_json_response() |
|
1742 | + { |
|
1743 | + // if this is an ajax request |
|
1744 | + if ($this->request->isAjax()) { |
|
1745 | + $this->checkout->json_response->set_registration_time_limit( |
|
1746 | + $this->checkout->get_registration_time_limit() |
|
1747 | + ); |
|
1748 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1749 | + // just send the ajax ( |
|
1750 | + $json_response = apply_filters( |
|
1751 | + 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1752 | + $this->checkout->json_response |
|
1753 | + ); |
|
1754 | + exit($json_response); |
|
1755 | + } |
|
1756 | + } |
|
1757 | + |
|
1758 | + |
|
1759 | + /** |
|
1760 | + * _handle_redirects |
|
1761 | + * |
|
1762 | + * @return void |
|
1763 | + */ |
|
1764 | + protected function _handle_html_redirects() |
|
1765 | + { |
|
1766 | + // going somewhere ? |
|
1767 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1768 | + // store notices in a transient |
|
1769 | + EE_Error::get_notices(false, true); |
|
1770 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1771 | + exit(); |
|
1772 | + } |
|
1773 | + } |
|
1774 | + |
|
1775 | + |
|
1776 | + /** |
|
1777 | + * set_checkout_anchor |
|
1778 | + * |
|
1779 | + * @return void |
|
1780 | + */ |
|
1781 | + public function set_checkout_anchor() |
|
1782 | + { |
|
1783 | + echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1784 | + } |
|
1785 | + |
|
1786 | + /** |
|
1787 | + * getRegistrationExpirationNotice |
|
1788 | + * |
|
1789 | + * @since 4.9.59.p |
|
1790 | + * @return string |
|
1791 | + */ |
|
1792 | + public static function getRegistrationExpirationNotice() |
|
1793 | + { |
|
1794 | + return sprintf( |
|
1795 | + esc_html__( |
|
1796 | + '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
1797 | + 'event_espresso' |
|
1798 | + ), |
|
1799 | + '<h4 class="important-notice">', |
|
1800 | + '</h4>', |
|
1801 | + '<br />', |
|
1802 | + '<p>', |
|
1803 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1804 | + '">', |
|
1805 | + '</a>', |
|
1806 | + '</p>' |
|
1807 | + ); |
|
1808 | + } |
|
1809 | 1809 | } |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | <label><?php esc_html_e('Amount Owing: ', 'event_espresso'); ?></label> |
31 | 31 | </td> |
32 | 32 | <td class="<?php echo sanitize_html_class( |
33 | - $transaction->paid() == $transaction->total() |
|
34 | - ? 'ee-transaction-paid' |
|
35 | - : 'ee-transaction-unpaid' |
|
36 | - ); ?>"> |
|
33 | + $transaction->paid() == $transaction->total() |
|
34 | + ? 'ee-transaction-paid' |
|
35 | + : 'ee-transaction-unpaid' |
|
36 | + ); ?>"> |
|
37 | 37 | <?php echo wp_kses(EEH_Template::format_currency($transaction->remaining()), AllowedTags::getAllowedTags()); ?> |
38 | 38 | </td> |
39 | 39 | </tr> |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | </td> |
44 | 44 | <td> |
45 | 45 | <?php $transaction->e_pretty_status(true); |
46 | - if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?> |
|
46 | + if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?> |
|
47 | 47 | <span class="small-text"> |
48 | 48 | <a href='<?php echo esc_url_raw($SPCO_payment_options_url) ?>'> |
49 | 49 | <?php esc_html_e('View Payment Options', 'event_espresso'); ?> |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | </td> |
62 | 62 | </tr> |
63 | 63 | <?php do_action( |
64 | - 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', |
|
65 | - $transaction |
|
66 | - ); ?> |
|
64 | + 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', |
|
65 | + $transaction |
|
66 | + ); ?> |
|
67 | 67 | </tbody> |
68 | 68 | </table> |
69 | 69 |
@@ -15,22 +15,22 @@ discard block |
||
15 | 15 | use EventEspresso\core\services\request\sanitizers\AllowedTags; |
16 | 16 | |
17 | 17 | $active_message = sprintf( |
18 | - esc_html__( |
|
19 | - 'The template for %1$s is currently %2$sactive%3$s.', |
|
20 | - 'event_espresso' |
|
21 | - ), |
|
22 | - $context_label, |
|
23 | - '<strong>', |
|
24 | - '</strong>' |
|
18 | + esc_html__( |
|
19 | + 'The template for %1$s is currently %2$sactive%3$s.', |
|
20 | + 'event_espresso' |
|
21 | + ), |
|
22 | + $context_label, |
|
23 | + '<strong>', |
|
24 | + '</strong>' |
|
25 | 25 | ); |
26 | 26 | $inactive_message = sprintf( |
27 | - esc_html__( |
|
28 | - 'The template for %1$s is currently %2$sinactive%3$s.', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - $context_label, |
|
32 | - '<strong>', |
|
33 | - '</strong>' |
|
27 | + esc_html__( |
|
28 | + 'The template for %1$s is currently %2$sinactive%3$s.', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + $context_label, |
|
32 | + '<strong>', |
|
33 | + '</strong>' |
|
34 | 34 | ); |
35 | 35 | |
36 | 36 | $context = esc_attr($context); |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | </span> |
45 | 45 | <span class="ee-on-off-toggle-label"> |
46 | 46 | <?php |
47 | - echo wp_kses( |
|
48 | - $is_active |
|
49 | - ? $active_message |
|
50 | - : $inactive_message, |
|
51 | - AllowedTags::getAllowedTags() |
|
52 | - ); |
|
53 | - ?> |
|
47 | + echo wp_kses( |
|
48 | + $is_active |
|
49 | + ? $active_message |
|
50 | + : $inactive_message, |
|
51 | + AllowedTags::getAllowedTags() |
|
52 | + ); |
|
53 | + ?> |
|
54 | 54 | </span> |
55 | 55 | <div class="hidden js-data"> |
56 | 56 | <span class="ee-active-message"><?php echo wp_kses($active_message, AllowedTags::getAllowedTags()); ?></span> |