@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * @param string $name |
492 | 492 | * @param string $config_class |
493 | 493 | * @param EE_Config_Base $config_obj |
494 | - * @param array $tests_to_run |
|
494 | + * @param integer[] $tests_to_run |
|
495 | 495 | * @param bool $display_errors |
496 | 496 | * @return bool TRUE on success, FALSE on fail |
497 | 497 | */ |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | |
1795 | 1795 | |
1796 | 1796 | /** |
1797 | - * @return array |
|
1797 | + * @return integer[] |
|
1798 | 1798 | */ |
1799 | 1799 | public function get_critical_pages_array() |
1800 | 1800 | { |
@@ -1808,7 +1808,7 @@ discard block |
||
1808 | 1808 | |
1809 | 1809 | |
1810 | 1810 | /** |
1811 | - * @return array |
|
1811 | + * @return string[] |
|
1812 | 1812 | */ |
1813 | 1813 | public function get_critical_pages_shortcodes_array() |
1814 | 1814 | { |
@@ -3088,7 +3088,7 @@ discard block |
||
3088 | 3088 | * according to max_input_vars |
3089 | 3089 | * |
3090 | 3090 | * @param int $input_count the count of input vars. |
3091 | - * @return array { |
|
3091 | + * @return string { |
|
3092 | 3092 | * An array that represents whether available space and if no available space the error |
3093 | 3093 | * message. |
3094 | 3094 | * @type bool $has_space whether more inputs can be added. |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\services\shortcodes\LegacyShortcodesManager; |
2 | 2 | |
3 | 3 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
4 | - exit('No direct script access allowed'); |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -16,2403 +16,2403 @@ discard block |
||
16 | 16 | final class EE_Config |
17 | 17 | { |
18 | 18 | |
19 | - const OPTION_NAME = 'ee_config'; |
|
19 | + const OPTION_NAME = 'ee_config'; |
|
20 | + |
|
21 | + const LOG_NAME = 'ee_config_log'; |
|
22 | + |
|
23 | + const LOG_LENGTH = 100; |
|
24 | + |
|
25 | + const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * instance of the EE_Config object |
|
30 | + * |
|
31 | + * @var EE_Config $_instance |
|
32 | + * @access private |
|
33 | + */ |
|
34 | + private static $_instance; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var boolean $_logging_enabled |
|
38 | + */ |
|
39 | + private static $_logging_enabled = false; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
43 | + */ |
|
44 | + private $legacy_shortcodes_manager; |
|
45 | + |
|
46 | + /** |
|
47 | + * An StdClass whose property names are addon slugs, |
|
48 | + * and values are their config classes |
|
49 | + * |
|
50 | + * @var StdClass |
|
51 | + */ |
|
52 | + public $addons; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var EE_Admin_Config |
|
56 | + */ |
|
57 | + public $admin; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var EE_Core_Config |
|
61 | + */ |
|
62 | + public $core; |
|
63 | + |
|
64 | + /** |
|
65 | + * @var EE_Currency_Config |
|
66 | + */ |
|
67 | + public $currency; |
|
68 | + |
|
69 | + /** |
|
70 | + * @var EE_Organization_Config |
|
71 | + */ |
|
72 | + public $organization; |
|
73 | + |
|
74 | + /** |
|
75 | + * @var EE_Registration_Config |
|
76 | + */ |
|
77 | + public $registration; |
|
78 | + |
|
79 | + /** |
|
80 | + * @var EE_Template_Config |
|
81 | + */ |
|
82 | + public $template_settings; |
|
83 | + |
|
84 | + /** |
|
85 | + * Holds EE environment values. |
|
86 | + * |
|
87 | + * @var EE_Environment_Config |
|
88 | + */ |
|
89 | + public $environment; |
|
90 | + |
|
91 | + /** |
|
92 | + * settings pertaining to Google maps |
|
93 | + * |
|
94 | + * @var EE_Map_Config |
|
95 | + */ |
|
96 | + public $map_settings; |
|
97 | + |
|
98 | + /** |
|
99 | + * settings pertaining to Taxes |
|
100 | + * |
|
101 | + * @var EE_Tax_Config |
|
102 | + */ |
|
103 | + public $tax_settings; |
|
104 | + |
|
105 | + /** |
|
106 | + * @deprecated |
|
107 | + * @var EE_Gateway_Config |
|
108 | + */ |
|
109 | + public $gateway; |
|
110 | + |
|
111 | + /** |
|
112 | + * @var array $_addon_option_names |
|
113 | + * @access private |
|
114 | + */ |
|
115 | + private $_addon_option_names = array(); |
|
116 | + |
|
117 | + /** |
|
118 | + * @var array $_module_route_map |
|
119 | + * @access private |
|
120 | + */ |
|
121 | + private static $_module_route_map = array(); |
|
122 | + |
|
123 | + /** |
|
124 | + * @var array $_module_forward_map |
|
125 | + * @access private |
|
126 | + */ |
|
127 | + private static $_module_forward_map = array(); |
|
128 | + |
|
129 | + /** |
|
130 | + * @var array $_module_view_map |
|
131 | + * @access private |
|
132 | + */ |
|
133 | + private static $_module_view_map = array(); |
|
134 | + |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @singleton method used to instantiate class object |
|
139 | + * @access public |
|
140 | + * @return EE_Config instance |
|
141 | + */ |
|
142 | + public static function instance() |
|
143 | + { |
|
144 | + // check if class object is instantiated, and instantiated properly |
|
145 | + if ( ! self::$_instance instanceof EE_Config) { |
|
146 | + self::$_instance = new self(); |
|
147 | + } |
|
148 | + return self::$_instance; |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * Resets the config |
|
155 | + * |
|
156 | + * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
157 | + * (default) leaves the database alone, and merely resets the EE_Config object to |
|
158 | + * reflect its state in the database |
|
159 | + * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
160 | + * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
161 | + * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
162 | + * site was put into maintenance mode) |
|
163 | + * @return EE_Config |
|
164 | + */ |
|
165 | + public static function reset($hard_reset = false, $reinstantiate = true) |
|
166 | + { |
|
167 | + if (self::$_instance instanceof EE_Config) { |
|
168 | + if ($hard_reset) { |
|
169 | + self::$_instance->_addon_option_names = array(); |
|
170 | + self::$_instance->_initialize_config(); |
|
171 | + self::$_instance->update_espresso_config(); |
|
172 | + } |
|
173 | + self::$_instance->update_addon_option_names(); |
|
174 | + } |
|
175 | + self::$_instance = null; |
|
176 | + //we don't need to reset the static properties imo because those should |
|
177 | + //only change when a module is added or removed. Currently we don't |
|
178 | + //support removing a module during a request when it previously existed |
|
179 | + if ($reinstantiate) { |
|
180 | + return self::instance(); |
|
181 | + } else { |
|
182 | + return null; |
|
183 | + } |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * class constructor |
|
190 | + * |
|
191 | + * @access private |
|
192 | + */ |
|
193 | + private function __construct() |
|
194 | + { |
|
195 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
196 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
197 | + // setup empty config classes |
|
198 | + $this->_initialize_config(); |
|
199 | + // load existing EE site settings |
|
200 | + $this->_load_core_config(); |
|
201 | + // confirm everything loaded correctly and set filtered defaults if not |
|
202 | + $this->_verify_config(); |
|
203 | + // register shortcodes and modules |
|
204 | + add_action( |
|
205 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
206 | + array($this, 'register_shortcodes_and_modules'), |
|
207 | + 999 |
|
208 | + ); |
|
209 | + // initialize shortcodes and modules |
|
210 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
211 | + // register widgets |
|
212 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
213 | + // shutdown |
|
214 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
215 | + // construct__end hook |
|
216 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
217 | + // hardcoded hack |
|
218 | + $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * @return boolean |
|
225 | + */ |
|
226 | + public static function logging_enabled() |
|
227 | + { |
|
228 | + return self::$_logging_enabled; |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * use to get the current theme if needed from static context |
|
235 | + * |
|
236 | + * @return string current theme set. |
|
237 | + */ |
|
238 | + public static function get_current_theme() |
|
239 | + { |
|
240 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
241 | + ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * _initialize_config |
|
248 | + * |
|
249 | + * @access private |
|
250 | + * @return void |
|
251 | + */ |
|
252 | + private function _initialize_config() |
|
253 | + { |
|
254 | + EE_Config::trim_log(); |
|
255 | + //set defaults |
|
256 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
257 | + $this->addons = new stdClass(); |
|
258 | + // set _module_route_map |
|
259 | + EE_Config::$_module_route_map = array(); |
|
260 | + // set _module_forward_map |
|
261 | + EE_Config::$_module_forward_map = array(); |
|
262 | + // set _module_view_map |
|
263 | + EE_Config::$_module_view_map = array(); |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * load core plugin configuration |
|
270 | + * |
|
271 | + * @access private |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + private function _load_core_config() |
|
275 | + { |
|
276 | + // load_core_config__start hook |
|
277 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
278 | + $espresso_config = $this->get_espresso_config(); |
|
279 | + foreach ($espresso_config as $config => $settings) { |
|
280 | + // load_core_config__start hook |
|
281 | + $settings = apply_filters( |
|
282 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
283 | + $settings, |
|
284 | + $config, |
|
285 | + $this |
|
286 | + ); |
|
287 | + if (is_object($settings) && property_exists($this, $config)) { |
|
288 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
289 | + //call configs populate method to ensure any defaults are set for empty values. |
|
290 | + if (method_exists($settings, 'populate')) { |
|
291 | + $this->{$config}->populate(); |
|
292 | + } |
|
293 | + if (method_exists($settings, 'do_hooks')) { |
|
294 | + $this->{$config}->do_hooks(); |
|
295 | + } |
|
296 | + } |
|
297 | + } |
|
298 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
299 | + $this->update_espresso_config(); |
|
300 | + } |
|
301 | + // load_core_config__end hook |
|
302 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * _verify_config |
|
309 | + * |
|
310 | + * @access protected |
|
311 | + * @return void |
|
312 | + */ |
|
313 | + protected function _verify_config() |
|
314 | + { |
|
315 | + $this->core = $this->core instanceof EE_Core_Config |
|
316 | + ? $this->core |
|
317 | + : new EE_Core_Config(); |
|
318 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
319 | + $this->organization = $this->organization instanceof EE_Organization_Config |
|
320 | + ? $this->organization |
|
321 | + : new EE_Organization_Config(); |
|
322 | + $this->organization = apply_filters( |
|
323 | + 'FHEE__EE_Config___initialize_config__organization', |
|
324 | + $this->organization |
|
325 | + ); |
|
326 | + $this->currency = $this->currency instanceof EE_Currency_Config |
|
327 | + ? $this->currency |
|
328 | + : new EE_Currency_Config(); |
|
329 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
330 | + $this->registration = $this->registration instanceof EE_Registration_Config |
|
331 | + ? $this->registration |
|
332 | + : new EE_Registration_Config(); |
|
333 | + $this->registration = apply_filters( |
|
334 | + 'FHEE__EE_Config___initialize_config__registration', |
|
335 | + $this->registration |
|
336 | + ); |
|
337 | + $this->admin = $this->admin instanceof EE_Admin_Config |
|
338 | + ? $this->admin |
|
339 | + : new EE_Admin_Config(); |
|
340 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
341 | + $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
342 | + ? $this->template_settings |
|
343 | + : new EE_Template_Config(); |
|
344 | + $this->template_settings = apply_filters( |
|
345 | + 'FHEE__EE_Config___initialize_config__template_settings', |
|
346 | + $this->template_settings |
|
347 | + ); |
|
348 | + $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
349 | + ? $this->map_settings |
|
350 | + : new EE_Map_Config(); |
|
351 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
352 | + $this->map_settings); |
|
353 | + $this->environment = $this->environment instanceof EE_Environment_Config |
|
354 | + ? $this->environment |
|
355 | + : new EE_Environment_Config(); |
|
356 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
357 | + $this->environment); |
|
358 | + $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
359 | + ? $this->tax_settings |
|
360 | + : new EE_Tax_Config(); |
|
361 | + $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
362 | + $this->tax_settings); |
|
363 | + $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
364 | + ? $this->gateway |
|
365 | + : new EE_Gateway_Config(); |
|
366 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * get_espresso_config |
|
373 | + * |
|
374 | + * @access public |
|
375 | + * @return array of espresso config stuff |
|
376 | + */ |
|
377 | + public function get_espresso_config() |
|
378 | + { |
|
379 | + // grab espresso configuration |
|
380 | + return apply_filters( |
|
381 | + 'FHEE__EE_Config__get_espresso_config__CFG', |
|
382 | + get_option(EE_Config::OPTION_NAME, array()) |
|
383 | + ); |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * double_check_config_comparison |
|
390 | + * |
|
391 | + * @access public |
|
392 | + * @param string $option |
|
393 | + * @param $old_value |
|
394 | + * @param $value |
|
395 | + */ |
|
396 | + public function double_check_config_comparison($option = '', $old_value, $value) |
|
397 | + { |
|
398 | + // make sure we're checking the ee config |
|
399 | + if ($option === EE_Config::OPTION_NAME) { |
|
400 | + // run a loose comparison of the old value against the new value for type and properties, |
|
401 | + // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
402 | + if ($value != $old_value) { |
|
403 | + // if they are NOT the same, then remove the hook, |
|
404 | + // which means the subsequent update results will be based solely on the update query results |
|
405 | + // the reason we do this is because, as stated above, |
|
406 | + // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
407 | + // this happens PRIOR to serialization and any subsequent update. |
|
408 | + // If values are found to match their previous old value, |
|
409 | + // then WP bails before performing any update. |
|
410 | + // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
411 | + // it just pulled from the db, with the one being passed to it (which will not match). |
|
412 | + // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
413 | + // MySQL MAY ALSO NOT perform the update because |
|
414 | + // the string it sees in the db looks the same as the new one it has been passed!!! |
|
415 | + // This results in the query returning an "affected rows" value of ZERO, |
|
416 | + // which gets returned immediately by WP update_option and looks like an error. |
|
417 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
418 | + } |
|
419 | + } |
|
420 | + } |
|
421 | + |
|
422 | + |
|
423 | + |
|
424 | + /** |
|
425 | + * update_espresso_config |
|
426 | + * |
|
427 | + * @access public |
|
428 | + */ |
|
429 | + protected function _reset_espresso_addon_config() |
|
430 | + { |
|
431 | + $this->_addon_option_names = array(); |
|
432 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
433 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
434 | + $config_class = get_class($addon_config_obj); |
|
435 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
436 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
437 | + } |
|
438 | + $this->addons->{$addon_name} = null; |
|
439 | + } |
|
440 | + } |
|
441 | + |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * update_espresso_config |
|
446 | + * |
|
447 | + * @access public |
|
448 | + * @param bool $add_success |
|
449 | + * @param bool $add_error |
|
450 | + * @return bool |
|
451 | + */ |
|
452 | + public function update_espresso_config($add_success = false, $add_error = true) |
|
453 | + { |
|
454 | + // don't allow config updates during WP heartbeats |
|
455 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
456 | + return false; |
|
457 | + } |
|
458 | + // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
459 | + //$clone = clone( self::$_instance ); |
|
460 | + //self::$_instance = NULL; |
|
461 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
462 | + $this->_reset_espresso_addon_config(); |
|
463 | + // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
464 | + // but BEFORE the actual update occurs |
|
465 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
466 | + // now update "ee_config" |
|
467 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
468 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
469 | + // if not saved... check if the hook we just added still exists; |
|
470 | + // if it does, it means one of two things: |
|
471 | + // that update_option bailed at the ( $value === $old_value ) conditional, |
|
472 | + // or... |
|
473 | + // the db update query returned 0 rows affected |
|
474 | + // (probably because the data value was the same from it's perspective) |
|
475 | + // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
476 | + // but just means no update occurred, so don't display an error to the user. |
|
477 | + // BUT... if update_option returns FALSE, AND the hook is missing, |
|
478 | + // then it means that something truly went wrong |
|
479 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
480 | + // remove our action since we don't want it in the system anymore |
|
481 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
482 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
483 | + //self::$_instance = $clone; |
|
484 | + //unset( $clone ); |
|
485 | + // if config remains the same or was updated successfully |
|
486 | + if ($saved) { |
|
487 | + if ($add_success) { |
|
488 | + EE_Error::add_success( |
|
489 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
490 | + __FILE__, |
|
491 | + __FUNCTION__, |
|
492 | + __LINE__ |
|
493 | + ); |
|
494 | + } |
|
495 | + return true; |
|
496 | + } else { |
|
497 | + if ($add_error) { |
|
498 | + EE_Error::add_error( |
|
499 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
500 | + __FILE__, |
|
501 | + __FUNCTION__, |
|
502 | + __LINE__ |
|
503 | + ); |
|
504 | + } |
|
505 | + return false; |
|
506 | + } |
|
507 | + } |
|
508 | + |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * _verify_config_params |
|
513 | + * |
|
514 | + * @access private |
|
515 | + * @param string $section |
|
516 | + * @param string $name |
|
517 | + * @param string $config_class |
|
518 | + * @param EE_Config_Base $config_obj |
|
519 | + * @param array $tests_to_run |
|
520 | + * @param bool $display_errors |
|
521 | + * @return bool TRUE on success, FALSE on fail |
|
522 | + */ |
|
523 | + private function _verify_config_params( |
|
524 | + $section = '', |
|
525 | + $name = '', |
|
526 | + $config_class = '', |
|
527 | + $config_obj = null, |
|
528 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
529 | + $display_errors = true |
|
530 | + ) { |
|
531 | + try { |
|
532 | + foreach ($tests_to_run as $test) { |
|
533 | + switch ($test) { |
|
534 | + // TEST #1 : check that section was set |
|
535 | + case 1 : |
|
536 | + if (empty($section)) { |
|
537 | + if ($display_errors) { |
|
538 | + throw new EE_Error( |
|
539 | + sprintf( |
|
540 | + __( |
|
541 | + 'No configuration section has been provided while attempting to save "%s".', |
|
542 | + 'event_espresso' |
|
543 | + ), |
|
544 | + $config_class |
|
545 | + ) |
|
546 | + ); |
|
547 | + } |
|
548 | + return false; |
|
549 | + } |
|
550 | + break; |
|
551 | + // TEST #2 : check that settings section exists |
|
552 | + case 2 : |
|
553 | + if ( ! isset($this->{$section})) { |
|
554 | + if ($display_errors) { |
|
555 | + throw new EE_Error( |
|
556 | + sprintf( |
|
557 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
558 | + $section |
|
559 | + ) |
|
560 | + ); |
|
561 | + } |
|
562 | + return false; |
|
563 | + } |
|
564 | + break; |
|
565 | + // TEST #3 : check that section is the proper format |
|
566 | + case 3 : |
|
567 | + if ( |
|
568 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
569 | + ) { |
|
570 | + if ($display_errors) { |
|
571 | + throw new EE_Error( |
|
572 | + sprintf( |
|
573 | + __( |
|
574 | + 'The "%s" configuration settings have not been formatted correctly.', |
|
575 | + 'event_espresso' |
|
576 | + ), |
|
577 | + $section |
|
578 | + ) |
|
579 | + ); |
|
580 | + } |
|
581 | + return false; |
|
582 | + } |
|
583 | + break; |
|
584 | + // TEST #4 : check that config section name has been set |
|
585 | + case 4 : |
|
586 | + if (empty($name)) { |
|
587 | + if ($display_errors) { |
|
588 | + throw new EE_Error( |
|
589 | + __( |
|
590 | + 'No name has been provided for the specific configuration section.', |
|
591 | + 'event_espresso' |
|
592 | + ) |
|
593 | + ); |
|
594 | + } |
|
595 | + return false; |
|
596 | + } |
|
597 | + break; |
|
598 | + // TEST #5 : check that a config class name has been set |
|
599 | + case 5 : |
|
600 | + if (empty($config_class)) { |
|
601 | + if ($display_errors) { |
|
602 | + throw new EE_Error( |
|
603 | + __( |
|
604 | + 'No class name has been provided for the specific configuration section.', |
|
605 | + 'event_espresso' |
|
606 | + ) |
|
607 | + ); |
|
608 | + } |
|
609 | + return false; |
|
610 | + } |
|
611 | + break; |
|
612 | + // TEST #6 : verify config class is accessible |
|
613 | + case 6 : |
|
614 | + if ( ! class_exists($config_class)) { |
|
615 | + if ($display_errors) { |
|
616 | + throw new EE_Error( |
|
617 | + sprintf( |
|
618 | + __( |
|
619 | + 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
620 | + 'event_espresso' |
|
621 | + ), |
|
622 | + $config_class |
|
623 | + ) |
|
624 | + ); |
|
625 | + } |
|
626 | + return false; |
|
627 | + } |
|
628 | + break; |
|
629 | + // TEST #7 : check that config has even been set |
|
630 | + case 7 : |
|
631 | + if ( ! isset($this->{$section}->{$name})) { |
|
632 | + if ($display_errors) { |
|
633 | + throw new EE_Error( |
|
634 | + sprintf( |
|
635 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
636 | + $section, |
|
637 | + $name |
|
638 | + ) |
|
639 | + ); |
|
640 | + } |
|
641 | + return false; |
|
642 | + } else { |
|
643 | + // and make sure it's not serialized |
|
644 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
645 | + } |
|
646 | + break; |
|
647 | + // TEST #8 : check that config is the requested type |
|
648 | + case 8 : |
|
649 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
650 | + if ($display_errors) { |
|
651 | + throw new EE_Error( |
|
652 | + sprintf( |
|
653 | + __( |
|
654 | + 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
655 | + 'event_espresso' |
|
656 | + ), |
|
657 | + $section, |
|
658 | + $name, |
|
659 | + $config_class |
|
660 | + ) |
|
661 | + ); |
|
662 | + } |
|
663 | + return false; |
|
664 | + } |
|
665 | + break; |
|
666 | + // TEST #9 : verify config object |
|
667 | + case 9 : |
|
668 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
669 | + if ($display_errors) { |
|
670 | + throw new EE_Error( |
|
671 | + sprintf( |
|
672 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
673 | + print_r($config_obj, true) |
|
674 | + ) |
|
675 | + ); |
|
676 | + } |
|
677 | + return false; |
|
678 | + } |
|
679 | + break; |
|
680 | + } |
|
681 | + } |
|
682 | + } catch (EE_Error $e) { |
|
683 | + $e->get_error(); |
|
684 | + } |
|
685 | + // you have successfully run the gauntlet |
|
686 | + return true; |
|
687 | + } |
|
688 | + |
|
689 | + |
|
690 | + |
|
691 | + /** |
|
692 | + * _generate_config_option_name |
|
693 | + * |
|
694 | + * @access protected |
|
695 | + * @param string $section |
|
696 | + * @param string $name |
|
697 | + * @return string |
|
698 | + */ |
|
699 | + private function _generate_config_option_name($section = '', $name = '') |
|
700 | + { |
|
701 | + return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
702 | + } |
|
703 | + |
|
704 | + |
|
705 | + |
|
706 | + /** |
|
707 | + * _set_config_class |
|
708 | + * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
709 | + * |
|
710 | + * @access private |
|
711 | + * @param string $config_class |
|
712 | + * @param string $name |
|
713 | + * @return string |
|
714 | + */ |
|
715 | + private function _set_config_class($config_class = '', $name = '') |
|
716 | + { |
|
717 | + return ! empty($config_class) |
|
718 | + ? $config_class |
|
719 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
720 | + } |
|
721 | + |
|
722 | + |
|
723 | + |
|
724 | + /** |
|
725 | + * set_config |
|
726 | + * |
|
727 | + * @access protected |
|
728 | + * @param string $section |
|
729 | + * @param string $name |
|
730 | + * @param string $config_class |
|
731 | + * @param EE_Config_Base $config_obj |
|
732 | + * @return EE_Config_Base |
|
733 | + */ |
|
734 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
735 | + { |
|
736 | + // ensure config class is set to something |
|
737 | + $config_class = $this->_set_config_class($config_class, $name); |
|
738 | + // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
739 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
740 | + return null; |
|
741 | + } |
|
742 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
743 | + // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
744 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
745 | + $this->_addon_option_names[$config_option_name] = $config_class; |
|
746 | + $this->update_addon_option_names(); |
|
747 | + } |
|
748 | + // verify the incoming config object but suppress errors |
|
749 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
750 | + $config_obj = new $config_class(); |
|
751 | + } |
|
752 | + if (get_option($config_option_name)) { |
|
753 | + EE_Config::log($config_option_name); |
|
754 | + update_option($config_option_name, $config_obj); |
|
755 | + $this->{$section}->{$name} = $config_obj; |
|
756 | + return $this->{$section}->{$name}; |
|
757 | + } else { |
|
758 | + // create a wp-option for this config |
|
759 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
760 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
761 | + return $this->{$section}->{$name}; |
|
762 | + } else { |
|
763 | + EE_Error::add_error( |
|
764 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
765 | + __FILE__, |
|
766 | + __FUNCTION__, |
|
767 | + __LINE__ |
|
768 | + ); |
|
769 | + return null; |
|
770 | + } |
|
771 | + } |
|
772 | + } |
|
773 | + |
|
774 | + |
|
775 | + |
|
776 | + /** |
|
777 | + * update_config |
|
778 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
779 | + * |
|
780 | + * @access public |
|
781 | + * @param string $section |
|
782 | + * @param string $name |
|
783 | + * @param EE_Config_Base|string $config_obj |
|
784 | + * @param bool $throw_errors |
|
785 | + * @return bool |
|
786 | + */ |
|
787 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
788 | + { |
|
789 | + // don't allow config updates during WP heartbeats |
|
790 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
791 | + return false; |
|
792 | + } |
|
793 | + $config_obj = maybe_unserialize($config_obj); |
|
794 | + // get class name of the incoming object |
|
795 | + $config_class = get_class($config_obj); |
|
796 | + // run tests 1-5 and 9 to verify config |
|
797 | + if ( ! $this->_verify_config_params( |
|
798 | + $section, |
|
799 | + $name, |
|
800 | + $config_class, |
|
801 | + $config_obj, |
|
802 | + array(1, 2, 3, 4, 7, 9) |
|
803 | + ) |
|
804 | + ) { |
|
805 | + return false; |
|
806 | + } |
|
807 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
808 | + // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
809 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
810 | + // save new config to db |
|
811 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
812 | + return true; |
|
813 | + } |
|
814 | + } else { |
|
815 | + // first check if the record already exists |
|
816 | + $existing_config = get_option($config_option_name); |
|
817 | + $config_obj = serialize($config_obj); |
|
818 | + // just return if db record is already up to date (NOT type safe comparison) |
|
819 | + if ($existing_config == $config_obj) { |
|
820 | + $this->{$section}->{$name} = $config_obj; |
|
821 | + return true; |
|
822 | + } else if (update_option($config_option_name, $config_obj)) { |
|
823 | + EE_Config::log($config_option_name); |
|
824 | + // update wp-option for this config class |
|
825 | + $this->{$section}->{$name} = $config_obj; |
|
826 | + return true; |
|
827 | + } elseif ($throw_errors) { |
|
828 | + EE_Error::add_error( |
|
829 | + sprintf( |
|
830 | + __( |
|
831 | + 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
832 | + 'event_espresso' |
|
833 | + ), |
|
834 | + $config_class, |
|
835 | + 'EE_Config->' . $section . '->' . $name |
|
836 | + ), |
|
837 | + __FILE__, |
|
838 | + __FUNCTION__, |
|
839 | + __LINE__ |
|
840 | + ); |
|
841 | + } |
|
842 | + } |
|
843 | + return false; |
|
844 | + } |
|
845 | + |
|
846 | + |
|
847 | + |
|
848 | + /** |
|
849 | + * get_config |
|
850 | + * |
|
851 | + * @access public |
|
852 | + * @param string $section |
|
853 | + * @param string $name |
|
854 | + * @param string $config_class |
|
855 | + * @return mixed EE_Config_Base | NULL |
|
856 | + */ |
|
857 | + public function get_config($section = '', $name = '', $config_class = '') |
|
858 | + { |
|
859 | + // ensure config class is set to something |
|
860 | + $config_class = $this->_set_config_class($config_class, $name); |
|
861 | + // run tests 1-4, 6 and 7 to verify that all params have been set |
|
862 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
863 | + return null; |
|
864 | + } |
|
865 | + // now test if the requested config object exists, but suppress errors |
|
866 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
867 | + // config already exists, so pass it back |
|
868 | + return $this->{$section}->{$name}; |
|
869 | + } |
|
870 | + // load config option from db if it exists |
|
871 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
872 | + // verify the newly retrieved config object, but suppress errors |
|
873 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
874 | + // config is good, so set it and pass it back |
|
875 | + $this->{$section}->{$name} = $config_obj; |
|
876 | + return $this->{$section}->{$name}; |
|
877 | + } |
|
878 | + // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
879 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
880 | + // verify the newly created config object |
|
881 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
882 | + return $this->{$section}->{$name}; |
|
883 | + } else { |
|
884 | + EE_Error::add_error( |
|
885 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
886 | + __FILE__, |
|
887 | + __FUNCTION__, |
|
888 | + __LINE__ |
|
889 | + ); |
|
890 | + } |
|
891 | + return null; |
|
892 | + } |
|
893 | + |
|
894 | + |
|
895 | + |
|
896 | + /** |
|
897 | + * get_config_option |
|
898 | + * |
|
899 | + * @access public |
|
900 | + * @param string $config_option_name |
|
901 | + * @return mixed EE_Config_Base | FALSE |
|
902 | + */ |
|
903 | + public function get_config_option($config_option_name = '') |
|
904 | + { |
|
905 | + // retrieve the wp-option for this config class. |
|
906 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
907 | + if (empty($config_option)) { |
|
908 | + EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
909 | + } |
|
910 | + return $config_option; |
|
911 | + } |
|
912 | + |
|
913 | + |
|
914 | + |
|
915 | + /** |
|
916 | + * log |
|
917 | + * |
|
918 | + * @param string $config_option_name |
|
919 | + */ |
|
920 | + public static function log($config_option_name = '') |
|
921 | + { |
|
922 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
923 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
924 | + //copy incoming $_REQUEST and sanitize it so we can save it |
|
925 | + $_request = $_REQUEST; |
|
926 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
927 | + $config_log[(string)microtime(true)] = array( |
|
928 | + 'config_name' => $config_option_name, |
|
929 | + 'request' => $_request, |
|
930 | + ); |
|
931 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
932 | + } |
|
933 | + } |
|
934 | + |
|
935 | + |
|
936 | + |
|
937 | + /** |
|
938 | + * trim_log |
|
939 | + * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
940 | + */ |
|
941 | + public static function trim_log() |
|
942 | + { |
|
943 | + if ( ! EE_Config::logging_enabled()) { |
|
944 | + return; |
|
945 | + } |
|
946 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
947 | + $log_length = count($config_log); |
|
948 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
949 | + ksort($config_log); |
|
950 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
951 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
952 | + } |
|
953 | + } |
|
954 | + |
|
955 | + |
|
956 | + |
|
957 | + /** |
|
958 | + * get_page_for_posts |
|
959 | + * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
960 | + * wp-option "page_for_posts", or "posts" if no page is selected |
|
961 | + * |
|
962 | + * @access public |
|
963 | + * @return string |
|
964 | + */ |
|
965 | + public static function get_page_for_posts() |
|
966 | + { |
|
967 | + $page_for_posts = get_option('page_for_posts'); |
|
968 | + if ( ! $page_for_posts) { |
|
969 | + return 'posts'; |
|
970 | + } |
|
971 | + /** @type WPDB $wpdb */ |
|
972 | + global $wpdb; |
|
973 | + $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
974 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
975 | + } |
|
976 | + |
|
977 | + |
|
978 | + |
|
979 | + /** |
|
980 | + * register_shortcodes_and_modules. |
|
981 | + * At this point, it's too early to tell if we're maintenance mode or not. |
|
982 | + * In fact, this is where we give modules a chance to let core know they exist |
|
983 | + * so they can help trigger maintenance mode if it's needed |
|
984 | + * |
|
985 | + * @access public |
|
986 | + * @return void |
|
987 | + */ |
|
988 | + public function register_shortcodes_and_modules() |
|
989 | + { |
|
990 | + // allow modules to set hooks for the rest of the system |
|
991 | + EE_Registry::instance()->modules = $this->_register_modules(); |
|
992 | + } |
|
993 | + |
|
994 | + |
|
995 | + |
|
996 | + /** |
|
997 | + * initialize_shortcodes_and_modules |
|
998 | + * meaning they can start adding their hooks to get stuff done |
|
999 | + * |
|
1000 | + * @access public |
|
1001 | + * @return void |
|
1002 | + */ |
|
1003 | + public function initialize_shortcodes_and_modules() |
|
1004 | + { |
|
1005 | + // allow modules to set hooks for the rest of the system |
|
1006 | + $this->_initialize_modules(); |
|
1007 | + } |
|
1008 | + |
|
1009 | + |
|
1010 | + |
|
1011 | + /** |
|
1012 | + * widgets_init |
|
1013 | + * |
|
1014 | + * @access private |
|
1015 | + * @return void |
|
1016 | + */ |
|
1017 | + public function widgets_init() |
|
1018 | + { |
|
1019 | + //only init widgets on admin pages when not in complete maintenance, and |
|
1020 | + //on frontend when not in any maintenance mode |
|
1021 | + if ( |
|
1022 | + ! EE_Maintenance_Mode::instance()->level() |
|
1023 | + || ( |
|
1024 | + is_admin() |
|
1025 | + && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1026 | + ) |
|
1027 | + ) { |
|
1028 | + // grab list of installed widgets |
|
1029 | + $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1030 | + // filter list of modules to register |
|
1031 | + $widgets_to_register = apply_filters( |
|
1032 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1033 | + $widgets_to_register |
|
1034 | + ); |
|
1035 | + if ( ! empty($widgets_to_register)) { |
|
1036 | + // cycle thru widget folders |
|
1037 | + foreach ($widgets_to_register as $widget_path) { |
|
1038 | + // add to list of installed widget modules |
|
1039 | + EE_Config::register_ee_widget($widget_path); |
|
1040 | + } |
|
1041 | + } |
|
1042 | + // filter list of installed modules |
|
1043 | + EE_Registry::instance()->widgets = apply_filters( |
|
1044 | + 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1045 | + EE_Registry::instance()->widgets |
|
1046 | + ); |
|
1047 | + } |
|
1048 | + } |
|
1049 | + |
|
1050 | + |
|
1051 | + |
|
1052 | + /** |
|
1053 | + * register_ee_widget - makes core aware of this widget |
|
1054 | + * |
|
1055 | + * @access public |
|
1056 | + * @param string $widget_path - full path up to and including widget folder |
|
1057 | + * @return void |
|
1058 | + */ |
|
1059 | + public static function register_ee_widget($widget_path = null) |
|
1060 | + { |
|
1061 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1062 | + $widget_ext = '.widget.php'; |
|
1063 | + // make all separators match |
|
1064 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1065 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1066 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
1067 | + // grab and shortcode file name from directory name and break apart at dots |
|
1068 | + $file_name = explode('.', basename($widget_path)); |
|
1069 | + // take first segment from file name pieces and remove class prefix if it exists |
|
1070 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1071 | + // sanitize shortcode directory name |
|
1072 | + $widget = sanitize_key($widget); |
|
1073 | + // now we need to rebuild the shortcode path |
|
1074 | + $widget_path = explode(DS, $widget_path); |
|
1075 | + // remove last segment |
|
1076 | + array_pop($widget_path); |
|
1077 | + // glue it back together |
|
1078 | + $widget_path = implode(DS, $widget_path); |
|
1079 | + } else { |
|
1080 | + // grab and sanitize widget directory name |
|
1081 | + $widget = sanitize_key(basename($widget_path)); |
|
1082 | + } |
|
1083 | + // create classname from widget directory name |
|
1084 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1085 | + // add class prefix |
|
1086 | + $widget_class = 'EEW_' . $widget; |
|
1087 | + // does the widget exist ? |
|
1088 | + if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1089 | + $msg = sprintf( |
|
1090 | + __( |
|
1091 | + 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1092 | + 'event_espresso' |
|
1093 | + ), |
|
1094 | + $widget_class, |
|
1095 | + $widget_path . DS . $widget_class . $widget_ext |
|
1096 | + ); |
|
1097 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1098 | + return; |
|
1099 | + } |
|
1100 | + // load the widget class file |
|
1101 | + require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1102 | + // verify that class exists |
|
1103 | + if ( ! class_exists($widget_class)) { |
|
1104 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1105 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1106 | + return; |
|
1107 | + } |
|
1108 | + register_widget($widget_class); |
|
1109 | + // add to array of registered widgets |
|
1110 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1111 | + } |
|
1112 | + |
|
1113 | + |
|
1114 | + |
|
1115 | + /** |
|
1116 | + * _register_modules |
|
1117 | + * |
|
1118 | + * @access private |
|
1119 | + * @return array |
|
1120 | + */ |
|
1121 | + private function _register_modules() |
|
1122 | + { |
|
1123 | + // grab list of installed modules |
|
1124 | + $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1125 | + // filter list of modules to register |
|
1126 | + $modules_to_register = apply_filters( |
|
1127 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1128 | + $modules_to_register |
|
1129 | + ); |
|
1130 | + if ( ! empty($modules_to_register)) { |
|
1131 | + // loop through folders |
|
1132 | + foreach ($modules_to_register as $module_path) { |
|
1133 | + /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1134 | + if ( |
|
1135 | + $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1136 | + && $module_path !== EE_MODULES . 'gateways' |
|
1137 | + ) { |
|
1138 | + // add to list of installed modules |
|
1139 | + EE_Config::register_module($module_path); |
|
1140 | + } |
|
1141 | + } |
|
1142 | + } |
|
1143 | + // filter list of installed modules |
|
1144 | + return apply_filters( |
|
1145 | + 'FHEE__EE_Config___register_modules__installed_modules', |
|
1146 | + EE_Registry::instance()->modules |
|
1147 | + ); |
|
1148 | + } |
|
1149 | + |
|
1150 | + |
|
1151 | + |
|
1152 | + /** |
|
1153 | + * register_module - makes core aware of this module |
|
1154 | + * |
|
1155 | + * @access public |
|
1156 | + * @param string $module_path - full path up to and including module folder |
|
1157 | + * @return bool |
|
1158 | + */ |
|
1159 | + public static function register_module($module_path = null) |
|
1160 | + { |
|
1161 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1162 | + $module_ext = '.module.php'; |
|
1163 | + // make all separators match |
|
1164 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1165 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1166 | + if (strpos($module_path, $module_ext) !== false) { |
|
1167 | + // grab and shortcode file name from directory name and break apart at dots |
|
1168 | + $module_file = explode('.', basename($module_path)); |
|
1169 | + // now we need to rebuild the shortcode path |
|
1170 | + $module_path = explode(DS, $module_path); |
|
1171 | + // remove last segment |
|
1172 | + array_pop($module_path); |
|
1173 | + // glue it back together |
|
1174 | + $module_path = implode(DS, $module_path) . DS; |
|
1175 | + // take first segment from file name pieces and sanitize it |
|
1176 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1177 | + // ensure class prefix is added |
|
1178 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1179 | + } else { |
|
1180 | + // we need to generate the filename based off of the folder name |
|
1181 | + // grab and sanitize module name |
|
1182 | + $module = strtolower(basename($module_path)); |
|
1183 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1184 | + // like trailingslashit() |
|
1185 | + $module_path = rtrim($module_path, DS) . DS; |
|
1186 | + // create classname from module directory name |
|
1187 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1188 | + // add class prefix |
|
1189 | + $module_class = 'EED_' . $module; |
|
1190 | + } |
|
1191 | + // does the module exist ? |
|
1192 | + if ( ! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1193 | + $msg = sprintf( |
|
1194 | + __( |
|
1195 | + 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1196 | + 'event_espresso' |
|
1197 | + ), |
|
1198 | + $module |
|
1199 | + ); |
|
1200 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1201 | + return false; |
|
1202 | + } |
|
1203 | + // load the module class file |
|
1204 | + require_once($module_path . $module_class . $module_ext); |
|
1205 | + // verify that class exists |
|
1206 | + if ( ! class_exists($module_class)) { |
|
1207 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1208 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1209 | + return false; |
|
1210 | + } |
|
1211 | + // add to array of registered modules |
|
1212 | + EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1213 | + do_action( |
|
1214 | + 'AHEE__EE_Config__register_module__complete', |
|
1215 | + $module_class, |
|
1216 | + EE_Registry::instance()->modules->{$module_class} |
|
1217 | + ); |
|
1218 | + return true; |
|
1219 | + } |
|
1220 | + |
|
1221 | + |
|
1222 | + |
|
1223 | + /** |
|
1224 | + * _initialize_modules |
|
1225 | + * allow modules to set hooks for the rest of the system |
|
1226 | + * |
|
1227 | + * @access private |
|
1228 | + * @return void |
|
1229 | + */ |
|
1230 | + private function _initialize_modules() |
|
1231 | + { |
|
1232 | + // cycle thru shortcode folders |
|
1233 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1234 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1235 | + // which set hooks ? |
|
1236 | + if (is_admin()) { |
|
1237 | + // fire immediately |
|
1238 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1239 | + } else { |
|
1240 | + // delay until other systems are online |
|
1241 | + add_action( |
|
1242 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1243 | + array($module_class, 'set_hooks') |
|
1244 | + ); |
|
1245 | + } |
|
1246 | + } |
|
1247 | + } |
|
1248 | + |
|
1249 | + |
|
1250 | + |
|
1251 | + /** |
|
1252 | + * register_route - adds module method routes to route_map |
|
1253 | + * |
|
1254 | + * @access public |
|
1255 | + * @param string $route - "pretty" public alias for module method |
|
1256 | + * @param string $module - module name (classname without EED_ prefix) |
|
1257 | + * @param string $method_name - the actual module method to be routed to |
|
1258 | + * @param string $key - url param key indicating a route is being called |
|
1259 | + * @return bool |
|
1260 | + */ |
|
1261 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1262 | + { |
|
1263 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1264 | + $module = str_replace('EED_', '', $module); |
|
1265 | + $module_class = 'EED_' . $module; |
|
1266 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1267 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1268 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1269 | + return false; |
|
1270 | + } |
|
1271 | + if (empty($route)) { |
|
1272 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1273 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1274 | + return false; |
|
1275 | + } |
|
1276 | + if ( ! method_exists('EED_' . $module, $method_name)) { |
|
1277 | + $msg = sprintf( |
|
1278 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1279 | + $route |
|
1280 | + ); |
|
1281 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1282 | + return false; |
|
1283 | + } |
|
1284 | + EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
1285 | + return true; |
|
1286 | + } |
|
1287 | + |
|
1288 | + |
|
1289 | + |
|
1290 | + /** |
|
1291 | + * get_route - get module method route |
|
1292 | + * |
|
1293 | + * @access public |
|
1294 | + * @param string $route - "pretty" public alias for module method |
|
1295 | + * @param string $key - url param key indicating a route is being called |
|
1296 | + * @return string |
|
1297 | + */ |
|
1298 | + public static function get_route($route = null, $key = 'ee') |
|
1299 | + { |
|
1300 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1301 | + $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
1302 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1303 | + return EE_Config::$_module_route_map[$key][$route]; |
|
1304 | + } |
|
1305 | + return null; |
|
1306 | + } |
|
1307 | + |
|
1308 | + |
|
1309 | + |
|
1310 | + /** |
|
1311 | + * get_routes - get ALL module method routes |
|
1312 | + * |
|
1313 | + * @access public |
|
1314 | + * @return array |
|
1315 | + */ |
|
1316 | + public static function get_routes() |
|
1317 | + { |
|
1318 | + return EE_Config::$_module_route_map; |
|
1319 | + } |
|
1320 | + |
|
1321 | + |
|
1322 | + |
|
1323 | + /** |
|
1324 | + * register_forward - allows modules to forward request to another module for further processing |
|
1325 | + * |
|
1326 | + * @access public |
|
1327 | + * @param string $route - "pretty" public alias for module method |
|
1328 | + * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1329 | + * class, allows different forwards to be served based on status |
|
1330 | + * @param array|string $forward - function name or array( class, method ) |
|
1331 | + * @param string $key - url param key indicating a route is being called |
|
1332 | + * @return bool |
|
1333 | + */ |
|
1334 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1335 | + { |
|
1336 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1337 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1338 | + $msg = sprintf( |
|
1339 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1340 | + $route |
|
1341 | + ); |
|
1342 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1343 | + return false; |
|
1344 | + } |
|
1345 | + if (empty($forward)) { |
|
1346 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1347 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1348 | + return false; |
|
1349 | + } |
|
1350 | + if (is_array($forward)) { |
|
1351 | + if ( ! isset($forward[1])) { |
|
1352 | + $msg = sprintf( |
|
1353 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1354 | + $route |
|
1355 | + ); |
|
1356 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1357 | + return false; |
|
1358 | + } |
|
1359 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
1360 | + $msg = sprintf( |
|
1361 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1362 | + $forward[1], |
|
1363 | + $route |
|
1364 | + ); |
|
1365 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1366 | + return false; |
|
1367 | + } |
|
1368 | + } else if ( ! function_exists($forward)) { |
|
1369 | + $msg = sprintf( |
|
1370 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1371 | + $forward, |
|
1372 | + $route |
|
1373 | + ); |
|
1374 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1375 | + return false; |
|
1376 | + } |
|
1377 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1378 | + return true; |
|
1379 | + } |
|
1380 | + |
|
1381 | + |
|
1382 | + |
|
1383 | + /** |
|
1384 | + * get_forward - get forwarding route |
|
1385 | + * |
|
1386 | + * @access public |
|
1387 | + * @param string $route - "pretty" public alias for module method |
|
1388 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1389 | + * allows different forwards to be served based on status |
|
1390 | + * @param string $key - url param key indicating a route is being called |
|
1391 | + * @return string |
|
1392 | + */ |
|
1393 | + public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1394 | + { |
|
1395 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1396 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1397 | + return apply_filters( |
|
1398 | + 'FHEE__EE_Config__get_forward', |
|
1399 | + EE_Config::$_module_forward_map[$key][$route][$status], |
|
1400 | + $route, |
|
1401 | + $status |
|
1402 | + ); |
|
1403 | + } |
|
1404 | + return null; |
|
1405 | + } |
|
1406 | + |
|
1407 | + |
|
1408 | + |
|
1409 | + /** |
|
1410 | + * register_forward - allows modules to specify different view templates for different method routes and status |
|
1411 | + * results |
|
1412 | + * |
|
1413 | + * @access public |
|
1414 | + * @param string $route - "pretty" public alias for module method |
|
1415 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1416 | + * allows different views to be served based on status |
|
1417 | + * @param string $view |
|
1418 | + * @param string $key - url param key indicating a route is being called |
|
1419 | + * @return bool |
|
1420 | + */ |
|
1421 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1422 | + { |
|
1423 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1424 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1425 | + $msg = sprintf( |
|
1426 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1427 | + $route |
|
1428 | + ); |
|
1429 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1430 | + return false; |
|
1431 | + } |
|
1432 | + if ( ! is_readable($view)) { |
|
1433 | + $msg = sprintf( |
|
1434 | + __( |
|
1435 | + 'The %s view file could not be found or is not readable due to file permissions.', |
|
1436 | + 'event_espresso' |
|
1437 | + ), |
|
1438 | + $view |
|
1439 | + ); |
|
1440 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1441 | + return false; |
|
1442 | + } |
|
1443 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1444 | + return true; |
|
1445 | + } |
|
1446 | + |
|
1447 | + |
|
1448 | + |
|
1449 | + /** |
|
1450 | + * get_view - get view for route and status |
|
1451 | + * |
|
1452 | + * @access public |
|
1453 | + * @param string $route - "pretty" public alias for module method |
|
1454 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1455 | + * allows different views to be served based on status |
|
1456 | + * @param string $key - url param key indicating a route is being called |
|
1457 | + * @return string |
|
1458 | + */ |
|
1459 | + public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1460 | + { |
|
1461 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1462 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1463 | + return apply_filters( |
|
1464 | + 'FHEE__EE_Config__get_view', |
|
1465 | + EE_Config::$_module_view_map[$key][$route][$status], |
|
1466 | + $route, |
|
1467 | + $status |
|
1468 | + ); |
|
1469 | + } |
|
1470 | + return null; |
|
1471 | + } |
|
1472 | + |
|
1473 | + |
|
1474 | + |
|
1475 | + public function update_addon_option_names() |
|
1476 | + { |
|
1477 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1478 | + } |
|
1479 | + |
|
1480 | + |
|
1481 | + |
|
1482 | + public function shutdown() |
|
1483 | + { |
|
1484 | + $this->update_addon_option_names(); |
|
1485 | + } |
|
1486 | + |
|
1487 | + |
|
1488 | + |
|
1489 | + /** |
|
1490 | + * @return LegacyShortcodesManager |
|
1491 | + */ |
|
1492 | + public static function getLegacyShortcodesManager() |
|
1493 | + { |
|
1494 | + if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1495 | + EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
1496 | + EE_Registry::instance() |
|
1497 | + ); |
|
1498 | + } |
|
1499 | + return EE_Config::instance()->legacy_shortcodes_manager; |
|
1500 | + } |
|
1501 | + |
|
1502 | + |
|
1503 | + |
|
1504 | + /** |
|
1505 | + * register_shortcode - makes core aware of this shortcode |
|
1506 | + * |
|
1507 | + * @deprecated 4.9.26 |
|
1508 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
1509 | + * @return bool |
|
1510 | + */ |
|
1511 | + public static function register_shortcode($shortcode_path = null) |
|
1512 | + { |
|
1513 | + EE_Error::doing_it_wrong( |
|
1514 | + __METHOD__, |
|
1515 | + __( |
|
1516 | + 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
1517 | + 'event_espresso' |
|
1518 | + ), |
|
1519 | + '4.9.26' |
|
1520 | + ); |
|
1521 | + return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
1522 | + } |
|
20 | 1523 | |
21 | - const LOG_NAME = 'ee_config_log'; |
|
22 | 1524 | |
23 | - const LOG_LENGTH = 100; |
|
24 | 1525 | |
25 | - const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * instance of the EE_Config object |
|
30 | - * |
|
31 | - * @var EE_Config $_instance |
|
32 | - * @access private |
|
33 | - */ |
|
34 | - private static $_instance; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var boolean $_logging_enabled |
|
38 | - */ |
|
39 | - private static $_logging_enabled = false; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
43 | - */ |
|
44 | - private $legacy_shortcodes_manager; |
|
45 | - |
|
46 | - /** |
|
47 | - * An StdClass whose property names are addon slugs, |
|
48 | - * and values are their config classes |
|
49 | - * |
|
50 | - * @var StdClass |
|
51 | - */ |
|
52 | - public $addons; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var EE_Admin_Config |
|
56 | - */ |
|
57 | - public $admin; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var EE_Core_Config |
|
61 | - */ |
|
62 | - public $core; |
|
63 | - |
|
64 | - /** |
|
65 | - * @var EE_Currency_Config |
|
66 | - */ |
|
67 | - public $currency; |
|
68 | - |
|
69 | - /** |
|
70 | - * @var EE_Organization_Config |
|
71 | - */ |
|
72 | - public $organization; |
|
73 | - |
|
74 | - /** |
|
75 | - * @var EE_Registration_Config |
|
76 | - */ |
|
77 | - public $registration; |
|
78 | - |
|
79 | - /** |
|
80 | - * @var EE_Template_Config |
|
81 | - */ |
|
82 | - public $template_settings; |
|
83 | - |
|
84 | - /** |
|
85 | - * Holds EE environment values. |
|
86 | - * |
|
87 | - * @var EE_Environment_Config |
|
88 | - */ |
|
89 | - public $environment; |
|
90 | - |
|
91 | - /** |
|
92 | - * settings pertaining to Google maps |
|
93 | - * |
|
94 | - * @var EE_Map_Config |
|
95 | - */ |
|
96 | - public $map_settings; |
|
97 | - |
|
98 | - /** |
|
99 | - * settings pertaining to Taxes |
|
100 | - * |
|
101 | - * @var EE_Tax_Config |
|
102 | - */ |
|
103 | - public $tax_settings; |
|
104 | - |
|
105 | - /** |
|
106 | - * @deprecated |
|
107 | - * @var EE_Gateway_Config |
|
108 | - */ |
|
109 | - public $gateway; |
|
110 | - |
|
111 | - /** |
|
112 | - * @var array $_addon_option_names |
|
113 | - * @access private |
|
114 | - */ |
|
115 | - private $_addon_option_names = array(); |
|
116 | - |
|
117 | - /** |
|
118 | - * @var array $_module_route_map |
|
119 | - * @access private |
|
120 | - */ |
|
121 | - private static $_module_route_map = array(); |
|
122 | - |
|
123 | - /** |
|
124 | - * @var array $_module_forward_map |
|
125 | - * @access private |
|
126 | - */ |
|
127 | - private static $_module_forward_map = array(); |
|
128 | - |
|
129 | - /** |
|
130 | - * @var array $_module_view_map |
|
131 | - * @access private |
|
132 | - */ |
|
133 | - private static $_module_view_map = array(); |
|
134 | - |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @singleton method used to instantiate class object |
|
139 | - * @access public |
|
140 | - * @return EE_Config instance |
|
141 | - */ |
|
142 | - public static function instance() |
|
143 | - { |
|
144 | - // check if class object is instantiated, and instantiated properly |
|
145 | - if ( ! self::$_instance instanceof EE_Config) { |
|
146 | - self::$_instance = new self(); |
|
147 | - } |
|
148 | - return self::$_instance; |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * Resets the config |
|
155 | - * |
|
156 | - * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
157 | - * (default) leaves the database alone, and merely resets the EE_Config object to |
|
158 | - * reflect its state in the database |
|
159 | - * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
160 | - * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
161 | - * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
162 | - * site was put into maintenance mode) |
|
163 | - * @return EE_Config |
|
164 | - */ |
|
165 | - public static function reset($hard_reset = false, $reinstantiate = true) |
|
166 | - { |
|
167 | - if (self::$_instance instanceof EE_Config) { |
|
168 | - if ($hard_reset) { |
|
169 | - self::$_instance->_addon_option_names = array(); |
|
170 | - self::$_instance->_initialize_config(); |
|
171 | - self::$_instance->update_espresso_config(); |
|
172 | - } |
|
173 | - self::$_instance->update_addon_option_names(); |
|
174 | - } |
|
175 | - self::$_instance = null; |
|
176 | - //we don't need to reset the static properties imo because those should |
|
177 | - //only change when a module is added or removed. Currently we don't |
|
178 | - //support removing a module during a request when it previously existed |
|
179 | - if ($reinstantiate) { |
|
180 | - return self::instance(); |
|
181 | - } else { |
|
182 | - return null; |
|
183 | - } |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * class constructor |
|
190 | - * |
|
191 | - * @access private |
|
192 | - */ |
|
193 | - private function __construct() |
|
194 | - { |
|
195 | - do_action('AHEE__EE_Config__construct__begin', $this); |
|
196 | - EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
197 | - // setup empty config classes |
|
198 | - $this->_initialize_config(); |
|
199 | - // load existing EE site settings |
|
200 | - $this->_load_core_config(); |
|
201 | - // confirm everything loaded correctly and set filtered defaults if not |
|
202 | - $this->_verify_config(); |
|
203 | - // register shortcodes and modules |
|
204 | - add_action( |
|
205 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
206 | - array($this, 'register_shortcodes_and_modules'), |
|
207 | - 999 |
|
208 | - ); |
|
209 | - // initialize shortcodes and modules |
|
210 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
211 | - // register widgets |
|
212 | - add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
213 | - // shutdown |
|
214 | - add_action('shutdown', array($this, 'shutdown'), 10); |
|
215 | - // construct__end hook |
|
216 | - do_action('AHEE__EE_Config__construct__end', $this); |
|
217 | - // hardcoded hack |
|
218 | - $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * @return boolean |
|
225 | - */ |
|
226 | - public static function logging_enabled() |
|
227 | - { |
|
228 | - return self::$_logging_enabled; |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * use to get the current theme if needed from static context |
|
235 | - * |
|
236 | - * @return string current theme set. |
|
237 | - */ |
|
238 | - public static function get_current_theme() |
|
239 | - { |
|
240 | - return isset(self::$_instance->template_settings->current_espresso_theme) |
|
241 | - ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * _initialize_config |
|
248 | - * |
|
249 | - * @access private |
|
250 | - * @return void |
|
251 | - */ |
|
252 | - private function _initialize_config() |
|
253 | - { |
|
254 | - EE_Config::trim_log(); |
|
255 | - //set defaults |
|
256 | - $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
257 | - $this->addons = new stdClass(); |
|
258 | - // set _module_route_map |
|
259 | - EE_Config::$_module_route_map = array(); |
|
260 | - // set _module_forward_map |
|
261 | - EE_Config::$_module_forward_map = array(); |
|
262 | - // set _module_view_map |
|
263 | - EE_Config::$_module_view_map = array(); |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * load core plugin configuration |
|
270 | - * |
|
271 | - * @access private |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - private function _load_core_config() |
|
275 | - { |
|
276 | - // load_core_config__start hook |
|
277 | - do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
278 | - $espresso_config = $this->get_espresso_config(); |
|
279 | - foreach ($espresso_config as $config => $settings) { |
|
280 | - // load_core_config__start hook |
|
281 | - $settings = apply_filters( |
|
282 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
283 | - $settings, |
|
284 | - $config, |
|
285 | - $this |
|
286 | - ); |
|
287 | - if (is_object($settings) && property_exists($this, $config)) { |
|
288 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
289 | - //call configs populate method to ensure any defaults are set for empty values. |
|
290 | - if (method_exists($settings, 'populate')) { |
|
291 | - $this->{$config}->populate(); |
|
292 | - } |
|
293 | - if (method_exists($settings, 'do_hooks')) { |
|
294 | - $this->{$config}->do_hooks(); |
|
295 | - } |
|
296 | - } |
|
297 | - } |
|
298 | - if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
299 | - $this->update_espresso_config(); |
|
300 | - } |
|
301 | - // load_core_config__end hook |
|
302 | - do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * _verify_config |
|
309 | - * |
|
310 | - * @access protected |
|
311 | - * @return void |
|
312 | - */ |
|
313 | - protected function _verify_config() |
|
314 | - { |
|
315 | - $this->core = $this->core instanceof EE_Core_Config |
|
316 | - ? $this->core |
|
317 | - : new EE_Core_Config(); |
|
318 | - $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
319 | - $this->organization = $this->organization instanceof EE_Organization_Config |
|
320 | - ? $this->organization |
|
321 | - : new EE_Organization_Config(); |
|
322 | - $this->organization = apply_filters( |
|
323 | - 'FHEE__EE_Config___initialize_config__organization', |
|
324 | - $this->organization |
|
325 | - ); |
|
326 | - $this->currency = $this->currency instanceof EE_Currency_Config |
|
327 | - ? $this->currency |
|
328 | - : new EE_Currency_Config(); |
|
329 | - $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
330 | - $this->registration = $this->registration instanceof EE_Registration_Config |
|
331 | - ? $this->registration |
|
332 | - : new EE_Registration_Config(); |
|
333 | - $this->registration = apply_filters( |
|
334 | - 'FHEE__EE_Config___initialize_config__registration', |
|
335 | - $this->registration |
|
336 | - ); |
|
337 | - $this->admin = $this->admin instanceof EE_Admin_Config |
|
338 | - ? $this->admin |
|
339 | - : new EE_Admin_Config(); |
|
340 | - $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
341 | - $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
342 | - ? $this->template_settings |
|
343 | - : new EE_Template_Config(); |
|
344 | - $this->template_settings = apply_filters( |
|
345 | - 'FHEE__EE_Config___initialize_config__template_settings', |
|
346 | - $this->template_settings |
|
347 | - ); |
|
348 | - $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
349 | - ? $this->map_settings |
|
350 | - : new EE_Map_Config(); |
|
351 | - $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
352 | - $this->map_settings); |
|
353 | - $this->environment = $this->environment instanceof EE_Environment_Config |
|
354 | - ? $this->environment |
|
355 | - : new EE_Environment_Config(); |
|
356 | - $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
357 | - $this->environment); |
|
358 | - $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
359 | - ? $this->tax_settings |
|
360 | - : new EE_Tax_Config(); |
|
361 | - $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
362 | - $this->tax_settings); |
|
363 | - $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
364 | - ? $this->gateway |
|
365 | - : new EE_Gateway_Config(); |
|
366 | - $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
367 | - } |
|
368 | - |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * get_espresso_config |
|
373 | - * |
|
374 | - * @access public |
|
375 | - * @return array of espresso config stuff |
|
376 | - */ |
|
377 | - public function get_espresso_config() |
|
378 | - { |
|
379 | - // grab espresso configuration |
|
380 | - return apply_filters( |
|
381 | - 'FHEE__EE_Config__get_espresso_config__CFG', |
|
382 | - get_option(EE_Config::OPTION_NAME, array()) |
|
383 | - ); |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * double_check_config_comparison |
|
390 | - * |
|
391 | - * @access public |
|
392 | - * @param string $option |
|
393 | - * @param $old_value |
|
394 | - * @param $value |
|
395 | - */ |
|
396 | - public function double_check_config_comparison($option = '', $old_value, $value) |
|
397 | - { |
|
398 | - // make sure we're checking the ee config |
|
399 | - if ($option === EE_Config::OPTION_NAME) { |
|
400 | - // run a loose comparison of the old value against the new value for type and properties, |
|
401 | - // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
402 | - if ($value != $old_value) { |
|
403 | - // if they are NOT the same, then remove the hook, |
|
404 | - // which means the subsequent update results will be based solely on the update query results |
|
405 | - // the reason we do this is because, as stated above, |
|
406 | - // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
407 | - // this happens PRIOR to serialization and any subsequent update. |
|
408 | - // If values are found to match their previous old value, |
|
409 | - // then WP bails before performing any update. |
|
410 | - // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
411 | - // it just pulled from the db, with the one being passed to it (which will not match). |
|
412 | - // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
413 | - // MySQL MAY ALSO NOT perform the update because |
|
414 | - // the string it sees in the db looks the same as the new one it has been passed!!! |
|
415 | - // This results in the query returning an "affected rows" value of ZERO, |
|
416 | - // which gets returned immediately by WP update_option and looks like an error. |
|
417 | - remove_action('update_option', array($this, 'check_config_updated')); |
|
418 | - } |
|
419 | - } |
|
420 | - } |
|
421 | - |
|
422 | - |
|
423 | - |
|
424 | - /** |
|
425 | - * update_espresso_config |
|
426 | - * |
|
427 | - * @access public |
|
428 | - */ |
|
429 | - protected function _reset_espresso_addon_config() |
|
430 | - { |
|
431 | - $this->_addon_option_names = array(); |
|
432 | - foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
433 | - $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
434 | - $config_class = get_class($addon_config_obj); |
|
435 | - if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
436 | - $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
437 | - } |
|
438 | - $this->addons->{$addon_name} = null; |
|
439 | - } |
|
440 | - } |
|
441 | - |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * update_espresso_config |
|
446 | - * |
|
447 | - * @access public |
|
448 | - * @param bool $add_success |
|
449 | - * @param bool $add_error |
|
450 | - * @return bool |
|
451 | - */ |
|
452 | - public function update_espresso_config($add_success = false, $add_error = true) |
|
453 | - { |
|
454 | - // don't allow config updates during WP heartbeats |
|
455 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
456 | - return false; |
|
457 | - } |
|
458 | - // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
459 | - //$clone = clone( self::$_instance ); |
|
460 | - //self::$_instance = NULL; |
|
461 | - do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
462 | - $this->_reset_espresso_addon_config(); |
|
463 | - // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
464 | - // but BEFORE the actual update occurs |
|
465 | - add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
466 | - // now update "ee_config" |
|
467 | - $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
468 | - EE_Config::log(EE_Config::OPTION_NAME); |
|
469 | - // if not saved... check if the hook we just added still exists; |
|
470 | - // if it does, it means one of two things: |
|
471 | - // that update_option bailed at the ( $value === $old_value ) conditional, |
|
472 | - // or... |
|
473 | - // the db update query returned 0 rows affected |
|
474 | - // (probably because the data value was the same from it's perspective) |
|
475 | - // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
476 | - // but just means no update occurred, so don't display an error to the user. |
|
477 | - // BUT... if update_option returns FALSE, AND the hook is missing, |
|
478 | - // then it means that something truly went wrong |
|
479 | - $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
480 | - // remove our action since we don't want it in the system anymore |
|
481 | - remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
482 | - do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
483 | - //self::$_instance = $clone; |
|
484 | - //unset( $clone ); |
|
485 | - // if config remains the same or was updated successfully |
|
486 | - if ($saved) { |
|
487 | - if ($add_success) { |
|
488 | - EE_Error::add_success( |
|
489 | - __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
490 | - __FILE__, |
|
491 | - __FUNCTION__, |
|
492 | - __LINE__ |
|
493 | - ); |
|
494 | - } |
|
495 | - return true; |
|
496 | - } else { |
|
497 | - if ($add_error) { |
|
498 | - EE_Error::add_error( |
|
499 | - __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
500 | - __FILE__, |
|
501 | - __FUNCTION__, |
|
502 | - __LINE__ |
|
503 | - ); |
|
504 | - } |
|
505 | - return false; |
|
506 | - } |
|
507 | - } |
|
508 | - |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * _verify_config_params |
|
513 | - * |
|
514 | - * @access private |
|
515 | - * @param string $section |
|
516 | - * @param string $name |
|
517 | - * @param string $config_class |
|
518 | - * @param EE_Config_Base $config_obj |
|
519 | - * @param array $tests_to_run |
|
520 | - * @param bool $display_errors |
|
521 | - * @return bool TRUE on success, FALSE on fail |
|
522 | - */ |
|
523 | - private function _verify_config_params( |
|
524 | - $section = '', |
|
525 | - $name = '', |
|
526 | - $config_class = '', |
|
527 | - $config_obj = null, |
|
528 | - $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
529 | - $display_errors = true |
|
530 | - ) { |
|
531 | - try { |
|
532 | - foreach ($tests_to_run as $test) { |
|
533 | - switch ($test) { |
|
534 | - // TEST #1 : check that section was set |
|
535 | - case 1 : |
|
536 | - if (empty($section)) { |
|
537 | - if ($display_errors) { |
|
538 | - throw new EE_Error( |
|
539 | - sprintf( |
|
540 | - __( |
|
541 | - 'No configuration section has been provided while attempting to save "%s".', |
|
542 | - 'event_espresso' |
|
543 | - ), |
|
544 | - $config_class |
|
545 | - ) |
|
546 | - ); |
|
547 | - } |
|
548 | - return false; |
|
549 | - } |
|
550 | - break; |
|
551 | - // TEST #2 : check that settings section exists |
|
552 | - case 2 : |
|
553 | - if ( ! isset($this->{$section})) { |
|
554 | - if ($display_errors) { |
|
555 | - throw new EE_Error( |
|
556 | - sprintf( |
|
557 | - __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
558 | - $section |
|
559 | - ) |
|
560 | - ); |
|
561 | - } |
|
562 | - return false; |
|
563 | - } |
|
564 | - break; |
|
565 | - // TEST #3 : check that section is the proper format |
|
566 | - case 3 : |
|
567 | - if ( |
|
568 | - ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
569 | - ) { |
|
570 | - if ($display_errors) { |
|
571 | - throw new EE_Error( |
|
572 | - sprintf( |
|
573 | - __( |
|
574 | - 'The "%s" configuration settings have not been formatted correctly.', |
|
575 | - 'event_espresso' |
|
576 | - ), |
|
577 | - $section |
|
578 | - ) |
|
579 | - ); |
|
580 | - } |
|
581 | - return false; |
|
582 | - } |
|
583 | - break; |
|
584 | - // TEST #4 : check that config section name has been set |
|
585 | - case 4 : |
|
586 | - if (empty($name)) { |
|
587 | - if ($display_errors) { |
|
588 | - throw new EE_Error( |
|
589 | - __( |
|
590 | - 'No name has been provided for the specific configuration section.', |
|
591 | - 'event_espresso' |
|
592 | - ) |
|
593 | - ); |
|
594 | - } |
|
595 | - return false; |
|
596 | - } |
|
597 | - break; |
|
598 | - // TEST #5 : check that a config class name has been set |
|
599 | - case 5 : |
|
600 | - if (empty($config_class)) { |
|
601 | - if ($display_errors) { |
|
602 | - throw new EE_Error( |
|
603 | - __( |
|
604 | - 'No class name has been provided for the specific configuration section.', |
|
605 | - 'event_espresso' |
|
606 | - ) |
|
607 | - ); |
|
608 | - } |
|
609 | - return false; |
|
610 | - } |
|
611 | - break; |
|
612 | - // TEST #6 : verify config class is accessible |
|
613 | - case 6 : |
|
614 | - if ( ! class_exists($config_class)) { |
|
615 | - if ($display_errors) { |
|
616 | - throw new EE_Error( |
|
617 | - sprintf( |
|
618 | - __( |
|
619 | - 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
620 | - 'event_espresso' |
|
621 | - ), |
|
622 | - $config_class |
|
623 | - ) |
|
624 | - ); |
|
625 | - } |
|
626 | - return false; |
|
627 | - } |
|
628 | - break; |
|
629 | - // TEST #7 : check that config has even been set |
|
630 | - case 7 : |
|
631 | - if ( ! isset($this->{$section}->{$name})) { |
|
632 | - if ($display_errors) { |
|
633 | - throw new EE_Error( |
|
634 | - sprintf( |
|
635 | - __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
636 | - $section, |
|
637 | - $name |
|
638 | - ) |
|
639 | - ); |
|
640 | - } |
|
641 | - return false; |
|
642 | - } else { |
|
643 | - // and make sure it's not serialized |
|
644 | - $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
645 | - } |
|
646 | - break; |
|
647 | - // TEST #8 : check that config is the requested type |
|
648 | - case 8 : |
|
649 | - if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
650 | - if ($display_errors) { |
|
651 | - throw new EE_Error( |
|
652 | - sprintf( |
|
653 | - __( |
|
654 | - 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
655 | - 'event_espresso' |
|
656 | - ), |
|
657 | - $section, |
|
658 | - $name, |
|
659 | - $config_class |
|
660 | - ) |
|
661 | - ); |
|
662 | - } |
|
663 | - return false; |
|
664 | - } |
|
665 | - break; |
|
666 | - // TEST #9 : verify config object |
|
667 | - case 9 : |
|
668 | - if ( ! $config_obj instanceof EE_Config_Base) { |
|
669 | - if ($display_errors) { |
|
670 | - throw new EE_Error( |
|
671 | - sprintf( |
|
672 | - __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
673 | - print_r($config_obj, true) |
|
674 | - ) |
|
675 | - ); |
|
676 | - } |
|
677 | - return false; |
|
678 | - } |
|
679 | - break; |
|
680 | - } |
|
681 | - } |
|
682 | - } catch (EE_Error $e) { |
|
683 | - $e->get_error(); |
|
684 | - } |
|
685 | - // you have successfully run the gauntlet |
|
686 | - return true; |
|
687 | - } |
|
688 | - |
|
689 | - |
|
690 | - |
|
691 | - /** |
|
692 | - * _generate_config_option_name |
|
693 | - * |
|
694 | - * @access protected |
|
695 | - * @param string $section |
|
696 | - * @param string $name |
|
697 | - * @return string |
|
698 | - */ |
|
699 | - private function _generate_config_option_name($section = '', $name = '') |
|
700 | - { |
|
701 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
702 | - } |
|
703 | - |
|
704 | - |
|
705 | - |
|
706 | - /** |
|
707 | - * _set_config_class |
|
708 | - * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
709 | - * |
|
710 | - * @access private |
|
711 | - * @param string $config_class |
|
712 | - * @param string $name |
|
713 | - * @return string |
|
714 | - */ |
|
715 | - private function _set_config_class($config_class = '', $name = '') |
|
716 | - { |
|
717 | - return ! empty($config_class) |
|
718 | - ? $config_class |
|
719 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
720 | - } |
|
721 | - |
|
722 | - |
|
723 | - |
|
724 | - /** |
|
725 | - * set_config |
|
726 | - * |
|
727 | - * @access protected |
|
728 | - * @param string $section |
|
729 | - * @param string $name |
|
730 | - * @param string $config_class |
|
731 | - * @param EE_Config_Base $config_obj |
|
732 | - * @return EE_Config_Base |
|
733 | - */ |
|
734 | - public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
735 | - { |
|
736 | - // ensure config class is set to something |
|
737 | - $config_class = $this->_set_config_class($config_class, $name); |
|
738 | - // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
739 | - if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
740 | - return null; |
|
741 | - } |
|
742 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
743 | - // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
744 | - if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
745 | - $this->_addon_option_names[$config_option_name] = $config_class; |
|
746 | - $this->update_addon_option_names(); |
|
747 | - } |
|
748 | - // verify the incoming config object but suppress errors |
|
749 | - if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
750 | - $config_obj = new $config_class(); |
|
751 | - } |
|
752 | - if (get_option($config_option_name)) { |
|
753 | - EE_Config::log($config_option_name); |
|
754 | - update_option($config_option_name, $config_obj); |
|
755 | - $this->{$section}->{$name} = $config_obj; |
|
756 | - return $this->{$section}->{$name}; |
|
757 | - } else { |
|
758 | - // create a wp-option for this config |
|
759 | - if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
760 | - $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
761 | - return $this->{$section}->{$name}; |
|
762 | - } else { |
|
763 | - EE_Error::add_error( |
|
764 | - sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
765 | - __FILE__, |
|
766 | - __FUNCTION__, |
|
767 | - __LINE__ |
|
768 | - ); |
|
769 | - return null; |
|
770 | - } |
|
771 | - } |
|
772 | - } |
|
773 | - |
|
774 | - |
|
775 | - |
|
776 | - /** |
|
777 | - * update_config |
|
778 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
779 | - * |
|
780 | - * @access public |
|
781 | - * @param string $section |
|
782 | - * @param string $name |
|
783 | - * @param EE_Config_Base|string $config_obj |
|
784 | - * @param bool $throw_errors |
|
785 | - * @return bool |
|
786 | - */ |
|
787 | - public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
788 | - { |
|
789 | - // don't allow config updates during WP heartbeats |
|
790 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
791 | - return false; |
|
792 | - } |
|
793 | - $config_obj = maybe_unserialize($config_obj); |
|
794 | - // get class name of the incoming object |
|
795 | - $config_class = get_class($config_obj); |
|
796 | - // run tests 1-5 and 9 to verify config |
|
797 | - if ( ! $this->_verify_config_params( |
|
798 | - $section, |
|
799 | - $name, |
|
800 | - $config_class, |
|
801 | - $config_obj, |
|
802 | - array(1, 2, 3, 4, 7, 9) |
|
803 | - ) |
|
804 | - ) { |
|
805 | - return false; |
|
806 | - } |
|
807 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
808 | - // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
809 | - if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
810 | - // save new config to db |
|
811 | - if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
812 | - return true; |
|
813 | - } |
|
814 | - } else { |
|
815 | - // first check if the record already exists |
|
816 | - $existing_config = get_option($config_option_name); |
|
817 | - $config_obj = serialize($config_obj); |
|
818 | - // just return if db record is already up to date (NOT type safe comparison) |
|
819 | - if ($existing_config == $config_obj) { |
|
820 | - $this->{$section}->{$name} = $config_obj; |
|
821 | - return true; |
|
822 | - } else if (update_option($config_option_name, $config_obj)) { |
|
823 | - EE_Config::log($config_option_name); |
|
824 | - // update wp-option for this config class |
|
825 | - $this->{$section}->{$name} = $config_obj; |
|
826 | - return true; |
|
827 | - } elseif ($throw_errors) { |
|
828 | - EE_Error::add_error( |
|
829 | - sprintf( |
|
830 | - __( |
|
831 | - 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
832 | - 'event_espresso' |
|
833 | - ), |
|
834 | - $config_class, |
|
835 | - 'EE_Config->' . $section . '->' . $name |
|
836 | - ), |
|
837 | - __FILE__, |
|
838 | - __FUNCTION__, |
|
839 | - __LINE__ |
|
840 | - ); |
|
841 | - } |
|
842 | - } |
|
843 | - return false; |
|
844 | - } |
|
845 | - |
|
846 | - |
|
847 | - |
|
848 | - /** |
|
849 | - * get_config |
|
850 | - * |
|
851 | - * @access public |
|
852 | - * @param string $section |
|
853 | - * @param string $name |
|
854 | - * @param string $config_class |
|
855 | - * @return mixed EE_Config_Base | NULL |
|
856 | - */ |
|
857 | - public function get_config($section = '', $name = '', $config_class = '') |
|
858 | - { |
|
859 | - // ensure config class is set to something |
|
860 | - $config_class = $this->_set_config_class($config_class, $name); |
|
861 | - // run tests 1-4, 6 and 7 to verify that all params have been set |
|
862 | - if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
863 | - return null; |
|
864 | - } |
|
865 | - // now test if the requested config object exists, but suppress errors |
|
866 | - if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
867 | - // config already exists, so pass it back |
|
868 | - return $this->{$section}->{$name}; |
|
869 | - } |
|
870 | - // load config option from db if it exists |
|
871 | - $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
872 | - // verify the newly retrieved config object, but suppress errors |
|
873 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
874 | - // config is good, so set it and pass it back |
|
875 | - $this->{$section}->{$name} = $config_obj; |
|
876 | - return $this->{$section}->{$name}; |
|
877 | - } |
|
878 | - // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
879 | - $config_obj = $this->set_config($section, $name, $config_class); |
|
880 | - // verify the newly created config object |
|
881 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
882 | - return $this->{$section}->{$name}; |
|
883 | - } else { |
|
884 | - EE_Error::add_error( |
|
885 | - sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
886 | - __FILE__, |
|
887 | - __FUNCTION__, |
|
888 | - __LINE__ |
|
889 | - ); |
|
890 | - } |
|
891 | - return null; |
|
892 | - } |
|
893 | - |
|
894 | - |
|
895 | - |
|
896 | - /** |
|
897 | - * get_config_option |
|
898 | - * |
|
899 | - * @access public |
|
900 | - * @param string $config_option_name |
|
901 | - * @return mixed EE_Config_Base | FALSE |
|
902 | - */ |
|
903 | - public function get_config_option($config_option_name = '') |
|
904 | - { |
|
905 | - // retrieve the wp-option for this config class. |
|
906 | - $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
907 | - if (empty($config_option)) { |
|
908 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
909 | - } |
|
910 | - return $config_option; |
|
911 | - } |
|
912 | - |
|
913 | - |
|
914 | - |
|
915 | - /** |
|
916 | - * log |
|
917 | - * |
|
918 | - * @param string $config_option_name |
|
919 | - */ |
|
920 | - public static function log($config_option_name = '') |
|
921 | - { |
|
922 | - if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
923 | - $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
924 | - //copy incoming $_REQUEST and sanitize it so we can save it |
|
925 | - $_request = $_REQUEST; |
|
926 | - array_walk_recursive($_request, 'sanitize_text_field'); |
|
927 | - $config_log[(string)microtime(true)] = array( |
|
928 | - 'config_name' => $config_option_name, |
|
929 | - 'request' => $_request, |
|
930 | - ); |
|
931 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
932 | - } |
|
933 | - } |
|
934 | - |
|
935 | - |
|
936 | - |
|
937 | - /** |
|
938 | - * trim_log |
|
939 | - * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
940 | - */ |
|
941 | - public static function trim_log() |
|
942 | - { |
|
943 | - if ( ! EE_Config::logging_enabled()) { |
|
944 | - return; |
|
945 | - } |
|
946 | - $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
947 | - $log_length = count($config_log); |
|
948 | - if ($log_length > EE_Config::LOG_LENGTH) { |
|
949 | - ksort($config_log); |
|
950 | - $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
951 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
952 | - } |
|
953 | - } |
|
954 | - |
|
955 | - |
|
956 | - |
|
957 | - /** |
|
958 | - * get_page_for_posts |
|
959 | - * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
960 | - * wp-option "page_for_posts", or "posts" if no page is selected |
|
961 | - * |
|
962 | - * @access public |
|
963 | - * @return string |
|
964 | - */ |
|
965 | - public static function get_page_for_posts() |
|
966 | - { |
|
967 | - $page_for_posts = get_option('page_for_posts'); |
|
968 | - if ( ! $page_for_posts) { |
|
969 | - return 'posts'; |
|
970 | - } |
|
971 | - /** @type WPDB $wpdb */ |
|
972 | - global $wpdb; |
|
973 | - $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
974 | - return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
975 | - } |
|
976 | - |
|
977 | - |
|
978 | - |
|
979 | - /** |
|
980 | - * register_shortcodes_and_modules. |
|
981 | - * At this point, it's too early to tell if we're maintenance mode or not. |
|
982 | - * In fact, this is where we give modules a chance to let core know they exist |
|
983 | - * so they can help trigger maintenance mode if it's needed |
|
984 | - * |
|
985 | - * @access public |
|
986 | - * @return void |
|
987 | - */ |
|
988 | - public function register_shortcodes_and_modules() |
|
989 | - { |
|
990 | - // allow modules to set hooks for the rest of the system |
|
991 | - EE_Registry::instance()->modules = $this->_register_modules(); |
|
992 | - } |
|
993 | - |
|
994 | - |
|
995 | - |
|
996 | - /** |
|
997 | - * initialize_shortcodes_and_modules |
|
998 | - * meaning they can start adding their hooks to get stuff done |
|
999 | - * |
|
1000 | - * @access public |
|
1001 | - * @return void |
|
1002 | - */ |
|
1003 | - public function initialize_shortcodes_and_modules() |
|
1004 | - { |
|
1005 | - // allow modules to set hooks for the rest of the system |
|
1006 | - $this->_initialize_modules(); |
|
1007 | - } |
|
1008 | - |
|
1009 | - |
|
1010 | - |
|
1011 | - /** |
|
1012 | - * widgets_init |
|
1013 | - * |
|
1014 | - * @access private |
|
1015 | - * @return void |
|
1016 | - */ |
|
1017 | - public function widgets_init() |
|
1018 | - { |
|
1019 | - //only init widgets on admin pages when not in complete maintenance, and |
|
1020 | - //on frontend when not in any maintenance mode |
|
1021 | - if ( |
|
1022 | - ! EE_Maintenance_Mode::instance()->level() |
|
1023 | - || ( |
|
1024 | - is_admin() |
|
1025 | - && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1026 | - ) |
|
1027 | - ) { |
|
1028 | - // grab list of installed widgets |
|
1029 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1030 | - // filter list of modules to register |
|
1031 | - $widgets_to_register = apply_filters( |
|
1032 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1033 | - $widgets_to_register |
|
1034 | - ); |
|
1035 | - if ( ! empty($widgets_to_register)) { |
|
1036 | - // cycle thru widget folders |
|
1037 | - foreach ($widgets_to_register as $widget_path) { |
|
1038 | - // add to list of installed widget modules |
|
1039 | - EE_Config::register_ee_widget($widget_path); |
|
1040 | - } |
|
1041 | - } |
|
1042 | - // filter list of installed modules |
|
1043 | - EE_Registry::instance()->widgets = apply_filters( |
|
1044 | - 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1045 | - EE_Registry::instance()->widgets |
|
1046 | - ); |
|
1047 | - } |
|
1048 | - } |
|
1049 | - |
|
1050 | - |
|
1051 | - |
|
1052 | - /** |
|
1053 | - * register_ee_widget - makes core aware of this widget |
|
1054 | - * |
|
1055 | - * @access public |
|
1056 | - * @param string $widget_path - full path up to and including widget folder |
|
1057 | - * @return void |
|
1058 | - */ |
|
1059 | - public static function register_ee_widget($widget_path = null) |
|
1060 | - { |
|
1061 | - do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1062 | - $widget_ext = '.widget.php'; |
|
1063 | - // make all separators match |
|
1064 | - $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1065 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1066 | - if (strpos($widget_path, $widget_ext) !== false) { |
|
1067 | - // grab and shortcode file name from directory name and break apart at dots |
|
1068 | - $file_name = explode('.', basename($widget_path)); |
|
1069 | - // take first segment from file name pieces and remove class prefix if it exists |
|
1070 | - $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1071 | - // sanitize shortcode directory name |
|
1072 | - $widget = sanitize_key($widget); |
|
1073 | - // now we need to rebuild the shortcode path |
|
1074 | - $widget_path = explode(DS, $widget_path); |
|
1075 | - // remove last segment |
|
1076 | - array_pop($widget_path); |
|
1077 | - // glue it back together |
|
1078 | - $widget_path = implode(DS, $widget_path); |
|
1079 | - } else { |
|
1080 | - // grab and sanitize widget directory name |
|
1081 | - $widget = sanitize_key(basename($widget_path)); |
|
1082 | - } |
|
1083 | - // create classname from widget directory name |
|
1084 | - $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1085 | - // add class prefix |
|
1086 | - $widget_class = 'EEW_' . $widget; |
|
1087 | - // does the widget exist ? |
|
1088 | - if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1089 | - $msg = sprintf( |
|
1090 | - __( |
|
1091 | - 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1092 | - 'event_espresso' |
|
1093 | - ), |
|
1094 | - $widget_class, |
|
1095 | - $widget_path . DS . $widget_class . $widget_ext |
|
1096 | - ); |
|
1097 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1098 | - return; |
|
1099 | - } |
|
1100 | - // load the widget class file |
|
1101 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1102 | - // verify that class exists |
|
1103 | - if ( ! class_exists($widget_class)) { |
|
1104 | - $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1105 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1106 | - return; |
|
1107 | - } |
|
1108 | - register_widget($widget_class); |
|
1109 | - // add to array of registered widgets |
|
1110 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1111 | - } |
|
1112 | - |
|
1113 | - |
|
1114 | - |
|
1115 | - /** |
|
1116 | - * _register_modules |
|
1117 | - * |
|
1118 | - * @access private |
|
1119 | - * @return array |
|
1120 | - */ |
|
1121 | - private function _register_modules() |
|
1122 | - { |
|
1123 | - // grab list of installed modules |
|
1124 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1125 | - // filter list of modules to register |
|
1126 | - $modules_to_register = apply_filters( |
|
1127 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1128 | - $modules_to_register |
|
1129 | - ); |
|
1130 | - if ( ! empty($modules_to_register)) { |
|
1131 | - // loop through folders |
|
1132 | - foreach ($modules_to_register as $module_path) { |
|
1133 | - /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1134 | - if ( |
|
1135 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1136 | - && $module_path !== EE_MODULES . 'gateways' |
|
1137 | - ) { |
|
1138 | - // add to list of installed modules |
|
1139 | - EE_Config::register_module($module_path); |
|
1140 | - } |
|
1141 | - } |
|
1142 | - } |
|
1143 | - // filter list of installed modules |
|
1144 | - return apply_filters( |
|
1145 | - 'FHEE__EE_Config___register_modules__installed_modules', |
|
1146 | - EE_Registry::instance()->modules |
|
1147 | - ); |
|
1148 | - } |
|
1149 | - |
|
1150 | - |
|
1151 | - |
|
1152 | - /** |
|
1153 | - * register_module - makes core aware of this module |
|
1154 | - * |
|
1155 | - * @access public |
|
1156 | - * @param string $module_path - full path up to and including module folder |
|
1157 | - * @return bool |
|
1158 | - */ |
|
1159 | - public static function register_module($module_path = null) |
|
1160 | - { |
|
1161 | - do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1162 | - $module_ext = '.module.php'; |
|
1163 | - // make all separators match |
|
1164 | - $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1165 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1166 | - if (strpos($module_path, $module_ext) !== false) { |
|
1167 | - // grab and shortcode file name from directory name and break apart at dots |
|
1168 | - $module_file = explode('.', basename($module_path)); |
|
1169 | - // now we need to rebuild the shortcode path |
|
1170 | - $module_path = explode(DS, $module_path); |
|
1171 | - // remove last segment |
|
1172 | - array_pop($module_path); |
|
1173 | - // glue it back together |
|
1174 | - $module_path = implode(DS, $module_path) . DS; |
|
1175 | - // take first segment from file name pieces and sanitize it |
|
1176 | - $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1177 | - // ensure class prefix is added |
|
1178 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1179 | - } else { |
|
1180 | - // we need to generate the filename based off of the folder name |
|
1181 | - // grab and sanitize module name |
|
1182 | - $module = strtolower(basename($module_path)); |
|
1183 | - $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1184 | - // like trailingslashit() |
|
1185 | - $module_path = rtrim($module_path, DS) . DS; |
|
1186 | - // create classname from module directory name |
|
1187 | - $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1188 | - // add class prefix |
|
1189 | - $module_class = 'EED_' . $module; |
|
1190 | - } |
|
1191 | - // does the module exist ? |
|
1192 | - if ( ! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1193 | - $msg = sprintf( |
|
1194 | - __( |
|
1195 | - 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1196 | - 'event_espresso' |
|
1197 | - ), |
|
1198 | - $module |
|
1199 | - ); |
|
1200 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1201 | - return false; |
|
1202 | - } |
|
1203 | - // load the module class file |
|
1204 | - require_once($module_path . $module_class . $module_ext); |
|
1205 | - // verify that class exists |
|
1206 | - if ( ! class_exists($module_class)) { |
|
1207 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1208 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1209 | - return false; |
|
1210 | - } |
|
1211 | - // add to array of registered modules |
|
1212 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1213 | - do_action( |
|
1214 | - 'AHEE__EE_Config__register_module__complete', |
|
1215 | - $module_class, |
|
1216 | - EE_Registry::instance()->modules->{$module_class} |
|
1217 | - ); |
|
1218 | - return true; |
|
1219 | - } |
|
1220 | - |
|
1221 | - |
|
1222 | - |
|
1223 | - /** |
|
1224 | - * _initialize_modules |
|
1225 | - * allow modules to set hooks for the rest of the system |
|
1226 | - * |
|
1227 | - * @access private |
|
1228 | - * @return void |
|
1229 | - */ |
|
1230 | - private function _initialize_modules() |
|
1231 | - { |
|
1232 | - // cycle thru shortcode folders |
|
1233 | - foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1234 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1235 | - // which set hooks ? |
|
1236 | - if (is_admin()) { |
|
1237 | - // fire immediately |
|
1238 | - call_user_func(array($module_class, 'set_hooks_admin')); |
|
1239 | - } else { |
|
1240 | - // delay until other systems are online |
|
1241 | - add_action( |
|
1242 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1243 | - array($module_class, 'set_hooks') |
|
1244 | - ); |
|
1245 | - } |
|
1246 | - } |
|
1247 | - } |
|
1248 | - |
|
1249 | - |
|
1250 | - |
|
1251 | - /** |
|
1252 | - * register_route - adds module method routes to route_map |
|
1253 | - * |
|
1254 | - * @access public |
|
1255 | - * @param string $route - "pretty" public alias for module method |
|
1256 | - * @param string $module - module name (classname without EED_ prefix) |
|
1257 | - * @param string $method_name - the actual module method to be routed to |
|
1258 | - * @param string $key - url param key indicating a route is being called |
|
1259 | - * @return bool |
|
1260 | - */ |
|
1261 | - public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1262 | - { |
|
1263 | - do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1264 | - $module = str_replace('EED_', '', $module); |
|
1265 | - $module_class = 'EED_' . $module; |
|
1266 | - if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1267 | - $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1268 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1269 | - return false; |
|
1270 | - } |
|
1271 | - if (empty($route)) { |
|
1272 | - $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1273 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1274 | - return false; |
|
1275 | - } |
|
1276 | - if ( ! method_exists('EED_' . $module, $method_name)) { |
|
1277 | - $msg = sprintf( |
|
1278 | - __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1279 | - $route |
|
1280 | - ); |
|
1281 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1282 | - return false; |
|
1283 | - } |
|
1284 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
1285 | - return true; |
|
1286 | - } |
|
1287 | - |
|
1288 | - |
|
1289 | - |
|
1290 | - /** |
|
1291 | - * get_route - get module method route |
|
1292 | - * |
|
1293 | - * @access public |
|
1294 | - * @param string $route - "pretty" public alias for module method |
|
1295 | - * @param string $key - url param key indicating a route is being called |
|
1296 | - * @return string |
|
1297 | - */ |
|
1298 | - public static function get_route($route = null, $key = 'ee') |
|
1299 | - { |
|
1300 | - do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1301 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
1302 | - if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1303 | - return EE_Config::$_module_route_map[$key][$route]; |
|
1304 | - } |
|
1305 | - return null; |
|
1306 | - } |
|
1307 | - |
|
1308 | - |
|
1309 | - |
|
1310 | - /** |
|
1311 | - * get_routes - get ALL module method routes |
|
1312 | - * |
|
1313 | - * @access public |
|
1314 | - * @return array |
|
1315 | - */ |
|
1316 | - public static function get_routes() |
|
1317 | - { |
|
1318 | - return EE_Config::$_module_route_map; |
|
1319 | - } |
|
1320 | - |
|
1321 | - |
|
1322 | - |
|
1323 | - /** |
|
1324 | - * register_forward - allows modules to forward request to another module for further processing |
|
1325 | - * |
|
1326 | - * @access public |
|
1327 | - * @param string $route - "pretty" public alias for module method |
|
1328 | - * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1329 | - * class, allows different forwards to be served based on status |
|
1330 | - * @param array|string $forward - function name or array( class, method ) |
|
1331 | - * @param string $key - url param key indicating a route is being called |
|
1332 | - * @return bool |
|
1333 | - */ |
|
1334 | - public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1335 | - { |
|
1336 | - do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1337 | - if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1338 | - $msg = sprintf( |
|
1339 | - __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1340 | - $route |
|
1341 | - ); |
|
1342 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1343 | - return false; |
|
1344 | - } |
|
1345 | - if (empty($forward)) { |
|
1346 | - $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1347 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1348 | - return false; |
|
1349 | - } |
|
1350 | - if (is_array($forward)) { |
|
1351 | - if ( ! isset($forward[1])) { |
|
1352 | - $msg = sprintf( |
|
1353 | - __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1354 | - $route |
|
1355 | - ); |
|
1356 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1357 | - return false; |
|
1358 | - } |
|
1359 | - if ( ! method_exists($forward[0], $forward[1])) { |
|
1360 | - $msg = sprintf( |
|
1361 | - __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1362 | - $forward[1], |
|
1363 | - $route |
|
1364 | - ); |
|
1365 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1366 | - return false; |
|
1367 | - } |
|
1368 | - } else if ( ! function_exists($forward)) { |
|
1369 | - $msg = sprintf( |
|
1370 | - __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1371 | - $forward, |
|
1372 | - $route |
|
1373 | - ); |
|
1374 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1375 | - return false; |
|
1376 | - } |
|
1377 | - EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1378 | - return true; |
|
1379 | - } |
|
1380 | - |
|
1381 | - |
|
1382 | - |
|
1383 | - /** |
|
1384 | - * get_forward - get forwarding route |
|
1385 | - * |
|
1386 | - * @access public |
|
1387 | - * @param string $route - "pretty" public alias for module method |
|
1388 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1389 | - * allows different forwards to be served based on status |
|
1390 | - * @param string $key - url param key indicating a route is being called |
|
1391 | - * @return string |
|
1392 | - */ |
|
1393 | - public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1394 | - { |
|
1395 | - do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1396 | - if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1397 | - return apply_filters( |
|
1398 | - 'FHEE__EE_Config__get_forward', |
|
1399 | - EE_Config::$_module_forward_map[$key][$route][$status], |
|
1400 | - $route, |
|
1401 | - $status |
|
1402 | - ); |
|
1403 | - } |
|
1404 | - return null; |
|
1405 | - } |
|
1406 | - |
|
1407 | - |
|
1408 | - |
|
1409 | - /** |
|
1410 | - * register_forward - allows modules to specify different view templates for different method routes and status |
|
1411 | - * results |
|
1412 | - * |
|
1413 | - * @access public |
|
1414 | - * @param string $route - "pretty" public alias for module method |
|
1415 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1416 | - * allows different views to be served based on status |
|
1417 | - * @param string $view |
|
1418 | - * @param string $key - url param key indicating a route is being called |
|
1419 | - * @return bool |
|
1420 | - */ |
|
1421 | - public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1422 | - { |
|
1423 | - do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1424 | - if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1425 | - $msg = sprintf( |
|
1426 | - __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1427 | - $route |
|
1428 | - ); |
|
1429 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1430 | - return false; |
|
1431 | - } |
|
1432 | - if ( ! is_readable($view)) { |
|
1433 | - $msg = sprintf( |
|
1434 | - __( |
|
1435 | - 'The %s view file could not be found or is not readable due to file permissions.', |
|
1436 | - 'event_espresso' |
|
1437 | - ), |
|
1438 | - $view |
|
1439 | - ); |
|
1440 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1441 | - return false; |
|
1442 | - } |
|
1443 | - EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1444 | - return true; |
|
1445 | - } |
|
1446 | - |
|
1447 | - |
|
1448 | - |
|
1449 | - /** |
|
1450 | - * get_view - get view for route and status |
|
1451 | - * |
|
1452 | - * @access public |
|
1453 | - * @param string $route - "pretty" public alias for module method |
|
1454 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1455 | - * allows different views to be served based on status |
|
1456 | - * @param string $key - url param key indicating a route is being called |
|
1457 | - * @return string |
|
1458 | - */ |
|
1459 | - public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1460 | - { |
|
1461 | - do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1462 | - if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1463 | - return apply_filters( |
|
1464 | - 'FHEE__EE_Config__get_view', |
|
1465 | - EE_Config::$_module_view_map[$key][$route][$status], |
|
1466 | - $route, |
|
1467 | - $status |
|
1468 | - ); |
|
1469 | - } |
|
1470 | - return null; |
|
1471 | - } |
|
1472 | - |
|
1473 | - |
|
1474 | - |
|
1475 | - public function update_addon_option_names() |
|
1476 | - { |
|
1477 | - update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1478 | - } |
|
1479 | - |
|
1480 | - |
|
1481 | - |
|
1482 | - public function shutdown() |
|
1483 | - { |
|
1484 | - $this->update_addon_option_names(); |
|
1485 | - } |
|
1486 | - |
|
1487 | - |
|
1488 | - |
|
1489 | - /** |
|
1490 | - * @return LegacyShortcodesManager |
|
1491 | - */ |
|
1492 | - public static function getLegacyShortcodesManager() |
|
1493 | - { |
|
1494 | - if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1495 | - EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
1496 | - EE_Registry::instance() |
|
1497 | - ); |
|
1498 | - } |
|
1499 | - return EE_Config::instance()->legacy_shortcodes_manager; |
|
1500 | - } |
|
1501 | - |
|
1502 | - |
|
1503 | - |
|
1504 | - /** |
|
1505 | - * register_shortcode - makes core aware of this shortcode |
|
1506 | - * |
|
1507 | - * @deprecated 4.9.26 |
|
1508 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
1509 | - * @return bool |
|
1510 | - */ |
|
1511 | - public static function register_shortcode($shortcode_path = null) |
|
1512 | - { |
|
1513 | - EE_Error::doing_it_wrong( |
|
1514 | - __METHOD__, |
|
1515 | - __( |
|
1516 | - 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
1517 | - 'event_espresso' |
|
1518 | - ), |
|
1519 | - '4.9.26' |
|
1520 | - ); |
|
1521 | - return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
1522 | - } |
|
1523 | - |
|
1524 | - |
|
1525 | - |
|
1526 | -} |
|
1527 | - |
|
1528 | - |
|
1529 | - |
|
1530 | -/** |
|
1531 | - * Base class used for config classes. These classes should generally not have |
|
1532 | - * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1533 | - * basically, they should just be well-defined stdClasses |
|
1534 | - */ |
|
1535 | -class EE_Config_Base |
|
1536 | -{ |
|
1537 | - |
|
1538 | - /** |
|
1539 | - * Utility function for escaping the value of a property and returning. |
|
1540 | - * |
|
1541 | - * @param string $property property name (checks to see if exists). |
|
1542 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1543 | - * @throws \EE_Error |
|
1544 | - */ |
|
1545 | - public function get_pretty($property) |
|
1546 | - { |
|
1547 | - if ( ! property_exists($this, $property)) { |
|
1548 | - throw new EE_Error( |
|
1549 | - sprintf( |
|
1550 | - __( |
|
1551 | - '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1552 | - 'event_espresso' |
|
1553 | - ), |
|
1554 | - get_class($this), |
|
1555 | - $property |
|
1556 | - ) |
|
1557 | - ); |
|
1558 | - } |
|
1559 | - //just handling escaping of strings for now. |
|
1560 | - if (is_string($this->{$property})) { |
|
1561 | - return stripslashes($this->{$property}); |
|
1562 | - } |
|
1563 | - return $this->{$property}; |
|
1564 | - } |
|
1565 | - |
|
1566 | - |
|
1567 | - |
|
1568 | - public function populate() |
|
1569 | - { |
|
1570 | - //grab defaults via a new instance of this class. |
|
1571 | - $class_name = get_class($this); |
|
1572 | - $defaults = new $class_name; |
|
1573 | - //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1574 | - //default from our $defaults object. |
|
1575 | - foreach (get_object_vars($defaults) as $property => $value) { |
|
1576 | - if ($this->{$property} === null) { |
|
1577 | - $this->{$property} = $value; |
|
1578 | - } |
|
1579 | - } |
|
1580 | - //cleanup |
|
1581 | - unset($defaults); |
|
1582 | - } |
|
1583 | - |
|
1584 | - |
|
1585 | - |
|
1586 | - /** |
|
1587 | - * __isset |
|
1588 | - * |
|
1589 | - * @param $a |
|
1590 | - * @return bool |
|
1591 | - */ |
|
1592 | - public function __isset($a) |
|
1593 | - { |
|
1594 | - return false; |
|
1595 | - } |
|
1596 | - |
|
1597 | - |
|
1598 | - |
|
1599 | - /** |
|
1600 | - * __unset |
|
1601 | - * |
|
1602 | - * @param $a |
|
1603 | - * @return bool |
|
1604 | - */ |
|
1605 | - public function __unset($a) |
|
1606 | - { |
|
1607 | - return false; |
|
1608 | - } |
|
1609 | - |
|
1610 | - |
|
1611 | - |
|
1612 | - /** |
|
1613 | - * __clone |
|
1614 | - */ |
|
1615 | - public function __clone() |
|
1616 | - { |
|
1617 | - } |
|
1618 | - |
|
1619 | - |
|
1620 | - |
|
1621 | - /** |
|
1622 | - * __wakeup |
|
1623 | - */ |
|
1624 | - public function __wakeup() |
|
1625 | - { |
|
1626 | - } |
|
1627 | - |
|
1628 | - |
|
1629 | - |
|
1630 | - /** |
|
1631 | - * __destruct |
|
1632 | - */ |
|
1633 | - public function __destruct() |
|
1634 | - { |
|
1635 | - } |
|
1636 | -} |
|
1637 | - |
|
1638 | - |
|
1639 | - |
|
1640 | -/** |
|
1641 | - * Class for defining what's in the EE_Config relating to registration settings |
|
1642 | - */ |
|
1643 | -class EE_Core_Config extends EE_Config_Base |
|
1644 | -{ |
|
1645 | - |
|
1646 | - public $current_blog_id; |
|
1647 | - |
|
1648 | - public $ee_ueip_optin; |
|
1649 | - |
|
1650 | - public $ee_ueip_has_notified; |
|
1651 | - |
|
1652 | - /** |
|
1653 | - * Not to be confused with the 4 critical page variables (See |
|
1654 | - * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1655 | - * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1656 | - * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1657 | - * |
|
1658 | - * @var array |
|
1659 | - */ |
|
1660 | - public $post_shortcodes; |
|
1661 | - |
|
1662 | - public $module_route_map; |
|
1663 | - |
|
1664 | - public $module_forward_map; |
|
1665 | - |
|
1666 | - public $module_view_map; |
|
1667 | - |
|
1668 | - /** |
|
1669 | - * The next 4 vars are the IDs of critical EE pages. |
|
1670 | - * |
|
1671 | - * @var int |
|
1672 | - */ |
|
1673 | - public $reg_page_id; |
|
1674 | - |
|
1675 | - public $txn_page_id; |
|
1676 | - |
|
1677 | - public $thank_you_page_id; |
|
1678 | - |
|
1679 | - public $cancel_page_id; |
|
1680 | - |
|
1681 | - /** |
|
1682 | - * The next 4 vars are the URLs of critical EE pages. |
|
1683 | - * |
|
1684 | - * @var int |
|
1685 | - */ |
|
1686 | - public $reg_page_url; |
|
1687 | - |
|
1688 | - public $txn_page_url; |
|
1689 | - |
|
1690 | - public $thank_you_page_url; |
|
1691 | - |
|
1692 | - public $cancel_page_url; |
|
1693 | - |
|
1694 | - /** |
|
1695 | - * The next vars relate to the custom slugs for EE CPT routes |
|
1696 | - */ |
|
1697 | - public $event_cpt_slug; |
|
1698 | - |
|
1699 | - |
|
1700 | - /** |
|
1701 | - * This caches the _ee_ueip_option in case this config is reset in the same |
|
1702 | - * request across blog switches in a multisite context. |
|
1703 | - * Avoids extra queries to the db for this option. |
|
1704 | - * |
|
1705 | - * @var bool |
|
1706 | - */ |
|
1707 | - public static $ee_ueip_option; |
|
1708 | - |
|
1709 | - |
|
1710 | - |
|
1711 | - /** |
|
1712 | - * class constructor |
|
1713 | - * |
|
1714 | - * @access public |
|
1715 | - */ |
|
1716 | - public function __construct() |
|
1717 | - { |
|
1718 | - // set default organization settings |
|
1719 | - $this->current_blog_id = get_current_blog_id(); |
|
1720 | - $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1721 | - $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1722 | - $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1723 | - $this->post_shortcodes = array(); |
|
1724 | - $this->module_route_map = array(); |
|
1725 | - $this->module_forward_map = array(); |
|
1726 | - $this->module_view_map = array(); |
|
1727 | - // critical EE page IDs |
|
1728 | - $this->reg_page_id = 0; |
|
1729 | - $this->txn_page_id = 0; |
|
1730 | - $this->thank_you_page_id = 0; |
|
1731 | - $this->cancel_page_id = 0; |
|
1732 | - // critical EE page URLs |
|
1733 | - $this->reg_page_url = ''; |
|
1734 | - $this->txn_page_url = ''; |
|
1735 | - $this->thank_you_page_url = ''; |
|
1736 | - $this->cancel_page_url = ''; |
|
1737 | - //cpt slugs |
|
1738 | - $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1739 | - //ueip constant check |
|
1740 | - if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1741 | - $this->ee_ueip_optin = false; |
|
1742 | - $this->ee_ueip_has_notified = true; |
|
1743 | - } |
|
1744 | - } |
|
1745 | - |
|
1746 | - |
|
1747 | - |
|
1748 | - /** |
|
1749 | - * @return array |
|
1750 | - */ |
|
1751 | - public function get_critical_pages_array() |
|
1752 | - { |
|
1753 | - return array( |
|
1754 | - $this->reg_page_id, |
|
1755 | - $this->txn_page_id, |
|
1756 | - $this->thank_you_page_id, |
|
1757 | - $this->cancel_page_id, |
|
1758 | - ); |
|
1759 | - } |
|
1760 | - |
|
1761 | - |
|
1762 | - |
|
1763 | - /** |
|
1764 | - * @return array |
|
1765 | - */ |
|
1766 | - public function get_critical_pages_shortcodes_array() |
|
1767 | - { |
|
1768 | - return array( |
|
1769 | - $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1770 | - $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1771 | - $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1772 | - $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1773 | - ); |
|
1774 | - } |
|
1775 | - |
|
1776 | - |
|
1777 | - |
|
1778 | - /** |
|
1779 | - * gets/returns URL for EE reg_page |
|
1780 | - * |
|
1781 | - * @access public |
|
1782 | - * @return string |
|
1783 | - */ |
|
1784 | - public function reg_page_url() |
|
1785 | - { |
|
1786 | - if ( ! $this->reg_page_url) { |
|
1787 | - $this->reg_page_url = add_query_arg( |
|
1788 | - array('uts' => time()), |
|
1789 | - get_permalink($this->reg_page_id) |
|
1790 | - ) . '#checkout'; |
|
1791 | - } |
|
1792 | - return $this->reg_page_url; |
|
1793 | - } |
|
1794 | - |
|
1795 | - |
|
1796 | - |
|
1797 | - /** |
|
1798 | - * gets/returns URL for EE txn_page |
|
1799 | - * |
|
1800 | - * @param array $query_args like what gets passed to |
|
1801 | - * add_query_arg() as the first argument |
|
1802 | - * @access public |
|
1803 | - * @return string |
|
1804 | - */ |
|
1805 | - public function txn_page_url($query_args = array()) |
|
1806 | - { |
|
1807 | - if ( ! $this->txn_page_url) { |
|
1808 | - $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1809 | - } |
|
1810 | - if ($query_args) { |
|
1811 | - return add_query_arg($query_args, $this->txn_page_url); |
|
1812 | - } else { |
|
1813 | - return $this->txn_page_url; |
|
1814 | - } |
|
1815 | - } |
|
1816 | - |
|
1817 | - |
|
1818 | - |
|
1819 | - /** |
|
1820 | - * gets/returns URL for EE thank_you_page |
|
1821 | - * |
|
1822 | - * @param array $query_args like what gets passed to |
|
1823 | - * add_query_arg() as the first argument |
|
1824 | - * @access public |
|
1825 | - * @return string |
|
1826 | - */ |
|
1827 | - public function thank_you_page_url($query_args = array()) |
|
1828 | - { |
|
1829 | - if ( ! $this->thank_you_page_url) { |
|
1830 | - $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1831 | - } |
|
1832 | - if ($query_args) { |
|
1833 | - return add_query_arg($query_args, $this->thank_you_page_url); |
|
1834 | - } else { |
|
1835 | - return $this->thank_you_page_url; |
|
1836 | - } |
|
1837 | - } |
|
1838 | - |
|
1839 | - |
|
1840 | - |
|
1841 | - /** |
|
1842 | - * gets/returns URL for EE cancel_page |
|
1843 | - * |
|
1844 | - * @access public |
|
1845 | - * @return string |
|
1846 | - */ |
|
1847 | - public function cancel_page_url() |
|
1848 | - { |
|
1849 | - if ( ! $this->cancel_page_url) { |
|
1850 | - $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1851 | - } |
|
1852 | - return $this->cancel_page_url; |
|
1853 | - } |
|
1854 | - |
|
1855 | - |
|
1856 | - |
|
1857 | - /** |
|
1858 | - * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1859 | - * |
|
1860 | - * @since 4.7.5 |
|
1861 | - */ |
|
1862 | - protected function _reset_urls() |
|
1863 | - { |
|
1864 | - $this->reg_page_url = ''; |
|
1865 | - $this->txn_page_url = ''; |
|
1866 | - $this->cancel_page_url = ''; |
|
1867 | - $this->thank_you_page_url = ''; |
|
1868 | - } |
|
1869 | - |
|
1870 | - |
|
1871 | - |
|
1872 | - /** |
|
1873 | - * Used to return what the optin value is set for the EE User Experience Program. |
|
1874 | - * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1875 | - * on the main site only. |
|
1876 | - * |
|
1877 | - * @return mixed|void |
|
1878 | - */ |
|
1879 | - protected function _get_main_ee_ueip_optin() |
|
1880 | - { |
|
1881 | - //if this is the main site then we can just bypass our direct query. |
|
1882 | - if (is_main_site()) { |
|
1883 | - return get_option('ee_ueip_optin', false); |
|
1884 | - } |
|
1885 | - //is this already cached for this request? If so use it. |
|
1886 | - if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1887 | - return EE_Core_Config::$ee_ueip_option; |
|
1888 | - } |
|
1889 | - global $wpdb; |
|
1890 | - $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1891 | - $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1892 | - $option = 'ee_ueip_optin'; |
|
1893 | - //set correct table for query |
|
1894 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1895 | - //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1896 | - //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1897 | - //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1898 | - //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1899 | - //for the purpose of caching. |
|
1900 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1901 | - if (false !== $pre) { |
|
1902 | - EE_Core_Config::$ee_ueip_option = $pre; |
|
1903 | - return EE_Core_Config::$ee_ueip_option; |
|
1904 | - } |
|
1905 | - $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
1906 | - $option)); |
|
1907 | - if (is_object($row)) { |
|
1908 | - $value = $row->option_value; |
|
1909 | - } else { //option does not exist so use default. |
|
1910 | - return apply_filters('default_option_' . $option, false, $option); |
|
1911 | - } |
|
1912 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1913 | - return EE_Core_Config::$ee_ueip_option; |
|
1914 | - } |
|
1915 | - |
|
1916 | - |
|
1917 | - |
|
1918 | - /** |
|
1919 | - * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
1920 | - * on the object. |
|
1921 | - * |
|
1922 | - * @return array |
|
1923 | - */ |
|
1924 | - public function __sleep() |
|
1925 | - { |
|
1926 | - //reset all url properties |
|
1927 | - $this->_reset_urls(); |
|
1928 | - //return what to save to db |
|
1929 | - return array_keys(get_object_vars($this)); |
|
1930 | - } |
|
1931 | - |
|
1932 | -} |
|
1933 | - |
|
1934 | - |
|
1935 | - |
|
1936 | -/** |
|
1937 | - * Config class for storing info on the Organization |
|
1938 | - */ |
|
1939 | -class EE_Organization_Config extends EE_Config_Base |
|
1940 | -{ |
|
1941 | - |
|
1942 | - /** |
|
1943 | - * @var string $name |
|
1944 | - * eg EE4.1 |
|
1945 | - */ |
|
1946 | - public $name; |
|
1947 | - |
|
1948 | - /** |
|
1949 | - * @var string $address_1 |
|
1950 | - * eg 123 Onna Road |
|
1951 | - */ |
|
1952 | - public $address_1; |
|
1953 | - |
|
1954 | - /** |
|
1955 | - * @var string $address_2 |
|
1956 | - * eg PO Box 123 |
|
1957 | - */ |
|
1958 | - public $address_2; |
|
1959 | - |
|
1960 | - /** |
|
1961 | - * @var string $city |
|
1962 | - * eg Inna City |
|
1963 | - */ |
|
1964 | - public $city; |
|
1965 | - |
|
1966 | - /** |
|
1967 | - * @var int $STA_ID |
|
1968 | - * eg 4 |
|
1969 | - */ |
|
1970 | - public $STA_ID; |
|
1971 | - |
|
1972 | - /** |
|
1973 | - * @var string $CNT_ISO |
|
1974 | - * eg US |
|
1975 | - */ |
|
1976 | - public $CNT_ISO; |
|
1977 | - |
|
1978 | - /** |
|
1979 | - * @var string $zip |
|
1980 | - * eg 12345 or V1A 2B3 |
|
1981 | - */ |
|
1982 | - public $zip; |
|
1983 | - |
|
1984 | - /** |
|
1985 | - * @var string $email |
|
1986 | - * eg [email protected] |
|
1987 | - */ |
|
1988 | - public $email; |
|
1989 | - |
|
1990 | - |
|
1991 | - /** |
|
1992 | - * @var string $phone |
|
1993 | - * eg. 111-111-1111 |
|
1994 | - */ |
|
1995 | - public $phone; |
|
1996 | - |
|
1997 | - |
|
1998 | - /** |
|
1999 | - * @var string $vat |
|
2000 | - * VAT/Tax Number |
|
2001 | - */ |
|
2002 | - public $vat; |
|
2003 | - |
|
2004 | - /** |
|
2005 | - * @var string $logo_url |
|
2006 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
2007 | - */ |
|
2008 | - public $logo_url; |
|
2009 | - |
|
2010 | - |
|
2011 | - /** |
|
2012 | - * The below are all various properties for holding links to organization social network profiles |
|
2013 | - * |
|
2014 | - * @var string |
|
2015 | - */ |
|
2016 | - /** |
|
2017 | - * facebook (facebook.com/profile.name) |
|
2018 | - * |
|
2019 | - * @var string |
|
2020 | - */ |
|
2021 | - public $facebook; |
|
2022 | - |
|
2023 | - |
|
2024 | - /** |
|
2025 | - * twitter (twitter.com/twitter_handle) |
|
2026 | - * |
|
2027 | - * @var string |
|
2028 | - */ |
|
2029 | - public $twitter; |
|
2030 | - |
|
2031 | - |
|
2032 | - /** |
|
2033 | - * linkedin (linkedin.com/in/profile_name) |
|
2034 | - * |
|
2035 | - * @var string |
|
2036 | - */ |
|
2037 | - public $linkedin; |
|
2038 | - |
|
2039 | - |
|
2040 | - /** |
|
2041 | - * pinterest (www.pinterest.com/profile_name) |
|
2042 | - * |
|
2043 | - * @var string |
|
2044 | - */ |
|
2045 | - public $pinterest; |
|
2046 | - |
|
2047 | - |
|
2048 | - /** |
|
2049 | - * google+ (google.com/+profileName) |
|
2050 | - * |
|
2051 | - * @var string |
|
2052 | - */ |
|
2053 | - public $google; |
|
2054 | - |
|
2055 | - |
|
2056 | - /** |
|
2057 | - * instagram (instagram.com/handle) |
|
2058 | - * |
|
2059 | - * @var string |
|
2060 | - */ |
|
2061 | - public $instagram; |
|
2062 | - |
|
2063 | - |
|
2064 | - |
|
2065 | - /** |
|
2066 | - * class constructor |
|
2067 | - * |
|
2068 | - * @access public |
|
2069 | - */ |
|
2070 | - public function __construct() |
|
2071 | - { |
|
2072 | - // set default organization settings |
|
2073 | - $this->name = get_bloginfo('name'); |
|
2074 | - $this->address_1 = '123 Onna Road'; |
|
2075 | - $this->address_2 = 'PO Box 123'; |
|
2076 | - $this->city = 'Inna City'; |
|
2077 | - $this->STA_ID = 4; |
|
2078 | - $this->CNT_ISO = 'US'; |
|
2079 | - $this->zip = '12345'; |
|
2080 | - $this->email = get_bloginfo('admin_email'); |
|
2081 | - $this->phone = ''; |
|
2082 | - $this->vat = '123456789'; |
|
2083 | - $this->logo_url = ''; |
|
2084 | - $this->facebook = ''; |
|
2085 | - $this->twitter = ''; |
|
2086 | - $this->linkedin = ''; |
|
2087 | - $this->pinterest = ''; |
|
2088 | - $this->google = ''; |
|
2089 | - $this->instagram = ''; |
|
2090 | - } |
|
2091 | - |
|
2092 | -} |
|
2093 | - |
|
2094 | - |
|
2095 | - |
|
2096 | -/** |
|
2097 | - * Class for defining what's in the EE_Config relating to currency |
|
2098 | - */ |
|
2099 | -class EE_Currency_Config extends EE_Config_Base |
|
2100 | -{ |
|
2101 | - |
|
2102 | - /** |
|
2103 | - * @var string $code |
|
2104 | - * eg 'US' |
|
2105 | - */ |
|
2106 | - public $code; |
|
2107 | - |
|
2108 | - /** |
|
2109 | - * @var string $name |
|
2110 | - * eg 'Dollar' |
|
2111 | - */ |
|
2112 | - public $name; |
|
2113 | - |
|
2114 | - /** |
|
2115 | - * plural name |
|
2116 | - * |
|
2117 | - * @var string $plural |
|
2118 | - * eg 'Dollars' |
|
2119 | - */ |
|
2120 | - public $plural; |
|
2121 | - |
|
2122 | - /** |
|
2123 | - * currency sign |
|
2124 | - * |
|
2125 | - * @var string $sign |
|
2126 | - * eg '$' |
|
2127 | - */ |
|
2128 | - public $sign; |
|
2129 | - |
|
2130 | - /** |
|
2131 | - * Whether the currency sign should come before the number or not |
|
2132 | - * |
|
2133 | - * @var boolean $sign_b4 |
|
2134 | - */ |
|
2135 | - public $sign_b4; |
|
2136 | - |
|
2137 | - /** |
|
2138 | - * How many digits should come after the decimal place |
|
2139 | - * |
|
2140 | - * @var int $dec_plc |
|
2141 | - */ |
|
2142 | - public $dec_plc; |
|
2143 | - |
|
2144 | - /** |
|
2145 | - * Symbol to use for decimal mark |
|
2146 | - * |
|
2147 | - * @var string $dec_mrk |
|
2148 | - * eg '.' |
|
2149 | - */ |
|
2150 | - public $dec_mrk; |
|
2151 | - |
|
2152 | - /** |
|
2153 | - * Symbol to use for thousands |
|
2154 | - * |
|
2155 | - * @var string $thsnds |
|
2156 | - * eg ',' |
|
2157 | - */ |
|
2158 | - public $thsnds; |
|
2159 | - |
|
2160 | - |
|
2161 | - |
|
2162 | - /** |
|
2163 | - * class constructor |
|
2164 | - * |
|
2165 | - * @access public |
|
2166 | - * @param string $CNT_ISO |
|
2167 | - * @throws \EE_Error |
|
2168 | - */ |
|
2169 | - public function __construct($CNT_ISO = '') |
|
2170 | - { |
|
2171 | - /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2172 | - $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2173 | - // get country code from organization settings or use default |
|
2174 | - $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2175 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2176 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2177 | - : ''; |
|
2178 | - // but override if requested |
|
2179 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2180 | - // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2181 | - if ( |
|
2182 | - ! empty($CNT_ISO) |
|
2183 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
2184 | - && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2185 | - ) { |
|
2186 | - // retrieve the country settings from the db, just in case they have been customized |
|
2187 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2188 | - if ($country instanceof EE_Country) { |
|
2189 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2190 | - $this->name = $country->currency_name_single(); // Dollar |
|
2191 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2192 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2193 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2194 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2195 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2196 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2197 | - } |
|
2198 | - } |
|
2199 | - // fallback to hardcoded defaults, in case the above failed |
|
2200 | - if (empty($this->code)) { |
|
2201 | - // set default currency settings |
|
2202 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2203 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2204 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2205 | - $this->sign = '$'; // currency sign: $ |
|
2206 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2207 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2208 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2209 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2210 | - } |
|
2211 | - } |
|
2212 | 1526 | } |
2213 | 1527 | |
2214 | 1528 | |
2215 | 1529 | |
2216 | 1530 | /** |
2217 | - * Class for defining what's in the EE_Config relating to registration settings |
|
1531 | + * Base class used for config classes. These classes should generally not have |
|
1532 | + * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1533 | + * basically, they should just be well-defined stdClasses |
|
2218 | 1534 | */ |
2219 | -class EE_Registration_Config extends EE_Config_Base |
|
1535 | +class EE_Config_Base |
|
2220 | 1536 | { |
2221 | 1537 | |
2222 | - /** |
|
2223 | - * Default registration status |
|
2224 | - * |
|
2225 | - * @var string $default_STS_ID |
|
2226 | - * eg 'RPP' |
|
2227 | - */ |
|
2228 | - public $default_STS_ID; |
|
2229 | - |
|
2230 | - /** |
|
2231 | - * level of validation to apply to email addresses |
|
2232 | - * |
|
2233 | - * @var string $email_validation_level |
|
2234 | - * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2235 | - */ |
|
2236 | - public $email_validation_level; |
|
2237 | - |
|
2238 | - /** |
|
2239 | - * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2240 | - * |
|
2241 | - * @var boolean $show_pending_payment_options |
|
2242 | - */ |
|
2243 | - public $show_pending_payment_options; |
|
2244 | - |
|
2245 | - /** |
|
2246 | - * Whether to skip the registration confirmation page |
|
2247 | - * |
|
2248 | - * @var boolean $skip_reg_confirmation |
|
2249 | - */ |
|
2250 | - public $skip_reg_confirmation; |
|
2251 | - |
|
2252 | - /** |
|
2253 | - * an array of SPCO reg steps where: |
|
2254 | - * the keys denotes the reg step order |
|
2255 | - * each element consists of an array with the following elements: |
|
2256 | - * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2257 | - * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2258 | - * "slug" => the URL param used to trigger the reg step |
|
2259 | - * |
|
2260 | - * @var array $reg_steps |
|
2261 | - */ |
|
2262 | - public $reg_steps; |
|
2263 | - |
|
2264 | - /** |
|
2265 | - * Whether registration confirmation should be the last page of SPCO |
|
2266 | - * |
|
2267 | - * @var boolean $reg_confirmation_last |
|
2268 | - */ |
|
2269 | - public $reg_confirmation_last; |
|
2270 | - |
|
2271 | - /** |
|
2272 | - * Whether or not to enable the EE Bot Trap |
|
2273 | - * |
|
2274 | - * @var boolean $use_bot_trap |
|
2275 | - */ |
|
2276 | - public $use_bot_trap; |
|
2277 | - |
|
2278 | - /** |
|
2279 | - * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2280 | - * |
|
2281 | - * @var boolean $use_encryption |
|
2282 | - */ |
|
2283 | - public $use_encryption; |
|
2284 | - |
|
2285 | - /** |
|
2286 | - * Whether or not to use ReCaptcha |
|
2287 | - * |
|
2288 | - * @var boolean $use_captcha |
|
2289 | - */ |
|
2290 | - public $use_captcha; |
|
2291 | - |
|
2292 | - /** |
|
2293 | - * ReCaptcha Theme |
|
2294 | - * |
|
2295 | - * @var string $recaptcha_theme |
|
2296 | - * options: 'dark ', 'light' |
|
2297 | - */ |
|
2298 | - public $recaptcha_theme; |
|
1538 | + /** |
|
1539 | + * Utility function for escaping the value of a property and returning. |
|
1540 | + * |
|
1541 | + * @param string $property property name (checks to see if exists). |
|
1542 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1543 | + * @throws \EE_Error |
|
1544 | + */ |
|
1545 | + public function get_pretty($property) |
|
1546 | + { |
|
1547 | + if ( ! property_exists($this, $property)) { |
|
1548 | + throw new EE_Error( |
|
1549 | + sprintf( |
|
1550 | + __( |
|
1551 | + '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1552 | + 'event_espresso' |
|
1553 | + ), |
|
1554 | + get_class($this), |
|
1555 | + $property |
|
1556 | + ) |
|
1557 | + ); |
|
1558 | + } |
|
1559 | + //just handling escaping of strings for now. |
|
1560 | + if (is_string($this->{$property})) { |
|
1561 | + return stripslashes($this->{$property}); |
|
1562 | + } |
|
1563 | + return $this->{$property}; |
|
1564 | + } |
|
1565 | + |
|
1566 | + |
|
1567 | + |
|
1568 | + public function populate() |
|
1569 | + { |
|
1570 | + //grab defaults via a new instance of this class. |
|
1571 | + $class_name = get_class($this); |
|
1572 | + $defaults = new $class_name; |
|
1573 | + //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1574 | + //default from our $defaults object. |
|
1575 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1576 | + if ($this->{$property} === null) { |
|
1577 | + $this->{$property} = $value; |
|
1578 | + } |
|
1579 | + } |
|
1580 | + //cleanup |
|
1581 | + unset($defaults); |
|
1582 | + } |
|
1583 | + |
|
1584 | + |
|
1585 | + |
|
1586 | + /** |
|
1587 | + * __isset |
|
1588 | + * |
|
1589 | + * @param $a |
|
1590 | + * @return bool |
|
1591 | + */ |
|
1592 | + public function __isset($a) |
|
1593 | + { |
|
1594 | + return false; |
|
1595 | + } |
|
1596 | + |
|
1597 | + |
|
1598 | + |
|
1599 | + /** |
|
1600 | + * __unset |
|
1601 | + * |
|
1602 | + * @param $a |
|
1603 | + * @return bool |
|
1604 | + */ |
|
1605 | + public function __unset($a) |
|
1606 | + { |
|
1607 | + return false; |
|
1608 | + } |
|
1609 | + |
|
1610 | + |
|
1611 | + |
|
1612 | + /** |
|
1613 | + * __clone |
|
1614 | + */ |
|
1615 | + public function __clone() |
|
1616 | + { |
|
1617 | + } |
|
1618 | + |
|
1619 | + |
|
1620 | + |
|
1621 | + /** |
|
1622 | + * __wakeup |
|
1623 | + */ |
|
1624 | + public function __wakeup() |
|
1625 | + { |
|
1626 | + } |
|
1627 | + |
|
1628 | + |
|
1629 | + |
|
1630 | + /** |
|
1631 | + * __destruct |
|
1632 | + */ |
|
1633 | + public function __destruct() |
|
1634 | + { |
|
1635 | + } |
|
1636 | +} |
|
2299 | 1637 | |
2300 | - /** |
|
2301 | - * ReCaptcha Type |
|
2302 | - * |
|
2303 | - * @var string $recaptcha_type |
|
2304 | - * options: 'audio', 'image' |
|
2305 | - */ |
|
2306 | - public $recaptcha_type; |
|
2307 | 1638 | |
2308 | - /** |
|
2309 | - * ReCaptcha language |
|
2310 | - * |
|
2311 | - * @var string $recaptcha_language |
|
2312 | - * eg 'en' |
|
2313 | - */ |
|
2314 | - public $recaptcha_language; |
|
2315 | 1639 | |
2316 | - /** |
|
2317 | - * ReCaptcha public key |
|
2318 | - * |
|
2319 | - * @var string $recaptcha_publickey |
|
2320 | - */ |
|
2321 | - public $recaptcha_publickey; |
|
1640 | +/** |
|
1641 | + * Class for defining what's in the EE_Config relating to registration settings |
|
1642 | + */ |
|
1643 | +class EE_Core_Config extends EE_Config_Base |
|
1644 | +{ |
|
2322 | 1645 | |
2323 | - /** |
|
2324 | - * ReCaptcha private key |
|
2325 | - * |
|
2326 | - * @var string $recaptcha_privatekey |
|
2327 | - */ |
|
2328 | - public $recaptcha_privatekey; |
|
1646 | + public $current_blog_id; |
|
1647 | + |
|
1648 | + public $ee_ueip_optin; |
|
1649 | + |
|
1650 | + public $ee_ueip_has_notified; |
|
1651 | + |
|
1652 | + /** |
|
1653 | + * Not to be confused with the 4 critical page variables (See |
|
1654 | + * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1655 | + * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1656 | + * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1657 | + * |
|
1658 | + * @var array |
|
1659 | + */ |
|
1660 | + public $post_shortcodes; |
|
1661 | + |
|
1662 | + public $module_route_map; |
|
1663 | + |
|
1664 | + public $module_forward_map; |
|
1665 | + |
|
1666 | + public $module_view_map; |
|
1667 | + |
|
1668 | + /** |
|
1669 | + * The next 4 vars are the IDs of critical EE pages. |
|
1670 | + * |
|
1671 | + * @var int |
|
1672 | + */ |
|
1673 | + public $reg_page_id; |
|
1674 | + |
|
1675 | + public $txn_page_id; |
|
1676 | + |
|
1677 | + public $thank_you_page_id; |
|
1678 | + |
|
1679 | + public $cancel_page_id; |
|
1680 | + |
|
1681 | + /** |
|
1682 | + * The next 4 vars are the URLs of critical EE pages. |
|
1683 | + * |
|
1684 | + * @var int |
|
1685 | + */ |
|
1686 | + public $reg_page_url; |
|
1687 | + |
|
1688 | + public $txn_page_url; |
|
1689 | + |
|
1690 | + public $thank_you_page_url; |
|
1691 | + |
|
1692 | + public $cancel_page_url; |
|
1693 | + |
|
1694 | + /** |
|
1695 | + * The next vars relate to the custom slugs for EE CPT routes |
|
1696 | + */ |
|
1697 | + public $event_cpt_slug; |
|
1698 | + |
|
1699 | + |
|
1700 | + /** |
|
1701 | + * This caches the _ee_ueip_option in case this config is reset in the same |
|
1702 | + * request across blog switches in a multisite context. |
|
1703 | + * Avoids extra queries to the db for this option. |
|
1704 | + * |
|
1705 | + * @var bool |
|
1706 | + */ |
|
1707 | + public static $ee_ueip_option; |
|
1708 | + |
|
1709 | + |
|
1710 | + |
|
1711 | + /** |
|
1712 | + * class constructor |
|
1713 | + * |
|
1714 | + * @access public |
|
1715 | + */ |
|
1716 | + public function __construct() |
|
1717 | + { |
|
1718 | + // set default organization settings |
|
1719 | + $this->current_blog_id = get_current_blog_id(); |
|
1720 | + $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1721 | + $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1722 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1723 | + $this->post_shortcodes = array(); |
|
1724 | + $this->module_route_map = array(); |
|
1725 | + $this->module_forward_map = array(); |
|
1726 | + $this->module_view_map = array(); |
|
1727 | + // critical EE page IDs |
|
1728 | + $this->reg_page_id = 0; |
|
1729 | + $this->txn_page_id = 0; |
|
1730 | + $this->thank_you_page_id = 0; |
|
1731 | + $this->cancel_page_id = 0; |
|
1732 | + // critical EE page URLs |
|
1733 | + $this->reg_page_url = ''; |
|
1734 | + $this->txn_page_url = ''; |
|
1735 | + $this->thank_you_page_url = ''; |
|
1736 | + $this->cancel_page_url = ''; |
|
1737 | + //cpt slugs |
|
1738 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1739 | + //ueip constant check |
|
1740 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1741 | + $this->ee_ueip_optin = false; |
|
1742 | + $this->ee_ueip_has_notified = true; |
|
1743 | + } |
|
1744 | + } |
|
1745 | + |
|
1746 | + |
|
1747 | + |
|
1748 | + /** |
|
1749 | + * @return array |
|
1750 | + */ |
|
1751 | + public function get_critical_pages_array() |
|
1752 | + { |
|
1753 | + return array( |
|
1754 | + $this->reg_page_id, |
|
1755 | + $this->txn_page_id, |
|
1756 | + $this->thank_you_page_id, |
|
1757 | + $this->cancel_page_id, |
|
1758 | + ); |
|
1759 | + } |
|
1760 | + |
|
1761 | + |
|
1762 | + |
|
1763 | + /** |
|
1764 | + * @return array |
|
1765 | + */ |
|
1766 | + public function get_critical_pages_shortcodes_array() |
|
1767 | + { |
|
1768 | + return array( |
|
1769 | + $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1770 | + $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1771 | + $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1772 | + $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1773 | + ); |
|
1774 | + } |
|
1775 | + |
|
1776 | + |
|
1777 | + |
|
1778 | + /** |
|
1779 | + * gets/returns URL for EE reg_page |
|
1780 | + * |
|
1781 | + * @access public |
|
1782 | + * @return string |
|
1783 | + */ |
|
1784 | + public function reg_page_url() |
|
1785 | + { |
|
1786 | + if ( ! $this->reg_page_url) { |
|
1787 | + $this->reg_page_url = add_query_arg( |
|
1788 | + array('uts' => time()), |
|
1789 | + get_permalink($this->reg_page_id) |
|
1790 | + ) . '#checkout'; |
|
1791 | + } |
|
1792 | + return $this->reg_page_url; |
|
1793 | + } |
|
1794 | + |
|
1795 | + |
|
1796 | + |
|
1797 | + /** |
|
1798 | + * gets/returns URL for EE txn_page |
|
1799 | + * |
|
1800 | + * @param array $query_args like what gets passed to |
|
1801 | + * add_query_arg() as the first argument |
|
1802 | + * @access public |
|
1803 | + * @return string |
|
1804 | + */ |
|
1805 | + public function txn_page_url($query_args = array()) |
|
1806 | + { |
|
1807 | + if ( ! $this->txn_page_url) { |
|
1808 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1809 | + } |
|
1810 | + if ($query_args) { |
|
1811 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1812 | + } else { |
|
1813 | + return $this->txn_page_url; |
|
1814 | + } |
|
1815 | + } |
|
1816 | + |
|
1817 | + |
|
1818 | + |
|
1819 | + /** |
|
1820 | + * gets/returns URL for EE thank_you_page |
|
1821 | + * |
|
1822 | + * @param array $query_args like what gets passed to |
|
1823 | + * add_query_arg() as the first argument |
|
1824 | + * @access public |
|
1825 | + * @return string |
|
1826 | + */ |
|
1827 | + public function thank_you_page_url($query_args = array()) |
|
1828 | + { |
|
1829 | + if ( ! $this->thank_you_page_url) { |
|
1830 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1831 | + } |
|
1832 | + if ($query_args) { |
|
1833 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1834 | + } else { |
|
1835 | + return $this->thank_you_page_url; |
|
1836 | + } |
|
1837 | + } |
|
1838 | + |
|
1839 | + |
|
1840 | + |
|
1841 | + /** |
|
1842 | + * gets/returns URL for EE cancel_page |
|
1843 | + * |
|
1844 | + * @access public |
|
1845 | + * @return string |
|
1846 | + */ |
|
1847 | + public function cancel_page_url() |
|
1848 | + { |
|
1849 | + if ( ! $this->cancel_page_url) { |
|
1850 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1851 | + } |
|
1852 | + return $this->cancel_page_url; |
|
1853 | + } |
|
1854 | + |
|
1855 | + |
|
1856 | + |
|
1857 | + /** |
|
1858 | + * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1859 | + * |
|
1860 | + * @since 4.7.5 |
|
1861 | + */ |
|
1862 | + protected function _reset_urls() |
|
1863 | + { |
|
1864 | + $this->reg_page_url = ''; |
|
1865 | + $this->txn_page_url = ''; |
|
1866 | + $this->cancel_page_url = ''; |
|
1867 | + $this->thank_you_page_url = ''; |
|
1868 | + } |
|
1869 | + |
|
1870 | + |
|
1871 | + |
|
1872 | + /** |
|
1873 | + * Used to return what the optin value is set for the EE User Experience Program. |
|
1874 | + * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1875 | + * on the main site only. |
|
1876 | + * |
|
1877 | + * @return mixed|void |
|
1878 | + */ |
|
1879 | + protected function _get_main_ee_ueip_optin() |
|
1880 | + { |
|
1881 | + //if this is the main site then we can just bypass our direct query. |
|
1882 | + if (is_main_site()) { |
|
1883 | + return get_option('ee_ueip_optin', false); |
|
1884 | + } |
|
1885 | + //is this already cached for this request? If so use it. |
|
1886 | + if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1887 | + return EE_Core_Config::$ee_ueip_option; |
|
1888 | + } |
|
1889 | + global $wpdb; |
|
1890 | + $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1891 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1892 | + $option = 'ee_ueip_optin'; |
|
1893 | + //set correct table for query |
|
1894 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1895 | + //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1896 | + //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1897 | + //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1898 | + //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1899 | + //for the purpose of caching. |
|
1900 | + $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1901 | + if (false !== $pre) { |
|
1902 | + EE_Core_Config::$ee_ueip_option = $pre; |
|
1903 | + return EE_Core_Config::$ee_ueip_option; |
|
1904 | + } |
|
1905 | + $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
1906 | + $option)); |
|
1907 | + if (is_object($row)) { |
|
1908 | + $value = $row->option_value; |
|
1909 | + } else { //option does not exist so use default. |
|
1910 | + return apply_filters('default_option_' . $option, false, $option); |
|
1911 | + } |
|
1912 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1913 | + return EE_Core_Config::$ee_ueip_option; |
|
1914 | + } |
|
1915 | + |
|
1916 | + |
|
1917 | + |
|
1918 | + /** |
|
1919 | + * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
1920 | + * on the object. |
|
1921 | + * |
|
1922 | + * @return array |
|
1923 | + */ |
|
1924 | + public function __sleep() |
|
1925 | + { |
|
1926 | + //reset all url properties |
|
1927 | + $this->_reset_urls(); |
|
1928 | + //return what to save to db |
|
1929 | + return array_keys(get_object_vars($this)); |
|
1930 | + } |
|
2329 | 1931 | |
2330 | - /** |
|
2331 | - * ReCaptcha width |
|
2332 | - * |
|
2333 | - * @var int $recaptcha_width |
|
2334 | - * @deprecated |
|
2335 | - */ |
|
2336 | - public $recaptcha_width; |
|
1932 | +} |
|
2337 | 1933 | |
2338 | - /** |
|
2339 | - * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2340 | - * |
|
2341 | - * @var boolean $track_invalid_checkout_access |
|
2342 | - */ |
|
2343 | - protected $track_invalid_checkout_access = true; |
|
2344 | 1934 | |
2345 | 1935 | |
1936 | +/** |
|
1937 | + * Config class for storing info on the Organization |
|
1938 | + */ |
|
1939 | +class EE_Organization_Config extends EE_Config_Base |
|
1940 | +{ |
|
2346 | 1941 | |
2347 | - /** |
|
2348 | - * class constructor |
|
2349 | - * |
|
2350 | - * @access public |
|
2351 | - */ |
|
2352 | - public function __construct() |
|
2353 | - { |
|
2354 | - // set default registration settings |
|
2355 | - $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2356 | - $this->email_validation_level = 'wp_default'; |
|
2357 | - $this->show_pending_payment_options = true; |
|
2358 | - $this->skip_reg_confirmation = false; |
|
2359 | - $this->reg_steps = array(); |
|
2360 | - $this->reg_confirmation_last = false; |
|
2361 | - $this->use_bot_trap = true; |
|
2362 | - $this->use_encryption = true; |
|
2363 | - $this->use_captcha = false; |
|
2364 | - $this->recaptcha_theme = 'light'; |
|
2365 | - $this->recaptcha_type = 'image'; |
|
2366 | - $this->recaptcha_language = 'en'; |
|
2367 | - $this->recaptcha_publickey = null; |
|
2368 | - $this->recaptcha_privatekey = null; |
|
2369 | - $this->recaptcha_width = 500; |
|
2370 | - } |
|
2371 | - |
|
2372 | - |
|
2373 | - |
|
2374 | - /** |
|
2375 | - * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2376 | - * |
|
2377 | - * @since 4.8.8.rc.019 |
|
2378 | - */ |
|
2379 | - public function do_hooks() |
|
2380 | - { |
|
2381 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2382 | - } |
|
1942 | + /** |
|
1943 | + * @var string $name |
|
1944 | + * eg EE4.1 |
|
1945 | + */ |
|
1946 | + public $name; |
|
1947 | + |
|
1948 | + /** |
|
1949 | + * @var string $address_1 |
|
1950 | + * eg 123 Onna Road |
|
1951 | + */ |
|
1952 | + public $address_1; |
|
1953 | + |
|
1954 | + /** |
|
1955 | + * @var string $address_2 |
|
1956 | + * eg PO Box 123 |
|
1957 | + */ |
|
1958 | + public $address_2; |
|
1959 | + |
|
1960 | + /** |
|
1961 | + * @var string $city |
|
1962 | + * eg Inna City |
|
1963 | + */ |
|
1964 | + public $city; |
|
1965 | + |
|
1966 | + /** |
|
1967 | + * @var int $STA_ID |
|
1968 | + * eg 4 |
|
1969 | + */ |
|
1970 | + public $STA_ID; |
|
1971 | + |
|
1972 | + /** |
|
1973 | + * @var string $CNT_ISO |
|
1974 | + * eg US |
|
1975 | + */ |
|
1976 | + public $CNT_ISO; |
|
1977 | + |
|
1978 | + /** |
|
1979 | + * @var string $zip |
|
1980 | + * eg 12345 or V1A 2B3 |
|
1981 | + */ |
|
1982 | + public $zip; |
|
1983 | + |
|
1984 | + /** |
|
1985 | + * @var string $email |
|
1986 | + * eg [email protected] |
|
1987 | + */ |
|
1988 | + public $email; |
|
1989 | + |
|
1990 | + |
|
1991 | + /** |
|
1992 | + * @var string $phone |
|
1993 | + * eg. 111-111-1111 |
|
1994 | + */ |
|
1995 | + public $phone; |
|
1996 | + |
|
1997 | + |
|
1998 | + /** |
|
1999 | + * @var string $vat |
|
2000 | + * VAT/Tax Number |
|
2001 | + */ |
|
2002 | + public $vat; |
|
2003 | + |
|
2004 | + /** |
|
2005 | + * @var string $logo_url |
|
2006 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
2007 | + */ |
|
2008 | + public $logo_url; |
|
2009 | + |
|
2010 | + |
|
2011 | + /** |
|
2012 | + * The below are all various properties for holding links to organization social network profiles |
|
2013 | + * |
|
2014 | + * @var string |
|
2015 | + */ |
|
2016 | + /** |
|
2017 | + * facebook (facebook.com/profile.name) |
|
2018 | + * |
|
2019 | + * @var string |
|
2020 | + */ |
|
2021 | + public $facebook; |
|
2022 | + |
|
2023 | + |
|
2024 | + /** |
|
2025 | + * twitter (twitter.com/twitter_handle) |
|
2026 | + * |
|
2027 | + * @var string |
|
2028 | + */ |
|
2029 | + public $twitter; |
|
2030 | + |
|
2031 | + |
|
2032 | + /** |
|
2033 | + * linkedin (linkedin.com/in/profile_name) |
|
2034 | + * |
|
2035 | + * @var string |
|
2036 | + */ |
|
2037 | + public $linkedin; |
|
2038 | + |
|
2039 | + |
|
2040 | + /** |
|
2041 | + * pinterest (www.pinterest.com/profile_name) |
|
2042 | + * |
|
2043 | + * @var string |
|
2044 | + */ |
|
2045 | + public $pinterest; |
|
2046 | + |
|
2047 | + |
|
2048 | + /** |
|
2049 | + * google+ (google.com/+profileName) |
|
2050 | + * |
|
2051 | + * @var string |
|
2052 | + */ |
|
2053 | + public $google; |
|
2054 | + |
|
2055 | + |
|
2056 | + /** |
|
2057 | + * instagram (instagram.com/handle) |
|
2058 | + * |
|
2059 | + * @var string |
|
2060 | + */ |
|
2061 | + public $instagram; |
|
2062 | + |
|
2063 | + |
|
2064 | + |
|
2065 | + /** |
|
2066 | + * class constructor |
|
2067 | + * |
|
2068 | + * @access public |
|
2069 | + */ |
|
2070 | + public function __construct() |
|
2071 | + { |
|
2072 | + // set default organization settings |
|
2073 | + $this->name = get_bloginfo('name'); |
|
2074 | + $this->address_1 = '123 Onna Road'; |
|
2075 | + $this->address_2 = 'PO Box 123'; |
|
2076 | + $this->city = 'Inna City'; |
|
2077 | + $this->STA_ID = 4; |
|
2078 | + $this->CNT_ISO = 'US'; |
|
2079 | + $this->zip = '12345'; |
|
2080 | + $this->email = get_bloginfo('admin_email'); |
|
2081 | + $this->phone = ''; |
|
2082 | + $this->vat = '123456789'; |
|
2083 | + $this->logo_url = ''; |
|
2084 | + $this->facebook = ''; |
|
2085 | + $this->twitter = ''; |
|
2086 | + $this->linkedin = ''; |
|
2087 | + $this->pinterest = ''; |
|
2088 | + $this->google = ''; |
|
2089 | + $this->instagram = ''; |
|
2090 | + } |
|
2383 | 2091 | |
2092 | +} |
|
2384 | 2093 | |
2385 | 2094 | |
2386 | - /** |
|
2387 | - * @return void |
|
2388 | - */ |
|
2389 | - public function set_default_reg_status_on_EEM_Event() |
|
2390 | - { |
|
2391 | - EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2392 | - } |
|
2393 | 2095 | |
2096 | +/** |
|
2097 | + * Class for defining what's in the EE_Config relating to currency |
|
2098 | + */ |
|
2099 | +class EE_Currency_Config extends EE_Config_Base |
|
2100 | +{ |
|
2394 | 2101 | |
2102 | + /** |
|
2103 | + * @var string $code |
|
2104 | + * eg 'US' |
|
2105 | + */ |
|
2106 | + public $code; |
|
2107 | + |
|
2108 | + /** |
|
2109 | + * @var string $name |
|
2110 | + * eg 'Dollar' |
|
2111 | + */ |
|
2112 | + public $name; |
|
2113 | + |
|
2114 | + /** |
|
2115 | + * plural name |
|
2116 | + * |
|
2117 | + * @var string $plural |
|
2118 | + * eg 'Dollars' |
|
2119 | + */ |
|
2120 | + public $plural; |
|
2121 | + |
|
2122 | + /** |
|
2123 | + * currency sign |
|
2124 | + * |
|
2125 | + * @var string $sign |
|
2126 | + * eg '$' |
|
2127 | + */ |
|
2128 | + public $sign; |
|
2129 | + |
|
2130 | + /** |
|
2131 | + * Whether the currency sign should come before the number or not |
|
2132 | + * |
|
2133 | + * @var boolean $sign_b4 |
|
2134 | + */ |
|
2135 | + public $sign_b4; |
|
2136 | + |
|
2137 | + /** |
|
2138 | + * How many digits should come after the decimal place |
|
2139 | + * |
|
2140 | + * @var int $dec_plc |
|
2141 | + */ |
|
2142 | + public $dec_plc; |
|
2143 | + |
|
2144 | + /** |
|
2145 | + * Symbol to use for decimal mark |
|
2146 | + * |
|
2147 | + * @var string $dec_mrk |
|
2148 | + * eg '.' |
|
2149 | + */ |
|
2150 | + public $dec_mrk; |
|
2151 | + |
|
2152 | + /** |
|
2153 | + * Symbol to use for thousands |
|
2154 | + * |
|
2155 | + * @var string $thsnds |
|
2156 | + * eg ',' |
|
2157 | + */ |
|
2158 | + public $thsnds; |
|
2159 | + |
|
2160 | + |
|
2161 | + |
|
2162 | + /** |
|
2163 | + * class constructor |
|
2164 | + * |
|
2165 | + * @access public |
|
2166 | + * @param string $CNT_ISO |
|
2167 | + * @throws \EE_Error |
|
2168 | + */ |
|
2169 | + public function __construct($CNT_ISO = '') |
|
2170 | + { |
|
2171 | + /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2172 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2173 | + // get country code from organization settings or use default |
|
2174 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2175 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2176 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2177 | + : ''; |
|
2178 | + // but override if requested |
|
2179 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2180 | + // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2181 | + if ( |
|
2182 | + ! empty($CNT_ISO) |
|
2183 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
2184 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2185 | + ) { |
|
2186 | + // retrieve the country settings from the db, just in case they have been customized |
|
2187 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2188 | + if ($country instanceof EE_Country) { |
|
2189 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2190 | + $this->name = $country->currency_name_single(); // Dollar |
|
2191 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2192 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2193 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2194 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2195 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2196 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2197 | + } |
|
2198 | + } |
|
2199 | + // fallback to hardcoded defaults, in case the above failed |
|
2200 | + if (empty($this->code)) { |
|
2201 | + // set default currency settings |
|
2202 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2203 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2204 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2205 | + $this->sign = '$'; // currency sign: $ |
|
2206 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2207 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2208 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2209 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2210 | + } |
|
2211 | + } |
|
2212 | +} |
|
2395 | 2213 | |
2396 | - /** |
|
2397 | - * @return boolean |
|
2398 | - */ |
|
2399 | - public function track_invalid_checkout_access() |
|
2400 | - { |
|
2401 | - return $this->track_invalid_checkout_access; |
|
2402 | - } |
|
2403 | 2214 | |
2404 | 2215 | |
2216 | +/** |
|
2217 | + * Class for defining what's in the EE_Config relating to registration settings |
|
2218 | + */ |
|
2219 | +class EE_Registration_Config extends EE_Config_Base |
|
2220 | +{ |
|
2405 | 2221 | |
2406 | - /** |
|
2407 | - * @param boolean $track_invalid_checkout_access |
|
2408 | - */ |
|
2409 | - public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2410 | - { |
|
2411 | - $this->track_invalid_checkout_access = filter_var( |
|
2412 | - $track_invalid_checkout_access, |
|
2413 | - FILTER_VALIDATE_BOOLEAN |
|
2414 | - ); |
|
2415 | - } |
|
2222 | + /** |
|
2223 | + * Default registration status |
|
2224 | + * |
|
2225 | + * @var string $default_STS_ID |
|
2226 | + * eg 'RPP' |
|
2227 | + */ |
|
2228 | + public $default_STS_ID; |
|
2229 | + |
|
2230 | + /** |
|
2231 | + * level of validation to apply to email addresses |
|
2232 | + * |
|
2233 | + * @var string $email_validation_level |
|
2234 | + * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2235 | + */ |
|
2236 | + public $email_validation_level; |
|
2237 | + |
|
2238 | + /** |
|
2239 | + * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2240 | + * |
|
2241 | + * @var boolean $show_pending_payment_options |
|
2242 | + */ |
|
2243 | + public $show_pending_payment_options; |
|
2244 | + |
|
2245 | + /** |
|
2246 | + * Whether to skip the registration confirmation page |
|
2247 | + * |
|
2248 | + * @var boolean $skip_reg_confirmation |
|
2249 | + */ |
|
2250 | + public $skip_reg_confirmation; |
|
2251 | + |
|
2252 | + /** |
|
2253 | + * an array of SPCO reg steps where: |
|
2254 | + * the keys denotes the reg step order |
|
2255 | + * each element consists of an array with the following elements: |
|
2256 | + * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2257 | + * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2258 | + * "slug" => the URL param used to trigger the reg step |
|
2259 | + * |
|
2260 | + * @var array $reg_steps |
|
2261 | + */ |
|
2262 | + public $reg_steps; |
|
2263 | + |
|
2264 | + /** |
|
2265 | + * Whether registration confirmation should be the last page of SPCO |
|
2266 | + * |
|
2267 | + * @var boolean $reg_confirmation_last |
|
2268 | + */ |
|
2269 | + public $reg_confirmation_last; |
|
2270 | + |
|
2271 | + /** |
|
2272 | + * Whether or not to enable the EE Bot Trap |
|
2273 | + * |
|
2274 | + * @var boolean $use_bot_trap |
|
2275 | + */ |
|
2276 | + public $use_bot_trap; |
|
2277 | + |
|
2278 | + /** |
|
2279 | + * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2280 | + * |
|
2281 | + * @var boolean $use_encryption |
|
2282 | + */ |
|
2283 | + public $use_encryption; |
|
2284 | + |
|
2285 | + /** |
|
2286 | + * Whether or not to use ReCaptcha |
|
2287 | + * |
|
2288 | + * @var boolean $use_captcha |
|
2289 | + */ |
|
2290 | + public $use_captcha; |
|
2291 | + |
|
2292 | + /** |
|
2293 | + * ReCaptcha Theme |
|
2294 | + * |
|
2295 | + * @var string $recaptcha_theme |
|
2296 | + * options: 'dark ', 'light' |
|
2297 | + */ |
|
2298 | + public $recaptcha_theme; |
|
2299 | + |
|
2300 | + /** |
|
2301 | + * ReCaptcha Type |
|
2302 | + * |
|
2303 | + * @var string $recaptcha_type |
|
2304 | + * options: 'audio', 'image' |
|
2305 | + */ |
|
2306 | + public $recaptcha_type; |
|
2307 | + |
|
2308 | + /** |
|
2309 | + * ReCaptcha language |
|
2310 | + * |
|
2311 | + * @var string $recaptcha_language |
|
2312 | + * eg 'en' |
|
2313 | + */ |
|
2314 | + public $recaptcha_language; |
|
2315 | + |
|
2316 | + /** |
|
2317 | + * ReCaptcha public key |
|
2318 | + * |
|
2319 | + * @var string $recaptcha_publickey |
|
2320 | + */ |
|
2321 | + public $recaptcha_publickey; |
|
2322 | + |
|
2323 | + /** |
|
2324 | + * ReCaptcha private key |
|
2325 | + * |
|
2326 | + * @var string $recaptcha_privatekey |
|
2327 | + */ |
|
2328 | + public $recaptcha_privatekey; |
|
2329 | + |
|
2330 | + /** |
|
2331 | + * ReCaptcha width |
|
2332 | + * |
|
2333 | + * @var int $recaptcha_width |
|
2334 | + * @deprecated |
|
2335 | + */ |
|
2336 | + public $recaptcha_width; |
|
2337 | + |
|
2338 | + /** |
|
2339 | + * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2340 | + * |
|
2341 | + * @var boolean $track_invalid_checkout_access |
|
2342 | + */ |
|
2343 | + protected $track_invalid_checkout_access = true; |
|
2344 | + |
|
2345 | + |
|
2346 | + |
|
2347 | + /** |
|
2348 | + * class constructor |
|
2349 | + * |
|
2350 | + * @access public |
|
2351 | + */ |
|
2352 | + public function __construct() |
|
2353 | + { |
|
2354 | + // set default registration settings |
|
2355 | + $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2356 | + $this->email_validation_level = 'wp_default'; |
|
2357 | + $this->show_pending_payment_options = true; |
|
2358 | + $this->skip_reg_confirmation = false; |
|
2359 | + $this->reg_steps = array(); |
|
2360 | + $this->reg_confirmation_last = false; |
|
2361 | + $this->use_bot_trap = true; |
|
2362 | + $this->use_encryption = true; |
|
2363 | + $this->use_captcha = false; |
|
2364 | + $this->recaptcha_theme = 'light'; |
|
2365 | + $this->recaptcha_type = 'image'; |
|
2366 | + $this->recaptcha_language = 'en'; |
|
2367 | + $this->recaptcha_publickey = null; |
|
2368 | + $this->recaptcha_privatekey = null; |
|
2369 | + $this->recaptcha_width = 500; |
|
2370 | + } |
|
2371 | + |
|
2372 | + |
|
2373 | + |
|
2374 | + /** |
|
2375 | + * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2376 | + * |
|
2377 | + * @since 4.8.8.rc.019 |
|
2378 | + */ |
|
2379 | + public function do_hooks() |
|
2380 | + { |
|
2381 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2382 | + } |
|
2383 | + |
|
2384 | + |
|
2385 | + |
|
2386 | + /** |
|
2387 | + * @return void |
|
2388 | + */ |
|
2389 | + public function set_default_reg_status_on_EEM_Event() |
|
2390 | + { |
|
2391 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2392 | + } |
|
2393 | + |
|
2394 | + |
|
2395 | + |
|
2396 | + /** |
|
2397 | + * @return boolean |
|
2398 | + */ |
|
2399 | + public function track_invalid_checkout_access() |
|
2400 | + { |
|
2401 | + return $this->track_invalid_checkout_access; |
|
2402 | + } |
|
2403 | + |
|
2404 | + |
|
2405 | + |
|
2406 | + /** |
|
2407 | + * @param boolean $track_invalid_checkout_access |
|
2408 | + */ |
|
2409 | + public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2410 | + { |
|
2411 | + $this->track_invalid_checkout_access = filter_var( |
|
2412 | + $track_invalid_checkout_access, |
|
2413 | + FILTER_VALIDATE_BOOLEAN |
|
2414 | + ); |
|
2415 | + } |
|
2416 | 2416 | |
2417 | 2417 | |
2418 | 2418 | |
@@ -2426,160 +2426,160 @@ discard block |
||
2426 | 2426 | class EE_Admin_Config extends EE_Config_Base |
2427 | 2427 | { |
2428 | 2428 | |
2429 | - /** |
|
2430 | - * @var boolean $use_personnel_manager |
|
2431 | - */ |
|
2432 | - public $use_personnel_manager; |
|
2433 | - |
|
2434 | - /** |
|
2435 | - * @var boolean $use_dashboard_widget |
|
2436 | - */ |
|
2437 | - public $use_dashboard_widget; |
|
2438 | - |
|
2439 | - /** |
|
2440 | - * @var int $events_in_dashboard |
|
2441 | - */ |
|
2442 | - public $events_in_dashboard; |
|
2443 | - |
|
2444 | - /** |
|
2445 | - * @var boolean $use_event_timezones |
|
2446 | - */ |
|
2447 | - public $use_event_timezones; |
|
2448 | - |
|
2449 | - /** |
|
2450 | - * @var boolean $use_full_logging |
|
2451 | - */ |
|
2452 | - public $use_full_logging; |
|
2453 | - |
|
2454 | - /** |
|
2455 | - * @var string $log_file_name |
|
2456 | - */ |
|
2457 | - public $log_file_name; |
|
2458 | - |
|
2459 | - /** |
|
2460 | - * @var string $debug_file_name |
|
2461 | - */ |
|
2462 | - public $debug_file_name; |
|
2463 | - |
|
2464 | - /** |
|
2465 | - * @var boolean $use_remote_logging |
|
2466 | - */ |
|
2467 | - public $use_remote_logging; |
|
2468 | - |
|
2469 | - /** |
|
2470 | - * @var string $remote_logging_url |
|
2471 | - */ |
|
2472 | - public $remote_logging_url; |
|
2473 | - |
|
2474 | - /** |
|
2475 | - * @var boolean $show_reg_footer |
|
2476 | - */ |
|
2477 | - public $show_reg_footer; |
|
2478 | - |
|
2479 | - /** |
|
2480 | - * @var string $affiliate_id |
|
2481 | - */ |
|
2482 | - public $affiliate_id; |
|
2483 | - |
|
2484 | - /** |
|
2485 | - * help tours on or off (global setting) |
|
2486 | - * |
|
2487 | - * @var boolean |
|
2488 | - */ |
|
2489 | - public $help_tour_activation; |
|
2490 | - |
|
2491 | - /** |
|
2492 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
2493 | - * but is incompatible with some server configuration errors |
|
2494 | - * if you get "500 internal server errors" during registration, try turning this on |
|
2495 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2496 | - * |
|
2497 | - * @var boolean $encode_session_data |
|
2498 | - */ |
|
2499 | - private $encode_session_data = false; |
|
2500 | - |
|
2501 | - |
|
2502 | - |
|
2503 | - /** |
|
2504 | - * class constructor |
|
2505 | - * |
|
2506 | - * @access public |
|
2507 | - */ |
|
2508 | - public function __construct() |
|
2509 | - { |
|
2510 | - // set default general admin settings |
|
2511 | - $this->use_personnel_manager = true; |
|
2512 | - $this->use_dashboard_widget = true; |
|
2513 | - $this->events_in_dashboard = 30; |
|
2514 | - $this->use_event_timezones = false; |
|
2515 | - $this->use_full_logging = false; |
|
2516 | - $this->use_remote_logging = false; |
|
2517 | - $this->remote_logging_url = null; |
|
2518 | - $this->show_reg_footer = true; |
|
2519 | - $this->affiliate_id = 'default'; |
|
2520 | - $this->help_tour_activation = true; |
|
2521 | - $this->encode_session_data = false; |
|
2522 | - } |
|
2523 | - |
|
2524 | - |
|
2525 | - |
|
2526 | - /** |
|
2527 | - * @param bool $reset |
|
2528 | - * @return string |
|
2529 | - */ |
|
2530 | - public function log_file_name($reset = false) |
|
2531 | - { |
|
2532 | - if (empty($this->log_file_name) || $reset) { |
|
2533 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2534 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2535 | - } |
|
2536 | - return $this->log_file_name; |
|
2537 | - } |
|
2538 | - |
|
2539 | - |
|
2540 | - |
|
2541 | - /** |
|
2542 | - * @param bool $reset |
|
2543 | - * @return string |
|
2544 | - */ |
|
2545 | - public function debug_file_name($reset = false) |
|
2546 | - { |
|
2547 | - if (empty($this->debug_file_name) || $reset) { |
|
2548 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2549 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2550 | - } |
|
2551 | - return $this->debug_file_name; |
|
2552 | - } |
|
2553 | - |
|
2554 | - |
|
2555 | - |
|
2556 | - /** |
|
2557 | - * @return string |
|
2558 | - */ |
|
2559 | - public function affiliate_id() |
|
2560 | - { |
|
2561 | - return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2562 | - } |
|
2563 | - |
|
2564 | - |
|
2565 | - |
|
2566 | - /** |
|
2567 | - * @return boolean |
|
2568 | - */ |
|
2569 | - public function encode_session_data() |
|
2570 | - { |
|
2571 | - return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2572 | - } |
|
2573 | - |
|
2574 | - |
|
2575 | - |
|
2576 | - /** |
|
2577 | - * @param boolean $encode_session_data |
|
2578 | - */ |
|
2579 | - public function set_encode_session_data($encode_session_data) |
|
2580 | - { |
|
2581 | - $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2582 | - } |
|
2429 | + /** |
|
2430 | + * @var boolean $use_personnel_manager |
|
2431 | + */ |
|
2432 | + public $use_personnel_manager; |
|
2433 | + |
|
2434 | + /** |
|
2435 | + * @var boolean $use_dashboard_widget |
|
2436 | + */ |
|
2437 | + public $use_dashboard_widget; |
|
2438 | + |
|
2439 | + /** |
|
2440 | + * @var int $events_in_dashboard |
|
2441 | + */ |
|
2442 | + public $events_in_dashboard; |
|
2443 | + |
|
2444 | + /** |
|
2445 | + * @var boolean $use_event_timezones |
|
2446 | + */ |
|
2447 | + public $use_event_timezones; |
|
2448 | + |
|
2449 | + /** |
|
2450 | + * @var boolean $use_full_logging |
|
2451 | + */ |
|
2452 | + public $use_full_logging; |
|
2453 | + |
|
2454 | + /** |
|
2455 | + * @var string $log_file_name |
|
2456 | + */ |
|
2457 | + public $log_file_name; |
|
2458 | + |
|
2459 | + /** |
|
2460 | + * @var string $debug_file_name |
|
2461 | + */ |
|
2462 | + public $debug_file_name; |
|
2463 | + |
|
2464 | + /** |
|
2465 | + * @var boolean $use_remote_logging |
|
2466 | + */ |
|
2467 | + public $use_remote_logging; |
|
2468 | + |
|
2469 | + /** |
|
2470 | + * @var string $remote_logging_url |
|
2471 | + */ |
|
2472 | + public $remote_logging_url; |
|
2473 | + |
|
2474 | + /** |
|
2475 | + * @var boolean $show_reg_footer |
|
2476 | + */ |
|
2477 | + public $show_reg_footer; |
|
2478 | + |
|
2479 | + /** |
|
2480 | + * @var string $affiliate_id |
|
2481 | + */ |
|
2482 | + public $affiliate_id; |
|
2483 | + |
|
2484 | + /** |
|
2485 | + * help tours on or off (global setting) |
|
2486 | + * |
|
2487 | + * @var boolean |
|
2488 | + */ |
|
2489 | + public $help_tour_activation; |
|
2490 | + |
|
2491 | + /** |
|
2492 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
2493 | + * but is incompatible with some server configuration errors |
|
2494 | + * if you get "500 internal server errors" during registration, try turning this on |
|
2495 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2496 | + * |
|
2497 | + * @var boolean $encode_session_data |
|
2498 | + */ |
|
2499 | + private $encode_session_data = false; |
|
2500 | + |
|
2501 | + |
|
2502 | + |
|
2503 | + /** |
|
2504 | + * class constructor |
|
2505 | + * |
|
2506 | + * @access public |
|
2507 | + */ |
|
2508 | + public function __construct() |
|
2509 | + { |
|
2510 | + // set default general admin settings |
|
2511 | + $this->use_personnel_manager = true; |
|
2512 | + $this->use_dashboard_widget = true; |
|
2513 | + $this->events_in_dashboard = 30; |
|
2514 | + $this->use_event_timezones = false; |
|
2515 | + $this->use_full_logging = false; |
|
2516 | + $this->use_remote_logging = false; |
|
2517 | + $this->remote_logging_url = null; |
|
2518 | + $this->show_reg_footer = true; |
|
2519 | + $this->affiliate_id = 'default'; |
|
2520 | + $this->help_tour_activation = true; |
|
2521 | + $this->encode_session_data = false; |
|
2522 | + } |
|
2523 | + |
|
2524 | + |
|
2525 | + |
|
2526 | + /** |
|
2527 | + * @param bool $reset |
|
2528 | + * @return string |
|
2529 | + */ |
|
2530 | + public function log_file_name($reset = false) |
|
2531 | + { |
|
2532 | + if (empty($this->log_file_name) || $reset) { |
|
2533 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2534 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2535 | + } |
|
2536 | + return $this->log_file_name; |
|
2537 | + } |
|
2538 | + |
|
2539 | + |
|
2540 | + |
|
2541 | + /** |
|
2542 | + * @param bool $reset |
|
2543 | + * @return string |
|
2544 | + */ |
|
2545 | + public function debug_file_name($reset = false) |
|
2546 | + { |
|
2547 | + if (empty($this->debug_file_name) || $reset) { |
|
2548 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2549 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2550 | + } |
|
2551 | + return $this->debug_file_name; |
|
2552 | + } |
|
2553 | + |
|
2554 | + |
|
2555 | + |
|
2556 | + /** |
|
2557 | + * @return string |
|
2558 | + */ |
|
2559 | + public function affiliate_id() |
|
2560 | + { |
|
2561 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2562 | + } |
|
2563 | + |
|
2564 | + |
|
2565 | + |
|
2566 | + /** |
|
2567 | + * @return boolean |
|
2568 | + */ |
|
2569 | + public function encode_session_data() |
|
2570 | + { |
|
2571 | + return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2572 | + } |
|
2573 | + |
|
2574 | + |
|
2575 | + |
|
2576 | + /** |
|
2577 | + * @param boolean $encode_session_data |
|
2578 | + */ |
|
2579 | + public function set_encode_session_data($encode_session_data) |
|
2580 | + { |
|
2581 | + $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2582 | + } |
|
2583 | 2583 | |
2584 | 2584 | |
2585 | 2585 | |
@@ -2593,71 +2593,71 @@ discard block |
||
2593 | 2593 | class EE_Template_Config extends EE_Config_Base |
2594 | 2594 | { |
2595 | 2595 | |
2596 | - /** |
|
2597 | - * @var boolean $enable_default_style |
|
2598 | - */ |
|
2599 | - public $enable_default_style; |
|
2600 | - |
|
2601 | - /** |
|
2602 | - * @var string $custom_style_sheet |
|
2603 | - */ |
|
2604 | - public $custom_style_sheet; |
|
2605 | - |
|
2606 | - /** |
|
2607 | - * @var boolean $display_address_in_regform |
|
2608 | - */ |
|
2609 | - public $display_address_in_regform; |
|
2610 | - |
|
2611 | - /** |
|
2612 | - * @var int $display_description_on_multi_reg_page |
|
2613 | - */ |
|
2614 | - public $display_description_on_multi_reg_page; |
|
2615 | - |
|
2616 | - /** |
|
2617 | - * @var boolean $use_custom_templates |
|
2618 | - */ |
|
2619 | - public $use_custom_templates; |
|
2620 | - |
|
2621 | - /** |
|
2622 | - * @var string $current_espresso_theme |
|
2623 | - */ |
|
2624 | - public $current_espresso_theme; |
|
2625 | - |
|
2626 | - /** |
|
2627 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2628 | - */ |
|
2629 | - public $EED_Ticket_Selector; |
|
2630 | - |
|
2631 | - /** |
|
2632 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
2633 | - */ |
|
2634 | - public $EED_Event_Single; |
|
2635 | - |
|
2636 | - /** |
|
2637 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2638 | - */ |
|
2639 | - public $EED_Events_Archive; |
|
2640 | - |
|
2641 | - |
|
2642 | - |
|
2643 | - /** |
|
2644 | - * class constructor |
|
2645 | - * |
|
2646 | - * @access public |
|
2647 | - */ |
|
2648 | - public function __construct() |
|
2649 | - { |
|
2650 | - // set default template settings |
|
2651 | - $this->enable_default_style = true; |
|
2652 | - $this->custom_style_sheet = null; |
|
2653 | - $this->display_address_in_regform = true; |
|
2654 | - $this->display_description_on_multi_reg_page = false; |
|
2655 | - $this->use_custom_templates = false; |
|
2656 | - $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2657 | - $this->EED_Event_Single = null; |
|
2658 | - $this->EED_Events_Archive = null; |
|
2659 | - $this->EED_Ticket_Selector = null; |
|
2660 | - } |
|
2596 | + /** |
|
2597 | + * @var boolean $enable_default_style |
|
2598 | + */ |
|
2599 | + public $enable_default_style; |
|
2600 | + |
|
2601 | + /** |
|
2602 | + * @var string $custom_style_sheet |
|
2603 | + */ |
|
2604 | + public $custom_style_sheet; |
|
2605 | + |
|
2606 | + /** |
|
2607 | + * @var boolean $display_address_in_regform |
|
2608 | + */ |
|
2609 | + public $display_address_in_regform; |
|
2610 | + |
|
2611 | + /** |
|
2612 | + * @var int $display_description_on_multi_reg_page |
|
2613 | + */ |
|
2614 | + public $display_description_on_multi_reg_page; |
|
2615 | + |
|
2616 | + /** |
|
2617 | + * @var boolean $use_custom_templates |
|
2618 | + */ |
|
2619 | + public $use_custom_templates; |
|
2620 | + |
|
2621 | + /** |
|
2622 | + * @var string $current_espresso_theme |
|
2623 | + */ |
|
2624 | + public $current_espresso_theme; |
|
2625 | + |
|
2626 | + /** |
|
2627 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2628 | + */ |
|
2629 | + public $EED_Ticket_Selector; |
|
2630 | + |
|
2631 | + /** |
|
2632 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
2633 | + */ |
|
2634 | + public $EED_Event_Single; |
|
2635 | + |
|
2636 | + /** |
|
2637 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2638 | + */ |
|
2639 | + public $EED_Events_Archive; |
|
2640 | + |
|
2641 | + |
|
2642 | + |
|
2643 | + /** |
|
2644 | + * class constructor |
|
2645 | + * |
|
2646 | + * @access public |
|
2647 | + */ |
|
2648 | + public function __construct() |
|
2649 | + { |
|
2650 | + // set default template settings |
|
2651 | + $this->enable_default_style = true; |
|
2652 | + $this->custom_style_sheet = null; |
|
2653 | + $this->display_address_in_regform = true; |
|
2654 | + $this->display_description_on_multi_reg_page = false; |
|
2655 | + $this->use_custom_templates = false; |
|
2656 | + $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2657 | + $this->EED_Event_Single = null; |
|
2658 | + $this->EED_Events_Archive = null; |
|
2659 | + $this->EED_Ticket_Selector = null; |
|
2660 | + } |
|
2661 | 2661 | |
2662 | 2662 | } |
2663 | 2663 | |
@@ -2669,115 +2669,115 @@ discard block |
||
2669 | 2669 | class EE_Map_Config extends EE_Config_Base |
2670 | 2670 | { |
2671 | 2671 | |
2672 | - /** |
|
2673 | - * @var boolean $use_google_maps |
|
2674 | - */ |
|
2675 | - public $use_google_maps; |
|
2676 | - |
|
2677 | - /** |
|
2678 | - * @var string $api_key |
|
2679 | - */ |
|
2680 | - public $google_map_api_key; |
|
2681 | - |
|
2682 | - /** |
|
2683 | - * @var int $event_details_map_width |
|
2684 | - */ |
|
2685 | - public $event_details_map_width; |
|
2686 | - |
|
2687 | - /** |
|
2688 | - * @var int $event_details_map_height |
|
2689 | - */ |
|
2690 | - public $event_details_map_height; |
|
2691 | - |
|
2692 | - /** |
|
2693 | - * @var int $event_details_map_zoom |
|
2694 | - */ |
|
2695 | - public $event_details_map_zoom; |
|
2696 | - |
|
2697 | - /** |
|
2698 | - * @var boolean $event_details_display_nav |
|
2699 | - */ |
|
2700 | - public $event_details_display_nav; |
|
2701 | - |
|
2702 | - /** |
|
2703 | - * @var boolean $event_details_nav_size |
|
2704 | - */ |
|
2705 | - public $event_details_nav_size; |
|
2706 | - |
|
2707 | - /** |
|
2708 | - * @var string $event_details_control_type |
|
2709 | - */ |
|
2710 | - public $event_details_control_type; |
|
2711 | - |
|
2712 | - /** |
|
2713 | - * @var string $event_details_map_align |
|
2714 | - */ |
|
2715 | - public $event_details_map_align; |
|
2716 | - |
|
2717 | - /** |
|
2718 | - * @var int $event_list_map_width |
|
2719 | - */ |
|
2720 | - public $event_list_map_width; |
|
2721 | - |
|
2722 | - /** |
|
2723 | - * @var int $event_list_map_height |
|
2724 | - */ |
|
2725 | - public $event_list_map_height; |
|
2726 | - |
|
2727 | - /** |
|
2728 | - * @var int $event_list_map_zoom |
|
2729 | - */ |
|
2730 | - public $event_list_map_zoom; |
|
2731 | - |
|
2732 | - /** |
|
2733 | - * @var boolean $event_list_display_nav |
|
2734 | - */ |
|
2735 | - public $event_list_display_nav; |
|
2736 | - |
|
2737 | - /** |
|
2738 | - * @var boolean $event_list_nav_size |
|
2739 | - */ |
|
2740 | - public $event_list_nav_size; |
|
2741 | - |
|
2742 | - /** |
|
2743 | - * @var string $event_list_control_type |
|
2744 | - */ |
|
2745 | - public $event_list_control_type; |
|
2746 | - |
|
2747 | - /** |
|
2748 | - * @var string $event_list_map_align |
|
2749 | - */ |
|
2750 | - public $event_list_map_align; |
|
2751 | - |
|
2752 | - |
|
2753 | - |
|
2754 | - /** |
|
2755 | - * class constructor |
|
2756 | - * |
|
2757 | - * @access public |
|
2758 | - */ |
|
2759 | - public function __construct() |
|
2760 | - { |
|
2761 | - // set default map settings |
|
2762 | - $this->use_google_maps = true; |
|
2763 | - $this->google_map_api_key = ''; |
|
2764 | - // for event details pages (reg page) |
|
2765 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2766 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2767 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2768 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2769 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2770 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2771 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2772 | - // for event list pages |
|
2773 | - $this->event_list_map_width = 300; // ee_map_width |
|
2774 | - $this->event_list_map_height = 185; // ee_map_height |
|
2775 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2776 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2777 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2778 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2779 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2780 | - } |
|
2672 | + /** |
|
2673 | + * @var boolean $use_google_maps |
|
2674 | + */ |
|
2675 | + public $use_google_maps; |
|
2676 | + |
|
2677 | + /** |
|
2678 | + * @var string $api_key |
|
2679 | + */ |
|
2680 | + public $google_map_api_key; |
|
2681 | + |
|
2682 | + /** |
|
2683 | + * @var int $event_details_map_width |
|
2684 | + */ |
|
2685 | + public $event_details_map_width; |
|
2686 | + |
|
2687 | + /** |
|
2688 | + * @var int $event_details_map_height |
|
2689 | + */ |
|
2690 | + public $event_details_map_height; |
|
2691 | + |
|
2692 | + /** |
|
2693 | + * @var int $event_details_map_zoom |
|
2694 | + */ |
|
2695 | + public $event_details_map_zoom; |
|
2696 | + |
|
2697 | + /** |
|
2698 | + * @var boolean $event_details_display_nav |
|
2699 | + */ |
|
2700 | + public $event_details_display_nav; |
|
2701 | + |
|
2702 | + /** |
|
2703 | + * @var boolean $event_details_nav_size |
|
2704 | + */ |
|
2705 | + public $event_details_nav_size; |
|
2706 | + |
|
2707 | + /** |
|
2708 | + * @var string $event_details_control_type |
|
2709 | + */ |
|
2710 | + public $event_details_control_type; |
|
2711 | + |
|
2712 | + /** |
|
2713 | + * @var string $event_details_map_align |
|
2714 | + */ |
|
2715 | + public $event_details_map_align; |
|
2716 | + |
|
2717 | + /** |
|
2718 | + * @var int $event_list_map_width |
|
2719 | + */ |
|
2720 | + public $event_list_map_width; |
|
2721 | + |
|
2722 | + /** |
|
2723 | + * @var int $event_list_map_height |
|
2724 | + */ |
|
2725 | + public $event_list_map_height; |
|
2726 | + |
|
2727 | + /** |
|
2728 | + * @var int $event_list_map_zoom |
|
2729 | + */ |
|
2730 | + public $event_list_map_zoom; |
|
2731 | + |
|
2732 | + /** |
|
2733 | + * @var boolean $event_list_display_nav |
|
2734 | + */ |
|
2735 | + public $event_list_display_nav; |
|
2736 | + |
|
2737 | + /** |
|
2738 | + * @var boolean $event_list_nav_size |
|
2739 | + */ |
|
2740 | + public $event_list_nav_size; |
|
2741 | + |
|
2742 | + /** |
|
2743 | + * @var string $event_list_control_type |
|
2744 | + */ |
|
2745 | + public $event_list_control_type; |
|
2746 | + |
|
2747 | + /** |
|
2748 | + * @var string $event_list_map_align |
|
2749 | + */ |
|
2750 | + public $event_list_map_align; |
|
2751 | + |
|
2752 | + |
|
2753 | + |
|
2754 | + /** |
|
2755 | + * class constructor |
|
2756 | + * |
|
2757 | + * @access public |
|
2758 | + */ |
|
2759 | + public function __construct() |
|
2760 | + { |
|
2761 | + // set default map settings |
|
2762 | + $this->use_google_maps = true; |
|
2763 | + $this->google_map_api_key = ''; |
|
2764 | + // for event details pages (reg page) |
|
2765 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2766 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2767 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2768 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2769 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2770 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2771 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2772 | + // for event list pages |
|
2773 | + $this->event_list_map_width = 300; // ee_map_width |
|
2774 | + $this->event_list_map_height = 185; // ee_map_height |
|
2775 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2776 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2777 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2778 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2779 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2780 | + } |
|
2781 | 2781 | |
2782 | 2782 | } |
2783 | 2783 | |
@@ -2789,47 +2789,47 @@ discard block |
||
2789 | 2789 | class EE_Events_Archive_Config extends EE_Config_Base |
2790 | 2790 | { |
2791 | 2791 | |
2792 | - public $display_status_banner; |
|
2792 | + public $display_status_banner; |
|
2793 | 2793 | |
2794 | - public $display_description; |
|
2794 | + public $display_description; |
|
2795 | 2795 | |
2796 | - public $display_ticket_selector; |
|
2796 | + public $display_ticket_selector; |
|
2797 | 2797 | |
2798 | - public $display_datetimes; |
|
2798 | + public $display_datetimes; |
|
2799 | 2799 | |
2800 | - public $display_venue; |
|
2800 | + public $display_venue; |
|
2801 | 2801 | |
2802 | - public $display_expired_events; |
|
2802 | + public $display_expired_events; |
|
2803 | 2803 | |
2804 | - public $use_sortable_display_order; |
|
2804 | + public $use_sortable_display_order; |
|
2805 | 2805 | |
2806 | - public $display_order_tickets; |
|
2806 | + public $display_order_tickets; |
|
2807 | 2807 | |
2808 | - public $display_order_datetimes; |
|
2808 | + public $display_order_datetimes; |
|
2809 | 2809 | |
2810 | - public $display_order_event; |
|
2810 | + public $display_order_event; |
|
2811 | 2811 | |
2812 | - public $display_order_venue; |
|
2812 | + public $display_order_venue; |
|
2813 | 2813 | |
2814 | 2814 | |
2815 | 2815 | |
2816 | - /** |
|
2817 | - * class constructor |
|
2818 | - */ |
|
2819 | - public function __construct() |
|
2820 | - { |
|
2821 | - $this->display_status_banner = 0; |
|
2822 | - $this->display_description = 1; |
|
2823 | - $this->display_ticket_selector = 0; |
|
2824 | - $this->display_datetimes = 1; |
|
2825 | - $this->display_venue = 0; |
|
2826 | - $this->display_expired_events = 0; |
|
2827 | - $this->use_sortable_display_order = false; |
|
2828 | - $this->display_order_tickets = 100; |
|
2829 | - $this->display_order_datetimes = 110; |
|
2830 | - $this->display_order_event = 120; |
|
2831 | - $this->display_order_venue = 130; |
|
2832 | - } |
|
2816 | + /** |
|
2817 | + * class constructor |
|
2818 | + */ |
|
2819 | + public function __construct() |
|
2820 | + { |
|
2821 | + $this->display_status_banner = 0; |
|
2822 | + $this->display_description = 1; |
|
2823 | + $this->display_ticket_selector = 0; |
|
2824 | + $this->display_datetimes = 1; |
|
2825 | + $this->display_venue = 0; |
|
2826 | + $this->display_expired_events = 0; |
|
2827 | + $this->use_sortable_display_order = false; |
|
2828 | + $this->display_order_tickets = 100; |
|
2829 | + $this->display_order_datetimes = 110; |
|
2830 | + $this->display_order_event = 120; |
|
2831 | + $this->display_order_venue = 130; |
|
2832 | + } |
|
2833 | 2833 | } |
2834 | 2834 | |
2835 | 2835 | |
@@ -2840,35 +2840,35 @@ discard block |
||
2840 | 2840 | class EE_Event_Single_Config extends EE_Config_Base |
2841 | 2841 | { |
2842 | 2842 | |
2843 | - public $display_status_banner_single; |
|
2843 | + public $display_status_banner_single; |
|
2844 | 2844 | |
2845 | - public $display_venue; |
|
2845 | + public $display_venue; |
|
2846 | 2846 | |
2847 | - public $use_sortable_display_order; |
|
2847 | + public $use_sortable_display_order; |
|
2848 | 2848 | |
2849 | - public $display_order_tickets; |
|
2849 | + public $display_order_tickets; |
|
2850 | 2850 | |
2851 | - public $display_order_datetimes; |
|
2851 | + public $display_order_datetimes; |
|
2852 | 2852 | |
2853 | - public $display_order_event; |
|
2853 | + public $display_order_event; |
|
2854 | 2854 | |
2855 | - public $display_order_venue; |
|
2855 | + public $display_order_venue; |
|
2856 | 2856 | |
2857 | 2857 | |
2858 | 2858 | |
2859 | - /** |
|
2860 | - * class constructor |
|
2861 | - */ |
|
2862 | - public function __construct() |
|
2863 | - { |
|
2864 | - $this->display_status_banner_single = 0; |
|
2865 | - $this->display_venue = 1; |
|
2866 | - $this->use_sortable_display_order = false; |
|
2867 | - $this->display_order_tickets = 100; |
|
2868 | - $this->display_order_datetimes = 110; |
|
2869 | - $this->display_order_event = 120; |
|
2870 | - $this->display_order_venue = 130; |
|
2871 | - } |
|
2859 | + /** |
|
2860 | + * class constructor |
|
2861 | + */ |
|
2862 | + public function __construct() |
|
2863 | + { |
|
2864 | + $this->display_status_banner_single = 0; |
|
2865 | + $this->display_venue = 1; |
|
2866 | + $this->use_sortable_display_order = false; |
|
2867 | + $this->display_order_tickets = 100; |
|
2868 | + $this->display_order_datetimes = 110; |
|
2869 | + $this->display_order_event = 120; |
|
2870 | + $this->display_order_venue = 130; |
|
2871 | + } |
|
2872 | 2872 | } |
2873 | 2873 | |
2874 | 2874 | |
@@ -2879,152 +2879,152 @@ discard block |
||
2879 | 2879 | class EE_Ticket_Selector_Config extends EE_Config_Base |
2880 | 2880 | { |
2881 | 2881 | |
2882 | - /** |
|
2883 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2884 | - */ |
|
2885 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2886 | - |
|
2887 | - /** |
|
2888 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2889 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2890 | - */ |
|
2891 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2892 | - |
|
2893 | - /** |
|
2894 | - * @var boolean $show_ticket_sale_columns |
|
2895 | - */ |
|
2896 | - public $show_ticket_sale_columns; |
|
2897 | - |
|
2898 | - /** |
|
2899 | - * @var boolean $show_ticket_details |
|
2900 | - */ |
|
2901 | - public $show_ticket_details; |
|
2902 | - |
|
2903 | - /** |
|
2904 | - * @var boolean $show_expired_tickets |
|
2905 | - */ |
|
2906 | - public $show_expired_tickets; |
|
2907 | - |
|
2908 | - /** |
|
2909 | - * whether or not to display a dropdown box populated with event datetimes |
|
2910 | - * that toggles which tickets are displayed for a ticket selector. |
|
2911 | - * uses one of the *_DATETIME_SELECTOR constants defined above |
|
2912 | - * |
|
2913 | - * @var string $show_datetime_selector |
|
2914 | - */ |
|
2915 | - private $show_datetime_selector = 'no_datetime_selector'; |
|
2916 | - |
|
2917 | - /** |
|
2918 | - * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
2919 | - * |
|
2920 | - * @var int $datetime_selector_threshold |
|
2921 | - */ |
|
2922 | - private $datetime_selector_threshold = 3; |
|
2923 | - |
|
2924 | - |
|
2925 | - |
|
2926 | - /** |
|
2927 | - * class constructor |
|
2928 | - */ |
|
2929 | - public function __construct() |
|
2930 | - { |
|
2931 | - $this->show_ticket_sale_columns = true; |
|
2932 | - $this->show_ticket_details = true; |
|
2933 | - $this->show_expired_tickets = true; |
|
2934 | - $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
2935 | - $this->datetime_selector_threshold = 3; |
|
2936 | - } |
|
2937 | - |
|
2938 | - |
|
2939 | - |
|
2940 | - /** |
|
2941 | - * returns true if a datetime selector should be displayed |
|
2942 | - * |
|
2943 | - * @param array $datetimes |
|
2944 | - * @return bool |
|
2945 | - */ |
|
2946 | - public function showDatetimeSelector(array $datetimes) |
|
2947 | - { |
|
2948 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2949 | - return ! ( |
|
2950 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
2951 | - || ( |
|
2952 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
2953 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
2954 | - ) |
|
2955 | - ); |
|
2956 | - } |
|
2957 | - |
|
2958 | - |
|
2959 | - |
|
2960 | - /** |
|
2961 | - * @return string |
|
2962 | - */ |
|
2963 | - public function getShowDatetimeSelector() |
|
2964 | - { |
|
2965 | - return $this->show_datetime_selector; |
|
2966 | - } |
|
2967 | - |
|
2968 | - |
|
2969 | - |
|
2970 | - /** |
|
2971 | - * @param bool $keys_only |
|
2972 | - * @return array |
|
2973 | - */ |
|
2974 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
2975 | - { |
|
2976 | - return $keys_only |
|
2977 | - ? array( |
|
2978 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
2979 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
2980 | - ) |
|
2981 | - : array( |
|
2982 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2983 | - 'Do not show date & time filter', 'event_espresso' |
|
2984 | - ), |
|
2985 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2986 | - 'Maybe show date & time filter', 'event_espresso' |
|
2987 | - ), |
|
2988 | - ); |
|
2989 | - } |
|
2990 | - |
|
2991 | - |
|
2992 | - |
|
2993 | - /** |
|
2994 | - * @param string $show_datetime_selector |
|
2995 | - */ |
|
2996 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
2997 | - { |
|
2998 | - $this->show_datetime_selector = in_array( |
|
2999 | - $show_datetime_selector, |
|
3000 | - $this->getShowDatetimeSelectorOptions(), |
|
3001 | - true |
|
3002 | - ) |
|
3003 | - ? $show_datetime_selector |
|
3004 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3005 | - } |
|
3006 | - |
|
3007 | - |
|
3008 | - |
|
3009 | - /** |
|
3010 | - * @return int |
|
3011 | - */ |
|
3012 | - public function getDatetimeSelectorThreshold() |
|
3013 | - { |
|
3014 | - return $this->datetime_selector_threshold; |
|
3015 | - } |
|
3016 | - |
|
3017 | - |
|
3018 | - |
|
3019 | - |
|
3020 | - /** |
|
3021 | - * @param int $datetime_selector_threshold |
|
3022 | - */ |
|
3023 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3024 | - { |
|
3025 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3026 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3027 | - } |
|
2882 | + /** |
|
2883 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2884 | + */ |
|
2885 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2886 | + |
|
2887 | + /** |
|
2888 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2889 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2890 | + */ |
|
2891 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2892 | + |
|
2893 | + /** |
|
2894 | + * @var boolean $show_ticket_sale_columns |
|
2895 | + */ |
|
2896 | + public $show_ticket_sale_columns; |
|
2897 | + |
|
2898 | + /** |
|
2899 | + * @var boolean $show_ticket_details |
|
2900 | + */ |
|
2901 | + public $show_ticket_details; |
|
2902 | + |
|
2903 | + /** |
|
2904 | + * @var boolean $show_expired_tickets |
|
2905 | + */ |
|
2906 | + public $show_expired_tickets; |
|
2907 | + |
|
2908 | + /** |
|
2909 | + * whether or not to display a dropdown box populated with event datetimes |
|
2910 | + * that toggles which tickets are displayed for a ticket selector. |
|
2911 | + * uses one of the *_DATETIME_SELECTOR constants defined above |
|
2912 | + * |
|
2913 | + * @var string $show_datetime_selector |
|
2914 | + */ |
|
2915 | + private $show_datetime_selector = 'no_datetime_selector'; |
|
2916 | + |
|
2917 | + /** |
|
2918 | + * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
2919 | + * |
|
2920 | + * @var int $datetime_selector_threshold |
|
2921 | + */ |
|
2922 | + private $datetime_selector_threshold = 3; |
|
2923 | + |
|
2924 | + |
|
2925 | + |
|
2926 | + /** |
|
2927 | + * class constructor |
|
2928 | + */ |
|
2929 | + public function __construct() |
|
2930 | + { |
|
2931 | + $this->show_ticket_sale_columns = true; |
|
2932 | + $this->show_ticket_details = true; |
|
2933 | + $this->show_expired_tickets = true; |
|
2934 | + $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
2935 | + $this->datetime_selector_threshold = 3; |
|
2936 | + } |
|
2937 | + |
|
2938 | + |
|
2939 | + |
|
2940 | + /** |
|
2941 | + * returns true if a datetime selector should be displayed |
|
2942 | + * |
|
2943 | + * @param array $datetimes |
|
2944 | + * @return bool |
|
2945 | + */ |
|
2946 | + public function showDatetimeSelector(array $datetimes) |
|
2947 | + { |
|
2948 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2949 | + return ! ( |
|
2950 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
2951 | + || ( |
|
2952 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
2953 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
2954 | + ) |
|
2955 | + ); |
|
2956 | + } |
|
2957 | + |
|
2958 | + |
|
2959 | + |
|
2960 | + /** |
|
2961 | + * @return string |
|
2962 | + */ |
|
2963 | + public function getShowDatetimeSelector() |
|
2964 | + { |
|
2965 | + return $this->show_datetime_selector; |
|
2966 | + } |
|
2967 | + |
|
2968 | + |
|
2969 | + |
|
2970 | + /** |
|
2971 | + * @param bool $keys_only |
|
2972 | + * @return array |
|
2973 | + */ |
|
2974 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
2975 | + { |
|
2976 | + return $keys_only |
|
2977 | + ? array( |
|
2978 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
2979 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
2980 | + ) |
|
2981 | + : array( |
|
2982 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2983 | + 'Do not show date & time filter', 'event_espresso' |
|
2984 | + ), |
|
2985 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2986 | + 'Maybe show date & time filter', 'event_espresso' |
|
2987 | + ), |
|
2988 | + ); |
|
2989 | + } |
|
2990 | + |
|
2991 | + |
|
2992 | + |
|
2993 | + /** |
|
2994 | + * @param string $show_datetime_selector |
|
2995 | + */ |
|
2996 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
2997 | + { |
|
2998 | + $this->show_datetime_selector = in_array( |
|
2999 | + $show_datetime_selector, |
|
3000 | + $this->getShowDatetimeSelectorOptions(), |
|
3001 | + true |
|
3002 | + ) |
|
3003 | + ? $show_datetime_selector |
|
3004 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3005 | + } |
|
3006 | + |
|
3007 | + |
|
3008 | + |
|
3009 | + /** |
|
3010 | + * @return int |
|
3011 | + */ |
|
3012 | + public function getDatetimeSelectorThreshold() |
|
3013 | + { |
|
3014 | + return $this->datetime_selector_threshold; |
|
3015 | + } |
|
3016 | + |
|
3017 | + |
|
3018 | + |
|
3019 | + |
|
3020 | + /** |
|
3021 | + * @param int $datetime_selector_threshold |
|
3022 | + */ |
|
3023 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3024 | + { |
|
3025 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3026 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3027 | + } |
|
3028 | 3028 | |
3029 | 3029 | |
3030 | 3030 | |
@@ -3042,85 +3042,85 @@ discard block |
||
3042 | 3042 | class EE_Environment_Config extends EE_Config_Base |
3043 | 3043 | { |
3044 | 3044 | |
3045 | - /** |
|
3046 | - * Hold any php environment variables that we want to track. |
|
3047 | - * |
|
3048 | - * @var stdClass; |
|
3049 | - */ |
|
3050 | - public $php; |
|
3051 | - |
|
3052 | - |
|
3053 | - |
|
3054 | - /** |
|
3055 | - * constructor |
|
3056 | - */ |
|
3057 | - public function __construct() |
|
3058 | - { |
|
3059 | - $this->php = new stdClass(); |
|
3060 | - $this->_set_php_values(); |
|
3061 | - } |
|
3062 | - |
|
3063 | - |
|
3064 | - |
|
3065 | - /** |
|
3066 | - * This sets the php environment variables. |
|
3067 | - * |
|
3068 | - * @since 4.4.0 |
|
3069 | - * @return void |
|
3070 | - */ |
|
3071 | - protected function _set_php_values() |
|
3072 | - { |
|
3073 | - $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3074 | - $this->php->version = phpversion(); |
|
3075 | - } |
|
3076 | - |
|
3077 | - |
|
3078 | - |
|
3079 | - /** |
|
3080 | - * helper method for determining whether input_count is |
|
3081 | - * reaching the potential maximum the server can handle |
|
3082 | - * according to max_input_vars |
|
3083 | - * |
|
3084 | - * @param int $input_count the count of input vars. |
|
3085 | - * @return array { |
|
3086 | - * An array that represents whether available space and if no available space the error |
|
3087 | - * message. |
|
3088 | - * @type bool $has_space whether more inputs can be added. |
|
3089 | - * @type string $msg Any message to be displayed. |
|
3090 | - * } |
|
3091 | - */ |
|
3092 | - public function max_input_vars_limit_check($input_count = 0) |
|
3093 | - { |
|
3094 | - if ( ! empty($this->php->max_input_vars) |
|
3095 | - && ($input_count >= $this->php->max_input_vars) |
|
3096 | - && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3097 | - ) { |
|
3098 | - return sprintf( |
|
3099 | - __( |
|
3100 | - 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3101 | - 'event_espresso' |
|
3102 | - ), |
|
3103 | - '<br>', |
|
3104 | - $input_count, |
|
3105 | - $this->php->max_input_vars |
|
3106 | - ); |
|
3107 | - } else { |
|
3108 | - return ''; |
|
3109 | - } |
|
3110 | - } |
|
3111 | - |
|
3112 | - |
|
3113 | - |
|
3114 | - /** |
|
3115 | - * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3116 | - * |
|
3117 | - * @since 4.4.1 |
|
3118 | - * @return void |
|
3119 | - */ |
|
3120 | - public function recheck_values() |
|
3121 | - { |
|
3122 | - $this->_set_php_values(); |
|
3123 | - } |
|
3045 | + /** |
|
3046 | + * Hold any php environment variables that we want to track. |
|
3047 | + * |
|
3048 | + * @var stdClass; |
|
3049 | + */ |
|
3050 | + public $php; |
|
3051 | + |
|
3052 | + |
|
3053 | + |
|
3054 | + /** |
|
3055 | + * constructor |
|
3056 | + */ |
|
3057 | + public function __construct() |
|
3058 | + { |
|
3059 | + $this->php = new stdClass(); |
|
3060 | + $this->_set_php_values(); |
|
3061 | + } |
|
3062 | + |
|
3063 | + |
|
3064 | + |
|
3065 | + /** |
|
3066 | + * This sets the php environment variables. |
|
3067 | + * |
|
3068 | + * @since 4.4.0 |
|
3069 | + * @return void |
|
3070 | + */ |
|
3071 | + protected function _set_php_values() |
|
3072 | + { |
|
3073 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3074 | + $this->php->version = phpversion(); |
|
3075 | + } |
|
3076 | + |
|
3077 | + |
|
3078 | + |
|
3079 | + /** |
|
3080 | + * helper method for determining whether input_count is |
|
3081 | + * reaching the potential maximum the server can handle |
|
3082 | + * according to max_input_vars |
|
3083 | + * |
|
3084 | + * @param int $input_count the count of input vars. |
|
3085 | + * @return array { |
|
3086 | + * An array that represents whether available space and if no available space the error |
|
3087 | + * message. |
|
3088 | + * @type bool $has_space whether more inputs can be added. |
|
3089 | + * @type string $msg Any message to be displayed. |
|
3090 | + * } |
|
3091 | + */ |
|
3092 | + public function max_input_vars_limit_check($input_count = 0) |
|
3093 | + { |
|
3094 | + if ( ! empty($this->php->max_input_vars) |
|
3095 | + && ($input_count >= $this->php->max_input_vars) |
|
3096 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3097 | + ) { |
|
3098 | + return sprintf( |
|
3099 | + __( |
|
3100 | + 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3101 | + 'event_espresso' |
|
3102 | + ), |
|
3103 | + '<br>', |
|
3104 | + $input_count, |
|
3105 | + $this->php->max_input_vars |
|
3106 | + ); |
|
3107 | + } else { |
|
3108 | + return ''; |
|
3109 | + } |
|
3110 | + } |
|
3111 | + |
|
3112 | + |
|
3113 | + |
|
3114 | + /** |
|
3115 | + * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3116 | + * |
|
3117 | + * @since 4.4.1 |
|
3118 | + * @return void |
|
3119 | + */ |
|
3120 | + public function recheck_values() |
|
3121 | + { |
|
3122 | + $this->_set_php_values(); |
|
3123 | + } |
|
3124 | 3124 | |
3125 | 3125 | |
3126 | 3126 | |
@@ -3138,22 +3138,22 @@ discard block |
||
3138 | 3138 | class EE_Tax_Config extends EE_Config_Base |
3139 | 3139 | { |
3140 | 3140 | |
3141 | - /* |
|
3141 | + /* |
|
3142 | 3142 | * flag to indicate whether or not to display ticket prices with the taxes included |
3143 | 3143 | * |
3144 | 3144 | * @var boolean $prices_displayed_including_taxes |
3145 | 3145 | */ |
3146 | - public $prices_displayed_including_taxes; |
|
3146 | + public $prices_displayed_including_taxes; |
|
3147 | 3147 | |
3148 | 3148 | |
3149 | 3149 | |
3150 | - /** |
|
3151 | - * class constructor |
|
3152 | - */ |
|
3153 | - public function __construct() |
|
3154 | - { |
|
3155 | - $this->prices_displayed_including_taxes = true; |
|
3156 | - } |
|
3150 | + /** |
|
3151 | + * class constructor |
|
3152 | + */ |
|
3153 | + public function __construct() |
|
3154 | + { |
|
3155 | + $this->prices_displayed_including_taxes = true; |
|
3156 | + } |
|
3157 | 3157 | } |
3158 | 3158 | |
3159 | 3159 | |
@@ -3166,34 +3166,34 @@ discard block |
||
3166 | 3166 | class EE_Gateway_Config extends EE_Config_Base |
3167 | 3167 | { |
3168 | 3168 | |
3169 | - /** |
|
3170 | - * Array with keys that are payment gateways slugs, and values are arrays |
|
3171 | - * with any config info the gateway wants to store |
|
3172 | - * |
|
3173 | - * @var array |
|
3174 | - */ |
|
3175 | - public $payment_settings; |
|
3176 | - |
|
3177 | - /** |
|
3178 | - * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3179 | - * the gateway is stored in the uploads directory |
|
3180 | - * |
|
3181 | - * @var array |
|
3182 | - */ |
|
3183 | - public $active_gateways; |
|
3184 | - |
|
3185 | - |
|
3186 | - |
|
3187 | - /** |
|
3188 | - * class constructor |
|
3189 | - * |
|
3190 | - * @deprecated |
|
3191 | - */ |
|
3192 | - public function __construct() |
|
3193 | - { |
|
3194 | - $this->payment_settings = array(); |
|
3195 | - $this->active_gateways = array('Invoice' => false); |
|
3196 | - } |
|
3169 | + /** |
|
3170 | + * Array with keys that are payment gateways slugs, and values are arrays |
|
3171 | + * with any config info the gateway wants to store |
|
3172 | + * |
|
3173 | + * @var array |
|
3174 | + */ |
|
3175 | + public $payment_settings; |
|
3176 | + |
|
3177 | + /** |
|
3178 | + * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3179 | + * the gateway is stored in the uploads directory |
|
3180 | + * |
|
3181 | + * @var array |
|
3182 | + */ |
|
3183 | + public $active_gateways; |
|
3184 | + |
|
3185 | + |
|
3186 | + |
|
3187 | + /** |
|
3188 | + * class constructor |
|
3189 | + * |
|
3190 | + * @deprecated |
|
3191 | + */ |
|
3192 | + public function __construct() |
|
3193 | + { |
|
3194 | + $this->payment_settings = array(); |
|
3195 | + $this->active_gateways = array('Invoice' => false); |
|
3196 | + } |
|
3197 | 3197 | } |
3198 | 3198 | |
3199 | 3199 | // End of file EE_Config.core.php |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $this |
286 | 286 | ); |
287 | 287 | if (is_object($settings) && property_exists($this, $config)) { |
288 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
288 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
289 | 289 | //call configs populate method to ensure any defaults are set for empty values. |
290 | 290 | if (method_exists($settings, 'populate')) { |
291 | 291 | $this->{$config}->populate(); |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | */ |
699 | 699 | private function _generate_config_option_name($section = '', $name = '') |
700 | 700 | { |
701 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
701 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | { |
717 | 717 | return ! empty($config_class) |
718 | 718 | ? $config_class |
719 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
719 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | 'event_espresso' |
833 | 833 | ), |
834 | 834 | $config_class, |
835 | - 'EE_Config->' . $section . '->' . $name |
|
835 | + 'EE_Config->'.$section.'->'.$name |
|
836 | 836 | ), |
837 | 837 | __FILE__, |
838 | 838 | __FUNCTION__, |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | // retrieve the wp-option for this config class. |
906 | 906 | $config_option = maybe_unserialize(get_option($config_option_name, array())); |
907 | 907 | if (empty($config_option)) { |
908 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
908 | + EE_Config::log($config_option_name.'-NOT-FOUND'); |
|
909 | 909 | } |
910 | 910 | return $config_option; |
911 | 911 | } |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | //copy incoming $_REQUEST and sanitize it so we can save it |
925 | 925 | $_request = $_REQUEST; |
926 | 926 | array_walk_recursive($_request, 'sanitize_text_field'); |
927 | - $config_log[(string)microtime(true)] = array( |
|
927 | + $config_log[(string) microtime(true)] = array( |
|
928 | 928 | 'config_name' => $config_option_name, |
929 | 929 | 'request' => $_request, |
930 | 930 | ); |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | ) |
1027 | 1027 | ) { |
1028 | 1028 | // grab list of installed widgets |
1029 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1029 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
1030 | 1030 | // filter list of modules to register |
1031 | 1031 | $widgets_to_register = apply_filters( |
1032 | 1032 | 'FHEE__EE_Config__register_widgets__widgets_to_register', |
@@ -1083,31 +1083,31 @@ discard block |
||
1083 | 1083 | // create classname from widget directory name |
1084 | 1084 | $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
1085 | 1085 | // add class prefix |
1086 | - $widget_class = 'EEW_' . $widget; |
|
1086 | + $widget_class = 'EEW_'.$widget; |
|
1087 | 1087 | // does the widget exist ? |
1088 | - if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1088 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
1089 | 1089 | $msg = sprintf( |
1090 | 1090 | __( |
1091 | 1091 | 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
1092 | 1092 | 'event_espresso' |
1093 | 1093 | ), |
1094 | 1094 | $widget_class, |
1095 | - $widget_path . DS . $widget_class . $widget_ext |
|
1095 | + $widget_path.DS.$widget_class.$widget_ext |
|
1096 | 1096 | ); |
1097 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1097 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1098 | 1098 | return; |
1099 | 1099 | } |
1100 | 1100 | // load the widget class file |
1101 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1101 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
1102 | 1102 | // verify that class exists |
1103 | 1103 | if ( ! class_exists($widget_class)) { |
1104 | 1104 | $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
1105 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1105 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1106 | 1106 | return; |
1107 | 1107 | } |
1108 | 1108 | register_widget($widget_class); |
1109 | 1109 | // add to array of registered widgets |
1110 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1110 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | private function _register_modules() |
1122 | 1122 | { |
1123 | 1123 | // grab list of installed modules |
1124 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1124 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
1125 | 1125 | // filter list of modules to register |
1126 | 1126 | $modules_to_register = apply_filters( |
1127 | 1127 | 'FHEE__EE_Config__register_modules__modules_to_register', |
@@ -1132,8 +1132,8 @@ discard block |
||
1132 | 1132 | foreach ($modules_to_register as $module_path) { |
1133 | 1133 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
1134 | 1134 | if ( |
1135 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1136 | - && $module_path !== EE_MODULES . 'gateways' |
|
1135 | + $module_path !== EE_MODULES.'zzz-copy-this-module-template' |
|
1136 | + && $module_path !== EE_MODULES.'gateways' |
|
1137 | 1137 | ) { |
1138 | 1138 | // add to list of installed modules |
1139 | 1139 | EE_Config::register_module($module_path); |
@@ -1171,25 +1171,25 @@ discard block |
||
1171 | 1171 | // remove last segment |
1172 | 1172 | array_pop($module_path); |
1173 | 1173 | // glue it back together |
1174 | - $module_path = implode(DS, $module_path) . DS; |
|
1174 | + $module_path = implode(DS, $module_path).DS; |
|
1175 | 1175 | // take first segment from file name pieces and sanitize it |
1176 | 1176 | $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
1177 | 1177 | // ensure class prefix is added |
1178 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1178 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
1179 | 1179 | } else { |
1180 | 1180 | // we need to generate the filename based off of the folder name |
1181 | 1181 | // grab and sanitize module name |
1182 | 1182 | $module = strtolower(basename($module_path)); |
1183 | 1183 | $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
1184 | 1184 | // like trailingslashit() |
1185 | - $module_path = rtrim($module_path, DS) . DS; |
|
1185 | + $module_path = rtrim($module_path, DS).DS; |
|
1186 | 1186 | // create classname from module directory name |
1187 | 1187 | $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
1188 | 1188 | // add class prefix |
1189 | - $module_class = 'EED_' . $module; |
|
1189 | + $module_class = 'EED_'.$module; |
|
1190 | 1190 | } |
1191 | 1191 | // does the module exist ? |
1192 | - if ( ! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1192 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
1193 | 1193 | $msg = sprintf( |
1194 | 1194 | __( |
1195 | 1195 | 'The requested %s module file could not be found or is not readable due to file permissions.', |
@@ -1197,19 +1197,19 @@ discard block |
||
1197 | 1197 | ), |
1198 | 1198 | $module |
1199 | 1199 | ); |
1200 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1200 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1201 | 1201 | return false; |
1202 | 1202 | } |
1203 | 1203 | // load the module class file |
1204 | - require_once($module_path . $module_class . $module_ext); |
|
1204 | + require_once($module_path.$module_class.$module_ext); |
|
1205 | 1205 | // verify that class exists |
1206 | 1206 | if ( ! class_exists($module_class)) { |
1207 | 1207 | $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
1208 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1208 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1209 | 1209 | return false; |
1210 | 1210 | } |
1211 | 1211 | // add to array of registered modules |
1212 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1212 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
1213 | 1213 | do_action( |
1214 | 1214 | 'AHEE__EE_Config__register_module__complete', |
1215 | 1215 | $module_class, |
@@ -1262,26 +1262,26 @@ discard block |
||
1262 | 1262 | { |
1263 | 1263 | do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
1264 | 1264 | $module = str_replace('EED_', '', $module); |
1265 | - $module_class = 'EED_' . $module; |
|
1265 | + $module_class = 'EED_'.$module; |
|
1266 | 1266 | if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
1267 | 1267 | $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
1268 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1268 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1269 | 1269 | return false; |
1270 | 1270 | } |
1271 | 1271 | if (empty($route)) { |
1272 | 1272 | $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
1273 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1273 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1274 | 1274 | return false; |
1275 | 1275 | } |
1276 | - if ( ! method_exists('EED_' . $module, $method_name)) { |
|
1276 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
1277 | 1277 | $msg = sprintf( |
1278 | 1278 | __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
1279 | 1279 | $route |
1280 | 1280 | ); |
1281 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1281 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1282 | 1282 | return false; |
1283 | 1283 | } |
1284 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
1284 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
1285 | 1285 | return true; |
1286 | 1286 | } |
1287 | 1287 | |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | public static function get_route($route = null, $key = 'ee') |
1299 | 1299 | { |
1300 | 1300 | do_action('AHEE__EE_Config__get_route__begin', $route); |
1301 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
1301 | + $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
1302 | 1302 | if (isset(EE_Config::$_module_route_map[$key][$route])) { |
1303 | 1303 | return EE_Config::$_module_route_map[$key][$route]; |
1304 | 1304 | } |
@@ -1339,12 +1339,12 @@ discard block |
||
1339 | 1339 | __('The module route %s for this forward has not been registered.', 'event_espresso'), |
1340 | 1340 | $route |
1341 | 1341 | ); |
1342 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1342 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1343 | 1343 | return false; |
1344 | 1344 | } |
1345 | 1345 | if (empty($forward)) { |
1346 | 1346 | $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
1347 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1347 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1348 | 1348 | return false; |
1349 | 1349 | } |
1350 | 1350 | if (is_array($forward)) { |
@@ -1353,7 +1353,7 @@ discard block |
||
1353 | 1353 | __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
1354 | 1354 | $route |
1355 | 1355 | ); |
1356 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1356 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1357 | 1357 | return false; |
1358 | 1358 | } |
1359 | 1359 | if ( ! method_exists($forward[0], $forward[1])) { |
@@ -1362,7 +1362,7 @@ discard block |
||
1362 | 1362 | $forward[1], |
1363 | 1363 | $route |
1364 | 1364 | ); |
1365 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1365 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1366 | 1366 | return false; |
1367 | 1367 | } |
1368 | 1368 | } else if ( ! function_exists($forward)) { |
@@ -1371,7 +1371,7 @@ discard block |
||
1371 | 1371 | $forward, |
1372 | 1372 | $route |
1373 | 1373 | ); |
1374 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1374 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1375 | 1375 | return false; |
1376 | 1376 | } |
1377 | 1377 | EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
@@ -1426,7 +1426,7 @@ discard block |
||
1426 | 1426 | __('The module route %s for this view has not been registered.', 'event_espresso'), |
1427 | 1427 | $route |
1428 | 1428 | ); |
1429 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1429 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1430 | 1430 | return false; |
1431 | 1431 | } |
1432 | 1432 | if ( ! is_readable($view)) { |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | ), |
1438 | 1438 | $view |
1439 | 1439 | ); |
1440 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1440 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1441 | 1441 | return false; |
1442 | 1442 | } |
1443 | 1443 | EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
@@ -1787,7 +1787,7 @@ discard block |
||
1787 | 1787 | $this->reg_page_url = add_query_arg( |
1788 | 1788 | array('uts' => time()), |
1789 | 1789 | get_permalink($this->reg_page_id) |
1790 | - ) . '#checkout'; |
|
1790 | + ).'#checkout'; |
|
1791 | 1791 | } |
1792 | 1792 | return $this->reg_page_url; |
1793 | 1793 | } |
@@ -1891,13 +1891,13 @@ discard block |
||
1891 | 1891 | $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
1892 | 1892 | $option = 'ee_ueip_optin'; |
1893 | 1893 | //set correct table for query |
1894 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1894 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options'; |
|
1895 | 1895 | //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
1896 | 1896 | //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
1897 | 1897 | //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
1898 | 1898 | //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
1899 | 1899 | //for the purpose of caching. |
1900 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1900 | + $pre = apply_filters('pre_option_'.$option, false, $option); |
|
1901 | 1901 | if (false !== $pre) { |
1902 | 1902 | EE_Core_Config::$ee_ueip_option = $pre; |
1903 | 1903 | return EE_Core_Config::$ee_ueip_option; |
@@ -1907,9 +1907,9 @@ discard block |
||
1907 | 1907 | if (is_object($row)) { |
1908 | 1908 | $value = $row->option_value; |
1909 | 1909 | } else { //option does not exist so use default. |
1910 | - return apply_filters('default_option_' . $option, false, $option); |
|
1910 | + return apply_filters('default_option_'.$option, false, $option); |
|
1911 | 1911 | } |
1912 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1912 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option); |
|
1913 | 1913 | return EE_Core_Config::$ee_ueip_option; |
1914 | 1914 | } |
1915 | 1915 | |
@@ -2186,27 +2186,27 @@ discard block |
||
2186 | 2186 | // retrieve the country settings from the db, just in case they have been customized |
2187 | 2187 | $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
2188 | 2188 | if ($country instanceof EE_Country) { |
2189 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2190 | - $this->name = $country->currency_name_single(); // Dollar |
|
2191 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2192 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2193 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2194 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2195 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2196 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2189 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2190 | + $this->name = $country->currency_name_single(); // Dollar |
|
2191 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2192 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2193 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2194 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2195 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2196 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2197 | 2197 | } |
2198 | 2198 | } |
2199 | 2199 | // fallback to hardcoded defaults, in case the above failed |
2200 | 2200 | if (empty($this->code)) { |
2201 | 2201 | // set default currency settings |
2202 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2203 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2204 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2205 | - $this->sign = '$'; // currency sign: $ |
|
2206 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2207 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2208 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2209 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2202 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2203 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2204 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2205 | + $this->sign = '$'; // currency sign: $ |
|
2206 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2207 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2208 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2209 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2210 | 2210 | } |
2211 | 2211 | } |
2212 | 2212 | } |
@@ -2530,7 +2530,7 @@ discard block |
||
2530 | 2530 | public function log_file_name($reset = false) |
2531 | 2531 | { |
2532 | 2532 | if (empty($this->log_file_name) || $reset) { |
2533 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2533 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt'; |
|
2534 | 2534 | EE_Config::instance()->update_espresso_config(false, false); |
2535 | 2535 | } |
2536 | 2536 | return $this->log_file_name; |
@@ -2545,7 +2545,7 @@ discard block |
||
2545 | 2545 | public function debug_file_name($reset = false) |
2546 | 2546 | { |
2547 | 2547 | if (empty($this->debug_file_name) || $reset) { |
2548 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2548 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt'; |
|
2549 | 2549 | EE_Config::instance()->update_espresso_config(false, false); |
2550 | 2550 | } |
2551 | 2551 | return $this->debug_file_name; |
@@ -2762,21 +2762,21 @@ discard block |
||
2762 | 2762 | $this->use_google_maps = true; |
2763 | 2763 | $this->google_map_api_key = ''; |
2764 | 2764 | // for event details pages (reg page) |
2765 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2766 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2767 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2768 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2769 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2770 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2771 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2765 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2766 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2767 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2768 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2769 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2770 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2771 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2772 | 2772 | // for event list pages |
2773 | - $this->event_list_map_width = 300; // ee_map_width |
|
2774 | - $this->event_list_map_height = 185; // ee_map_height |
|
2775 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2776 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2777 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2778 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2779 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2773 | + $this->event_list_map_width = 300; // ee_map_width |
|
2774 | + $this->event_list_map_height = 185; // ee_map_height |
|
2775 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2776 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2777 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2778 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2779 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2780 | 2780 | } |
2781 | 2781 | |
2782 | 2782 | } |
@@ -16,282 +16,282 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $iframe_name |
|
21 | - */ |
|
22 | - private $iframe_name; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var string $route_name |
|
26 | - */ |
|
27 | - private $route_name; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $slug |
|
31 | - */ |
|
32 | - private $slug; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean $append_filterable_content |
|
36 | - */ |
|
37 | - private $append_filterable_content; |
|
38 | - |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * IframeEmbedButton constructor. |
|
43 | - * |
|
44 | - * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | - * @param string $route_name the name of the registered route |
|
46 | - * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | - * will most likely be "event" since that's the only usage atm |
|
48 | - */ |
|
49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
50 | - { |
|
51 | - $this->iframe_name = $iframe_name; |
|
52 | - $this->route_name = $route_name; |
|
53 | - $this->slug = $slug; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Adds an iframe embed code button to the Event editor. |
|
60 | - */ |
|
61 | - public function addEventEditorIframeEmbedButtonFilter() |
|
62 | - { |
|
63 | - // add button for iframe code to event editor. |
|
64 | - add_filter( |
|
65 | - 'get_sample_permalink_html', |
|
66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
67 | - 10, |
|
68 | - 2 |
|
69 | - ); |
|
70 | - add_action( |
|
71 | - 'admin_enqueue_scripts', |
|
72 | - array( $this, 'embedButtonAssets' ), |
|
73 | - 10 |
|
74 | - ); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param $permalink_string |
|
81 | - * @param $id |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
85 | - { |
|
86 | - return $this->eventEditorIframeEmbedButton( |
|
87 | - $permalink_string, |
|
88 | - $id |
|
89 | - ); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * iframe embed code button to the Event editor. |
|
96 | - * |
|
97 | - * @param string $permalink_string |
|
98 | - * @param int $id |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function eventEditorIframeEmbedButton( |
|
102 | - $permalink_string, |
|
103 | - $id |
|
104 | - ) { |
|
105 | - //make sure this is ONLY when editing and the event id has been set. |
|
106 | - if ( ! empty( $id ) ) { |
|
107 | - $post = get_post( $id ); |
|
108 | - //if NOT event then let's get out. |
|
109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
110 | - return $permalink_string; |
|
111 | - } |
|
112 | - $permalink_string .= $this->embedButtonHtml( |
|
113 | - array( $this->slug => $id ), |
|
114 | - 'button-small' |
|
115 | - ); |
|
116 | - } |
|
117 | - return $permalink_string; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
124 | - * |
|
125 | - * @param string $action name of the WP do_action() to hook into |
|
126 | - */ |
|
127 | - public function addActionIframeEmbedButton( $action ) |
|
128 | - { |
|
129 | - // add button for iframe code to event editor. |
|
130 | - add_action( |
|
131 | - $action, |
|
132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
133 | - 10, 2 |
|
134 | - ); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @return void |
|
141 | - */ |
|
142 | - public function addActionIframeEmbedButtonCallback() |
|
143 | - { |
|
144 | - echo $this->embedButtonHtml(); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
151 | - * |
|
152 | - * @param string $filter name of the WP apply_filters() to hook into |
|
153 | - * @param bool $append if true, will add iframe embed button to end of content, |
|
154 | - * else if false, will add to the beginning of the content |
|
155 | - */ |
|
156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
157 | - { |
|
158 | - $this->append_filterable_content = $append; |
|
159 | - // add button for iframe code to event editor. |
|
160 | - add_filter( |
|
161 | - $filter, |
|
162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
163 | - 10 |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @param array|string $filterable_content |
|
171 | - * @return array|string |
|
172 | - */ |
|
173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
174 | - { |
|
175 | - $embedButtonHtml = $this->embedButtonHtml(); |
|
176 | - if ( is_array( $filterable_content ) ) { |
|
177 | - $filterable_content = $this->append_filterable_content |
|
178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
180 | - } else { |
|
181 | - $filterable_content = $this->append_filterable_content |
|
182 | - ? $filterable_content . $embedButtonHtml |
|
183 | - : $embedButtonHtml . $filterable_content; |
|
184 | - } |
|
185 | - return $filterable_content; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * iframe_embed_html |
|
192 | - * |
|
193 | - * @param array $query_args |
|
194 | - * @param string $button_class |
|
195 | - * @return string |
|
196 | - */ |
|
197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
198 | - { |
|
199 | - // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | - $query_args = (array)apply_filters( |
|
202 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
203 | - $query_args |
|
204 | - ); |
|
205 | - // add this route to our localized vars |
|
206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
208 | - : array(); |
|
209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
211 | - $iframe_embed_html = \EEH_HTML::link( |
|
212 | - '#', |
|
213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
214 | - sprintf( |
|
215 | - esc_html__( |
|
216 | - 'click here to generate code for embedding %1$s iframe into another site.', |
|
217 | - 'event_espresso' |
|
218 | - ), |
|
219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
220 | - ), |
|
221 | - "{$this->route_name}-iframe-embed-trigger-js", |
|
222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
223 | - '', |
|
224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
225 | - ); |
|
226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | - 'display:none;' ); |
|
228 | - $iframe_embed_html .= esc_html( |
|
229 | - \EEH_HTML::div( |
|
230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
231 | - '', |
|
232 | - '', |
|
233 | - 'width:100%; height: 500px;' |
|
234 | - ) |
|
235 | - ); |
|
236 | - $iframe_embed_html .= \EEH_HTML::divx(); |
|
237 | - return $iframe_embed_html; |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * enqueue iframe button js |
|
244 | - */ |
|
245 | - public function embedButtonAssets() |
|
246 | - { |
|
247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
248 | - 'copy and paste the following into any other site\'s content to display this event:', |
|
249 | - 'event_espresso' |
|
250 | - ); |
|
251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
252 | - 'click anywhere outside of this window to close it.', |
|
253 | - 'event_espresso' |
|
254 | - ); |
|
255 | - wp_register_script( |
|
256 | - 'iframe_embed_button', |
|
257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | - array( 'ee-dialog' ), |
|
259 | - EVENT_ESPRESSO_VERSION, |
|
260 | - true |
|
261 | - ); |
|
262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * generates embed button sections for admin pages |
|
269 | - * |
|
270 | - * @param array $embed_buttons |
|
271 | - * @return string |
|
272 | - */ |
|
273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
274 | - { |
|
275 | - $embed_buttons = (array)apply_filters( |
|
276 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
277 | - $embed_buttons |
|
278 | - ); |
|
279 | - if ( empty($embed_buttons)) { |
|
280 | - return ''; |
|
281 | - } |
|
282 | - // add button for iframe code to event editor. |
|
283 | - $html = \EEH_HTML::br( 2 ); |
|
284 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
285 | - $html .= \EEH_HTML::p( |
|
286 | - esc_html__( |
|
287 | - 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
288 | - 'event_espresso' |
|
289 | - ) |
|
290 | - ); |
|
291 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
292 | - $html .= \EEH_HTML::br( 2 ); |
|
293 | - return $html; |
|
294 | - } |
|
19 | + /** |
|
20 | + * @var string $iframe_name |
|
21 | + */ |
|
22 | + private $iframe_name; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var string $route_name |
|
26 | + */ |
|
27 | + private $route_name; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $slug |
|
31 | + */ |
|
32 | + private $slug; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean $append_filterable_content |
|
36 | + */ |
|
37 | + private $append_filterable_content; |
|
38 | + |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * IframeEmbedButton constructor. |
|
43 | + * |
|
44 | + * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | + * @param string $route_name the name of the registered route |
|
46 | + * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | + * will most likely be "event" since that's the only usage atm |
|
48 | + */ |
|
49 | + public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
50 | + { |
|
51 | + $this->iframe_name = $iframe_name; |
|
52 | + $this->route_name = $route_name; |
|
53 | + $this->slug = $slug; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Adds an iframe embed code button to the Event editor. |
|
60 | + */ |
|
61 | + public function addEventEditorIframeEmbedButtonFilter() |
|
62 | + { |
|
63 | + // add button for iframe code to event editor. |
|
64 | + add_filter( |
|
65 | + 'get_sample_permalink_html', |
|
66 | + array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
67 | + 10, |
|
68 | + 2 |
|
69 | + ); |
|
70 | + add_action( |
|
71 | + 'admin_enqueue_scripts', |
|
72 | + array( $this, 'embedButtonAssets' ), |
|
73 | + 10 |
|
74 | + ); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param $permalink_string |
|
81 | + * @param $id |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
85 | + { |
|
86 | + return $this->eventEditorIframeEmbedButton( |
|
87 | + $permalink_string, |
|
88 | + $id |
|
89 | + ); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * iframe embed code button to the Event editor. |
|
96 | + * |
|
97 | + * @param string $permalink_string |
|
98 | + * @param int $id |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function eventEditorIframeEmbedButton( |
|
102 | + $permalink_string, |
|
103 | + $id |
|
104 | + ) { |
|
105 | + //make sure this is ONLY when editing and the event id has been set. |
|
106 | + if ( ! empty( $id ) ) { |
|
107 | + $post = get_post( $id ); |
|
108 | + //if NOT event then let's get out. |
|
109 | + if ( $post->post_type !== 'espresso_events' ) { |
|
110 | + return $permalink_string; |
|
111 | + } |
|
112 | + $permalink_string .= $this->embedButtonHtml( |
|
113 | + array( $this->slug => $id ), |
|
114 | + 'button-small' |
|
115 | + ); |
|
116 | + } |
|
117 | + return $permalink_string; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
124 | + * |
|
125 | + * @param string $action name of the WP do_action() to hook into |
|
126 | + */ |
|
127 | + public function addActionIframeEmbedButton( $action ) |
|
128 | + { |
|
129 | + // add button for iframe code to event editor. |
|
130 | + add_action( |
|
131 | + $action, |
|
132 | + array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
133 | + 10, 2 |
|
134 | + ); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @return void |
|
141 | + */ |
|
142 | + public function addActionIframeEmbedButtonCallback() |
|
143 | + { |
|
144 | + echo $this->embedButtonHtml(); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
151 | + * |
|
152 | + * @param string $filter name of the WP apply_filters() to hook into |
|
153 | + * @param bool $append if true, will add iframe embed button to end of content, |
|
154 | + * else if false, will add to the beginning of the content |
|
155 | + */ |
|
156 | + public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
157 | + { |
|
158 | + $this->append_filterable_content = $append; |
|
159 | + // add button for iframe code to event editor. |
|
160 | + add_filter( |
|
161 | + $filter, |
|
162 | + array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
163 | + 10 |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @param array|string $filterable_content |
|
171 | + * @return array|string |
|
172 | + */ |
|
173 | + public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
174 | + { |
|
175 | + $embedButtonHtml = $this->embedButtonHtml(); |
|
176 | + if ( is_array( $filterable_content ) ) { |
|
177 | + $filterable_content = $this->append_filterable_content |
|
178 | + ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | + : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
180 | + } else { |
|
181 | + $filterable_content = $this->append_filterable_content |
|
182 | + ? $filterable_content . $embedButtonHtml |
|
183 | + : $embedButtonHtml . $filterable_content; |
|
184 | + } |
|
185 | + return $filterable_content; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * iframe_embed_html |
|
192 | + * |
|
193 | + * @param array $query_args |
|
194 | + * @param string $button_class |
|
195 | + * @return string |
|
196 | + */ |
|
197 | + public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
198 | + { |
|
199 | + // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
200 | + $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | + $query_args = (array)apply_filters( |
|
202 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
203 | + $query_args |
|
204 | + ); |
|
205 | + // add this route to our localized vars |
|
206 | + $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | + ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
208 | + : array(); |
|
209 | + $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | + \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
211 | + $iframe_embed_html = \EEH_HTML::link( |
|
212 | + '#', |
|
213 | + sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
214 | + sprintf( |
|
215 | + esc_html__( |
|
216 | + 'click here to generate code for embedding %1$s iframe into another site.', |
|
217 | + 'event_espresso' |
|
218 | + ), |
|
219 | + \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
220 | + ), |
|
221 | + "{$this->route_name}-iframe-embed-trigger-js", |
|
222 | + 'iframe-embed-trigger-js button ' . $button_class, |
|
223 | + '', |
|
224 | + ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
225 | + ); |
|
226 | + $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | + 'display:none;' ); |
|
228 | + $iframe_embed_html .= esc_html( |
|
229 | + \EEH_HTML::div( |
|
230 | + '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
231 | + '', |
|
232 | + '', |
|
233 | + 'width:100%; height: 500px;' |
|
234 | + ) |
|
235 | + ); |
|
236 | + $iframe_embed_html .= \EEH_HTML::divx(); |
|
237 | + return $iframe_embed_html; |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * enqueue iframe button js |
|
244 | + */ |
|
245 | + public function embedButtonAssets() |
|
246 | + { |
|
247 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
248 | + 'copy and paste the following into any other site\'s content to display this event:', |
|
249 | + 'event_espresso' |
|
250 | + ); |
|
251 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
252 | + 'click anywhere outside of this window to close it.', |
|
253 | + 'event_espresso' |
|
254 | + ); |
|
255 | + wp_register_script( |
|
256 | + 'iframe_embed_button', |
|
257 | + plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | + array( 'ee-dialog' ), |
|
259 | + EVENT_ESPRESSO_VERSION, |
|
260 | + true |
|
261 | + ); |
|
262 | + wp_enqueue_script( 'iframe_embed_button' ); |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * generates embed button sections for admin pages |
|
269 | + * |
|
270 | + * @param array $embed_buttons |
|
271 | + * @return string |
|
272 | + */ |
|
273 | + public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
274 | + { |
|
275 | + $embed_buttons = (array)apply_filters( |
|
276 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
277 | + $embed_buttons |
|
278 | + ); |
|
279 | + if ( empty($embed_buttons)) { |
|
280 | + return ''; |
|
281 | + } |
|
282 | + // add button for iframe code to event editor. |
|
283 | + $html = \EEH_HTML::br( 2 ); |
|
284 | + $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
285 | + $html .= \EEH_HTML::p( |
|
286 | + esc_html__( |
|
287 | + 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
288 | + 'event_espresso' |
|
289 | + ) |
|
290 | + ); |
|
291 | + $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
292 | + $html .= \EEH_HTML::br( 2 ); |
|
293 | + return $html; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | 297 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | -defined( 'ABSPATH' ) || exit; |
|
4 | +defined('ABSPATH') || exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
47 | 47 | * will most likely be "event" since that's the only usage atm |
48 | 48 | */ |
49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
49 | + public function __construct($iframe_name, $route_name, $slug = 'event') |
|
50 | 50 | { |
51 | 51 | $this->iframe_name = $iframe_name; |
52 | 52 | $this->route_name = $route_name; |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | // add button for iframe code to event editor. |
64 | 64 | add_filter( |
65 | 65 | 'get_sample_permalink_html', |
66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
66 | + array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'), |
|
67 | 67 | 10, |
68 | 68 | 2 |
69 | 69 | ); |
70 | 70 | add_action( |
71 | 71 | 'admin_enqueue_scripts', |
72 | - array( $this, 'embedButtonAssets' ), |
|
72 | + array($this, 'embedButtonAssets'), |
|
73 | 73 | 10 |
74 | 74 | ); |
75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param $id |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id) |
|
85 | 85 | { |
86 | 86 | return $this->eventEditorIframeEmbedButton( |
87 | 87 | $permalink_string, |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | $id |
104 | 104 | ) { |
105 | 105 | //make sure this is ONLY when editing and the event id has been set. |
106 | - if ( ! empty( $id ) ) { |
|
107 | - $post = get_post( $id ); |
|
106 | + if ( ! empty($id)) { |
|
107 | + $post = get_post($id); |
|
108 | 108 | //if NOT event then let's get out. |
109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
109 | + if ($post->post_type !== 'espresso_events') { |
|
110 | 110 | return $permalink_string; |
111 | 111 | } |
112 | 112 | $permalink_string .= $this->embedButtonHtml( |
113 | - array( $this->slug => $id ), |
|
113 | + array($this->slug => $id), |
|
114 | 114 | 'button-small' |
115 | 115 | ); |
116 | 116 | } |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param string $action name of the WP do_action() to hook into |
126 | 126 | */ |
127 | - public function addActionIframeEmbedButton( $action ) |
|
127 | + public function addActionIframeEmbedButton($action) |
|
128 | 128 | { |
129 | 129 | // add button for iframe code to event editor. |
130 | 130 | add_action( |
131 | 131 | $action, |
132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
132 | + array($this, 'addActionIframeEmbedButtonCallback'), |
|
133 | 133 | 10, 2 |
134 | 134 | ); |
135 | 135 | } |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | * @param bool $append if true, will add iframe embed button to end of content, |
154 | 154 | * else if false, will add to the beginning of the content |
155 | 155 | */ |
156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
156 | + public function addFilterIframeEmbedButton($filter, $append = true) |
|
157 | 157 | { |
158 | 158 | $this->append_filterable_content = $append; |
159 | 159 | // add button for iframe code to event editor. |
160 | 160 | add_filter( |
161 | 161 | $filter, |
162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
162 | + array($this, 'addFilterIframeEmbedButtonCallback'), |
|
163 | 163 | 10 |
164 | 164 | ); |
165 | 165 | } |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | * @param array|string $filterable_content |
171 | 171 | * @return array|string |
172 | 172 | */ |
173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
173 | + public function addFilterIframeEmbedButtonCallback($filterable_content) |
|
174 | 174 | { |
175 | 175 | $embedButtonHtml = $this->embedButtonHtml(); |
176 | - if ( is_array( $filterable_content ) ) { |
|
176 | + if (is_array($filterable_content)) { |
|
177 | 177 | $filterable_content = $this->append_filterable_content |
178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
178 | + ? $filterable_content + array($this->route_name => $embedButtonHtml) |
|
179 | + : array($this->route_name => $embedButtonHtml) + $filterable_content; |
|
180 | 180 | } else { |
181 | 181 | $filterable_content = $this->append_filterable_content |
182 | - ? $filterable_content . $embedButtonHtml |
|
183 | - : $embedButtonHtml . $filterable_content; |
|
182 | + ? $filterable_content.$embedButtonHtml |
|
183 | + : $embedButtonHtml.$filterable_content; |
|
184 | 184 | } |
185 | 185 | return $filterable_content; |
186 | 186 | } |
@@ -194,40 +194,40 @@ discard block |
||
194 | 194 | * @param string $button_class |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
197 | + public function embedButtonHtml($query_args = array(), $button_class = '') |
|
198 | 198 | { |
199 | 199 | // incoming args will replace the defaults listed here in the second array (union preserves first array) |
200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | - $query_args = (array)apply_filters( |
|
200 | + $query_args = (array) $query_args + array($this->route_name => 'iframe'); |
|
201 | + $query_args = (array) apply_filters( |
|
202 | 202 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
203 | 203 | $query_args |
204 | 204 | ); |
205 | 205 | // add this route to our localized vars |
206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
206 | + $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes']) |
|
207 | + ? \EE_Registry::$i18n_js_strings['iframe_module_routes'] |
|
208 | 208 | : array(); |
209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
209 | + $iframe_module_routes[$this->route_name] = $this->route_name; |
|
210 | + \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
|
211 | 211 | $iframe_embed_html = \EEH_HTML::link( |
212 | 212 | '#', |
213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
213 | + sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name), |
|
214 | 214 | sprintf( |
215 | 215 | esc_html__( |
216 | 216 | 'click here to generate code for embedding %1$s iframe into another site.', |
217 | 217 | 'event_espresso' |
218 | 218 | ), |
219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
219 | + \EEH_Inflector::add_indefinite_article($this->iframe_name) |
|
220 | 220 | ), |
221 | 221 | "{$this->route_name}-iframe-embed-trigger-js", |
222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
222 | + 'iframe-embed-trigger-js button '.$button_class, |
|
223 | 223 | '', |
224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
224 | + ' data-iframe_embed_button="#'.$this->route_name.'-iframe-js" tabindex="-1"' |
|
225 | 225 | ); |
226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | - 'display:none;' ); |
|
226 | + $iframe_embed_html .= \EEH_HTML::div('', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | + 'display:none;'); |
|
228 | 228 | $iframe_embed_html .= esc_html( |
229 | 229 | \EEH_HTML::div( |
230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
230 | + '<iframe src="'.add_query_arg($query_args, site_url()).'" width="100%" height="100%"></iframe>', |
|
231 | 231 | '', |
232 | 232 | '', |
233 | 233 | 'width:100%; height: 500px;' |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function embedButtonAssets() |
246 | 246 | { |
247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
247 | + \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__( |
|
248 | 248 | 'copy and paste the following into any other site\'s content to display this event:', |
249 | 249 | 'event_espresso' |
250 | 250 | ); |
251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
251 | + \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__( |
|
252 | 252 | 'click anywhere outside of this window to close it.', |
253 | 253 | 'event_espresso' |
254 | 254 | ); |
255 | 255 | wp_register_script( |
256 | 256 | 'iframe_embed_button', |
257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | - array( 'ee-dialog' ), |
|
257 | + plugin_dir_url(__FILE__).'iframe-embed-button.js', |
|
258 | + array('ee-dialog'), |
|
259 | 259 | EVENT_ESPRESSO_VERSION, |
260 | 260 | true |
261 | 261 | ); |
262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
262 | + wp_enqueue_script('iframe_embed_button'); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -270,26 +270,26 @@ discard block |
||
270 | 270 | * @param array $embed_buttons |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
273 | + public function addIframeEmbedButtonsSection(array $embed_buttons) |
|
274 | 274 | { |
275 | - $embed_buttons = (array)apply_filters( |
|
275 | + $embed_buttons = (array) apply_filters( |
|
276 | 276 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
277 | 277 | $embed_buttons |
278 | 278 | ); |
279 | - if ( empty($embed_buttons)) { |
|
279 | + if (empty($embed_buttons)) { |
|
280 | 280 | return ''; |
281 | 281 | } |
282 | 282 | // add button for iframe code to event editor. |
283 | - $html = \EEH_HTML::br( 2 ); |
|
284 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
283 | + $html = \EEH_HTML::br(2); |
|
284 | + $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso')); |
|
285 | 285 | $html .= \EEH_HTML::p( |
286 | 286 | esc_html__( |
287 | 287 | 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
288 | 288 | 'event_espresso' |
289 | 289 | ) |
290 | 290 | ); |
291 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
292 | - $html .= \EEH_HTML::br( 2 ); |
|
291 | + $html .= ' '.implode(' ', $embed_buttons).' '; |
|
292 | + $html .= \EEH_HTML::br(2); |
|
293 | 293 | return $html; |
294 | 294 | } |
295 | 295 |
@@ -15,21 +15,21 @@ discard block |
||
15 | 15 | class EventListIframeEmbedButton extends IframeEmbedButton |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * EventListIframeEmbedButton constructor. |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct( |
|
24 | - esc_html__( 'Event List', 'event_espresso' ), |
|
25 | - 'event_list' |
|
26 | - ); |
|
27 | - } |
|
18 | + /** |
|
19 | + * EventListIframeEmbedButton constructor. |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct( |
|
24 | + esc_html__( 'Event List', 'event_espresso' ), |
|
25 | + 'event_list' |
|
26 | + ); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | 31 | public function addEmbedButton() { |
32 | - add_filter( |
|
32 | + add_filter( |
|
33 | 33 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
34 | 34 | array( $this, 'addEventListIframeEmbedButtonSection' ) |
35 | 35 | ); |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | * @param array $after_list_table |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
53 | - { |
|
54 | - return \EEH_Array::insert_into_array( |
|
55 | - $after_list_table, |
|
56 | - array( |
|
57 | - 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
58 | - array() |
|
59 | - // array( 'event_list' => $this->embedButtonHtml() ) |
|
60 | - ) |
|
61 | - ), |
|
62 | - 'legend' |
|
63 | - ); |
|
64 | - } |
|
52 | + public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
53 | + { |
|
54 | + return \EEH_Array::insert_into_array( |
|
55 | + $after_list_table, |
|
56 | + array( |
|
57 | + 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
58 | + array() |
|
59 | + // array( 'event_list' => $this->embedButtonHtml() ) |
|
60 | + ) |
|
61 | + ), |
|
62 | + 'legend' |
|
63 | + ); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | 67 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | -defined( 'ABSPATH' ) || exit; |
|
4 | +defined('ABSPATH') || exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function __construct() |
22 | 22 | { |
23 | 23 | parent::__construct( |
24 | - esc_html__( 'Event List', 'event_espresso' ), |
|
24 | + esc_html__('Event List', 'event_espresso'), |
|
25 | 25 | 'event_list' |
26 | 26 | ); |
27 | 27 | } |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | public function addEmbedButton() { |
32 | 32 | add_filter( |
33 | 33 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
34 | - array( $this, 'addEventListIframeEmbedButtonSection' ) |
|
34 | + array($this, 'addEventListIframeEmbedButtonSection') |
|
35 | 35 | ); |
36 | 36 | add_action( |
37 | 37 | 'admin_enqueue_scripts', |
38 | - array( $this, 'embedButtonAssets' ), |
|
38 | + array($this, 'embedButtonAssets'), |
|
39 | 39 | 10 |
40 | 40 | ); |
41 | 41 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $after_list_table |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
52 | + public function addEventListIframeEmbedButtonSection(array $after_list_table) |
|
53 | 53 | { |
54 | 54 | return \EEH_Array::insert_into_array( |
55 | 55 | $after_list_table, |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -13,168 +13,168 @@ discard block |
||
13 | 13 | class EE_Messages_Scheduler extends EE_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Number of seconds between batch sends/generates on the cron job. |
|
18 | - * Defaults to 5 minutes in seconds. If you want to change this interval, you can use the native WordPress |
|
19 | - * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added. |
|
20 | - * |
|
21 | - * @type int |
|
22 | - */ |
|
23 | - const message_cron_schedule = 300; |
|
24 | - |
|
25 | - /** |
|
26 | - * Constructor |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - //register tasks (and make sure only registered once). |
|
31 | - if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
32 | - add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
33 | - } |
|
34 | - |
|
35 | - //register callbacks for scheduled events (but make sure they are set only once). |
|
36 | - if (! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
37 | - array('EE_Messages_Scheduler', 'batch_generation')) |
|
38 | - ) { |
|
39 | - add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
40 | - add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
41 | - } |
|
42 | - |
|
43 | - //add custom schedules |
|
44 | - add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Add custom schedules for wp_cron |
|
50 | - * |
|
51 | - * @param $schedules |
|
52 | - */ |
|
53 | - public function custom_schedules($schedules) |
|
54 | - { |
|
55 | - $schedules['ee_message_cron'] = array( |
|
56 | - 'interval' => self::message_cron_schedule, |
|
57 | - 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', |
|
58 | - 'event_espresso'), |
|
59 | - ); |
|
60 | - return $schedules; |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and |
|
66 | - * remove. |
|
67 | - * |
|
68 | - * @param array $tasks already existing scheduled tasks |
|
69 | - * @return array |
|
70 | - */ |
|
71 | - public function register_scheduled_tasks($tasks) |
|
72 | - { |
|
73 | - $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
|
74 | - $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
|
75 | - return $tasks; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * This initiates a non-blocking separate request to execute on a scheduled task. |
|
81 | - * Note: The EED_Messages module has the handlers for these requests. |
|
82 | - * |
|
83 | - * @param string $task The task the request is being generated for. |
|
84 | - */ |
|
85 | - public static function initiate_scheduled_non_blocking_request($task) |
|
86 | - { |
|
87 | - if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
|
88 | - true)) { |
|
89 | - $request_url = add_query_arg( |
|
90 | - array_merge( |
|
91 | - array('ee' => 'msg_cron_trigger'), |
|
92 | - EE_Messages_Scheduler::get_request_params($task) |
|
93 | - ), |
|
94 | - site_url() |
|
95 | - ); |
|
96 | - $request_args = array( |
|
97 | - 'timeout' => 300, |
|
98 | - 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
99 | - 'sslverify' => false, |
|
100 | - 'redirection' => 10, |
|
101 | - ); |
|
102 | - $response = wp_remote_get($request_url, $request_args); |
|
103 | - if (is_wp_error($response)) { |
|
104 | - trigger_error($response->get_error_message()); |
|
105 | - } |
|
106 | - } else { |
|
107 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * This returns |
|
114 | - * the request params used for a scheduled message task request. |
|
115 | - * |
|
116 | - * @param string $task The task the request is for. |
|
117 | - * @return array |
|
118 | - */ |
|
119 | - public static function get_request_params($task) |
|
120 | - { |
|
121 | - //transient is used for flood control on msg_cron_trigger requests |
|
122 | - $transient_key = 'ee_trans_' . uniqid($task); |
|
123 | - set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
124 | - return array( |
|
125 | - 'type' => $task, |
|
126 | - 'key' => $transient_key, |
|
127 | - ); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
|
133 | - * |
|
134 | - * @param string $task The task the request is being generated for. |
|
135 | - */ |
|
136 | - public static function initiate_immediate_request_on_cron($task) |
|
137 | - { |
|
138 | - $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
139 | - //set those request args in the request so it gets picked up |
|
140 | - foreach ($request_args as $request_key => $request_value) { |
|
141 | - EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
142 | - } |
|
143 | - EED_Messages::instance()->run_cron(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
|
149 | - */ |
|
150 | - public static function batch_generation() |
|
151 | - { |
|
152 | - /** |
|
153 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
154 | - */ |
|
155 | - if ( |
|
156 | - ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
157 | - || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
158 | - ) { |
|
159 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
|
166 | - */ |
|
167 | - public static function batch_sending() |
|
168 | - { |
|
169 | - /** |
|
170 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
171 | - */ |
|
172 | - if ( |
|
173 | - ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
174 | - || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
175 | - ) { |
|
176 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
177 | - } |
|
178 | - } |
|
16 | + /** |
|
17 | + * Number of seconds between batch sends/generates on the cron job. |
|
18 | + * Defaults to 5 minutes in seconds. If you want to change this interval, you can use the native WordPress |
|
19 | + * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added. |
|
20 | + * |
|
21 | + * @type int |
|
22 | + */ |
|
23 | + const message_cron_schedule = 300; |
|
24 | + |
|
25 | + /** |
|
26 | + * Constructor |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + //register tasks (and make sure only registered once). |
|
31 | + if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
32 | + add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
33 | + } |
|
34 | + |
|
35 | + //register callbacks for scheduled events (but make sure they are set only once). |
|
36 | + if (! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
37 | + array('EE_Messages_Scheduler', 'batch_generation')) |
|
38 | + ) { |
|
39 | + add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
40 | + add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
41 | + } |
|
42 | + |
|
43 | + //add custom schedules |
|
44 | + add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Add custom schedules for wp_cron |
|
50 | + * |
|
51 | + * @param $schedules |
|
52 | + */ |
|
53 | + public function custom_schedules($schedules) |
|
54 | + { |
|
55 | + $schedules['ee_message_cron'] = array( |
|
56 | + 'interval' => self::message_cron_schedule, |
|
57 | + 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', |
|
58 | + 'event_espresso'), |
|
59 | + ); |
|
60 | + return $schedules; |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and |
|
66 | + * remove. |
|
67 | + * |
|
68 | + * @param array $tasks already existing scheduled tasks |
|
69 | + * @return array |
|
70 | + */ |
|
71 | + public function register_scheduled_tasks($tasks) |
|
72 | + { |
|
73 | + $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
|
74 | + $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
|
75 | + return $tasks; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * This initiates a non-blocking separate request to execute on a scheduled task. |
|
81 | + * Note: The EED_Messages module has the handlers for these requests. |
|
82 | + * |
|
83 | + * @param string $task The task the request is being generated for. |
|
84 | + */ |
|
85 | + public static function initiate_scheduled_non_blocking_request($task) |
|
86 | + { |
|
87 | + if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
|
88 | + true)) { |
|
89 | + $request_url = add_query_arg( |
|
90 | + array_merge( |
|
91 | + array('ee' => 'msg_cron_trigger'), |
|
92 | + EE_Messages_Scheduler::get_request_params($task) |
|
93 | + ), |
|
94 | + site_url() |
|
95 | + ); |
|
96 | + $request_args = array( |
|
97 | + 'timeout' => 300, |
|
98 | + 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
99 | + 'sslverify' => false, |
|
100 | + 'redirection' => 10, |
|
101 | + ); |
|
102 | + $response = wp_remote_get($request_url, $request_args); |
|
103 | + if (is_wp_error($response)) { |
|
104 | + trigger_error($response->get_error_message()); |
|
105 | + } |
|
106 | + } else { |
|
107 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * This returns |
|
114 | + * the request params used for a scheduled message task request. |
|
115 | + * |
|
116 | + * @param string $task The task the request is for. |
|
117 | + * @return array |
|
118 | + */ |
|
119 | + public static function get_request_params($task) |
|
120 | + { |
|
121 | + //transient is used for flood control on msg_cron_trigger requests |
|
122 | + $transient_key = 'ee_trans_' . uniqid($task); |
|
123 | + set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
124 | + return array( |
|
125 | + 'type' => $task, |
|
126 | + 'key' => $transient_key, |
|
127 | + ); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
|
133 | + * |
|
134 | + * @param string $task The task the request is being generated for. |
|
135 | + */ |
|
136 | + public static function initiate_immediate_request_on_cron($task) |
|
137 | + { |
|
138 | + $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
139 | + //set those request args in the request so it gets picked up |
|
140 | + foreach ($request_args as $request_key => $request_value) { |
|
141 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
142 | + } |
|
143 | + EED_Messages::instance()->run_cron(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
|
149 | + */ |
|
150 | + public static function batch_generation() |
|
151 | + { |
|
152 | + /** |
|
153 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
154 | + */ |
|
155 | + if ( |
|
156 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
157 | + || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
158 | + ) { |
|
159 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
|
166 | + */ |
|
167 | + public static function batch_sending() |
|
168 | + { |
|
169 | + /** |
|
170 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
171 | + */ |
|
172 | + if ( |
|
173 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
174 | + || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
175 | + ) { |
|
176 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
177 | + } |
|
178 | + } |
|
179 | 179 | |
180 | 180 | } //end EE_Messages_Scheduler |
181 | 181 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | public function __construct() |
29 | 29 | { |
30 | 30 | //register tasks (and make sure only registered once). |
31 | - if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
31 | + if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
32 | 32 | add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
33 | 33 | } |
34 | 34 | |
35 | 35 | //register callbacks for scheduled events (but make sure they are set only once). |
36 | - if (! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
36 | + if ( ! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
37 | 37 | array('EE_Messages_Scheduler', 'batch_generation')) |
38 | 38 | ) { |
39 | 39 | add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
88 | 88 | true)) { |
89 | - $request_url = add_query_arg( |
|
89 | + $request_url = add_query_arg( |
|
90 | 90 | array_merge( |
91 | 91 | array('ee' => 'msg_cron_trigger'), |
92 | 92 | EE_Messages_Scheduler::get_request_params($task) |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | 'sslverify' => false, |
100 | 100 | 'redirection' => 10, |
101 | 101 | ); |
102 | - $response = wp_remote_get($request_url, $request_args); |
|
102 | + $response = wp_remote_get($request_url, $request_args); |
|
103 | 103 | if (is_wp_error($response)) { |
104 | 104 | trigger_error($response->get_error_message()); |
105 | 105 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public static function get_request_params($task) |
120 | 120 | { |
121 | 121 | //transient is used for flood control on msg_cron_trigger requests |
122 | - $transient_key = 'ee_trans_' . uniqid($task); |
|
122 | + $transient_key = 'ee_trans_'.uniqid($task); |
|
123 | 123 | set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
124 | 124 | return array( |
125 | 125 | 'type' => $task, |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\libraries\iframe_display\Iframe; |
5 | 5 | |
6 | 6 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
7 | - exit( 'No direct script access allowed' ); |
|
7 | + exit( 'No direct script access allowed' ); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -21,64 +21,64 @@ discard block |
||
21 | 21 | class TicketSelectorIframe extends Iframe |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * TicketSelectorIframe constructor. |
|
26 | - * |
|
27 | - * @throws \DomainException |
|
28 | - * @throws \EE_Error |
|
29 | - */ |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - \EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
33 | - /** @type \EEM_Event $EEM_Event */ |
|
34 | - $EEM_Event = \EE_Registry::instance()->load_model( 'Event' ); |
|
35 | - $event = $EEM_Event->get_one_by_ID( |
|
36 | - \EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
37 | - ); |
|
38 | - $ticket_selector = new DisplayTicketSelector(); |
|
39 | - $ticket_selector->setIframe( true ); |
|
40 | - parent::__construct( |
|
41 | - esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
42 | - $ticket_selector->display( $event ) |
|
43 | - ); |
|
44 | - $this->addStylesheets( |
|
45 | - apply_filters( |
|
46 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
47 | - array( |
|
48 | - 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
49 | - . 'ticket_selector_embed.css?ver=' |
|
50 | - . EVENT_ESPRESSO_VERSION, |
|
51 | - 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
52 | - . 'ticket_selector.css?ver=' |
|
53 | - . EVENT_ESPRESSO_VERSION, |
|
54 | - ), |
|
55 | - $this |
|
56 | - ) |
|
57 | - ); |
|
58 | - if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
59 | - $this->addStylesheets( array('site_theme' => '' ) ); |
|
60 | - } |
|
61 | - $this->addScripts( |
|
62 | - apply_filters( |
|
63 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
64 | - array( |
|
65 | - 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
66 | - . 'ticket_selector_iframe_embed.js?ver=' |
|
67 | - . EVENT_ESPRESSO_VERSION, |
|
68 | - ), |
|
69 | - $this |
|
70 | - ) |
|
71 | - ); |
|
72 | - $this->addLocalizedVars( |
|
73 | - array( |
|
74 | - 'ticket_selector_iframe' => true, |
|
75 | - 'EEDTicketSelectorMsg' => __( |
|
76 | - 'Please choose at least one ticket before continuing.', |
|
77 | - 'event_espresso' |
|
78 | - ), |
|
79 | - ) |
|
80 | - ); |
|
81 | - } |
|
24 | + /** |
|
25 | + * TicketSelectorIframe constructor. |
|
26 | + * |
|
27 | + * @throws \DomainException |
|
28 | + * @throws \EE_Error |
|
29 | + */ |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + \EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
33 | + /** @type \EEM_Event $EEM_Event */ |
|
34 | + $EEM_Event = \EE_Registry::instance()->load_model( 'Event' ); |
|
35 | + $event = $EEM_Event->get_one_by_ID( |
|
36 | + \EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
37 | + ); |
|
38 | + $ticket_selector = new DisplayTicketSelector(); |
|
39 | + $ticket_selector->setIframe( true ); |
|
40 | + parent::__construct( |
|
41 | + esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
42 | + $ticket_selector->display( $event ) |
|
43 | + ); |
|
44 | + $this->addStylesheets( |
|
45 | + apply_filters( |
|
46 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
47 | + array( |
|
48 | + 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
49 | + . 'ticket_selector_embed.css?ver=' |
|
50 | + . EVENT_ESPRESSO_VERSION, |
|
51 | + 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
52 | + . 'ticket_selector.css?ver=' |
|
53 | + . EVENT_ESPRESSO_VERSION, |
|
54 | + ), |
|
55 | + $this |
|
56 | + ) |
|
57 | + ); |
|
58 | + if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
59 | + $this->addStylesheets( array('site_theme' => '' ) ); |
|
60 | + } |
|
61 | + $this->addScripts( |
|
62 | + apply_filters( |
|
63 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
64 | + array( |
|
65 | + 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
66 | + . 'ticket_selector_iframe_embed.js?ver=' |
|
67 | + . EVENT_ESPRESSO_VERSION, |
|
68 | + ), |
|
69 | + $this |
|
70 | + ) |
|
71 | + ); |
|
72 | + $this->addLocalizedVars( |
|
73 | + array( |
|
74 | + 'ticket_selector_iframe' => true, |
|
75 | + 'EEDTicketSelectorMsg' => __( |
|
76 | + 'Please choose at least one ticket before continuing.', |
|
77 | + 'event_espresso' |
|
78 | + ), |
|
79 | + ) |
|
80 | + ); |
|
81 | + } |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | // End of file TicketSelectorIframe.php |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use EventEspresso\core\libraries\iframe_display\Iframe; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct() |
31 | 31 | { |
32 | - \EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
32 | + \EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | 33 | /** @type \EEM_Event $EEM_Event */ |
34 | - $EEM_Event = \EE_Registry::instance()->load_model( 'Event' ); |
|
34 | + $EEM_Event = \EE_Registry::instance()->load_model('Event'); |
|
35 | 35 | $event = $EEM_Event->get_one_by_ID( |
36 | - \EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
36 | + \EE_Registry::instance()->REQ->get('event', 0) |
|
37 | 37 | ); |
38 | 38 | $ticket_selector = new DisplayTicketSelector(); |
39 | - $ticket_selector->setIframe( true ); |
|
39 | + $ticket_selector->setIframe(true); |
|
40 | 40 | parent::__construct( |
41 | - esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
42 | - $ticket_selector->display( $event ) |
|
41 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
42 | + $ticket_selector->display($event) |
|
43 | 43 | ); |
44 | 44 | $this->addStylesheets( |
45 | 45 | apply_filters( |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | ) |
57 | 57 | ); |
58 | 58 | if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
59 | - $this->addStylesheets( array('site_theme' => '' ) ); |
|
59 | + $this->addStylesheets(array('site_theme' => '')); |
|
60 | 60 | } |
61 | 61 | $this->addScripts( |
62 | 62 | apply_filters( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -17,151 +17,151 @@ discard block |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * enqueues css and js, so that this can be called statically |
|
22 | - */ |
|
23 | - public static function enqueue_styles_and_scripts() |
|
24 | - { |
|
25 | - wp_register_style( |
|
26 | - 'checkbox_dropdown_selector', |
|
27 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
28 | - array('espresso_default'), |
|
29 | - EVENT_ESPRESSO_VERSION |
|
30 | - ); |
|
31 | - wp_enqueue_style('checkbox_dropdown_selector'); |
|
32 | - wp_register_script( |
|
33 | - 'checkbox_dropdown_selector', |
|
34 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
35 | - array('jquery'), |
|
36 | - EVENT_ESPRESSO_VERSION, |
|
37 | - true |
|
38 | - ); |
|
39 | - wp_enqueue_script('checkbox_dropdown_selector'); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
46 | - */ |
|
47 | - public function enqueue_js(){ |
|
48 | - EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * callback for Iframe::addStylesheets() child class methods |
|
55 | - * |
|
56 | - * @param array $iframe_css |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public function iframe_css(array $iframe_css){ |
|
60 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
61 | - return $iframe_css; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * callback for Iframe::addScripts() child class methods |
|
68 | - * |
|
69 | - * @param array $iframe_js |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - public function iframe_js(array $iframe_js){ |
|
73 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
74 | - return $iframe_js; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @throws EE_Error |
|
80 | - * @return string of html to display the field |
|
81 | - */ |
|
82 | - public function display() |
|
83 | - { |
|
84 | - $input = $this->get_input(); |
|
85 | - $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
86 | - // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
87 | - $input->set_label_sizes(); |
|
88 | - $label_size_class = $input->get_label_size_class(); |
|
89 | - if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
90 | - EE_Error::doing_it_wrong( |
|
91 | - 'EE_Checkbox_Display_Strategy::display()', |
|
92 | - sprintf( |
|
93 | - esc_html__( |
|
94 | - 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
95 | - 'event_espresso' |
|
96 | - ), |
|
97 | - $input->html_id(), |
|
98 | - var_export($input->raw_value(), true), |
|
99 | - $input->html_name() . '[]' |
|
100 | - ), |
|
101 | - '4.8.1' |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
107 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
108 | - // $html .= ' name="' . $input->html_name() . '"'; |
|
109 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | - $html .= ' style="' . $input->html_style() . '"'; |
|
111 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
112 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
113 | - $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
114 | - $html .= $select_button_text; |
|
115 | - $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
116 | - $html .= '</button>'; |
|
117 | - $html .= EEH_HTML::div( |
|
118 | - '', |
|
119 | - $input->html_id() . '-options-dv', |
|
120 | - 'checkbox-dropdown-selector' |
|
121 | - ); |
|
122 | - $html .= EEH_HTML::link( |
|
123 | - '', |
|
124 | - '<span class="dashicons dashicons-no"></span>', |
|
125 | - esc_html__('close datetime selector', 'event_espresso'), |
|
126 | - '', |
|
127 | - 'close-espresso-notice' |
|
128 | - ); |
|
129 | - $html .= EEH_HTML::ul(); |
|
130 | - $input_raw_value = (array)$input->raw_value(); |
|
131 | - foreach ($input->options() as $value => $display_text) { |
|
132 | - $html .= EEH_HTML::li(); |
|
133 | - $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
134 | - $html_id = $this->get_sub_input_id($value); |
|
135 | - $html .= EEH_HTML::nl(0, 'checkbox'); |
|
136 | - $html .= '<label for="' |
|
137 | - . $html_id |
|
138 | - . '" id="' |
|
139 | - . $html_id |
|
140 | - . '-lbl" class="ee-checkbox-label-after' |
|
141 | - . $label_size_class |
|
142 | - . '">'; |
|
143 | - $html .= EEH_HTML::nl(1, 'checkbox'); |
|
144 | - $html .= '<input type="checkbox"'; |
|
145 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
146 | - $html .= ' id="' . $html_id . '"'; |
|
147 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
148 | - $html .= ' style="' . $input->html_style() . '"'; |
|
149 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
150 | - $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
151 | - ? ' checked="checked"' |
|
152 | - : ''; |
|
153 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
154 | - $html .= '>'; |
|
155 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
156 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
157 | - $html .= EEH_HTML::lix(); |
|
158 | - } |
|
159 | - $html .= EEH_HTML::ulx(); |
|
160 | - $html .= EEH_HTML::divx(); |
|
161 | - $html .= EEH_HTML::divx(); |
|
162 | - $html .= \EEH_HTML::br(); |
|
163 | - return $html; |
|
164 | - } |
|
20 | + /** |
|
21 | + * enqueues css and js, so that this can be called statically |
|
22 | + */ |
|
23 | + public static function enqueue_styles_and_scripts() |
|
24 | + { |
|
25 | + wp_register_style( |
|
26 | + 'checkbox_dropdown_selector', |
|
27 | + EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
28 | + array('espresso_default'), |
|
29 | + EVENT_ESPRESSO_VERSION |
|
30 | + ); |
|
31 | + wp_enqueue_style('checkbox_dropdown_selector'); |
|
32 | + wp_register_script( |
|
33 | + 'checkbox_dropdown_selector', |
|
34 | + EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
35 | + array('jquery'), |
|
36 | + EVENT_ESPRESSO_VERSION, |
|
37 | + true |
|
38 | + ); |
|
39 | + wp_enqueue_script('checkbox_dropdown_selector'); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
46 | + */ |
|
47 | + public function enqueue_js(){ |
|
48 | + EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * callback for Iframe::addStylesheets() child class methods |
|
55 | + * |
|
56 | + * @param array $iframe_css |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public function iframe_css(array $iframe_css){ |
|
60 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
61 | + return $iframe_css; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * callback for Iframe::addScripts() child class methods |
|
68 | + * |
|
69 | + * @param array $iframe_js |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + public function iframe_js(array $iframe_js){ |
|
73 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
74 | + return $iframe_js; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @throws EE_Error |
|
80 | + * @return string of html to display the field |
|
81 | + */ |
|
82 | + public function display() |
|
83 | + { |
|
84 | + $input = $this->get_input(); |
|
85 | + $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
86 | + // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
87 | + $input->set_label_sizes(); |
|
88 | + $label_size_class = $input->get_label_size_class(); |
|
89 | + if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
90 | + EE_Error::doing_it_wrong( |
|
91 | + 'EE_Checkbox_Display_Strategy::display()', |
|
92 | + sprintf( |
|
93 | + esc_html__( |
|
94 | + 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
95 | + 'event_espresso' |
|
96 | + ), |
|
97 | + $input->html_id(), |
|
98 | + var_export($input->raw_value(), true), |
|
99 | + $input->html_name() . '[]' |
|
100 | + ), |
|
101 | + '4.8.1' |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
107 | + $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
108 | + // $html .= ' name="' . $input->html_name() . '"'; |
|
109 | + $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | + $html .= ' style="' . $input->html_style() . '"'; |
|
111 | + $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
112 | + $html .= ' ' . $input->html_other_attributes() . '>'; |
|
113 | + $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
114 | + $html .= $select_button_text; |
|
115 | + $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
116 | + $html .= '</button>'; |
|
117 | + $html .= EEH_HTML::div( |
|
118 | + '', |
|
119 | + $input->html_id() . '-options-dv', |
|
120 | + 'checkbox-dropdown-selector' |
|
121 | + ); |
|
122 | + $html .= EEH_HTML::link( |
|
123 | + '', |
|
124 | + '<span class="dashicons dashicons-no"></span>', |
|
125 | + esc_html__('close datetime selector', 'event_espresso'), |
|
126 | + '', |
|
127 | + 'close-espresso-notice' |
|
128 | + ); |
|
129 | + $html .= EEH_HTML::ul(); |
|
130 | + $input_raw_value = (array)$input->raw_value(); |
|
131 | + foreach ($input->options() as $value => $display_text) { |
|
132 | + $html .= EEH_HTML::li(); |
|
133 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
134 | + $html_id = $this->get_sub_input_id($value); |
|
135 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
136 | + $html .= '<label for="' |
|
137 | + . $html_id |
|
138 | + . '" id="' |
|
139 | + . $html_id |
|
140 | + . '-lbl" class="ee-checkbox-label-after' |
|
141 | + . $label_size_class |
|
142 | + . '">'; |
|
143 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
144 | + $html .= '<input type="checkbox"'; |
|
145 | + $html .= ' name="' . $input->html_name() . '[]"'; |
|
146 | + $html .= ' id="' . $html_id . '"'; |
|
147 | + $html .= ' class="' . $input->html_class() . '-option"'; |
|
148 | + $html .= ' style="' . $input->html_style() . '"'; |
|
149 | + $html .= ' value="' . esc_attr($value) . '"'; |
|
150 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
151 | + ? ' checked="checked"' |
|
152 | + : ''; |
|
153 | + $html .= ' ' . $this->_input->other_html_attributes(); |
|
154 | + $html .= '>'; |
|
155 | + $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
156 | + $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
157 | + $html .= EEH_HTML::lix(); |
|
158 | + } |
|
159 | + $html .= EEH_HTML::ulx(); |
|
160 | + $html .= EEH_HTML::divx(); |
|
161 | + $html .= EEH_HTML::divx(); |
|
162 | + $html .= \EEH_HTML::br(); |
|
163 | + return $html; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | |
167 | 167 |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | { |
25 | 25 | wp_register_style( |
26 | 26 | 'checkbox_dropdown_selector', |
27 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
27 | + EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css', |
|
28 | 28 | array('espresso_default'), |
29 | 29 | EVENT_ESPRESSO_VERSION |
30 | 30 | ); |
31 | 31 | wp_enqueue_style('checkbox_dropdown_selector'); |
32 | 32 | wp_register_script( |
33 | 33 | 'checkbox_dropdown_selector', |
34 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
34 | + EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js', |
|
35 | 35 | array('jquery'), |
36 | 36 | EVENT_ESPRESSO_VERSION, |
37 | 37 | true |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * Informs the rest of the forms system what CSS and JS is needed to display the input |
46 | 46 | */ |
47 | - public function enqueue_js(){ |
|
47 | + public function enqueue_js() { |
|
48 | 48 | EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
49 | 49 | } |
50 | 50 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param array $iframe_css |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function iframe_css(array $iframe_css){ |
|
60 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
59 | + public function iframe_css(array $iframe_css) { |
|
60 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css'; |
|
61 | 61 | return $iframe_css; |
62 | 62 | } |
63 | 63 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @param array $iframe_js |
70 | 70 | * @return array |
71 | 71 | */ |
72 | - public function iframe_js(array $iframe_js){ |
|
73 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
72 | + public function iframe_js(array $iframe_js) { |
|
73 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js'; |
|
74 | 74 | return $iframe_js; |
75 | 75 | } |
76 | 76 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ), |
97 | 97 | $input->html_id(), |
98 | 98 | var_export($input->raw_value(), true), |
99 | - $input->html_name() . '[]' |
|
99 | + $input->html_name().'[]' |
|
100 | 100 | ), |
101 | 101 | '4.8.1' |
102 | 102 | ); |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | |
105 | 105 | |
106 | 106 | $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
107 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
107 | + $html .= '<button id="'.$input->html_id().'-btn"'; |
|
108 | 108 | // $html .= ' name="' . $input->html_name() . '"'; |
109 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | - $html .= ' style="' . $input->html_style() . '"'; |
|
111 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
112 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
109 | + $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | + $html .= ' style="'.$input->html_style().'"'; |
|
111 | + $html .= ' data-target="'.$input->html_id().'-options-dv"'; |
|
112 | + $html .= ' '.$input->html_other_attributes().'>'; |
|
113 | 113 | $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
114 | 114 | $html .= $select_button_text; |
115 | 115 | $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
116 | 116 | $html .= '</button>'; |
117 | 117 | $html .= EEH_HTML::div( |
118 | 118 | '', |
119 | - $input->html_id() . '-options-dv', |
|
119 | + $input->html_id().'-options-dv', |
|
120 | 120 | 'checkbox-dropdown-selector' |
121 | 121 | ); |
122 | 122 | $html .= EEH_HTML::link( |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'close-espresso-notice' |
128 | 128 | ); |
129 | 129 | $html .= EEH_HTML::ul(); |
130 | - $input_raw_value = (array)$input->raw_value(); |
|
130 | + $input_raw_value = (array) $input->raw_value(); |
|
131 | 131 | foreach ($input->options() as $value => $display_text) { |
132 | 132 | $html .= EEH_HTML::li(); |
133 | 133 | $value = $input->get_normalization_strategy()->unnormalize_one($value); |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | . '">'; |
143 | 143 | $html .= EEH_HTML::nl(1, 'checkbox'); |
144 | 144 | $html .= '<input type="checkbox"'; |
145 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
146 | - $html .= ' id="' . $html_id . '"'; |
|
147 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
148 | - $html .= ' style="' . $input->html_style() . '"'; |
|
149 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
145 | + $html .= ' name="'.$input->html_name().'[]"'; |
|
146 | + $html .= ' id="'.$html_id.'"'; |
|
147 | + $html .= ' class="'.$input->html_class().'-option"'; |
|
148 | + $html .= ' style="'.$input->html_style().'"'; |
|
149 | + $html .= ' value="'.esc_attr($value).'"'; |
|
150 | 150 | $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
151 | 151 | ? ' checked="checked"' |
152 | 152 | : ''; |
153 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
153 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
154 | 154 | $html .= '>'; |
155 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
156 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
155 | + $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>'; |
|
156 | + $html .= EEH_HTML::nl(-1, 'checkbox').'</label>'; |
|
157 | 157 | $html .= EEH_HTML::lix(); |
158 | 158 | } |
159 | 159 | $html .= EEH_HTML::ulx(); |
@@ -17,127 +17,127 @@ |
||
17 | 17 | class TicketSelectorStandard extends TicketSelector |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string $date_format |
|
22 | - */ |
|
23 | - protected $date_format; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string $time_format |
|
27 | - */ |
|
28 | - protected $time_format; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | - */ |
|
33 | - protected $ticket_selector_config; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var \EE_Tax_Config $tax_config |
|
37 | - */ |
|
38 | - protected $tax_config; |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * TicketSelectorSimple constructor. |
|
44 | - * |
|
45 | - * @param \EE_Event $event |
|
46 | - * @param \EE_Ticket[] $tickets |
|
47 | - * @param int $max_attendees |
|
48 | - * @param array $template_args |
|
49 | - * @param string $date_format |
|
50 | - * @param string $time_format |
|
51 | - * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | - * @param \EE_Tax_Config $tax_config |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - \EE_Event $event, |
|
56 | - array $tickets, |
|
57 | - $max_attendees, |
|
58 | - array $template_args, |
|
59 | - $date_format = 'Y-m-d', |
|
60 | - $time_format = 'g:i a', |
|
61 | - \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | - \EE_Tax_Config $tax_config = null |
|
63 | - ) { |
|
64 | - $this->date_format = $date_format; |
|
65 | - $this->time_format = $time_format; |
|
66 | - // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | - $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | - ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | - : new \EE_Ticket_Selector_Config(); |
|
70 | - // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | - // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | - // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | - $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | - ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | - : new \EE_Tax_Config(); |
|
76 | - parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * sets any and all template args that are required for this Ticket Selector |
|
83 | - * |
|
84 | - * @return void |
|
85 | - * @throws \EE_Error |
|
86 | - */ |
|
87 | - protected function addTemplateArgs() |
|
88 | - { |
|
89 | - $row = 1; |
|
90 | - $ticket_row_html = ''; |
|
91 | - $required_ticket_sold_out = false; |
|
92 | - // flag to indicate that at least one taxable ticket has been encountered |
|
93 | - $taxable_tickets = false; |
|
94 | - $datetime_selector = null; |
|
95 | - $this->template_args['datetime_selector'] = ''; |
|
96 | - if ( |
|
97 | - $this->ticket_selector_config->getShowDatetimeSelector() |
|
98 | - !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
99 | - ) { |
|
100 | - $datetime_selector = new DatetimeSelector( |
|
101 | - $this->event, |
|
102 | - $this->tickets, |
|
103 | - $this->ticket_selector_config, |
|
104 | - $this->date_format, |
|
105 | - $this->time_format |
|
106 | - ); |
|
107 | - $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
108 | - } |
|
109 | - // loop through tickets |
|
110 | - foreach ($this->tickets as $TKT_ID => $ticket) { |
|
111 | - if ($ticket instanceof \EE_Ticket) { |
|
112 | - $cols = 2; |
|
113 | - $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
114 | - $ticket_selector_row = new TicketSelectorRowStandard( |
|
115 | - $ticket, |
|
116 | - new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
117 | - $this->ticket_selector_config, |
|
118 | - $this->tax_config, |
|
119 | - $this->max_attendees, |
|
120 | - $row, |
|
121 | - $cols, |
|
122 | - $required_ticket_sold_out, |
|
123 | - $this->template_args['event_status'], |
|
124 | - $this->template_args['date_format'], |
|
125 | - $datetime_selector instanceof DatetimeSelector |
|
126 | - ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
127 | - : '' |
|
128 | - ); |
|
129 | - $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
130 | - $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
131 | - $row++; |
|
132 | - } |
|
133 | - } |
|
134 | - $this->template_args['row'] = $row; |
|
135 | - $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
136 | - $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
137 | - $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
138 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
139 | - remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
140 | - } |
|
20 | + /** |
|
21 | + * @var string $date_format |
|
22 | + */ |
|
23 | + protected $date_format; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string $time_format |
|
27 | + */ |
|
28 | + protected $time_format; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | + */ |
|
33 | + protected $ticket_selector_config; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var \EE_Tax_Config $tax_config |
|
37 | + */ |
|
38 | + protected $tax_config; |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * TicketSelectorSimple constructor. |
|
44 | + * |
|
45 | + * @param \EE_Event $event |
|
46 | + * @param \EE_Ticket[] $tickets |
|
47 | + * @param int $max_attendees |
|
48 | + * @param array $template_args |
|
49 | + * @param string $date_format |
|
50 | + * @param string $time_format |
|
51 | + * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | + * @param \EE_Tax_Config $tax_config |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + \EE_Event $event, |
|
56 | + array $tickets, |
|
57 | + $max_attendees, |
|
58 | + array $template_args, |
|
59 | + $date_format = 'Y-m-d', |
|
60 | + $time_format = 'g:i a', |
|
61 | + \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | + \EE_Tax_Config $tax_config = null |
|
63 | + ) { |
|
64 | + $this->date_format = $date_format; |
|
65 | + $this->time_format = $time_format; |
|
66 | + // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | + $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | + ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | + : new \EE_Ticket_Selector_Config(); |
|
70 | + // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | + // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | + // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | + $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | + ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | + : new \EE_Tax_Config(); |
|
76 | + parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * sets any and all template args that are required for this Ticket Selector |
|
83 | + * |
|
84 | + * @return void |
|
85 | + * @throws \EE_Error |
|
86 | + */ |
|
87 | + protected function addTemplateArgs() |
|
88 | + { |
|
89 | + $row = 1; |
|
90 | + $ticket_row_html = ''; |
|
91 | + $required_ticket_sold_out = false; |
|
92 | + // flag to indicate that at least one taxable ticket has been encountered |
|
93 | + $taxable_tickets = false; |
|
94 | + $datetime_selector = null; |
|
95 | + $this->template_args['datetime_selector'] = ''; |
|
96 | + if ( |
|
97 | + $this->ticket_selector_config->getShowDatetimeSelector() |
|
98 | + !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
99 | + ) { |
|
100 | + $datetime_selector = new DatetimeSelector( |
|
101 | + $this->event, |
|
102 | + $this->tickets, |
|
103 | + $this->ticket_selector_config, |
|
104 | + $this->date_format, |
|
105 | + $this->time_format |
|
106 | + ); |
|
107 | + $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
108 | + } |
|
109 | + // loop through tickets |
|
110 | + foreach ($this->tickets as $TKT_ID => $ticket) { |
|
111 | + if ($ticket instanceof \EE_Ticket) { |
|
112 | + $cols = 2; |
|
113 | + $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
114 | + $ticket_selector_row = new TicketSelectorRowStandard( |
|
115 | + $ticket, |
|
116 | + new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
117 | + $this->ticket_selector_config, |
|
118 | + $this->tax_config, |
|
119 | + $this->max_attendees, |
|
120 | + $row, |
|
121 | + $cols, |
|
122 | + $required_ticket_sold_out, |
|
123 | + $this->template_args['event_status'], |
|
124 | + $this->template_args['date_format'], |
|
125 | + $datetime_selector instanceof DatetimeSelector |
|
126 | + ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
127 | + : '' |
|
128 | + ); |
|
129 | + $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
130 | + $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
131 | + $row++; |
|
132 | + } |
|
133 | + } |
|
134 | + $this->template_args['row'] = $row; |
|
135 | + $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
136 | + $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
137 | + $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
138 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
139 | + remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
140 | + } |
|
141 | 141 | |
142 | 142 | |
143 | 143 |
@@ -135,7 +135,7 @@ |
||
135 | 135 | $this->template_args['ticket_row_html'] = $ticket_row_html; |
136 | 136 | $this->template_args['taxable_tickets'] = $taxable_tickets; |
137 | 137 | $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
138 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
138 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php'; |
|
139 | 139 | remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
140 | 140 | } |
141 | 141 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -12,165 +12,165 @@ discard block |
||
12 | 12 | class EE_Cron_Tasks extends EE_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * WordPress doesn't allow duplicate crons within 10 minutes of the original, |
|
17 | - * so we'll set our retry time for just over 10 minutes to avoid that |
|
18 | - */ |
|
19 | - const reschedule_timeout = 605; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * @var EE_Cron_Tasks |
|
24 | - */ |
|
25 | - private static $_instance; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @return EE_Cron_Tasks |
|
30 | - */ |
|
31 | - public static function instance() |
|
32 | - { |
|
33 | - if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
34 | - self::$_instance = new self(); |
|
35 | - } |
|
36 | - return self::$_instance; |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @access private |
|
42 | - */ |
|
43 | - private function __construct() |
|
44 | - { |
|
45 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
46 | - // verify that WP Cron is enabled |
|
47 | - if ( |
|
48 | - defined('DISABLE_WP_CRON') |
|
49 | - && DISABLE_WP_CRON |
|
50 | - && is_admin() |
|
51 | - && ! get_option('ee_disabled_wp_cron_check') |
|
52 | - ) { |
|
53 | - /** |
|
54 | - * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before |
|
55 | - * config is loaded. |
|
56 | - * This is intentionally using a anonymous function so that its not easily de-registered. Client code |
|
57 | - * wanting to not have this functionality can just register its own action at a priority after this one to |
|
58 | - * reverse any changes. |
|
59 | - */ |
|
60 | - add_action('AHEE__EE_System__load_core_configuration__complete', function () { |
|
61 | - EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
|
62 | - EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
63 | - add_option('ee_disabled_wp_cron_check', 1, '', false); |
|
64 | - }); |
|
65 | - } |
|
66 | - // UPDATE TRANSACTION WITH PAYMENT |
|
67 | - add_action( |
|
68 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
69 | - array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
70 | - 10, 2 |
|
71 | - ); |
|
72 | - // FINALIZE ABANDONED TRANSACTIONS |
|
73 | - add_action( |
|
74 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
75 | - array('EE_Cron_Tasks', 'check_for_abandoned_transactions'), |
|
76 | - 10, 1 |
|
77 | - ); |
|
15 | + /** |
|
16 | + * WordPress doesn't allow duplicate crons within 10 minutes of the original, |
|
17 | + * so we'll set our retry time for just over 10 minutes to avoid that |
|
18 | + */ |
|
19 | + const reschedule_timeout = 605; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * @var EE_Cron_Tasks |
|
24 | + */ |
|
25 | + private static $_instance; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @return EE_Cron_Tasks |
|
30 | + */ |
|
31 | + public static function instance() |
|
32 | + { |
|
33 | + if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
34 | + self::$_instance = new self(); |
|
35 | + } |
|
36 | + return self::$_instance; |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @access private |
|
42 | + */ |
|
43 | + private function __construct() |
|
44 | + { |
|
45 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
46 | + // verify that WP Cron is enabled |
|
47 | + if ( |
|
48 | + defined('DISABLE_WP_CRON') |
|
49 | + && DISABLE_WP_CRON |
|
50 | + && is_admin() |
|
51 | + && ! get_option('ee_disabled_wp_cron_check') |
|
52 | + ) { |
|
53 | + /** |
|
54 | + * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before |
|
55 | + * config is loaded. |
|
56 | + * This is intentionally using a anonymous function so that its not easily de-registered. Client code |
|
57 | + * wanting to not have this functionality can just register its own action at a priority after this one to |
|
58 | + * reverse any changes. |
|
59 | + */ |
|
60 | + add_action('AHEE__EE_System__load_core_configuration__complete', function () { |
|
61 | + EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
|
62 | + EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
63 | + add_option('ee_disabled_wp_cron_check', 1, '', false); |
|
64 | + }); |
|
65 | + } |
|
66 | + // UPDATE TRANSACTION WITH PAYMENT |
|
67 | + add_action( |
|
68 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
69 | + array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
70 | + 10, 2 |
|
71 | + ); |
|
72 | + // FINALIZE ABANDONED TRANSACTIONS |
|
73 | + add_action( |
|
74 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
75 | + array('EE_Cron_Tasks', 'check_for_abandoned_transactions'), |
|
76 | + 10, 1 |
|
77 | + ); |
|
78 | 78 | // EXPIRED TRANSACTION CHECK |
79 | 79 | add_action( |
80 | 80 | 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
81 | 81 | array( 'EE_Cron_Tasks', 'expired_transaction_check' ), |
82 | 82 | 10, 1 |
83 | 83 | ); |
84 | - // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
|
85 | - add_action( |
|
86 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
87 | - array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
88 | - ); |
|
89 | - // logging |
|
90 | - add_action( |
|
91 | - 'AHEE__EE_System__load_core_configuration__complete', |
|
92 | - array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
93 | - ); |
|
94 | - EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
95 | - //clean out old gateway logs |
|
96 | - add_action( |
|
97 | - 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs', |
|
98 | - array('EE_Cron_Tasks', 'clean_out_old_gateway_logs') |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * @access protected |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public static function log_scheduled_ee_crons() |
|
108 | - { |
|
109 | - $ee_crons = array( |
|
110 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment', |
|
111 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
112 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
113 | - ); |
|
114 | - $crons = (array) get_option('cron'); |
|
115 | - if ( ! is_array($crons)) { |
|
116 | - return; |
|
117 | - } |
|
118 | - foreach ($crons as $timestamp => $cron) { |
|
119 | - foreach ($ee_crons as $ee_cron) { |
|
120 | - if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) { |
|
121 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
122 | - foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
123 | - if ( ! empty($ee_cron_details['args'])) { |
|
124 | - do_action( |
|
125 | - 'AHEE_log', |
|
126 | - __CLASS__, |
|
127 | - __FUNCTION__, |
|
128 | - print_r($ee_cron_details['args'], true), |
|
129 | - "{$ee_cron} args" |
|
130 | - ); |
|
131 | - } |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * reschedule_cron_for_transactions_if_maintenance_mode |
|
142 | - * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes |
|
143 | - * |
|
144 | - * @param string $cron_task |
|
145 | - * @param array $TXN_IDs |
|
146 | - * @return bool |
|
147 | - * @throws \DomainException |
|
148 | - */ |
|
84 | + // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
|
85 | + add_action( |
|
86 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
87 | + array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
88 | + ); |
|
89 | + // logging |
|
90 | + add_action( |
|
91 | + 'AHEE__EE_System__load_core_configuration__complete', |
|
92 | + array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
93 | + ); |
|
94 | + EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
95 | + //clean out old gateway logs |
|
96 | + add_action( |
|
97 | + 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs', |
|
98 | + array('EE_Cron_Tasks', 'clean_out_old_gateway_logs') |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * @access protected |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public static function log_scheduled_ee_crons() |
|
108 | + { |
|
109 | + $ee_crons = array( |
|
110 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment', |
|
111 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
112 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
|
113 | + ); |
|
114 | + $crons = (array) get_option('cron'); |
|
115 | + if ( ! is_array($crons)) { |
|
116 | + return; |
|
117 | + } |
|
118 | + foreach ($crons as $timestamp => $cron) { |
|
119 | + foreach ($ee_crons as $ee_cron) { |
|
120 | + if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) { |
|
121 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
122 | + foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
123 | + if ( ! empty($ee_cron_details['args'])) { |
|
124 | + do_action( |
|
125 | + 'AHEE_log', |
|
126 | + __CLASS__, |
|
127 | + __FUNCTION__, |
|
128 | + print_r($ee_cron_details['args'], true), |
|
129 | + "{$ee_cron} args" |
|
130 | + ); |
|
131 | + } |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * reschedule_cron_for_transactions_if_maintenance_mode |
|
142 | + * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes |
|
143 | + * |
|
144 | + * @param string $cron_task |
|
145 | + * @param array $TXN_IDs |
|
146 | + * @return bool |
|
147 | + * @throws \DomainException |
|
148 | + */ |
|
149 | 149 | public static function reschedule_cron_for_transactions_if_maintenance_mode( $cron_task, array $TXN_IDs ) { |
150 | - if( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
151 | - throw new \DomainException( |
|
152 | - sprintf( |
|
153 | - __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
|
154 | - $cron_task |
|
155 | - ) |
|
156 | - ); |
|
157 | - } |
|
150 | + if( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
151 | + throw new \DomainException( |
|
152 | + sprintf( |
|
153 | + __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
|
154 | + $cron_task |
|
155 | + ) |
|
156 | + ); |
|
157 | + } |
|
158 | 158 | // reschedule the cron if we can't hit the db right now |
159 | 159 | if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
160 | 160 | foreach( $TXN_IDs as $TXN_ID => $additional_vars ) { |
161 | - // ensure $additional_vars is an array |
|
162 | - $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
|
161 | + // ensure $additional_vars is an array |
|
162 | + $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
|
163 | 163 | // reset cron job for the TXN |
164 | - call_user_func_array( |
|
165 | - array('EE_Cron_Tasks', $cron_task), |
|
166 | - array_merge( |
|
167 | - array( |
|
168 | - time() + (10 * MINUTE_IN_SECONDS), |
|
169 | - $TXN_ID |
|
170 | - ), |
|
171 | - $additional_vars |
|
172 | - ) |
|
173 | - ); |
|
164 | + call_user_func_array( |
|
165 | + array('EE_Cron_Tasks', $cron_task), |
|
166 | + array_merge( |
|
167 | + array( |
|
168 | + time() + (10 * MINUTE_IN_SECONDS), |
|
169 | + $TXN_ID |
|
170 | + ), |
|
171 | + $additional_vars |
|
172 | + ) |
|
173 | + ); |
|
174 | 174 | } |
175 | 175 | return true; |
176 | 176 | } |
@@ -180,85 +180,85 @@ discard block |
||
180 | 180 | |
181 | 181 | |
182 | 182 | |
183 | - /**************** UPDATE TRANSACTION WITH PAYMENT ****************/ |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * array of TXN IDs and the payment |
|
188 | - * |
|
189 | - * @var array |
|
190 | - */ |
|
191 | - protected static $_update_transactions_with_payment = array(); |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * schedule_update_transaction_with_payment |
|
196 | - * sets a wp_schedule_single_event() for updating any TXNs that may |
|
197 | - * require updating due to recently received payments |
|
198 | - * |
|
199 | - * @param int $timestamp |
|
200 | - * @param int $TXN_ID |
|
201 | - * @param int $PAY_ID |
|
202 | - */ |
|
203 | - public static function schedule_update_transaction_with_payment( |
|
204 | - $timestamp, |
|
205 | - $TXN_ID, |
|
206 | - $PAY_ID |
|
207 | - ) { |
|
208 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
209 | - // validate $TXN_ID and $timestamp |
|
210 | - $TXN_ID = absint($TXN_ID); |
|
211 | - $timestamp = absint($timestamp); |
|
212 | - if ($TXN_ID && $timestamp) { |
|
213 | - wp_schedule_single_event( |
|
214 | - $timestamp, |
|
215 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
216 | - array($TXN_ID, $PAY_ID) |
|
217 | - ); |
|
218 | - } |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * setup_update_for_transaction_with_payment |
|
224 | - * this is the callback for the action hook: |
|
225 | - * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' |
|
226 | - * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment(). |
|
227 | - * The passed TXN_ID and associated payment gets added to an array, and then |
|
228 | - * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into |
|
229 | - * 'shutdown' which will actually handle the processing of any |
|
230 | - * transactions requiring updating, because doing so now would be too early |
|
231 | - * and the required resources may not be available |
|
232 | - * |
|
233 | - * @param int $TXN_ID |
|
234 | - * @param int $PAY_ID |
|
235 | - */ |
|
236 | - public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) |
|
237 | - { |
|
238 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
239 | - if (absint($TXN_ID)) { |
|
240 | - self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
241 | - add_action( |
|
242 | - 'shutdown', |
|
243 | - array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
244 | - 5 |
|
245 | - ); |
|
246 | - } |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * update_transaction_with_payment |
|
252 | - * loops through the self::$_abandoned_transactions array |
|
253 | - * and attempts to finalize any TXNs that have not been completed |
|
254 | - * but have had their sessions expired, most likely due to a user not |
|
255 | - * returning from an off-site payment gateway |
|
256 | - * |
|
257 | - * @throws \EE_Error |
|
258 | - */ |
|
259 | - public static function update_transaction_with_payment() |
|
260 | - { |
|
261 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
183 | + /**************** UPDATE TRANSACTION WITH PAYMENT ****************/ |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * array of TXN IDs and the payment |
|
188 | + * |
|
189 | + * @var array |
|
190 | + */ |
|
191 | + protected static $_update_transactions_with_payment = array(); |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * schedule_update_transaction_with_payment |
|
196 | + * sets a wp_schedule_single_event() for updating any TXNs that may |
|
197 | + * require updating due to recently received payments |
|
198 | + * |
|
199 | + * @param int $timestamp |
|
200 | + * @param int $TXN_ID |
|
201 | + * @param int $PAY_ID |
|
202 | + */ |
|
203 | + public static function schedule_update_transaction_with_payment( |
|
204 | + $timestamp, |
|
205 | + $TXN_ID, |
|
206 | + $PAY_ID |
|
207 | + ) { |
|
208 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
209 | + // validate $TXN_ID and $timestamp |
|
210 | + $TXN_ID = absint($TXN_ID); |
|
211 | + $timestamp = absint($timestamp); |
|
212 | + if ($TXN_ID && $timestamp) { |
|
213 | + wp_schedule_single_event( |
|
214 | + $timestamp, |
|
215 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
|
216 | + array($TXN_ID, $PAY_ID) |
|
217 | + ); |
|
218 | + } |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * setup_update_for_transaction_with_payment |
|
224 | + * this is the callback for the action hook: |
|
225 | + * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' |
|
226 | + * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment(). |
|
227 | + * The passed TXN_ID and associated payment gets added to an array, and then |
|
228 | + * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into |
|
229 | + * 'shutdown' which will actually handle the processing of any |
|
230 | + * transactions requiring updating, because doing so now would be too early |
|
231 | + * and the required resources may not be available |
|
232 | + * |
|
233 | + * @param int $TXN_ID |
|
234 | + * @param int $PAY_ID |
|
235 | + */ |
|
236 | + public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) |
|
237 | + { |
|
238 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
239 | + if (absint($TXN_ID)) { |
|
240 | + self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
241 | + add_action( |
|
242 | + 'shutdown', |
|
243 | + array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
244 | + 5 |
|
245 | + ); |
|
246 | + } |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * update_transaction_with_payment |
|
252 | + * loops through the self::$_abandoned_transactions array |
|
253 | + * and attempts to finalize any TXNs that have not been completed |
|
254 | + * but have had their sessions expired, most likely due to a user not |
|
255 | + * returning from an off-site payment gateway |
|
256 | + * |
|
257 | + * @throws \EE_Error |
|
258 | + */ |
|
259 | + public static function update_transaction_with_payment() |
|
260 | + { |
|
261 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
262 | 262 | if ( |
263 | 263 | // are there any TXNs that need cleaning up ? |
264 | 264 | empty( self::$_update_transactions_with_payment ) |
@@ -268,119 +268,119 @@ discard block |
||
268 | 268 | self::$_update_transactions_with_payment |
269 | 269 | ) |
270 | 270 | ) { |
271 | - return; |
|
272 | - } |
|
273 | - /** @type EE_Payment_Processor $payment_processor */ |
|
274 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
275 | - // set revisit flag for payment processor |
|
276 | - $payment_processor->set_revisit(false); |
|
277 | - // load EEM_Transaction |
|
278 | - EE_Registry::instance()->load_model('Transaction'); |
|
279 | - foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
280 | - // reschedule the cron if we can't hit the db right now |
|
281 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
282 | - // reset cron job for updating the TXN |
|
283 | - EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
284 | - time() + EE_Cron_Tasks::reschedule_timeout, |
|
285 | - $TXN_ID, |
|
286 | - $PAY_ID |
|
287 | - ); |
|
288 | - continue; |
|
289 | - } |
|
290 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
291 | - $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
292 | - // verify transaction |
|
293 | - if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
294 | - // now try to update the TXN with any payments |
|
295 | - $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
296 | - } |
|
297 | - unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
298 | - } |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - |
|
303 | - /************ END OF UPDATE TRANSACTION WITH PAYMENT ************/ |
|
304 | - |
|
305 | - |
|
306 | - /***************** FINALIZE ABANDONED TRANSACTIONS *****************/ |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * array of TXN IDs |
|
311 | - * |
|
312 | - * @var array |
|
313 | - */ |
|
314 | - protected static $_abandoned_transactions = array(); |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * schedule_finalize_abandoned_transactions_check |
|
319 | - * sets a wp_schedule_single_event() for finalizing any TXNs that may |
|
320 | - * have been abandoned during the registration process |
|
321 | - * |
|
322 | - * @param int $timestamp |
|
323 | - * @param int $TXN_ID |
|
324 | - */ |
|
325 | - public static function schedule_finalize_abandoned_transactions_check( |
|
326 | - $timestamp, |
|
327 | - $TXN_ID |
|
328 | - ) { |
|
329 | - // validate $TXN_ID and $timestamp |
|
330 | - $TXN_ID = absint($TXN_ID); |
|
331 | - $timestamp = absint($timestamp); |
|
332 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
333 | - if ($TXN_ID && $timestamp) { |
|
334 | - wp_schedule_single_event( |
|
335 | - $timestamp, |
|
336 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
337 | - array($TXN_ID) |
|
338 | - ); |
|
339 | - } |
|
340 | - } |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * check_for_abandoned_transactions |
|
345 | - * this is the callback for the action hook: |
|
346 | - * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions' |
|
347 | - * which is utilized by wp_schedule_single_event() |
|
348 | - * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing(). |
|
349 | - * The passed TXN_ID gets added to an array, and then the |
|
350 | - * espresso_finalize_abandoned_transactions() function is hooked into |
|
351 | - * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
352 | - * processing of any abandoned transactions, because doing so now would be |
|
353 | - * too early and the required resources may not be available |
|
354 | - * |
|
355 | - * @param int $TXN_ID |
|
356 | - */ |
|
357 | - public static function check_for_abandoned_transactions($TXN_ID = 0) |
|
358 | - { |
|
359 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
360 | - if (absint($TXN_ID)) { |
|
361 | - self::$_abandoned_transactions[] = $TXN_ID; |
|
362 | - add_action( |
|
363 | - 'shutdown', |
|
364 | - array('EE_Cron_Tasks', 'finalize_abandoned_transactions'), |
|
365 | - 5 |
|
366 | - ); |
|
367 | - } |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * finalize_abandoned_transactions |
|
373 | - * loops through the self::$_abandoned_transactions array |
|
374 | - * and attempts to finalize any TXNs that have not been completed |
|
375 | - * but have had their sessions expired, most likely due to a user not |
|
376 | - * returning from an off-site payment gateway |
|
377 | - * |
|
378 | - * @throws \EE_Error |
|
379 | - */ |
|
380 | - public static function finalize_abandoned_transactions() |
|
381 | - { |
|
382 | - do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
383 | - if ( |
|
271 | + return; |
|
272 | + } |
|
273 | + /** @type EE_Payment_Processor $payment_processor */ |
|
274 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
275 | + // set revisit flag for payment processor |
|
276 | + $payment_processor->set_revisit(false); |
|
277 | + // load EEM_Transaction |
|
278 | + EE_Registry::instance()->load_model('Transaction'); |
|
279 | + foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
280 | + // reschedule the cron if we can't hit the db right now |
|
281 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
282 | + // reset cron job for updating the TXN |
|
283 | + EE_Cron_Tasks::schedule_update_transaction_with_payment( |
|
284 | + time() + EE_Cron_Tasks::reschedule_timeout, |
|
285 | + $TXN_ID, |
|
286 | + $PAY_ID |
|
287 | + ); |
|
288 | + continue; |
|
289 | + } |
|
290 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
291 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
292 | + // verify transaction |
|
293 | + if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
294 | + // now try to update the TXN with any payments |
|
295 | + $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
296 | + } |
|
297 | + unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
298 | + } |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + |
|
303 | + /************ END OF UPDATE TRANSACTION WITH PAYMENT ************/ |
|
304 | + |
|
305 | + |
|
306 | + /***************** FINALIZE ABANDONED TRANSACTIONS *****************/ |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * array of TXN IDs |
|
311 | + * |
|
312 | + * @var array |
|
313 | + */ |
|
314 | + protected static $_abandoned_transactions = array(); |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * schedule_finalize_abandoned_transactions_check |
|
319 | + * sets a wp_schedule_single_event() for finalizing any TXNs that may |
|
320 | + * have been abandoned during the registration process |
|
321 | + * |
|
322 | + * @param int $timestamp |
|
323 | + * @param int $TXN_ID |
|
324 | + */ |
|
325 | + public static function schedule_finalize_abandoned_transactions_check( |
|
326 | + $timestamp, |
|
327 | + $TXN_ID |
|
328 | + ) { |
|
329 | + // validate $TXN_ID and $timestamp |
|
330 | + $TXN_ID = absint($TXN_ID); |
|
331 | + $timestamp = absint($timestamp); |
|
332 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
333 | + if ($TXN_ID && $timestamp) { |
|
334 | + wp_schedule_single_event( |
|
335 | + $timestamp, |
|
336 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
|
337 | + array($TXN_ID) |
|
338 | + ); |
|
339 | + } |
|
340 | + } |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * check_for_abandoned_transactions |
|
345 | + * this is the callback for the action hook: |
|
346 | + * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions' |
|
347 | + * which is utilized by wp_schedule_single_event() |
|
348 | + * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing(). |
|
349 | + * The passed TXN_ID gets added to an array, and then the |
|
350 | + * espresso_finalize_abandoned_transactions() function is hooked into |
|
351 | + * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the |
|
352 | + * processing of any abandoned transactions, because doing so now would be |
|
353 | + * too early and the required resources may not be available |
|
354 | + * |
|
355 | + * @param int $TXN_ID |
|
356 | + */ |
|
357 | + public static function check_for_abandoned_transactions($TXN_ID = 0) |
|
358 | + { |
|
359 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
360 | + if (absint($TXN_ID)) { |
|
361 | + self::$_abandoned_transactions[] = $TXN_ID; |
|
362 | + add_action( |
|
363 | + 'shutdown', |
|
364 | + array('EE_Cron_Tasks', 'finalize_abandoned_transactions'), |
|
365 | + 5 |
|
366 | + ); |
|
367 | + } |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * finalize_abandoned_transactions |
|
373 | + * loops through the self::$_abandoned_transactions array |
|
374 | + * and attempts to finalize any TXNs that have not been completed |
|
375 | + * but have had their sessions expired, most likely due to a user not |
|
376 | + * returning from an off-site payment gateway |
|
377 | + * |
|
378 | + * @throws \EE_Error |
|
379 | + */ |
|
380 | + public static function finalize_abandoned_transactions() |
|
381 | + { |
|
382 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
383 | + if ( |
|
384 | 384 | // are there any TXNs that need cleaning up ? |
385 | 385 | empty( self::$_abandoned_transactions ) |
386 | 386 | // reschedule the cron if we can't hit the db right now |
@@ -389,45 +389,45 @@ discard block |
||
389 | 389 | self::$_abandoned_transactions |
390 | 390 | ) |
391 | 391 | ) { |
392 | - return; |
|
393 | - } |
|
394 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
395 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
396 | - // set revisit flag for txn processor |
|
397 | - $transaction_processor->set_revisit(false); |
|
398 | - /** @type EE_Payment_Processor $payment_processor */ |
|
399 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
400 | - // load EEM_Transaction |
|
401 | - EE_Registry::instance()->load_model('Transaction'); |
|
402 | - foreach (self::$_abandoned_transactions as $TXN_ID) { |
|
403 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
404 | - // reschedule the cron if we can't hit the db right now |
|
405 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
406 | - // reset cron job for finalizing the TXN |
|
407 | - EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
|
408 | - time() + EE_Cron_Tasks::reschedule_timeout, |
|
409 | - $TXN_ID |
|
410 | - ); |
|
411 | - continue; |
|
412 | - } |
|
413 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
414 | - // verify transaction |
|
415 | - if ($transaction instanceof EE_Transaction) { |
|
416 | - // don't finalize the TXN if it has already been completed |
|
417 | - if ($transaction->all_reg_steps_completed() === true) { |
|
418 | - continue; |
|
419 | - } |
|
420 | - // let's simulate an IPN here which will trigger any notifications that need to go out |
|
421 | - $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, |
|
422 | - true); |
|
423 | - } |
|
424 | - unset(self::$_abandoned_transactions[$TXN_ID]); |
|
425 | - } |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - |
|
430 | - /************* END OF FINALIZE ABANDONED TRANSACTIONS *************/ |
|
392 | + return; |
|
393 | + } |
|
394 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
395 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
396 | + // set revisit flag for txn processor |
|
397 | + $transaction_processor->set_revisit(false); |
|
398 | + /** @type EE_Payment_Processor $payment_processor */ |
|
399 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
400 | + // load EEM_Transaction |
|
401 | + EE_Registry::instance()->load_model('Transaction'); |
|
402 | + foreach (self::$_abandoned_transactions as $TXN_ID) { |
|
403 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
404 | + // reschedule the cron if we can't hit the db right now |
|
405 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
406 | + // reset cron job for finalizing the TXN |
|
407 | + EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
|
408 | + time() + EE_Cron_Tasks::reschedule_timeout, |
|
409 | + $TXN_ID |
|
410 | + ); |
|
411 | + continue; |
|
412 | + } |
|
413 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
414 | + // verify transaction |
|
415 | + if ($transaction instanceof EE_Transaction) { |
|
416 | + // don't finalize the TXN if it has already been completed |
|
417 | + if ($transaction->all_reg_steps_completed() === true) { |
|
418 | + continue; |
|
419 | + } |
|
420 | + // let's simulate an IPN here which will trigger any notifications that need to go out |
|
421 | + $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, |
|
422 | + true); |
|
423 | + } |
|
424 | + unset(self::$_abandoned_transactions[$TXN_ID]); |
|
425 | + } |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + |
|
430 | + /************* END OF FINALIZE ABANDONED TRANSACTIONS *************/ |
|
431 | 431 | |
432 | 432 | |
433 | 433 | /***************** EXPIRED TRANSACTION CHECK *****************/ |
@@ -496,12 +496,12 @@ discard block |
||
496 | 496 | |
497 | 497 | |
498 | 498 | |
499 | - /** |
|
500 | - * process_expired_transactions |
|
501 | - * loops through the self::$_expired_transactions array and processes any failed TXNs |
|
502 | - * |
|
503 | - * @throws \EE_Error |
|
504 | - */ |
|
499 | + /** |
|
500 | + * process_expired_transactions |
|
501 | + * loops through the self::$_expired_transactions array and processes any failed TXNs |
|
502 | + * |
|
503 | + * @throws \EE_Error |
|
504 | + */ |
|
505 | 505 | public static function process_expired_transactions() { |
506 | 506 | if ( |
507 | 507 | // are there any TXNs that need cleaning up ? |
@@ -512,58 +512,58 @@ discard block |
||
512 | 512 | self::$_expired_transactions |
513 | 513 | ) |
514 | 514 | ) { |
515 | - return; |
|
516 | - } |
|
517 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
518 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
519 | - // set revisit flag for txn processor |
|
520 | - $transaction_processor->set_revisit( false ); |
|
521 | - // load EEM_Transaction |
|
522 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
523 | - foreach ( self::$_expired_transactions as $TXN_ID ) { |
|
524 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
525 | - // verify transaction and whether it is failed or not |
|
526 | - if ( $transaction instanceof EE_Transaction) { |
|
527 | - switch( $transaction->status_ID() ) { |
|
528 | - // Completed TXNs |
|
529 | - case EEM_Transaction::complete_status_code : |
|
530 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction ); |
|
531 | - break; |
|
532 | - // Overpaid TXNs |
|
533 | - case EEM_Transaction::overpaid_status_code : |
|
534 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction ); |
|
535 | - break; |
|
536 | - // Incomplete TXNs |
|
537 | - case EEM_Transaction::incomplete_status_code : |
|
538 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction ); |
|
539 | - // todo : merge the finalize_abandoned_transactions cron into this one... |
|
540 | - // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
541 | - break; |
|
542 | - // Failed TXNs |
|
543 | - case EEM_Transaction::failed_status_code : |
|
544 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction ); |
|
545 | - // todo : perform garbage collection here and remove clean_out_junk_transactions() |
|
546 | - //$registrations = $transaction->registrations(); |
|
547 | - //if ( ! empty( $registrations ) ) { |
|
548 | - // foreach ( $registrations as $registration ) { |
|
549 | - // if ( $registration instanceof EE_Registration ) { |
|
550 | - //$delete_registration = true; |
|
551 | - //if ( $registration->attendee() instanceof EE_Attendee ) { |
|
552 | - // $delete_registration = false; |
|
553 | - //} |
|
554 | - //if ( $delete_registration ) { |
|
555 | - // $registration->delete_permanently(); |
|
556 | - // $registration->delete_related_permanently(); |
|
557 | - //} |
|
558 | - // } |
|
559 | - // } |
|
560 | - //} |
|
561 | - break; |
|
562 | - } |
|
563 | - |
|
564 | - } |
|
565 | - unset( self::$_expired_transactions[ $TXN_ID ] ); |
|
566 | - } |
|
515 | + return; |
|
516 | + } |
|
517 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
518 | + $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
519 | + // set revisit flag for txn processor |
|
520 | + $transaction_processor->set_revisit( false ); |
|
521 | + // load EEM_Transaction |
|
522 | + EE_Registry::instance()->load_model( 'Transaction' ); |
|
523 | + foreach ( self::$_expired_transactions as $TXN_ID ) { |
|
524 | + $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
525 | + // verify transaction and whether it is failed or not |
|
526 | + if ( $transaction instanceof EE_Transaction) { |
|
527 | + switch( $transaction->status_ID() ) { |
|
528 | + // Completed TXNs |
|
529 | + case EEM_Transaction::complete_status_code : |
|
530 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction ); |
|
531 | + break; |
|
532 | + // Overpaid TXNs |
|
533 | + case EEM_Transaction::overpaid_status_code : |
|
534 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction ); |
|
535 | + break; |
|
536 | + // Incomplete TXNs |
|
537 | + case EEM_Transaction::incomplete_status_code : |
|
538 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction ); |
|
539 | + // todo : merge the finalize_abandoned_transactions cron into this one... |
|
540 | + // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
|
541 | + break; |
|
542 | + // Failed TXNs |
|
543 | + case EEM_Transaction::failed_status_code : |
|
544 | + do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction ); |
|
545 | + // todo : perform garbage collection here and remove clean_out_junk_transactions() |
|
546 | + //$registrations = $transaction->registrations(); |
|
547 | + //if ( ! empty( $registrations ) ) { |
|
548 | + // foreach ( $registrations as $registration ) { |
|
549 | + // if ( $registration instanceof EE_Registration ) { |
|
550 | + //$delete_registration = true; |
|
551 | + //if ( $registration->attendee() instanceof EE_Attendee ) { |
|
552 | + // $delete_registration = false; |
|
553 | + //} |
|
554 | + //if ( $delete_registration ) { |
|
555 | + // $registration->delete_permanently(); |
|
556 | + // $registration->delete_related_permanently(); |
|
557 | + //} |
|
558 | + // } |
|
559 | + // } |
|
560 | + //} |
|
561 | + break; |
|
562 | + } |
|
563 | + |
|
564 | + } |
|
565 | + unset( self::$_expired_transactions[ $TXN_ID ] ); |
|
566 | + } |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -571,33 +571,33 @@ discard block |
||
571 | 571 | /************* END OF EXPIRED TRANSACTION CHECK *************/ |
572 | 572 | |
573 | 573 | |
574 | - /************* START CLEAN UP BOT TRANSACTIONS **********************/ |
|
575 | - |
|
576 | - //when a transaction is initially made, schedule this check. |
|
577 | - //if it has NO REG data by the time it has expired, forget about it |
|
578 | - public static function clean_out_junk_transactions() |
|
579 | - { |
|
580 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
581 | - EEM_Transaction::instance('')->delete_junk_transactions(); |
|
582 | - EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
|
583 | - EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
|
584 | - } |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - |
|
589 | - /** |
|
590 | - * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
|
591 | - */ |
|
592 | - public static function clean_out_old_gateway_logs(){ |
|
593 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
594 | - $time_diff_for_comparison = apply_filters( |
|
595 | - 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
|
596 | - "-1 week" |
|
597 | - ); |
|
598 | - EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison)); |
|
599 | - } |
|
600 | - } |
|
574 | + /************* START CLEAN UP BOT TRANSACTIONS **********************/ |
|
575 | + |
|
576 | + //when a transaction is initially made, schedule this check. |
|
577 | + //if it has NO REG data by the time it has expired, forget about it |
|
578 | + public static function clean_out_junk_transactions() |
|
579 | + { |
|
580 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
581 | + EEM_Transaction::instance('')->delete_junk_transactions(); |
|
582 | + EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
|
583 | + EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
|
584 | + } |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + |
|
589 | + /** |
|
590 | + * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
|
591 | + */ |
|
592 | + public static function clean_out_old_gateway_logs(){ |
|
593 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
594 | + $time_diff_for_comparison = apply_filters( |
|
595 | + 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
|
596 | + "-1 week" |
|
597 | + ); |
|
598 | + EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison)); |
|
599 | + } |
|
600 | + } |
|
601 | 601 | |
602 | 602 | |
603 | 603 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * wanting to not have this functionality can just register its own action at a priority after this one to |
58 | 58 | * reverse any changes. |
59 | 59 | */ |
60 | - add_action('AHEE__EE_System__load_core_configuration__complete', function () { |
|
60 | + add_action('AHEE__EE_System__load_core_configuration__complete', function() { |
|
61 | 61 | EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true; |
62 | 62 | EE_Registry::instance()->NET_CFG->update_config(true, false); |
63 | 63 | add_option('ee_disabled_wp_cron_check', 1, '', false); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // EXPIRED TRANSACTION CHECK |
79 | 79 | add_action( |
80 | 80 | 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
81 | - array( 'EE_Cron_Tasks', 'expired_transaction_check' ), |
|
81 | + array('EE_Cron_Tasks', 'expired_transaction_check'), |
|
82 | 82 | 10, 1 |
83 | 83 | ); |
84 | 84 | // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @return bool |
147 | 147 | * @throws \DomainException |
148 | 148 | */ |
149 | - public static function reschedule_cron_for_transactions_if_maintenance_mode( $cron_task, array $TXN_IDs ) { |
|
150 | - if( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
149 | + public static function reschedule_cron_for_transactions_if_maintenance_mode($cron_task, array $TXN_IDs) { |
|
150 | + if ( ! method_exists('EE_Cron_Tasks', $cron_task)) { |
|
151 | 151 | throw new \DomainException( |
152 | 152 | sprintf( |
153 | 153 | __('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'), |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | ); |
157 | 157 | } |
158 | 158 | // reschedule the cron if we can't hit the db right now |
159 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
160 | - foreach( $TXN_IDs as $TXN_ID => $additional_vars ) { |
|
159 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
160 | + foreach ($TXN_IDs as $TXN_ID => $additional_vars) { |
|
161 | 161 | // ensure $additional_vars is an array |
162 | 162 | $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars); |
163 | 163 | // reset cron job for the TXN |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | do_action('AHEE_log', __CLASS__, __FUNCTION__); |
262 | 262 | if ( |
263 | 263 | // are there any TXNs that need cleaning up ? |
264 | - empty( self::$_update_transactions_with_payment ) |
|
264 | + empty(self::$_update_transactions_with_payment) |
|
265 | 265 | // reschedule the cron if we can't hit the db right now |
266 | 266 | || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
267 | 267 | 'schedule_update_transaction_with_payment', |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | do_action('AHEE_log', __CLASS__, __FUNCTION__); |
383 | 383 | if ( |
384 | 384 | // are there any TXNs that need cleaning up ? |
385 | - empty( self::$_abandoned_transactions ) |
|
385 | + empty(self::$_abandoned_transactions) |
|
386 | 386 | // reschedule the cron if we can't hit the db right now |
387 | 387 | || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
388 | 388 | 'schedule_finalize_abandoned_transactions_check', |
@@ -455,13 +455,13 @@ discard block |
||
455 | 455 | $TXN_ID |
456 | 456 | ) { |
457 | 457 | // validate $TXN_ID and $timestamp |
458 | - $TXN_ID = absint( $TXN_ID ); |
|
459 | - $timestamp = absint( $timestamp ); |
|
460 | - if ( $TXN_ID && $timestamp ) { |
|
458 | + $TXN_ID = absint($TXN_ID); |
|
459 | + $timestamp = absint($timestamp); |
|
460 | + if ($TXN_ID && $timestamp) { |
|
461 | 461 | wp_schedule_single_event( |
462 | 462 | $timestamp, |
463 | 463 | 'AHEE__EE_Cron_Tasks__expired_transaction_check', |
464 | - array( $TXN_ID ) |
|
464 | + array($TXN_ID) |
|
465 | 465 | ); |
466 | 466 | } |
467 | 467 | } |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | * |
484 | 484 | * @param int $TXN_ID |
485 | 485 | */ |
486 | - public static function expired_transaction_check( $TXN_ID = 0 ) { |
|
487 | - if ( absint( $TXN_ID )) { |
|
488 | - self::$_expired_transactions[ $TXN_ID ] = $TXN_ID; |
|
486 | + public static function expired_transaction_check($TXN_ID = 0) { |
|
487 | + if (absint($TXN_ID)) { |
|
488 | + self::$_expired_transactions[$TXN_ID] = $TXN_ID; |
|
489 | 489 | add_action( |
490 | 490 | 'shutdown', |
491 | - array( 'EE_Cron_Tasks', 'process_expired_transactions' ), |
|
491 | + array('EE_Cron_Tasks', 'process_expired_transactions'), |
|
492 | 492 | 5 |
493 | 493 | ); |
494 | 494 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | public static function process_expired_transactions() { |
506 | 506 | if ( |
507 | 507 | // are there any TXNs that need cleaning up ? |
508 | - empty( self::$_expired_transactions ) |
|
508 | + empty(self::$_expired_transactions) |
|
509 | 509 | // reschedule the cron if we can't hit the db right now |
510 | 510 | || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode( |
511 | 511 | 'schedule_expired_transaction_check', |
@@ -515,33 +515,33 @@ discard block |
||
515 | 515 | return; |
516 | 516 | } |
517 | 517 | /** @type EE_Transaction_Processor $transaction_processor */ |
518 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
518 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
519 | 519 | // set revisit flag for txn processor |
520 | - $transaction_processor->set_revisit( false ); |
|
520 | + $transaction_processor->set_revisit(false); |
|
521 | 521 | // load EEM_Transaction |
522 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
523 | - foreach ( self::$_expired_transactions as $TXN_ID ) { |
|
524 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
522 | + EE_Registry::instance()->load_model('Transaction'); |
|
523 | + foreach (self::$_expired_transactions as $TXN_ID) { |
|
524 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
525 | 525 | // verify transaction and whether it is failed or not |
526 | - if ( $transaction instanceof EE_Transaction) { |
|
527 | - switch( $transaction->status_ID() ) { |
|
526 | + if ($transaction instanceof EE_Transaction) { |
|
527 | + switch ($transaction->status_ID()) { |
|
528 | 528 | // Completed TXNs |
529 | 529 | case EEM_Transaction::complete_status_code : |
530 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction ); |
|
530 | + do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction', $transaction); |
|
531 | 531 | break; |
532 | 532 | // Overpaid TXNs |
533 | 533 | case EEM_Transaction::overpaid_status_code : |
534 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction ); |
|
534 | + do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction', $transaction); |
|
535 | 535 | break; |
536 | 536 | // Incomplete TXNs |
537 | 537 | case EEM_Transaction::incomplete_status_code : |
538 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction ); |
|
538 | + do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', $transaction); |
|
539 | 539 | // todo : merge the finalize_abandoned_transactions cron into this one... |
540 | 540 | // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions |
541 | 541 | break; |
542 | 542 | // Failed TXNs |
543 | 543 | case EEM_Transaction::failed_status_code : |
544 | - do_action( 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction ); |
|
544 | + do_action('AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', $transaction); |
|
545 | 545 | // todo : perform garbage collection here and remove clean_out_junk_transactions() |
546 | 546 | //$registrations = $transaction->registrations(); |
547 | 547 | //if ( ! empty( $registrations ) ) { |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | } |
563 | 563 | |
564 | 564 | } |
565 | - unset( self::$_expired_transactions[ $TXN_ID ] ); |
|
565 | + unset(self::$_expired_transactions[$TXN_ID]); |
|
566 | 566 | } |
567 | 567 | } |
568 | 568 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | /** |
590 | 590 | * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that. |
591 | 591 | */ |
592 | - public static function clean_out_old_gateway_logs(){ |
|
592 | + public static function clean_out_old_gateway_logs() { |
|
593 | 593 | if (EE_Maintenance_Mode::instance()->models_can_query()) { |
594 | 594 | $time_diff_for_comparison = apply_filters( |
595 | 595 | 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison', |
@@ -174,22 +174,22 @@ |
||
174 | 174 | |
175 | 175 | |
176 | 176 | |
177 | - /** |
|
178 | - * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use |
|
179 | - * models after this, they may be out-of-sync with the database |
|
180 | - * @param DateTime $datetime |
|
181 | - * @return false|int |
|
182 | - */ |
|
177 | + /** |
|
178 | + * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use |
|
179 | + * models after this, they may be out-of-sync with the database |
|
180 | + * @param DateTime $datetime |
|
181 | + * @return false|int |
|
182 | + */ |
|
183 | 183 | public function delete_gateway_logs_older_than(DateTime $datetime ) { |
184 | - global $wpdb; |
|
185 | - return $wpdb->query( |
|
186 | - $wpdb->prepare( |
|
187 | - 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
188 | - EEM_Change_Log::type_gateway, |
|
189 | - $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
|
190 | - ) |
|
191 | - ); |
|
192 | - } |
|
184 | + global $wpdb; |
|
185 | + return $wpdb->query( |
|
186 | + $wpdb->prepare( |
|
187 | + 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
188 | + EEM_Change_Log::type_gateway, |
|
189 | + $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
|
190 | + ) |
|
191 | + ); |
|
192 | + } |
|
193 | 193 | |
194 | 194 | |
195 | 195 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEM_Change_Log extends EEM_Base{ |
|
28 | +class EEM_Change_Log extends EEM_Base { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * the related object was created log type |
@@ -68,19 +68,19 @@ discard block |
||
68 | 68 | * @access protected |
69 | 69 | * @return EEM_Change_Log |
70 | 70 | */ |
71 | - protected function __construct( $timezone = null ){ |
|
71 | + protected function __construct($timezone = null) { |
|
72 | 72 | global $current_user; |
73 | - $this->singular_item = __('Log','event_espresso'); |
|
74 | - $this->plural_item = __('Logs','event_espresso'); |
|
73 | + $this->singular_item = __('Log', 'event_espresso'); |
|
74 | + $this->plural_item = __('Logs', 'event_espresso'); |
|
75 | 75 | $this->_tables = array( |
76 | 76 | 'Log'=> new EE_Primary_Table('esp_log', 'LOG_ID') |
77 | 77 | ); |
78 | 78 | $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
79 | 79 | $this->_fields = array( |
80 | 80 | 'Log'=>array( |
81 | - 'LOG_ID'=> new EE_Primary_Key_Int_Field('LOG_ID', __('Log ID','event_espresso')), |
|
82 | - 'LOG_time'=>new EE_Datetime_Field('LOG_time', __("Log Time", 'event_espresso'), false, EE_Datetime_Field::now ), |
|
83 | - 'OBJ_ID'=>new EE_Foreign_Key_String_Field('OBJ_ID', __("Object ID (int or string)", 'event_espresso'), true, NULL,$models_this_can_attach_to), |
|
81 | + 'LOG_ID'=> new EE_Primary_Key_Int_Field('LOG_ID', __('Log ID', 'event_espresso')), |
|
82 | + 'LOG_time'=>new EE_Datetime_Field('LOG_time', __("Log Time", 'event_espresso'), false, EE_Datetime_Field::now), |
|
83 | + 'OBJ_ID'=>new EE_Foreign_Key_String_Field('OBJ_ID', __("Object ID (int or string)", 'event_espresso'), true, NULL, $models_this_can_attach_to), |
|
84 | 84 | 'OBJ_type'=>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Object Type", 'event_espresso'), true, NULL, $models_this_can_attach_to), |
85 | 85 | 'LOG_type'=>new EE_Enum_Text_Field('LOG_type', __("Type of log entry", "event_espresso"), false, self::type_debug, |
86 | 86 | array( |
@@ -92,24 +92,24 @@ discard block |
||
92 | 92 | self::type_gateway=> __("Gateway Interaction (IPN or Direct Payment)", 'event_espresso'), |
93 | 93 | )), |
94 | 94 | 'LOG_message'=>new EE_Maybe_Serialized_Text_Field('LOG_message', __("Log Message (body)", 'event_espresso'), true), |
95 | - 'LOG_wp_user' => new EE_WP_User_Field('LOG_wp_user', __("User who was logged in while this occurred", 'event_espresso'), true ), |
|
95 | + 'LOG_wp_user' => new EE_WP_User_Field('LOG_wp_user', __("User who was logged in while this occurred", 'event_espresso'), true), |
|
96 | 96 | |
97 | 97 | )); |
98 | 98 | $this->_model_relations = array(); |
99 | - foreach($models_this_can_attach_to as $model){ |
|
100 | - if( $model == 'WP_User' ){ |
|
101 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
102 | - }elseif( $model != 'Change_Log' ) { |
|
99 | + foreach ($models_this_can_attach_to as $model) { |
|
100 | + if ($model == 'WP_User') { |
|
101 | + $this->_model_relations[$model] = new EE_Belongs_To_Relation(); |
|
102 | + }elseif ($model != 'Change_Log') { |
|
103 | 103 | $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation(); |
104 | 104 | } |
105 | 105 | } |
106 | 106 | //use completely custom caps for this |
107 | 107 | $this->_cap_restriction_generators = false; |
108 | 108 | //caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
109 | - foreach( $this->_cap_contexts_to_cap_action_map as $cap_context => $action ) { |
|
110 | - $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions(); |
|
109 | + foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
|
110 | + $this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()] = new EE_Return_None_Where_Conditions(); |
|
111 | 111 | } |
112 | - parent::__construct( $timezone ); |
|
112 | + parent::__construct($timezone); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | * @param EE_Base_Class $related_model_obj |
120 | 120 | * @return EE_Change_Log |
121 | 121 | */ |
122 | - public function log($log_type,$message,$related_model_obj){ |
|
123 | - if($related_model_obj instanceof EE_Base_Class){ |
|
122 | + public function log($log_type, $message, $related_model_obj) { |
|
123 | + if ($related_model_obj instanceof EE_Base_Class) { |
|
124 | 124 | $obj_id = $related_model_obj->ID(); |
125 | 125 | $obj_type = $related_model_obj->get_model()->get_this_model_name(); |
126 | - }else{ |
|
126 | + } else { |
|
127 | 127 | $obj_id = NULL; |
128 | 128 | $obj_type = NULL; |
129 | 129 | } |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * @throws EE_Error |
148 | 148 | * @return EE_Change_Log |
149 | 149 | */ |
150 | - public function gateway_log( $message, $related_obj_id, $related_obj_type ){ |
|
151 | - if( ! EE_Registry::instance()->is_model_name($related_obj_type)){ |
|
152 | - throw new EE_Error(sprintf(__("'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", "event_espresso"),$related_obj_type)); |
|
150 | + public function gateway_log($message, $related_obj_id, $related_obj_type) { |
|
151 | + if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
152 | + throw new EE_Error(sprintf(__("'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", "event_espresso"), $related_obj_type)); |
|
153 | 153 | } |
154 | 154 | $log = EE_Change_Log::new_instance(array( |
155 | 155 | 'LOG_type'=>EEM_Change_Log::type_gateway, |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param array $query_params @see EEM_Base::get_all |
169 | 169 | * @return array of arrays |
170 | 170 | */ |
171 | - public function get_all_efficiently($query_params){ |
|
171 | + public function get_all_efficiently($query_params) { |
|
172 | 172 | return $this->_get_all_wpdb_results($query_params); |
173 | 173 | } |
174 | 174 | |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | * @param DateTime $datetime |
181 | 181 | * @return false|int |
182 | 182 | */ |
183 | - public function delete_gateway_logs_older_than(DateTime $datetime ) { |
|
183 | + public function delete_gateway_logs_older_than(DateTime $datetime) { |
|
184 | 184 | global $wpdb; |
185 | 185 | return $wpdb->query( |
186 | 186 | $wpdb->prepare( |
187 | - 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
187 | + 'DELETE FROM '.$this->table().' WHERE LOG_type = %s AND LOG_time < %s', |
|
188 | 188 | EEM_Change_Log::type_gateway, |
189 | 189 | $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
190 | 190 | ) |