@@ -21,576 +21,576 @@ |
||
21 | 21 | class EE_Payment_Method_Manager implements ResettableInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * prefix added to all payment method capabilities names |
|
26 | - */ |
|
27 | - const CAPABILITIES_PREFIX= 'ee_payment_method_'; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var EE_Payment_Method_Manager $_instance |
|
31 | - */ |
|
32 | - private static $_instance; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean |
|
36 | - */ |
|
37 | - protected $payment_method_caps_initialized = false; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var array keys are class names without 'EE_PMT_', values are their filepaths |
|
41 | - */ |
|
42 | - protected $_payment_method_types = array(); |
|
43 | - |
|
44 | - /** |
|
45 | - * @var EE_PMT_Base[] |
|
46 | - */ |
|
47 | - protected $payment_method_objects = array(); |
|
48 | - |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * EE_Payment_Method_Manager constructor. |
|
53 | - * |
|
54 | - * @throws EE_Error |
|
55 | - * @throws DomainException |
|
56 | - */ |
|
57 | - public function __construct() |
|
58 | - { |
|
59 | - // if in admin lets ensure caps are set. |
|
60 | - if (is_admin()) { |
|
61 | - $this->_register_payment_methods(); |
|
62 | - // set them immediately |
|
63 | - $this->initializePaymentMethodCaps(); |
|
64 | - // plus any time they get reset |
|
65 | - add_filter( |
|
66 | - 'FHEE__EE_Capabilities__addCaps__capabilities_to_add', |
|
67 | - array($this, 'addPaymentMethodCapsDuringReset') |
|
68 | - ); |
|
69 | - } |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @singleton method used to instantiate class object |
|
76 | - * @return EE_Payment_Method_Manager instance |
|
77 | - * @throws DomainException |
|
78 | - * @throws EE_Error |
|
79 | - */ |
|
80 | - public static function instance() |
|
81 | - { |
|
82 | - // check if class object is instantiated, and instantiated properly |
|
83 | - if (! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
84 | - EE_Registry::instance()->load_lib('PMT_Base'); |
|
85 | - self::$_instance = new self(); |
|
86 | - } |
|
87 | - return self::$_instance; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * Resets the instance and returns a new one |
|
94 | - * |
|
95 | - * @return EE_Payment_Method_Manager |
|
96 | - * @throws DomainException |
|
97 | - * @throws EE_Error |
|
98 | - */ |
|
99 | - public static function reset() |
|
100 | - { |
|
101 | - self::$_instance = null; |
|
102 | - return self::instance(); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * If necessary, re-register payment methods |
|
109 | - * |
|
110 | - * @param boolean $force_recheck whether to recheck for payment method types, |
|
111 | - * or just re-use the PMTs we found last time we checked during this request (if |
|
112 | - * we have not yet checked during this request, then we need to check anyways) |
|
113 | - */ |
|
114 | - public function maybe_register_payment_methods($force_recheck = false) |
|
115 | - { |
|
116 | - if (! $this->_payment_method_types || $force_recheck) { |
|
117 | - $this->_register_payment_methods(); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * register_payment_methods |
|
125 | - * |
|
126 | - * @return array |
|
127 | - */ |
|
128 | - protected function _register_payment_methods() |
|
129 | - { |
|
130 | - // grab list of installed modules |
|
131 | - $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
132 | - // filter list of modules to register |
|
133 | - $pm_to_register = apply_filters( |
|
134 | - 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
135 | - $pm_to_register |
|
136 | - ); |
|
137 | - // remove any duplicates if that should happen for some reason |
|
138 | - $pm_to_register = array_unique($pm_to_register); |
|
139 | - // loop through folders |
|
140 | - foreach ($pm_to_register as $pm_path) { |
|
141 | - $this->register_payment_method($pm_path); |
|
142 | - } |
|
143 | - do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
144 | - // filter list of installed modules |
|
145 | - //keep them organized alphabetically by the payment method type's name |
|
146 | - ksort($this->_payment_method_types); |
|
147 | - return apply_filters( |
|
148 | - 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', |
|
149 | - $this->_payment_method_types |
|
150 | - ); |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * register_payment_method- makes core aware of this payment method |
|
157 | - * |
|
158 | - * @param string $payment_method_path - full path up to and including payment method folder |
|
159 | - * @return boolean |
|
160 | - */ |
|
161 | - public function register_payment_method($payment_method_path = '') |
|
162 | - { |
|
163 | - do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
164 | - $module_ext = '.pm.php'; |
|
165 | - // make all separators match |
|
166 | - $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
167 | - // grab and sanitize module name |
|
168 | - $module_dir = basename($payment_method_path); |
|
169 | - // create class name from module directory name |
|
170 | - $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir); |
|
171 | - // add class prefix |
|
172 | - $module_class = 'EE_PMT_' . $module; |
|
173 | - // does the module exist ? |
|
174 | - if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) { |
|
175 | - $msg = sprintf( |
|
176 | - esc_html__( |
|
177 | - 'The requested %s payment method file could not be found or is not readable due to file permissions.', |
|
178 | - 'event_espresso' |
|
179 | - ), $module |
|
180 | - ); |
|
181 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
182 | - return false; |
|
183 | - } |
|
184 | - // load the module class file |
|
185 | - require_once($payment_method_path . DS . $module_class . $module_ext); |
|
186 | - // verify that class exists |
|
187 | - if (! class_exists($module_class)) { |
|
188 | - $msg = sprintf( |
|
189 | - esc_html__('The requested %s module class does not exist.', 'event_espresso'), |
|
190 | - $module_class |
|
191 | - ); |
|
192 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
193 | - return false; |
|
194 | - } |
|
195 | - // add to array of registered modules |
|
196 | - $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext; |
|
197 | - return true; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * Checks if a payment method has been registered, and if so includes it |
|
204 | - * |
|
205 | - * @param string $payment_method_name like 'PayPal_Pro', (ie class name without the prefix 'EEPM_') |
|
206 | - * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
207 | - * @return boolean |
|
208 | - */ |
|
209 | - public function payment_method_type_exists($payment_method_name, $force_recheck = false) |
|
210 | - { |
|
211 | - if ( |
|
212 | - $force_recheck |
|
213 | - || ! is_array($this->_payment_method_types) |
|
214 | - || ! isset($this->_payment_method_types[$payment_method_name]) |
|
215 | - ) { |
|
216 | - $this->maybe_register_payment_methods($force_recheck); |
|
217 | - } |
|
218 | - if (isset($this->_payment_method_types[$payment_method_name])) { |
|
219 | - require_once($this->_payment_method_types[$payment_method_name]); |
|
220 | - return true; |
|
221 | - } |
|
222 | - return false; |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * Returns all the class names of the various payment method types |
|
229 | - * |
|
230 | - * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names' |
|
231 | - * (what you'd find in wp_esp_payment_method.PMD_type) |
|
232 | - * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
233 | - * @return array |
|
234 | - */ |
|
235 | - public function payment_method_type_names($with_prefixes = false, $force_recheck = false) |
|
236 | - { |
|
237 | - $this->maybe_register_payment_methods($force_recheck); |
|
238 | - if ($with_prefixes) { |
|
239 | - $classnames = array_keys($this->_payment_method_types); |
|
240 | - $payment_methods = array(); |
|
241 | - foreach ($classnames as $classname) { |
|
242 | - $payment_methods[] = $this->payment_method_class_from_type($classname); |
|
243 | - } |
|
244 | - return $payment_methods; |
|
245 | - } |
|
246 | - return array_keys($this->_payment_method_types); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - |
|
251 | - /** |
|
252 | - * Gets an object of each payment method type, none of which are bound to a |
|
253 | - * payment method instance |
|
254 | - * |
|
255 | - * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
256 | - * @return EE_PMT_Base[] |
|
257 | - */ |
|
258 | - public function payment_method_types($force_recheck = false) |
|
259 | - { |
|
260 | - if ($force_recheck || empty($this->payment_method_objects)) { |
|
261 | - $this->maybe_register_payment_methods($force_recheck); |
|
262 | - foreach ($this->payment_method_type_names(true) as $classname) { |
|
263 | - if (! isset($this->payment_method_objects[$classname])) { |
|
264 | - $this->payment_method_objects[$classname] = new $classname; |
|
265 | - } |
|
266 | - } |
|
267 | - } |
|
268 | - return $this->payment_method_objects; |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * Changes the payment method's class name into the payment method type's name |
|
275 | - * (as used on the payment method's table's PMD_type field) |
|
276 | - * |
|
277 | - * @param string $classname |
|
278 | - * @return string |
|
279 | - */ |
|
280 | - public function payment_method_type_sans_class_prefix($classname) |
|
281 | - { |
|
282 | - return str_replace('EE_PMT_', '', $classname); |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * Does the opposite of payment-method_type_sans_prefix |
|
289 | - * |
|
290 | - * @param string $type |
|
291 | - * @return string |
|
292 | - */ |
|
293 | - public function payment_method_class_from_type($type) |
|
294 | - { |
|
295 | - return 'EE_PMT_' . $type; |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * Activates a payment method of the given type. |
|
302 | - * |
|
303 | - * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice' |
|
304 | - * @return EE_Payment_Method |
|
305 | - * @throws InvalidDataTypeException |
|
306 | - * @throws EE_Error |
|
307 | - */ |
|
308 | - public function activate_a_payment_method_of_type($payment_method_type) |
|
309 | - { |
|
310 | - $this->maybe_register_payment_methods(); |
|
311 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
|
312 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
313 | - $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
|
314 | - if (class_exists($pm_type_class)) { |
|
315 | - /** @var $pm_type_obj EE_PMT_Base */ |
|
316 | - $pm_type_obj = new $pm_type_class; |
|
317 | - $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
|
318 | - if (! $payment_method) { |
|
319 | - $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
320 | - } |
|
321 | - $payment_method->set_type($payment_method_type); |
|
322 | - $this->initialize_payment_method($payment_method); |
|
323 | - } else { |
|
324 | - throw new EE_Error( |
|
325 | - sprintf( |
|
326 | - esc_html__( |
|
327 | - 'There is no payment method of type %1$s, so it could not be activated', |
|
328 | - 'event_espresso' |
|
329 | - ), |
|
330 | - $pm_type_class |
|
331 | - ) |
|
332 | - ); |
|
333 | - } |
|
334 | - } |
|
335 | - $payment_method->set_active(); |
|
336 | - $payment_method->save(); |
|
337 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
338 | - //if this was the invoice message type, make sure users can view their invoices |
|
339 | - if ($payment_method->type() === 'Invoice' |
|
340 | - && ( |
|
341 | - ! EEH_MSG_Template::is_mt_active('invoice') |
|
342 | - ) |
|
343 | - ) { |
|
344 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
345 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
346 | - $message_resource_manager->ensure_message_type_is_active('invoice', 'html'); |
|
347 | - new PersistentAdminNotice( |
|
348 | - 'invoice_pm_requirements_notice', |
|
349 | - sprintf( |
|
350 | - esc_html__( |
|
351 | - 'The Invoice payment method has been activated. It requires the %1$sinvoice message%2$s type to be active, so it was automatically activated for you.', |
|
352 | - 'event_espresso' |
|
353 | - ), |
|
354 | - '<a href="' . admin_url('admin.php?page=espresso_messages&action=settings') . '">', |
|
355 | - '</a>' |
|
356 | - ), |
|
357 | - true |
|
358 | - ); |
|
359 | - } |
|
360 | - return $payment_method; |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * Creates a payment method of the specified type. Does not save it. |
|
367 | - * |
|
368 | - * @global WP_User $current_user |
|
369 | - * @param EE_PMT_Base $pm_type_obj |
|
370 | - * @return EE_Payment_Method |
|
371 | - * @throws EE_Error |
|
372 | - */ |
|
373 | - public function create_payment_method_of_type($pm_type_obj) |
|
374 | - { |
|
375 | - global $current_user; |
|
376 | - $payment_method = EE_Payment_Method::new_instance( |
|
377 | - array( |
|
378 | - 'PMD_type' => $pm_type_obj->system_name(), |
|
379 | - 'PMD_name' => $pm_type_obj->pretty_name(), |
|
380 | - 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
|
381 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
382 | - 'PMD_wp_user' => $current_user->ID, |
|
383 | - 'PMD_order' => EEM_Payment_Method::instance()->count( |
|
384 | - array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
385 | - ) * 10, |
|
386 | - ) |
|
387 | - ); |
|
388 | - return $payment_method; |
|
389 | - } |
|
390 | - |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * Sets the initial payment method properties (including extra meta) |
|
395 | - * |
|
396 | - * @param EE_Payment_Method $payment_method |
|
397 | - * @return EE_Payment_Method |
|
398 | - * @throws EE_Error |
|
399 | - */ |
|
400 | - public function initialize_payment_method($payment_method) |
|
401 | - { |
|
402 | - $pm_type_obj = $payment_method->type_obj(); |
|
403 | - $payment_method->set_description($pm_type_obj->default_description()); |
|
404 | - if (! $payment_method->button_url()) { |
|
405 | - $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
406 | - } |
|
407 | - //now add setup its default extra meta properties |
|
408 | - $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
|
409 | - if (! empty($extra_metas)) { |
|
410 | - //verify the payment method has an ID before adding extra meta |
|
411 | - if (! $payment_method->ID()) { |
|
412 | - $payment_method->save(); |
|
413 | - } |
|
414 | - foreach ($extra_metas as $meta_name => $input) { |
|
415 | - $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
416 | - } |
|
417 | - } |
|
418 | - return $payment_method; |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - |
|
423 | - /** |
|
424 | - * Makes sure the payment method is related to the specified payment method |
|
425 | - * |
|
426 | - * @deprecated in 4.9.40 because the currency payment method table is being deprecated |
|
427 | - * @param EE_Payment_Method $payment_method |
|
428 | - * @return EE_Payment_Method |
|
429 | - * @throws EE_Error |
|
430 | - */ |
|
431 | - public function set_usable_currencies_on_payment_method($payment_method) |
|
432 | - { |
|
433 | - EE_Error::doing_it_wrong( |
|
434 | - 'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method', |
|
435 | - esc_html__( |
|
436 | - 'We no longer define what currencies are usable by payment methods. Its not used nor efficient.', |
|
437 | - 'event_espresso' |
|
438 | - ), |
|
439 | - '4.9.40' |
|
440 | - ); |
|
441 | - return $payment_method; |
|
442 | - } |
|
443 | - |
|
444 | - |
|
445 | - |
|
446 | - /** |
|
447 | - * Deactivates a payment method of the given payment method slug. |
|
448 | - * |
|
449 | - * @param string $payment_method_slug The slug for the payment method to deactivate. |
|
450 | - * @return int count of rows updated. |
|
451 | - * @throws EE_Error |
|
452 | - */ |
|
453 | - public function deactivate_payment_method($payment_method_slug) |
|
454 | - { |
|
455 | - EE_Log::instance()->log( |
|
456 | - __FILE__, |
|
457 | - __FUNCTION__, |
|
458 | - sprintf( |
|
459 | - esc_html__( |
|
460 | - 'Payment method with slug %1$s is being deactivated by site admin', |
|
461 | - 'event_espresso' |
|
462 | - ), |
|
463 | - $payment_method_slug |
|
464 | - ), |
|
465 | - 'payment_method_change' |
|
466 | - ); |
|
467 | - $count_updated = EEM_Payment_Method::instance()->update( |
|
468 | - array('PMD_scope' => array()), |
|
469 | - array(array('PMD_slug' => $payment_method_slug)) |
|
470 | - ); |
|
471 | - return $count_updated; |
|
472 | - } |
|
473 | - |
|
474 | - |
|
475 | - |
|
476 | - /** |
|
477 | - * initializes payment method access caps via EE_Capabilities::init_role_caps() |
|
478 | - * upon EE_Payment_Method_Manager construction |
|
479 | - * |
|
480 | - * @throws EE_Error |
|
481 | - * @throws DomainException |
|
482 | - */ |
|
483 | - protected function initializePaymentMethodCaps() |
|
484 | - { |
|
485 | - // don't do this twice |
|
486 | - if ($this->payment_method_caps_initialized) { |
|
487 | - return; |
|
488 | - } |
|
489 | - EE_Capabilities::instance()->addCaps( |
|
490 | - $this->getPaymentMethodCaps() |
|
491 | - ); |
|
492 | - $this->payment_method_caps_initialized = true; |
|
493 | - } |
|
494 | - |
|
495 | - |
|
496 | - |
|
497 | - /** |
|
498 | - * array of dynamic payment method access caps. |
|
499 | - * at the time of writing, october 20 2014, these are the caps added: |
|
500 | - * ee_payment_method_admin_only |
|
501 | - * ee_payment_method_aim |
|
502 | - * ee_payment_method_bank |
|
503 | - * ee_payment_method_check |
|
504 | - * ee_payment_method_invoice |
|
505 | - * ee_payment_method_mijireh |
|
506 | - * ee_payment_method_paypal_pro |
|
507 | - * ee_payment_method_paypal_standard |
|
508 | - * Any other payment methods added to core or via addons will also get |
|
509 | - * their related capability automatically added too, so long as they are |
|
510 | - * registered properly using EE_Register_Payment_Method::register() |
|
511 | - * |
|
512 | - * @return array |
|
513 | - * @throws DomainException |
|
514 | - */ |
|
515 | - protected function getPaymentMethodCaps() |
|
516 | - { |
|
517 | - $caps = array(); |
|
518 | - foreach ($this->payment_method_type_names() as $payment_method_name) { |
|
519 | - $caps = $this->addPaymentMethodCap($payment_method_name,$caps); |
|
520 | - } |
|
521 | - return $caps; |
|
522 | - } |
|
523 | - |
|
524 | - |
|
525 | - |
|
526 | - /** |
|
527 | - * @param string $payment_method_name |
|
528 | - * @param array $payment_method_caps |
|
529 | - * @param string $role |
|
530 | - * @return array |
|
531 | - * @throws DomainException |
|
532 | - */ |
|
533 | - public function addPaymentMethodCap($payment_method_name, array $payment_method_caps, $role = 'administrator') |
|
534 | - { |
|
535 | - if (empty($payment_method_name)) { |
|
536 | - throw new DomainException( |
|
537 | - esc_html__( |
|
538 | - 'The name of a payment method must be specified to add capabilities.', |
|
539 | - 'event_espresso' |
|
540 | - ) |
|
541 | - ); |
|
542 | - } |
|
543 | - if (empty($role)) { |
|
544 | - throw new DomainException( |
|
545 | - sprintf( |
|
546 | - esc_html__( |
|
547 | - 'No role was supplied while trying to add capabilities for the %1$s payment method.', |
|
548 | - 'event_espresso' |
|
549 | - ), |
|
550 | - $payment_method_name |
|
551 | - ) |
|
552 | - ); |
|
553 | - } |
|
554 | - if(! isset($payment_method_caps[$role])) { |
|
555 | - $payment_method_caps[$role] = array(); |
|
556 | - } |
|
557 | - $payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX |
|
558 | - . strtolower($payment_method_name); |
|
559 | - return $payment_method_caps; |
|
560 | - } |
|
561 | - |
|
562 | - |
|
563 | - |
|
564 | - /** |
|
565 | - * callback for FHEE__EE_Capabilities__init_role_caps__caps_map filter |
|
566 | - * to add dynamic payment method access caps when capabilities are reset |
|
567 | - * (or if that filter is called and PM caps are not already set) |
|
568 | - * |
|
569 | - * @param array $caps capabilities being filtered |
|
570 | - * @param bool $reset |
|
571 | - * @return array |
|
572 | - * @throws DomainException |
|
573 | - */ |
|
574 | - public function addPaymentMethodCapsDuringReset(array $caps, $reset = false) |
|
575 | - { |
|
576 | - if ($reset || ! $this->payment_method_caps_initialized) { |
|
577 | - $this->payment_method_caps_initialized = true; |
|
578 | - $caps = array_merge_recursive($caps, $this->getPaymentMethodCaps()); |
|
579 | - } |
|
580 | - return $caps; |
|
581 | - } |
|
582 | - |
|
583 | - |
|
584 | - |
|
585 | - /** |
|
586 | - * @deprecated 4.9.42 |
|
587 | - * @param $caps |
|
588 | - * @return mixed |
|
589 | - */ |
|
590 | - public function add_payment_method_caps($caps) |
|
591 | - { |
|
592 | - return $caps; |
|
593 | - } |
|
24 | + /** |
|
25 | + * prefix added to all payment method capabilities names |
|
26 | + */ |
|
27 | + const CAPABILITIES_PREFIX= 'ee_payment_method_'; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var EE_Payment_Method_Manager $_instance |
|
31 | + */ |
|
32 | + private static $_instance; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean |
|
36 | + */ |
|
37 | + protected $payment_method_caps_initialized = false; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var array keys are class names without 'EE_PMT_', values are their filepaths |
|
41 | + */ |
|
42 | + protected $_payment_method_types = array(); |
|
43 | + |
|
44 | + /** |
|
45 | + * @var EE_PMT_Base[] |
|
46 | + */ |
|
47 | + protected $payment_method_objects = array(); |
|
48 | + |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * EE_Payment_Method_Manager constructor. |
|
53 | + * |
|
54 | + * @throws EE_Error |
|
55 | + * @throws DomainException |
|
56 | + */ |
|
57 | + public function __construct() |
|
58 | + { |
|
59 | + // if in admin lets ensure caps are set. |
|
60 | + if (is_admin()) { |
|
61 | + $this->_register_payment_methods(); |
|
62 | + // set them immediately |
|
63 | + $this->initializePaymentMethodCaps(); |
|
64 | + // plus any time they get reset |
|
65 | + add_filter( |
|
66 | + 'FHEE__EE_Capabilities__addCaps__capabilities_to_add', |
|
67 | + array($this, 'addPaymentMethodCapsDuringReset') |
|
68 | + ); |
|
69 | + } |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @singleton method used to instantiate class object |
|
76 | + * @return EE_Payment_Method_Manager instance |
|
77 | + * @throws DomainException |
|
78 | + * @throws EE_Error |
|
79 | + */ |
|
80 | + public static function instance() |
|
81 | + { |
|
82 | + // check if class object is instantiated, and instantiated properly |
|
83 | + if (! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
84 | + EE_Registry::instance()->load_lib('PMT_Base'); |
|
85 | + self::$_instance = new self(); |
|
86 | + } |
|
87 | + return self::$_instance; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * Resets the instance and returns a new one |
|
94 | + * |
|
95 | + * @return EE_Payment_Method_Manager |
|
96 | + * @throws DomainException |
|
97 | + * @throws EE_Error |
|
98 | + */ |
|
99 | + public static function reset() |
|
100 | + { |
|
101 | + self::$_instance = null; |
|
102 | + return self::instance(); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * If necessary, re-register payment methods |
|
109 | + * |
|
110 | + * @param boolean $force_recheck whether to recheck for payment method types, |
|
111 | + * or just re-use the PMTs we found last time we checked during this request (if |
|
112 | + * we have not yet checked during this request, then we need to check anyways) |
|
113 | + */ |
|
114 | + public function maybe_register_payment_methods($force_recheck = false) |
|
115 | + { |
|
116 | + if (! $this->_payment_method_types || $force_recheck) { |
|
117 | + $this->_register_payment_methods(); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * register_payment_methods |
|
125 | + * |
|
126 | + * @return array |
|
127 | + */ |
|
128 | + protected function _register_payment_methods() |
|
129 | + { |
|
130 | + // grab list of installed modules |
|
131 | + $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
132 | + // filter list of modules to register |
|
133 | + $pm_to_register = apply_filters( |
|
134 | + 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
135 | + $pm_to_register |
|
136 | + ); |
|
137 | + // remove any duplicates if that should happen for some reason |
|
138 | + $pm_to_register = array_unique($pm_to_register); |
|
139 | + // loop through folders |
|
140 | + foreach ($pm_to_register as $pm_path) { |
|
141 | + $this->register_payment_method($pm_path); |
|
142 | + } |
|
143 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
144 | + // filter list of installed modules |
|
145 | + //keep them organized alphabetically by the payment method type's name |
|
146 | + ksort($this->_payment_method_types); |
|
147 | + return apply_filters( |
|
148 | + 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', |
|
149 | + $this->_payment_method_types |
|
150 | + ); |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * register_payment_method- makes core aware of this payment method |
|
157 | + * |
|
158 | + * @param string $payment_method_path - full path up to and including payment method folder |
|
159 | + * @return boolean |
|
160 | + */ |
|
161 | + public function register_payment_method($payment_method_path = '') |
|
162 | + { |
|
163 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
164 | + $module_ext = '.pm.php'; |
|
165 | + // make all separators match |
|
166 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
167 | + // grab and sanitize module name |
|
168 | + $module_dir = basename($payment_method_path); |
|
169 | + // create class name from module directory name |
|
170 | + $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir); |
|
171 | + // add class prefix |
|
172 | + $module_class = 'EE_PMT_' . $module; |
|
173 | + // does the module exist ? |
|
174 | + if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) { |
|
175 | + $msg = sprintf( |
|
176 | + esc_html__( |
|
177 | + 'The requested %s payment method file could not be found or is not readable due to file permissions.', |
|
178 | + 'event_espresso' |
|
179 | + ), $module |
|
180 | + ); |
|
181 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
182 | + return false; |
|
183 | + } |
|
184 | + // load the module class file |
|
185 | + require_once($payment_method_path . DS . $module_class . $module_ext); |
|
186 | + // verify that class exists |
|
187 | + if (! class_exists($module_class)) { |
|
188 | + $msg = sprintf( |
|
189 | + esc_html__('The requested %s module class does not exist.', 'event_espresso'), |
|
190 | + $module_class |
|
191 | + ); |
|
192 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
193 | + return false; |
|
194 | + } |
|
195 | + // add to array of registered modules |
|
196 | + $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext; |
|
197 | + return true; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * Checks if a payment method has been registered, and if so includes it |
|
204 | + * |
|
205 | + * @param string $payment_method_name like 'PayPal_Pro', (ie class name without the prefix 'EEPM_') |
|
206 | + * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
207 | + * @return boolean |
|
208 | + */ |
|
209 | + public function payment_method_type_exists($payment_method_name, $force_recheck = false) |
|
210 | + { |
|
211 | + if ( |
|
212 | + $force_recheck |
|
213 | + || ! is_array($this->_payment_method_types) |
|
214 | + || ! isset($this->_payment_method_types[$payment_method_name]) |
|
215 | + ) { |
|
216 | + $this->maybe_register_payment_methods($force_recheck); |
|
217 | + } |
|
218 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
219 | + require_once($this->_payment_method_types[$payment_method_name]); |
|
220 | + return true; |
|
221 | + } |
|
222 | + return false; |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * Returns all the class names of the various payment method types |
|
229 | + * |
|
230 | + * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names' |
|
231 | + * (what you'd find in wp_esp_payment_method.PMD_type) |
|
232 | + * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
233 | + * @return array |
|
234 | + */ |
|
235 | + public function payment_method_type_names($with_prefixes = false, $force_recheck = false) |
|
236 | + { |
|
237 | + $this->maybe_register_payment_methods($force_recheck); |
|
238 | + if ($with_prefixes) { |
|
239 | + $classnames = array_keys($this->_payment_method_types); |
|
240 | + $payment_methods = array(); |
|
241 | + foreach ($classnames as $classname) { |
|
242 | + $payment_methods[] = $this->payment_method_class_from_type($classname); |
|
243 | + } |
|
244 | + return $payment_methods; |
|
245 | + } |
|
246 | + return array_keys($this->_payment_method_types); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + |
|
251 | + /** |
|
252 | + * Gets an object of each payment method type, none of which are bound to a |
|
253 | + * payment method instance |
|
254 | + * |
|
255 | + * @param boolean $force_recheck whether to force re-checking for new payment method types |
|
256 | + * @return EE_PMT_Base[] |
|
257 | + */ |
|
258 | + public function payment_method_types($force_recheck = false) |
|
259 | + { |
|
260 | + if ($force_recheck || empty($this->payment_method_objects)) { |
|
261 | + $this->maybe_register_payment_methods($force_recheck); |
|
262 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
263 | + if (! isset($this->payment_method_objects[$classname])) { |
|
264 | + $this->payment_method_objects[$classname] = new $classname; |
|
265 | + } |
|
266 | + } |
|
267 | + } |
|
268 | + return $this->payment_method_objects; |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * Changes the payment method's class name into the payment method type's name |
|
275 | + * (as used on the payment method's table's PMD_type field) |
|
276 | + * |
|
277 | + * @param string $classname |
|
278 | + * @return string |
|
279 | + */ |
|
280 | + public function payment_method_type_sans_class_prefix($classname) |
|
281 | + { |
|
282 | + return str_replace('EE_PMT_', '', $classname); |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * Does the opposite of payment-method_type_sans_prefix |
|
289 | + * |
|
290 | + * @param string $type |
|
291 | + * @return string |
|
292 | + */ |
|
293 | + public function payment_method_class_from_type($type) |
|
294 | + { |
|
295 | + return 'EE_PMT_' . $type; |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * Activates a payment method of the given type. |
|
302 | + * |
|
303 | + * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice' |
|
304 | + * @return EE_Payment_Method |
|
305 | + * @throws InvalidDataTypeException |
|
306 | + * @throws EE_Error |
|
307 | + */ |
|
308 | + public function activate_a_payment_method_of_type($payment_method_type) |
|
309 | + { |
|
310 | + $this->maybe_register_payment_methods(); |
|
311 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
|
312 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
313 | + $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
|
314 | + if (class_exists($pm_type_class)) { |
|
315 | + /** @var $pm_type_obj EE_PMT_Base */ |
|
316 | + $pm_type_obj = new $pm_type_class; |
|
317 | + $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
|
318 | + if (! $payment_method) { |
|
319 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
320 | + } |
|
321 | + $payment_method->set_type($payment_method_type); |
|
322 | + $this->initialize_payment_method($payment_method); |
|
323 | + } else { |
|
324 | + throw new EE_Error( |
|
325 | + sprintf( |
|
326 | + esc_html__( |
|
327 | + 'There is no payment method of type %1$s, so it could not be activated', |
|
328 | + 'event_espresso' |
|
329 | + ), |
|
330 | + $pm_type_class |
|
331 | + ) |
|
332 | + ); |
|
333 | + } |
|
334 | + } |
|
335 | + $payment_method->set_active(); |
|
336 | + $payment_method->save(); |
|
337 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
338 | + //if this was the invoice message type, make sure users can view their invoices |
|
339 | + if ($payment_method->type() === 'Invoice' |
|
340 | + && ( |
|
341 | + ! EEH_MSG_Template::is_mt_active('invoice') |
|
342 | + ) |
|
343 | + ) { |
|
344 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
345 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
346 | + $message_resource_manager->ensure_message_type_is_active('invoice', 'html'); |
|
347 | + new PersistentAdminNotice( |
|
348 | + 'invoice_pm_requirements_notice', |
|
349 | + sprintf( |
|
350 | + esc_html__( |
|
351 | + 'The Invoice payment method has been activated. It requires the %1$sinvoice message%2$s type to be active, so it was automatically activated for you.', |
|
352 | + 'event_espresso' |
|
353 | + ), |
|
354 | + '<a href="' . admin_url('admin.php?page=espresso_messages&action=settings') . '">', |
|
355 | + '</a>' |
|
356 | + ), |
|
357 | + true |
|
358 | + ); |
|
359 | + } |
|
360 | + return $payment_method; |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * Creates a payment method of the specified type. Does not save it. |
|
367 | + * |
|
368 | + * @global WP_User $current_user |
|
369 | + * @param EE_PMT_Base $pm_type_obj |
|
370 | + * @return EE_Payment_Method |
|
371 | + * @throws EE_Error |
|
372 | + */ |
|
373 | + public function create_payment_method_of_type($pm_type_obj) |
|
374 | + { |
|
375 | + global $current_user; |
|
376 | + $payment_method = EE_Payment_Method::new_instance( |
|
377 | + array( |
|
378 | + 'PMD_type' => $pm_type_obj->system_name(), |
|
379 | + 'PMD_name' => $pm_type_obj->pretty_name(), |
|
380 | + 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
|
381 | + 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
382 | + 'PMD_wp_user' => $current_user->ID, |
|
383 | + 'PMD_order' => EEM_Payment_Method::instance()->count( |
|
384 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
385 | + ) * 10, |
|
386 | + ) |
|
387 | + ); |
|
388 | + return $payment_method; |
|
389 | + } |
|
390 | + |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * Sets the initial payment method properties (including extra meta) |
|
395 | + * |
|
396 | + * @param EE_Payment_Method $payment_method |
|
397 | + * @return EE_Payment_Method |
|
398 | + * @throws EE_Error |
|
399 | + */ |
|
400 | + public function initialize_payment_method($payment_method) |
|
401 | + { |
|
402 | + $pm_type_obj = $payment_method->type_obj(); |
|
403 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
404 | + if (! $payment_method->button_url()) { |
|
405 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
406 | + } |
|
407 | + //now add setup its default extra meta properties |
|
408 | + $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
|
409 | + if (! empty($extra_metas)) { |
|
410 | + //verify the payment method has an ID before adding extra meta |
|
411 | + if (! $payment_method->ID()) { |
|
412 | + $payment_method->save(); |
|
413 | + } |
|
414 | + foreach ($extra_metas as $meta_name => $input) { |
|
415 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
416 | + } |
|
417 | + } |
|
418 | + return $payment_method; |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + |
|
423 | + /** |
|
424 | + * Makes sure the payment method is related to the specified payment method |
|
425 | + * |
|
426 | + * @deprecated in 4.9.40 because the currency payment method table is being deprecated |
|
427 | + * @param EE_Payment_Method $payment_method |
|
428 | + * @return EE_Payment_Method |
|
429 | + * @throws EE_Error |
|
430 | + */ |
|
431 | + public function set_usable_currencies_on_payment_method($payment_method) |
|
432 | + { |
|
433 | + EE_Error::doing_it_wrong( |
|
434 | + 'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method', |
|
435 | + esc_html__( |
|
436 | + 'We no longer define what currencies are usable by payment methods. Its not used nor efficient.', |
|
437 | + 'event_espresso' |
|
438 | + ), |
|
439 | + '4.9.40' |
|
440 | + ); |
|
441 | + return $payment_method; |
|
442 | + } |
|
443 | + |
|
444 | + |
|
445 | + |
|
446 | + /** |
|
447 | + * Deactivates a payment method of the given payment method slug. |
|
448 | + * |
|
449 | + * @param string $payment_method_slug The slug for the payment method to deactivate. |
|
450 | + * @return int count of rows updated. |
|
451 | + * @throws EE_Error |
|
452 | + */ |
|
453 | + public function deactivate_payment_method($payment_method_slug) |
|
454 | + { |
|
455 | + EE_Log::instance()->log( |
|
456 | + __FILE__, |
|
457 | + __FUNCTION__, |
|
458 | + sprintf( |
|
459 | + esc_html__( |
|
460 | + 'Payment method with slug %1$s is being deactivated by site admin', |
|
461 | + 'event_espresso' |
|
462 | + ), |
|
463 | + $payment_method_slug |
|
464 | + ), |
|
465 | + 'payment_method_change' |
|
466 | + ); |
|
467 | + $count_updated = EEM_Payment_Method::instance()->update( |
|
468 | + array('PMD_scope' => array()), |
|
469 | + array(array('PMD_slug' => $payment_method_slug)) |
|
470 | + ); |
|
471 | + return $count_updated; |
|
472 | + } |
|
473 | + |
|
474 | + |
|
475 | + |
|
476 | + /** |
|
477 | + * initializes payment method access caps via EE_Capabilities::init_role_caps() |
|
478 | + * upon EE_Payment_Method_Manager construction |
|
479 | + * |
|
480 | + * @throws EE_Error |
|
481 | + * @throws DomainException |
|
482 | + */ |
|
483 | + protected function initializePaymentMethodCaps() |
|
484 | + { |
|
485 | + // don't do this twice |
|
486 | + if ($this->payment_method_caps_initialized) { |
|
487 | + return; |
|
488 | + } |
|
489 | + EE_Capabilities::instance()->addCaps( |
|
490 | + $this->getPaymentMethodCaps() |
|
491 | + ); |
|
492 | + $this->payment_method_caps_initialized = true; |
|
493 | + } |
|
494 | + |
|
495 | + |
|
496 | + |
|
497 | + /** |
|
498 | + * array of dynamic payment method access caps. |
|
499 | + * at the time of writing, october 20 2014, these are the caps added: |
|
500 | + * ee_payment_method_admin_only |
|
501 | + * ee_payment_method_aim |
|
502 | + * ee_payment_method_bank |
|
503 | + * ee_payment_method_check |
|
504 | + * ee_payment_method_invoice |
|
505 | + * ee_payment_method_mijireh |
|
506 | + * ee_payment_method_paypal_pro |
|
507 | + * ee_payment_method_paypal_standard |
|
508 | + * Any other payment methods added to core or via addons will also get |
|
509 | + * their related capability automatically added too, so long as they are |
|
510 | + * registered properly using EE_Register_Payment_Method::register() |
|
511 | + * |
|
512 | + * @return array |
|
513 | + * @throws DomainException |
|
514 | + */ |
|
515 | + protected function getPaymentMethodCaps() |
|
516 | + { |
|
517 | + $caps = array(); |
|
518 | + foreach ($this->payment_method_type_names() as $payment_method_name) { |
|
519 | + $caps = $this->addPaymentMethodCap($payment_method_name,$caps); |
|
520 | + } |
|
521 | + return $caps; |
|
522 | + } |
|
523 | + |
|
524 | + |
|
525 | + |
|
526 | + /** |
|
527 | + * @param string $payment_method_name |
|
528 | + * @param array $payment_method_caps |
|
529 | + * @param string $role |
|
530 | + * @return array |
|
531 | + * @throws DomainException |
|
532 | + */ |
|
533 | + public function addPaymentMethodCap($payment_method_name, array $payment_method_caps, $role = 'administrator') |
|
534 | + { |
|
535 | + if (empty($payment_method_name)) { |
|
536 | + throw new DomainException( |
|
537 | + esc_html__( |
|
538 | + 'The name of a payment method must be specified to add capabilities.', |
|
539 | + 'event_espresso' |
|
540 | + ) |
|
541 | + ); |
|
542 | + } |
|
543 | + if (empty($role)) { |
|
544 | + throw new DomainException( |
|
545 | + sprintf( |
|
546 | + esc_html__( |
|
547 | + 'No role was supplied while trying to add capabilities for the %1$s payment method.', |
|
548 | + 'event_espresso' |
|
549 | + ), |
|
550 | + $payment_method_name |
|
551 | + ) |
|
552 | + ); |
|
553 | + } |
|
554 | + if(! isset($payment_method_caps[$role])) { |
|
555 | + $payment_method_caps[$role] = array(); |
|
556 | + } |
|
557 | + $payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX |
|
558 | + . strtolower($payment_method_name); |
|
559 | + return $payment_method_caps; |
|
560 | + } |
|
561 | + |
|
562 | + |
|
563 | + |
|
564 | + /** |
|
565 | + * callback for FHEE__EE_Capabilities__init_role_caps__caps_map filter |
|
566 | + * to add dynamic payment method access caps when capabilities are reset |
|
567 | + * (or if that filter is called and PM caps are not already set) |
|
568 | + * |
|
569 | + * @param array $caps capabilities being filtered |
|
570 | + * @param bool $reset |
|
571 | + * @return array |
|
572 | + * @throws DomainException |
|
573 | + */ |
|
574 | + public function addPaymentMethodCapsDuringReset(array $caps, $reset = false) |
|
575 | + { |
|
576 | + if ($reset || ! $this->payment_method_caps_initialized) { |
|
577 | + $this->payment_method_caps_initialized = true; |
|
578 | + $caps = array_merge_recursive($caps, $this->getPaymentMethodCaps()); |
|
579 | + } |
|
580 | + return $caps; |
|
581 | + } |
|
582 | + |
|
583 | + |
|
584 | + |
|
585 | + /** |
|
586 | + * @deprecated 4.9.42 |
|
587 | + * @param $caps |
|
588 | + * @return mixed |
|
589 | + */ |
|
590 | + public function add_payment_method_caps($caps) |
|
591 | + { |
|
592 | + return $caps; |
|
593 | + } |
|
594 | 594 | |
595 | 595 | |
596 | 596 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * prefix added to all payment method capabilities names |
26 | 26 | */ |
27 | - const CAPABILITIES_PREFIX= 'ee_payment_method_'; |
|
27 | + const CAPABILITIES_PREFIX = 'ee_payment_method_'; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @var EE_Payment_Method_Manager $_instance |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | public static function instance() |
81 | 81 | { |
82 | 82 | // check if class object is instantiated, and instantiated properly |
83 | - if (! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
83 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
84 | 84 | EE_Registry::instance()->load_lib('PMT_Base'); |
85 | 85 | self::$_instance = new self(); |
86 | 86 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function maybe_register_payment_methods($force_recheck = false) |
115 | 115 | { |
116 | - if (! $this->_payment_method_types || $force_recheck) { |
|
116 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
117 | 117 | $this->_register_payment_methods(); |
118 | 118 | } |
119 | 119 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | protected function _register_payment_methods() |
129 | 129 | { |
130 | 130 | // grab list of installed modules |
131 | - $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
131 | + $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
132 | 132 | // filter list of modules to register |
133 | 133 | $pm_to_register = apply_filters( |
134 | 134 | 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
@@ -169,31 +169,31 @@ discard block |
||
169 | 169 | // create class name from module directory name |
170 | 170 | $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir); |
171 | 171 | // add class prefix |
172 | - $module_class = 'EE_PMT_' . $module; |
|
172 | + $module_class = 'EE_PMT_'.$module; |
|
173 | 173 | // does the module exist ? |
174 | - if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) { |
|
174 | + if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) { |
|
175 | 175 | $msg = sprintf( |
176 | 176 | esc_html__( |
177 | 177 | 'The requested %s payment method file could not be found or is not readable due to file permissions.', |
178 | 178 | 'event_espresso' |
179 | 179 | ), $module |
180 | 180 | ); |
181 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
181 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | // load the module class file |
185 | - require_once($payment_method_path . DS . $module_class . $module_ext); |
|
185 | + require_once($payment_method_path.DS.$module_class.$module_ext); |
|
186 | 186 | // verify that class exists |
187 | - if (! class_exists($module_class)) { |
|
187 | + if ( ! class_exists($module_class)) { |
|
188 | 188 | $msg = sprintf( |
189 | 189 | esc_html__('The requested %s module class does not exist.', 'event_espresso'), |
190 | 190 | $module_class |
191 | 191 | ); |
192 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
192 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
193 | 193 | return false; |
194 | 194 | } |
195 | 195 | // add to array of registered modules |
196 | - $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext; |
|
196 | + $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext; |
|
197 | 197 | return true; |
198 | 198 | } |
199 | 199 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | if ($force_recheck || empty($this->payment_method_objects)) { |
261 | 261 | $this->maybe_register_payment_methods($force_recheck); |
262 | 262 | foreach ($this->payment_method_type_names(true) as $classname) { |
263 | - if (! isset($this->payment_method_objects[$classname])) { |
|
263 | + if ( ! isset($this->payment_method_objects[$classname])) { |
|
264 | 264 | $this->payment_method_objects[$classname] = new $classname; |
265 | 265 | } |
266 | 266 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function payment_method_class_from_type($type) |
294 | 294 | { |
295 | - return 'EE_PMT_' . $type; |
|
295 | + return 'EE_PMT_'.$type; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | { |
310 | 310 | $this->maybe_register_payment_methods(); |
311 | 311 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
312 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
312 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
313 | 313 | $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
314 | 314 | if (class_exists($pm_type_class)) { |
315 | 315 | /** @var $pm_type_obj EE_PMT_Base */ |
316 | 316 | $pm_type_obj = new $pm_type_class; |
317 | 317 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
318 | - if (! $payment_method) { |
|
318 | + if ( ! $payment_method) { |
|
319 | 319 | $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
320 | 320 | } |
321 | 321 | $payment_method->set_type($payment_method_type); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | 'The Invoice payment method has been activated. It requires the %1$sinvoice message%2$s type to be active, so it was automatically activated for you.', |
352 | 352 | 'event_espresso' |
353 | 353 | ), |
354 | - '<a href="' . admin_url('admin.php?page=espresso_messages&action=settings') . '">', |
|
354 | + '<a href="'.admin_url('admin.php?page=espresso_messages&action=settings').'">', |
|
355 | 355 | '</a>' |
356 | 356 | ), |
357 | 357 | true |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | 'PMD_type' => $pm_type_obj->system_name(), |
379 | 379 | 'PMD_name' => $pm_type_obj->pretty_name(), |
380 | 380 | 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
381 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
381 | + 'PMD_slug' => $pm_type_obj->system_name(), //automatically converted to slug |
|
382 | 382 | 'PMD_wp_user' => $current_user->ID, |
383 | 383 | 'PMD_order' => EEM_Payment_Method::instance()->count( |
384 | 384 | array(array('PMD_type' => array('!=', 'Admin_Only'))) |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | { |
402 | 402 | $pm_type_obj = $payment_method->type_obj(); |
403 | 403 | $payment_method->set_description($pm_type_obj->default_description()); |
404 | - if (! $payment_method->button_url()) { |
|
404 | + if ( ! $payment_method->button_url()) { |
|
405 | 405 | $payment_method->set_button_url($pm_type_obj->default_button_url()); |
406 | 406 | } |
407 | 407 | //now add setup its default extra meta properties |
408 | 408 | $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
409 | - if (! empty($extra_metas)) { |
|
409 | + if ( ! empty($extra_metas)) { |
|
410 | 410 | //verify the payment method has an ID before adding extra meta |
411 | - if (! $payment_method->ID()) { |
|
411 | + if ( ! $payment_method->ID()) { |
|
412 | 412 | $payment_method->save(); |
413 | 413 | } |
414 | 414 | foreach ($extra_metas as $meta_name => $input) { |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | { |
517 | 517 | $caps = array(); |
518 | 518 | foreach ($this->payment_method_type_names() as $payment_method_name) { |
519 | - $caps = $this->addPaymentMethodCap($payment_method_name,$caps); |
|
519 | + $caps = $this->addPaymentMethodCap($payment_method_name, $caps); |
|
520 | 520 | } |
521 | 521 | return $caps; |
522 | 522 | } |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | ) |
552 | 552 | ); |
553 | 553 | } |
554 | - if(! isset($payment_method_caps[$role])) { |
|
554 | + if ( ! isset($payment_method_caps[$role])) { |
|
555 | 555 | $payment_method_caps[$role] = array(); |
556 | 556 | } |
557 | 557 | $payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX |
@@ -38,216 +38,216 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | |
64 | 64 | } else { |
65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | - /** |
|
68 | - * espresso_minimum_php_version_error |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | + /** |
|
68 | + * espresso_minimum_php_version_error |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.56.rc.018'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.56.rc.018'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | - /** |
|
119 | - * espresso_load_error_handling |
|
120 | - * this function loads EE's class for handling exceptions and errors |
|
121 | - */ |
|
122 | - function espresso_load_error_handling() |
|
123 | - { |
|
124 | - static $error_handling_loaded = false; |
|
125 | - if ($error_handling_loaded) { |
|
126 | - return; |
|
127 | - } |
|
128 | - // load debugging tools |
|
129 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
130 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
131 | - \EEH_Debug_Tools::instance(); |
|
132 | - } |
|
133 | - // load error handling |
|
134 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
135 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
136 | - } else { |
|
137 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
138 | - } |
|
139 | - $error_handling_loaded = true; |
|
140 | - } |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | + /** |
|
119 | + * espresso_load_error_handling |
|
120 | + * this function loads EE's class for handling exceptions and errors |
|
121 | + */ |
|
122 | + function espresso_load_error_handling() |
|
123 | + { |
|
124 | + static $error_handling_loaded = false; |
|
125 | + if ($error_handling_loaded) { |
|
126 | + return; |
|
127 | + } |
|
128 | + // load debugging tools |
|
129 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
130 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
131 | + \EEH_Debug_Tools::instance(); |
|
132 | + } |
|
133 | + // load error handling |
|
134 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
135 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
136 | + } else { |
|
137 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
138 | + } |
|
139 | + $error_handling_loaded = true; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * espresso_load_required |
|
144 | - * given a class name and path, this function will load that file or throw an exception |
|
145 | - * |
|
146 | - * @param string $classname |
|
147 | - * @param string $full_path_to_file |
|
148 | - * @throws EE_Error |
|
149 | - */ |
|
150 | - function espresso_load_required($classname, $full_path_to_file) |
|
151 | - { |
|
152 | - if (is_readable($full_path_to_file)) { |
|
153 | - require_once $full_path_to_file; |
|
154 | - } else { |
|
155 | - throw new \EE_Error ( |
|
156 | - sprintf( |
|
157 | - esc_html__( |
|
158 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
159 | - 'event_espresso' |
|
160 | - ), |
|
161 | - $classname |
|
162 | - ) |
|
163 | - ); |
|
164 | - } |
|
165 | - } |
|
142 | + /** |
|
143 | + * espresso_load_required |
|
144 | + * given a class name and path, this function will load that file or throw an exception |
|
145 | + * |
|
146 | + * @param string $classname |
|
147 | + * @param string $full_path_to_file |
|
148 | + * @throws EE_Error |
|
149 | + */ |
|
150 | + function espresso_load_required($classname, $full_path_to_file) |
|
151 | + { |
|
152 | + if (is_readable($full_path_to_file)) { |
|
153 | + require_once $full_path_to_file; |
|
154 | + } else { |
|
155 | + throw new \EE_Error ( |
|
156 | + sprintf( |
|
157 | + esc_html__( |
|
158 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
159 | + 'event_espresso' |
|
160 | + ), |
|
161 | + $classname |
|
162 | + ) |
|
163 | + ); |
|
164 | + } |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @since 4.9.27 |
|
169 | - * @throws \EE_Error |
|
170 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
171 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
172 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
173 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
174 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
175 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
177 | - * @throws \OutOfBoundsException |
|
178 | - */ |
|
179 | - function bootstrap_espresso() |
|
180 | - { |
|
181 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
182 | - try { |
|
183 | - espresso_load_error_handling(); |
|
184 | - espresso_load_required( |
|
185 | - 'EEH_Base', |
|
186 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
187 | - ); |
|
188 | - espresso_load_required( |
|
189 | - 'EEH_File', |
|
190 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
191 | - ); |
|
192 | - espresso_load_required( |
|
193 | - 'EEH_File', |
|
194 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
195 | - ); |
|
196 | - espresso_load_required( |
|
197 | - 'EEH_Array', |
|
198 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
199 | - ); |
|
200 | - // instantiate and configure PSR4 autoloader |
|
201 | - espresso_load_required( |
|
202 | - 'Psr4Autoloader', |
|
203 | - EE_CORE . 'Psr4Autoloader.php' |
|
204 | - ); |
|
205 | - espresso_load_required( |
|
206 | - 'EE_Psr4AutoloaderInit', |
|
207 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
208 | - ); |
|
209 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
210 | - $AutoloaderInit->initializeAutoloader(); |
|
211 | - espresso_load_required( |
|
212 | - 'EE_Request', |
|
213 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
214 | - ); |
|
215 | - espresso_load_required( |
|
216 | - 'EE_Response', |
|
217 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
218 | - ); |
|
219 | - espresso_load_required( |
|
220 | - 'EE_Bootstrap', |
|
221 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
222 | - ); |
|
223 | - // bootstrap EE and the request stack |
|
224 | - new EE_Bootstrap( |
|
225 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
226 | - new EE_Response() |
|
227 | - ); |
|
228 | - } catch (Exception $e) { |
|
229 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
230 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
231 | - } |
|
232 | - } |
|
233 | - bootstrap_espresso(); |
|
234 | - } |
|
167 | + /** |
|
168 | + * @since 4.9.27 |
|
169 | + * @throws \EE_Error |
|
170 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
171 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
172 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
173 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
174 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
175 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
177 | + * @throws \OutOfBoundsException |
|
178 | + */ |
|
179 | + function bootstrap_espresso() |
|
180 | + { |
|
181 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
182 | + try { |
|
183 | + espresso_load_error_handling(); |
|
184 | + espresso_load_required( |
|
185 | + 'EEH_Base', |
|
186 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
187 | + ); |
|
188 | + espresso_load_required( |
|
189 | + 'EEH_File', |
|
190 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
191 | + ); |
|
192 | + espresso_load_required( |
|
193 | + 'EEH_File', |
|
194 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
195 | + ); |
|
196 | + espresso_load_required( |
|
197 | + 'EEH_Array', |
|
198 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
199 | + ); |
|
200 | + // instantiate and configure PSR4 autoloader |
|
201 | + espresso_load_required( |
|
202 | + 'Psr4Autoloader', |
|
203 | + EE_CORE . 'Psr4Autoloader.php' |
|
204 | + ); |
|
205 | + espresso_load_required( |
|
206 | + 'EE_Psr4AutoloaderInit', |
|
207 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
208 | + ); |
|
209 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
210 | + $AutoloaderInit->initializeAutoloader(); |
|
211 | + espresso_load_required( |
|
212 | + 'EE_Request', |
|
213 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
214 | + ); |
|
215 | + espresso_load_required( |
|
216 | + 'EE_Response', |
|
217 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
218 | + ); |
|
219 | + espresso_load_required( |
|
220 | + 'EE_Bootstrap', |
|
221 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
222 | + ); |
|
223 | + // bootstrap EE and the request stack |
|
224 | + new EE_Bootstrap( |
|
225 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
226 | + new EE_Response() |
|
227 | + ); |
|
228 | + } catch (Exception $e) { |
|
229 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
230 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
231 | + } |
|
232 | + } |
|
233 | + bootstrap_espresso(); |
|
234 | + } |
|
235 | 235 | } |
236 | 236 | if (! function_exists('espresso_deactivate_plugin')) { |
237 | - /** |
|
238 | - * deactivate_plugin |
|
239 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
240 | - * |
|
241 | - * @access public |
|
242 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
246 | - { |
|
247 | - if (! function_exists('deactivate_plugins')) { |
|
248 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
249 | - } |
|
250 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
251 | - deactivate_plugins($plugin_basename); |
|
252 | - } |
|
237 | + /** |
|
238 | + * deactivate_plugin |
|
239 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
240 | + * |
|
241 | + * @access public |
|
242 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
246 | + { |
|
247 | + if (! function_exists('deactivate_plugins')) { |
|
248 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
249 | + } |
|
250 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
251 | + deactivate_plugins($plugin_basename); |
|
252 | + } |
|
253 | 253 | } |
@@ -22,457 +22,457 @@ discard block |
||
22 | 22 | final class EE_Admin implements InterminableInterface |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var EE_Admin $_instance |
|
27 | - */ |
|
28 | - private static $_instance; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
32 | - */ |
|
33 | - private $persistent_admin_notice_manager; |
|
34 | - |
|
35 | - /** |
|
36 | - * @singleton method used to instantiate class object |
|
37 | - * @return EE_Admin |
|
38 | - * @throws EE_Error |
|
39 | - */ |
|
40 | - public static function instance() |
|
41 | - { |
|
42 | - // check if class object is instantiated |
|
43 | - if (! self::$_instance instanceof EE_Admin) { |
|
44 | - self::$_instance = new self(); |
|
45 | - } |
|
46 | - return self::$_instance; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * @return EE_Admin |
|
52 | - * @throws EE_Error |
|
53 | - */ |
|
54 | - public static function reset() |
|
55 | - { |
|
56 | - self::$_instance = null; |
|
57 | - return self::instance(); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * class constructor |
|
63 | - * |
|
64 | - * @throws EE_Error |
|
65 | - * @throws InvalidDataTypeException |
|
66 | - * @throws InvalidInterfaceException |
|
67 | - * @throws InvalidArgumentException |
|
68 | - */ |
|
69 | - protected function __construct() |
|
70 | - { |
|
71 | - // define global EE_Admin constants |
|
72 | - $this->_define_all_constants(); |
|
73 | - // set autoloaders for our admin page classes based on included path information |
|
74 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
75 | - // admin hooks |
|
76 | - add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
77 | - // load EE_Request_Handler early |
|
78 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
79 | - add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
80 | - add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
81 | - add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
82 | - add_action('admin_init', array($this, 'admin_init'), 100); |
|
83 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
84 | - add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
85 | - add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
86 | - add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
87 | - add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
88 | - //reset Environment config (we only do this on admin page loads); |
|
89 | - EE_Registry::instance()->CFG->environment->recheck_values(); |
|
90 | - do_action('AHEE__EE_Admin__loaded'); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * _define_all_constants |
|
97 | - * define constants that are set globally for all admin pages |
|
98 | - * |
|
99 | - * @return void |
|
100 | - */ |
|
101 | - private function _define_all_constants() |
|
102 | - { |
|
103 | - if (! defined('EE_ADMIN_URL')) { |
|
104 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
105 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
106 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
107 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
108 | - define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * filter_plugin_actions - adds links to the Plugins page listing |
|
115 | - * |
|
116 | - * @param array $links |
|
117 | - * @param string $plugin |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - public function filter_plugin_actions($links, $plugin) |
|
121 | - { |
|
122 | - // set $main_file in stone |
|
123 | - static $main_file; |
|
124 | - // if $main_file is not set yet |
|
125 | - if (! $main_file) { |
|
126 | - $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
127 | - } |
|
128 | - if ($plugin === $main_file) { |
|
129 | - // compare current plugin to this one |
|
130 | - if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
131 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
132 | - . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
133 | - . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
134 | - . '</a>'; |
|
135 | - array_unshift($links, $maintenance_link); |
|
136 | - } else { |
|
137 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
138 | - . esc_html__('Settings', 'event_espresso') |
|
139 | - . '</a>'; |
|
140 | - $events_link = '<a href="admin.php?page=espresso_events">' |
|
141 | - . esc_html__('Events', 'event_espresso') |
|
142 | - . '</a>'; |
|
143 | - // add before other links |
|
144 | - array_unshift($links, $org_settings_link, $events_link); |
|
145 | - } |
|
146 | - } |
|
147 | - return $links; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * _get_request |
|
153 | - * |
|
154 | - * @return void |
|
155 | - * @throws EE_Error |
|
156 | - * @throws InvalidArgumentException |
|
157 | - * @throws InvalidDataTypeException |
|
158 | - * @throws InvalidInterfaceException |
|
159 | - * @throws ReflectionException |
|
160 | - */ |
|
161 | - public function get_request() |
|
162 | - { |
|
163 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
164 | - EE_Registry::instance()->load_core('CPT_Strategy'); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * hide_admin_pages_except_maintenance_mode |
|
171 | - * |
|
172 | - * @param array $admin_page_folder_names |
|
173 | - * @return array |
|
174 | - */ |
|
175 | - public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
176 | - { |
|
177 | - return array( |
|
178 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
179 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
180 | - 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
188 | - * EE_Front_Controller's init phases have run |
|
189 | - * |
|
190 | - * @return void |
|
191 | - * @throws EE_Error |
|
192 | - * @throws InvalidArgumentException |
|
193 | - * @throws InvalidDataTypeException |
|
194 | - * @throws InvalidInterfaceException |
|
195 | - * @throws ReflectionException |
|
196 | - * @throws ServiceNotFoundException |
|
197 | - */ |
|
198 | - public function init() |
|
199 | - { |
|
200 | - //only enable most of the EE_Admin IF we're not in full maintenance mode |
|
201 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
202 | - //ok so we want to enable the entire admin |
|
203 | - $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
204 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager', |
|
205 | - array( |
|
206 | - EE_Admin_Page::add_query_args_and_nonce( |
|
207 | - array( |
|
208 | - 'page' => EE_Registry::instance()->REQ->get('page', ''), |
|
209 | - 'action' => EE_Registry::instance()->REQ->get('action', ''), |
|
210 | - ), |
|
211 | - EE_ADMIN_URL |
|
212 | - ), |
|
213 | - ) |
|
214 | - ); |
|
215 | - $this->maybeSetDatetimeWarningNotice(); |
|
216 | - //at a glance dashboard widget |
|
217 | - add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
218 | - //filter for get_edit_post_link used on comments for custom post types |
|
219 | - add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
220 | - } |
|
221 | - // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
222 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
223 | - try { |
|
224 | - //this loads the controller for the admin pages which will setup routing etc |
|
225 | - EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
226 | - } catch (EE_Error $e) { |
|
227 | - $e->get_error(); |
|
228 | - } |
|
229 | - } |
|
230 | - add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
231 | - //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
232 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
233 | - add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
234 | - //exclude EE critical pages from all nav menus and wp_list_pages |
|
235 | - add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * get_persistent_admin_notices |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @return void |
|
244 | - * @throws EE_Error |
|
245 | - * @throws InvalidArgumentException |
|
246 | - * @throws InvalidDataTypeException |
|
247 | - * @throws InvalidInterfaceException |
|
248 | - */ |
|
249 | - public function maybeSetDatetimeWarningNotice() |
|
250 | - { |
|
251 | - //add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
252 | - //@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
253 | - //with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
254 | - //this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
255 | - if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
256 | - && ! get_option('timezone_string') |
|
257 | - && EEM_Event::instance()->count() > 0 |
|
258 | - ) { |
|
259 | - new PersistentAdminNotice( |
|
260 | - 'datetime_fix_notice', |
|
261 | - sprintf( |
|
262 | - esc_html__( |
|
263 | - '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
264 | - 'event_espresso' |
|
265 | - ), |
|
266 | - '<strong>', |
|
267 | - '</strong>', |
|
268 | - '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
269 | - '</a>', |
|
270 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
271 | - array( |
|
272 | - 'page' => 'espresso_maintenance_settings', |
|
273 | - 'action' => 'datetime_tools' |
|
274 | - ), |
|
275 | - admin_url('admin.php') |
|
276 | - ) . '">' |
|
277 | - ), |
|
278 | - false, |
|
279 | - 'manage_options', |
|
280 | - 'datetime_fix_persistent_notice' |
|
281 | - ); |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
289 | - * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
290 | - * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
291 | - * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
292 | - * normal property on the post_type object. It's found ONLY in this particular context. |
|
293 | - * |
|
294 | - * @param WP_Post $post_type WP post type object |
|
295 | - * @return WP_Post |
|
296 | - * @throws InvalidArgumentException |
|
297 | - * @throws InvalidDataTypeException |
|
298 | - * @throws InvalidInterfaceException |
|
299 | - */ |
|
300 | - public function remove_pages_from_nav_menu($post_type) |
|
301 | - { |
|
302 | - //if this isn't the "pages" post type let's get out |
|
303 | - if ($post_type->name !== 'page') { |
|
304 | - return $post_type; |
|
305 | - } |
|
306 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
307 | - $post_type->_default_query = array( |
|
308 | - 'post__not_in' => $critical_pages, |
|
309 | - ); |
|
310 | - return $post_type; |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
317 | - * metaboxes get shown as well |
|
318 | - * |
|
319 | - * @return void |
|
320 | - */ |
|
321 | - public function enable_hidden_ee_nav_menu_metaboxes() |
|
322 | - { |
|
323 | - global $wp_meta_boxes, $pagenow; |
|
324 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
325 | - return; |
|
326 | - } |
|
327 | - $user = wp_get_current_user(); |
|
328 | - //has this been done yet? |
|
329 | - if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
330 | - return; |
|
331 | - } |
|
332 | - |
|
333 | - $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
334 | - $initial_meta_boxes = apply_filters( |
|
335 | - 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
336 | - array( |
|
337 | - 'nav-menu-theme-locations', |
|
338 | - 'add-page', |
|
339 | - 'add-custom-links', |
|
340 | - 'add-category', |
|
341 | - 'add-espresso_events', |
|
342 | - 'add-espresso_venues', |
|
343 | - 'add-espresso_event_categories', |
|
344 | - 'add-espresso_venue_categories', |
|
345 | - 'add-post-type-post', |
|
346 | - 'add-post-type-page', |
|
347 | - ) |
|
348 | - ); |
|
349 | - |
|
350 | - if (is_array($hidden_meta_boxes)) { |
|
351 | - foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
352 | - if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
353 | - unset($hidden_meta_boxes[$key]); |
|
354 | - } |
|
355 | - } |
|
356 | - } |
|
357 | - update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
358 | - update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - |
|
363 | - /** |
|
364 | - * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
365 | - * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
366 | - * |
|
367 | - * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
368 | - * addons etc. |
|
369 | - * @return void |
|
370 | - */ |
|
371 | - public function register_custom_nav_menu_boxes() |
|
372 | - { |
|
373 | - add_meta_box( |
|
374 | - 'add-extra-nav-menu-pages', |
|
375 | - esc_html__('Event Espresso Pages', 'event_espresso'), |
|
376 | - array($this, 'ee_cpt_archive_pages'), |
|
377 | - 'nav-menus', |
|
378 | - 'side', |
|
379 | - 'core' |
|
380 | - ); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
387 | - * |
|
388 | - * @since 4.3.0 |
|
389 | - * @param string $link the original link generated by wp |
|
390 | - * @param int $id post id |
|
391 | - * @return string the (maybe) modified link |
|
392 | - */ |
|
393 | - public function modify_edit_post_link($link, $id) |
|
394 | - { |
|
395 | - if (! $post = get_post($id)) { |
|
396 | - return $link; |
|
397 | - } |
|
398 | - if ($post->post_type === 'espresso_attendees') { |
|
399 | - $query_args = array( |
|
400 | - 'action' => 'edit_attendee', |
|
401 | - 'post' => $id, |
|
402 | - ); |
|
403 | - return EEH_URL::add_query_args_and_nonce( |
|
404 | - $query_args, |
|
405 | - admin_url('admin.php?page=espresso_registrations') |
|
406 | - ); |
|
407 | - } |
|
408 | - return $link; |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - |
|
413 | - public function ee_cpt_archive_pages() |
|
414 | - { |
|
415 | - global $nav_menu_selected_id; |
|
416 | - $db_fields = false; |
|
417 | - $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
418 | - $current_tab = 'event-archives'; |
|
419 | - $removed_args = array( |
|
420 | - 'action', |
|
421 | - 'customlink-tab', |
|
422 | - 'edit-menu-item', |
|
423 | - 'menu-item', |
|
424 | - 'page-tab', |
|
425 | - '_wpnonce', |
|
426 | - ); |
|
427 | - ?> |
|
25 | + /** |
|
26 | + * @var EE_Admin $_instance |
|
27 | + */ |
|
28 | + private static $_instance; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
32 | + */ |
|
33 | + private $persistent_admin_notice_manager; |
|
34 | + |
|
35 | + /** |
|
36 | + * @singleton method used to instantiate class object |
|
37 | + * @return EE_Admin |
|
38 | + * @throws EE_Error |
|
39 | + */ |
|
40 | + public static function instance() |
|
41 | + { |
|
42 | + // check if class object is instantiated |
|
43 | + if (! self::$_instance instanceof EE_Admin) { |
|
44 | + self::$_instance = new self(); |
|
45 | + } |
|
46 | + return self::$_instance; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * @return EE_Admin |
|
52 | + * @throws EE_Error |
|
53 | + */ |
|
54 | + public static function reset() |
|
55 | + { |
|
56 | + self::$_instance = null; |
|
57 | + return self::instance(); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * class constructor |
|
63 | + * |
|
64 | + * @throws EE_Error |
|
65 | + * @throws InvalidDataTypeException |
|
66 | + * @throws InvalidInterfaceException |
|
67 | + * @throws InvalidArgumentException |
|
68 | + */ |
|
69 | + protected function __construct() |
|
70 | + { |
|
71 | + // define global EE_Admin constants |
|
72 | + $this->_define_all_constants(); |
|
73 | + // set autoloaders for our admin page classes based on included path information |
|
74 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
75 | + // admin hooks |
|
76 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
77 | + // load EE_Request_Handler early |
|
78 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
79 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
80 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
81 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
82 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
83 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
84 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
85 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
86 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
87 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
88 | + //reset Environment config (we only do this on admin page loads); |
|
89 | + EE_Registry::instance()->CFG->environment->recheck_values(); |
|
90 | + do_action('AHEE__EE_Admin__loaded'); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * _define_all_constants |
|
97 | + * define constants that are set globally for all admin pages |
|
98 | + * |
|
99 | + * @return void |
|
100 | + */ |
|
101 | + private function _define_all_constants() |
|
102 | + { |
|
103 | + if (! defined('EE_ADMIN_URL')) { |
|
104 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
105 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
106 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
107 | + define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
108 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * filter_plugin_actions - adds links to the Plugins page listing |
|
115 | + * |
|
116 | + * @param array $links |
|
117 | + * @param string $plugin |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + public function filter_plugin_actions($links, $plugin) |
|
121 | + { |
|
122 | + // set $main_file in stone |
|
123 | + static $main_file; |
|
124 | + // if $main_file is not set yet |
|
125 | + if (! $main_file) { |
|
126 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
127 | + } |
|
128 | + if ($plugin === $main_file) { |
|
129 | + // compare current plugin to this one |
|
130 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
131 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
132 | + . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
133 | + . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
134 | + . '</a>'; |
|
135 | + array_unshift($links, $maintenance_link); |
|
136 | + } else { |
|
137 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
138 | + . esc_html__('Settings', 'event_espresso') |
|
139 | + . '</a>'; |
|
140 | + $events_link = '<a href="admin.php?page=espresso_events">' |
|
141 | + . esc_html__('Events', 'event_espresso') |
|
142 | + . '</a>'; |
|
143 | + // add before other links |
|
144 | + array_unshift($links, $org_settings_link, $events_link); |
|
145 | + } |
|
146 | + } |
|
147 | + return $links; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * _get_request |
|
153 | + * |
|
154 | + * @return void |
|
155 | + * @throws EE_Error |
|
156 | + * @throws InvalidArgumentException |
|
157 | + * @throws InvalidDataTypeException |
|
158 | + * @throws InvalidInterfaceException |
|
159 | + * @throws ReflectionException |
|
160 | + */ |
|
161 | + public function get_request() |
|
162 | + { |
|
163 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
164 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * hide_admin_pages_except_maintenance_mode |
|
171 | + * |
|
172 | + * @param array $admin_page_folder_names |
|
173 | + * @return array |
|
174 | + */ |
|
175 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
176 | + { |
|
177 | + return array( |
|
178 | + 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
179 | + 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
180 | + 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
181 | + ); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
188 | + * EE_Front_Controller's init phases have run |
|
189 | + * |
|
190 | + * @return void |
|
191 | + * @throws EE_Error |
|
192 | + * @throws InvalidArgumentException |
|
193 | + * @throws InvalidDataTypeException |
|
194 | + * @throws InvalidInterfaceException |
|
195 | + * @throws ReflectionException |
|
196 | + * @throws ServiceNotFoundException |
|
197 | + */ |
|
198 | + public function init() |
|
199 | + { |
|
200 | + //only enable most of the EE_Admin IF we're not in full maintenance mode |
|
201 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
202 | + //ok so we want to enable the entire admin |
|
203 | + $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
204 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager', |
|
205 | + array( |
|
206 | + EE_Admin_Page::add_query_args_and_nonce( |
|
207 | + array( |
|
208 | + 'page' => EE_Registry::instance()->REQ->get('page', ''), |
|
209 | + 'action' => EE_Registry::instance()->REQ->get('action', ''), |
|
210 | + ), |
|
211 | + EE_ADMIN_URL |
|
212 | + ), |
|
213 | + ) |
|
214 | + ); |
|
215 | + $this->maybeSetDatetimeWarningNotice(); |
|
216 | + //at a glance dashboard widget |
|
217 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
218 | + //filter for get_edit_post_link used on comments for custom post types |
|
219 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
220 | + } |
|
221 | + // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
222 | + if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
223 | + try { |
|
224 | + //this loads the controller for the admin pages which will setup routing etc |
|
225 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
226 | + } catch (EE_Error $e) { |
|
227 | + $e->get_error(); |
|
228 | + } |
|
229 | + } |
|
230 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
231 | + //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
232 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
233 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
234 | + //exclude EE critical pages from all nav menus and wp_list_pages |
|
235 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * get_persistent_admin_notices |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @return void |
|
244 | + * @throws EE_Error |
|
245 | + * @throws InvalidArgumentException |
|
246 | + * @throws InvalidDataTypeException |
|
247 | + * @throws InvalidInterfaceException |
|
248 | + */ |
|
249 | + public function maybeSetDatetimeWarningNotice() |
|
250 | + { |
|
251 | + //add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
252 | + //@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
253 | + //with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
254 | + //this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
255 | + if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
256 | + && ! get_option('timezone_string') |
|
257 | + && EEM_Event::instance()->count() > 0 |
|
258 | + ) { |
|
259 | + new PersistentAdminNotice( |
|
260 | + 'datetime_fix_notice', |
|
261 | + sprintf( |
|
262 | + esc_html__( |
|
263 | + '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
264 | + 'event_espresso' |
|
265 | + ), |
|
266 | + '<strong>', |
|
267 | + '</strong>', |
|
268 | + '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
269 | + '</a>', |
|
270 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
271 | + array( |
|
272 | + 'page' => 'espresso_maintenance_settings', |
|
273 | + 'action' => 'datetime_tools' |
|
274 | + ), |
|
275 | + admin_url('admin.php') |
|
276 | + ) . '">' |
|
277 | + ), |
|
278 | + false, |
|
279 | + 'manage_options', |
|
280 | + 'datetime_fix_persistent_notice' |
|
281 | + ); |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
289 | + * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
290 | + * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
291 | + * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
292 | + * normal property on the post_type object. It's found ONLY in this particular context. |
|
293 | + * |
|
294 | + * @param WP_Post $post_type WP post type object |
|
295 | + * @return WP_Post |
|
296 | + * @throws InvalidArgumentException |
|
297 | + * @throws InvalidDataTypeException |
|
298 | + * @throws InvalidInterfaceException |
|
299 | + */ |
|
300 | + public function remove_pages_from_nav_menu($post_type) |
|
301 | + { |
|
302 | + //if this isn't the "pages" post type let's get out |
|
303 | + if ($post_type->name !== 'page') { |
|
304 | + return $post_type; |
|
305 | + } |
|
306 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
307 | + $post_type->_default_query = array( |
|
308 | + 'post__not_in' => $critical_pages, |
|
309 | + ); |
|
310 | + return $post_type; |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
317 | + * metaboxes get shown as well |
|
318 | + * |
|
319 | + * @return void |
|
320 | + */ |
|
321 | + public function enable_hidden_ee_nav_menu_metaboxes() |
|
322 | + { |
|
323 | + global $wp_meta_boxes, $pagenow; |
|
324 | + if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
325 | + return; |
|
326 | + } |
|
327 | + $user = wp_get_current_user(); |
|
328 | + //has this been done yet? |
|
329 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
330 | + return; |
|
331 | + } |
|
332 | + |
|
333 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
334 | + $initial_meta_boxes = apply_filters( |
|
335 | + 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
336 | + array( |
|
337 | + 'nav-menu-theme-locations', |
|
338 | + 'add-page', |
|
339 | + 'add-custom-links', |
|
340 | + 'add-category', |
|
341 | + 'add-espresso_events', |
|
342 | + 'add-espresso_venues', |
|
343 | + 'add-espresso_event_categories', |
|
344 | + 'add-espresso_venue_categories', |
|
345 | + 'add-post-type-post', |
|
346 | + 'add-post-type-page', |
|
347 | + ) |
|
348 | + ); |
|
349 | + |
|
350 | + if (is_array($hidden_meta_boxes)) { |
|
351 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
352 | + if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
353 | + unset($hidden_meta_boxes[$key]); |
|
354 | + } |
|
355 | + } |
|
356 | + } |
|
357 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
358 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + |
|
363 | + /** |
|
364 | + * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
365 | + * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
366 | + * |
|
367 | + * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
368 | + * addons etc. |
|
369 | + * @return void |
|
370 | + */ |
|
371 | + public function register_custom_nav_menu_boxes() |
|
372 | + { |
|
373 | + add_meta_box( |
|
374 | + 'add-extra-nav-menu-pages', |
|
375 | + esc_html__('Event Espresso Pages', 'event_espresso'), |
|
376 | + array($this, 'ee_cpt_archive_pages'), |
|
377 | + 'nav-menus', |
|
378 | + 'side', |
|
379 | + 'core' |
|
380 | + ); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
387 | + * |
|
388 | + * @since 4.3.0 |
|
389 | + * @param string $link the original link generated by wp |
|
390 | + * @param int $id post id |
|
391 | + * @return string the (maybe) modified link |
|
392 | + */ |
|
393 | + public function modify_edit_post_link($link, $id) |
|
394 | + { |
|
395 | + if (! $post = get_post($id)) { |
|
396 | + return $link; |
|
397 | + } |
|
398 | + if ($post->post_type === 'espresso_attendees') { |
|
399 | + $query_args = array( |
|
400 | + 'action' => 'edit_attendee', |
|
401 | + 'post' => $id, |
|
402 | + ); |
|
403 | + return EEH_URL::add_query_args_and_nonce( |
|
404 | + $query_args, |
|
405 | + admin_url('admin.php?page=espresso_registrations') |
|
406 | + ); |
|
407 | + } |
|
408 | + return $link; |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + |
|
413 | + public function ee_cpt_archive_pages() |
|
414 | + { |
|
415 | + global $nav_menu_selected_id; |
|
416 | + $db_fields = false; |
|
417 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
418 | + $current_tab = 'event-archives'; |
|
419 | + $removed_args = array( |
|
420 | + 'action', |
|
421 | + 'customlink-tab', |
|
422 | + 'edit-menu-item', |
|
423 | + 'menu-item', |
|
424 | + 'page-tab', |
|
425 | + '_wpnonce', |
|
426 | + ); |
|
427 | + ?> |
|
428 | 428 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
429 | 429 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
430 | 430 | <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
431 | 431 | <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" |
432 | 432 | href="<?php if ($nav_menu_selected_id) { |
433 | - echo esc_url( |
|
434 | - add_query_arg( |
|
435 | - 'extra-nav-menu-pages-tab', |
|
436 | - 'event-archives', |
|
437 | - remove_query_arg($removed_args) |
|
438 | - ) |
|
439 | - ); |
|
440 | - } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
433 | + echo esc_url( |
|
434 | + add_query_arg( |
|
435 | + 'extra-nav-menu-pages-tab', |
|
436 | + 'event-archives', |
|
437 | + remove_query_arg($removed_args) |
|
438 | + ) |
|
439 | + ); |
|
440 | + } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
441 | 441 | <?php _e('Event Archive Pages', 'event_espresso'); ?> |
442 | 442 | </a> |
443 | 443 | </li> |
444 | 444 | </ul><!-- .posttype-tabs --> |
445 | 445 | |
446 | 446 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
447 | - echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
448 | - ?>"> |
|
447 | + echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
448 | + ?>"> |
|
449 | 449 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
450 | 450 | <?php |
451 | - $pages = $this->_get_extra_nav_menu_pages_items(); |
|
452 | - $args['walker'] = $walker; |
|
453 | - echo walk_nav_menu_tree( |
|
454 | - array_map( |
|
455 | - array($this, '_setup_extra_nav_menu_pages_items'), |
|
456 | - $pages |
|
457 | - ), |
|
458 | - 0, |
|
459 | - (object) $args |
|
460 | - ); |
|
461 | - ?> |
|
451 | + $pages = $this->_get_extra_nav_menu_pages_items(); |
|
452 | + $args['walker'] = $walker; |
|
453 | + echo walk_nav_menu_tree( |
|
454 | + array_map( |
|
455 | + array($this, '_setup_extra_nav_menu_pages_items'), |
|
456 | + $pages |
|
457 | + ), |
|
458 | + 0, |
|
459 | + (object) $args |
|
460 | + ); |
|
461 | + ?> |
|
462 | 462 | </ul> |
463 | 463 | </div><!-- /.tabs-panel --> |
464 | 464 | |
465 | 465 | <p class="button-controls"> |
466 | 466 | <span class="list-controls"> |
467 | 467 | <a href="<?php |
468 | - echo esc_url(add_query_arg( |
|
469 | - array( |
|
470 | - 'extra-nav-menu-pages-tab' => 'event-archives', |
|
471 | - 'selectall' => 1, |
|
472 | - ), |
|
473 | - remove_query_arg($removed_args) |
|
474 | - )); |
|
475 | - ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
|
468 | + echo esc_url(add_query_arg( |
|
469 | + array( |
|
470 | + 'extra-nav-menu-pages-tab' => 'event-archives', |
|
471 | + 'selectall' => 1, |
|
472 | + ), |
|
473 | + remove_query_arg($removed_args) |
|
474 | + )); |
|
475 | + ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
|
476 | 476 | </span> |
477 | 477 | <span class="add-to-menu"> |
478 | 478 | <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> |
@@ -485,471 +485,471 @@ discard block |
||
485 | 485 | |
486 | 486 | </div><!-- /.posttypediv --> |
487 | 487 | <?php |
488 | - } |
|
489 | - |
|
490 | - |
|
491 | - /** |
|
492 | - * Returns an array of event archive nav items. |
|
493 | - * |
|
494 | - * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
495 | - * method we use for getting the extra nav menu items |
|
496 | - * @return array |
|
497 | - */ |
|
498 | - private function _get_extra_nav_menu_pages_items() |
|
499 | - { |
|
500 | - $menuitems[] = array( |
|
501 | - 'title' => esc_html__('Event List', 'event_espresso'), |
|
502 | - 'url' => get_post_type_archive_link('espresso_events'), |
|
503 | - 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
504 | - ); |
|
505 | - return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
506 | - } |
|
507 | - |
|
508 | - |
|
509 | - /** |
|
510 | - * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
511 | - * the properties and converts it to the menu item object. |
|
512 | - * |
|
513 | - * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
514 | - * @param $menu_item_values |
|
515 | - * @return stdClass |
|
516 | - */ |
|
517 | - private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
518 | - { |
|
519 | - $menu_item = new stdClass(); |
|
520 | - $keys = array( |
|
521 | - 'ID' => 0, |
|
522 | - 'db_id' => 0, |
|
523 | - 'menu_item_parent' => 0, |
|
524 | - 'object_id' => -1, |
|
525 | - 'post_parent' => 0, |
|
526 | - 'type' => 'custom', |
|
527 | - 'object' => '', |
|
528 | - 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
529 | - 'title' => '', |
|
530 | - 'url' => '', |
|
531 | - 'target' => '', |
|
532 | - 'attr_title' => '', |
|
533 | - 'description' => '', |
|
534 | - 'classes' => array(), |
|
535 | - 'xfn' => '', |
|
536 | - ); |
|
537 | - |
|
538 | - foreach ($keys as $key => $value) { |
|
539 | - $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
540 | - } |
|
541 | - return $menu_item; |
|
542 | - } |
|
543 | - |
|
544 | - |
|
545 | - /** |
|
546 | - * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
547 | - * EE_Admin_Page route is called. |
|
548 | - * |
|
549 | - * @return void |
|
550 | - */ |
|
551 | - public function route_admin_request() |
|
552 | - { |
|
553 | - } |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
558 | - * |
|
559 | - * @return void |
|
560 | - */ |
|
561 | - public function wp_loaded() |
|
562 | - { |
|
563 | - } |
|
564 | - |
|
565 | - |
|
566 | - /** |
|
567 | - * admin_init |
|
568 | - * |
|
569 | - * @return void |
|
570 | - * @throws EE_Error |
|
571 | - * @throws InvalidArgumentException |
|
572 | - * @throws InvalidDataTypeException |
|
573 | - * @throws InvalidInterfaceException |
|
574 | - * @throws ReflectionException |
|
575 | - */ |
|
576 | - public function admin_init() |
|
577 | - { |
|
578 | - |
|
579 | - /** |
|
580 | - * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
581 | - * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
582 | - * - check if doing post processing. |
|
583 | - * - check if doing post processing of one of EE CPTs |
|
584 | - * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
585 | - */ |
|
586 | - if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
587 | - EE_Registry::instance()->load_core('Register_CPTs'); |
|
588 | - EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
589 | - } |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
594 | - * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
595 | - * Pages" tab in the EE General Settings Admin page. |
|
596 | - * This is for user-proofing. |
|
597 | - */ |
|
598 | - add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
599 | - } |
|
600 | - |
|
601 | - |
|
602 | - /** |
|
603 | - * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
604 | - * |
|
605 | - * @param string $output Current output. |
|
606 | - * @return string |
|
607 | - * @throws InvalidArgumentException |
|
608 | - * @throws InvalidDataTypeException |
|
609 | - * @throws InvalidInterfaceException |
|
610 | - */ |
|
611 | - public function modify_dropdown_pages($output) |
|
612 | - { |
|
613 | - //get critical pages |
|
614 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
615 | - |
|
616 | - //split current output by line break for easier parsing. |
|
617 | - $split_output = explode("\n", $output); |
|
618 | - |
|
619 | - //loop through to remove any critical pages from the array. |
|
620 | - foreach ($critical_pages as $page_id) { |
|
621 | - $needle = 'value="' . $page_id . '"'; |
|
622 | - foreach ($split_output as $key => $haystack) { |
|
623 | - if (strpos($haystack, $needle) !== false) { |
|
624 | - unset($split_output[$key]); |
|
625 | - } |
|
626 | - } |
|
627 | - } |
|
628 | - //replace output with the new contents |
|
629 | - return implode("\n", $split_output); |
|
630 | - } |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * enqueue all admin scripts that need loaded for admin pages |
|
635 | - * |
|
636 | - * @return void |
|
637 | - */ |
|
638 | - public function enqueue_admin_scripts() |
|
639 | - { |
|
640 | - // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
|
641 | - // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script |
|
642 | - // calls. |
|
643 | - wp_enqueue_script( |
|
644 | - 'ee-inject-wp', |
|
645 | - EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
646 | - array('jquery'), |
|
647 | - EVENT_ESPRESSO_VERSION, |
|
648 | - true |
|
649 | - ); |
|
650 | - // register cookie script for future dependencies |
|
651 | - wp_register_script( |
|
652 | - 'jquery-cookie', |
|
653 | - EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
654 | - array('jquery'), |
|
655 | - '2.1', |
|
656 | - true |
|
657 | - ); |
|
658 | - //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again |
|
659 | - // via: add_filter('FHEE_load_joyride', '__return_true' ); |
|
660 | - if (apply_filters('FHEE_load_joyride', false)) { |
|
661 | - //joyride style |
|
662 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
663 | - wp_register_style( |
|
664 | - 'ee-joyride-css', |
|
665 | - EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
666 | - array('joyride-css'), |
|
667 | - EVENT_ESPRESSO_VERSION |
|
668 | - ); |
|
669 | - wp_register_script( |
|
670 | - 'joyride-modernizr', |
|
671 | - EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
672 | - array(), |
|
673 | - '2.1', |
|
674 | - true |
|
675 | - ); |
|
676 | - //joyride JS |
|
677 | - wp_register_script( |
|
678 | - 'jquery-joyride', |
|
679 | - EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
680 | - array('jquery-cookie', 'joyride-modernizr'), |
|
681 | - '2.1', |
|
682 | - true |
|
683 | - ); |
|
684 | - // wanna go for a joyride? |
|
685 | - wp_enqueue_style('ee-joyride-css'); |
|
686 | - wp_enqueue_script('jquery-joyride'); |
|
687 | - } |
|
688 | - } |
|
689 | - |
|
690 | - |
|
691 | - /** |
|
692 | - * display_admin_notices |
|
693 | - * |
|
694 | - * @return void |
|
695 | - */ |
|
696 | - public function display_admin_notices() |
|
697 | - { |
|
698 | - echo EE_Error::get_notices(); |
|
699 | - } |
|
700 | - |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * @param array $elements |
|
705 | - * @return array |
|
706 | - * @throws EE_Error |
|
707 | - * @throws InvalidArgumentException |
|
708 | - * @throws InvalidDataTypeException |
|
709 | - * @throws InvalidInterfaceException |
|
710 | - */ |
|
711 | - public function dashboard_glance_items($elements) |
|
712 | - { |
|
713 | - $elements = is_array($elements) ? $elements : array($elements); |
|
714 | - $events = EEM_Event::instance()->count(); |
|
715 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
716 | - array('page' => 'espresso_events'), |
|
717 | - admin_url('admin.php') |
|
718 | - ); |
|
719 | - $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
720 | - $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
721 | - $registrations = EEM_Registration::instance()->count( |
|
722 | - array( |
|
723 | - array( |
|
724 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
725 | - ), |
|
726 | - ) |
|
727 | - ); |
|
728 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
729 | - array('page' => 'espresso_registrations'), |
|
730 | - admin_url('admin.php') |
|
731 | - ); |
|
732 | - $items['registrations']['text'] = sprintf( |
|
733 | - _n('%s Registration', '%s Registrations', $registrations), |
|
734 | - number_format_i18n($registrations) |
|
735 | - ); |
|
736 | - $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
737 | - |
|
738 | - $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
739 | - |
|
740 | - foreach ($items as $type => $item_properties) { |
|
741 | - $elements[] = sprintf( |
|
742 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
743 | - $item_properties['url'], |
|
744 | - $item_properties['title'], |
|
745 | - $item_properties['text'] |
|
746 | - ); |
|
747 | - } |
|
748 | - return $elements; |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - /** |
|
753 | - * check_for_invalid_datetime_formats |
|
754 | - * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
755 | - * their selected format can be parsed by PHP |
|
756 | - * |
|
757 | - * @param $value |
|
758 | - * @param $option |
|
759 | - * @throws EE_Error |
|
760 | - * @return string |
|
761 | - */ |
|
762 | - public function check_for_invalid_datetime_formats($value, $option) |
|
763 | - { |
|
764 | - // check for date_format or time_format |
|
765 | - switch ($option) { |
|
766 | - case 'date_format': |
|
767 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
768 | - break; |
|
769 | - case 'time_format': |
|
770 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
771 | - break; |
|
772 | - default: |
|
773 | - $date_time_format = false; |
|
774 | - } |
|
775 | - // do we have a date_time format to check ? |
|
776 | - if ($date_time_format) { |
|
777 | - $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
778 | - |
|
779 | - if (is_array($error_msg)) { |
|
780 | - $msg = '<p>' |
|
781 | - . sprintf( |
|
782 | - esc_html__( |
|
783 | - 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
784 | - 'event_espresso' |
|
785 | - ), |
|
786 | - date($date_time_format), |
|
787 | - $date_time_format |
|
788 | - ) |
|
789 | - . '</p><p><ul>'; |
|
790 | - |
|
791 | - |
|
792 | - foreach ($error_msg as $error) { |
|
793 | - $msg .= '<li>' . $error . '</li>'; |
|
794 | - } |
|
795 | - |
|
796 | - $msg .= '</ul></p><p>' |
|
797 | - . sprintf( |
|
798 | - esc_html__( |
|
799 | - '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
800 | - 'event_espresso' |
|
801 | - ), |
|
802 | - '<span style="color:#D54E21;">', |
|
803 | - '</span>' |
|
804 | - ) |
|
805 | - . '</p>'; |
|
806 | - |
|
807 | - // trigger WP settings error |
|
808 | - add_settings_error( |
|
809 | - 'date_format', |
|
810 | - 'date_format', |
|
811 | - $msg |
|
812 | - ); |
|
813 | - |
|
814 | - // set format to something valid |
|
815 | - switch ($option) { |
|
816 | - case 'date_format': |
|
817 | - $value = 'F j, Y'; |
|
818 | - break; |
|
819 | - case 'time_format': |
|
820 | - $value = 'g:i a'; |
|
821 | - break; |
|
822 | - } |
|
823 | - } |
|
824 | - } |
|
825 | - return $value; |
|
826 | - } |
|
827 | - |
|
828 | - |
|
829 | - /** |
|
830 | - * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
831 | - * |
|
832 | - * @param $content |
|
833 | - * @return string |
|
834 | - */ |
|
835 | - public function its_eSpresso($content) |
|
836 | - { |
|
837 | - return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
838 | - } |
|
839 | - |
|
840 | - |
|
841 | - /** |
|
842 | - * espresso_admin_footer |
|
843 | - * |
|
844 | - * @return string |
|
845 | - */ |
|
846 | - public function espresso_admin_footer() |
|
847 | - { |
|
848 | - return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
849 | - } |
|
850 | - |
|
851 | - |
|
852 | - /** |
|
853 | - * static method for registering ee admin page. |
|
854 | - * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
855 | - * |
|
856 | - * @since 4.3.0 |
|
857 | - * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
858 | - * @see EE_Register_Admin_Page::register() |
|
859 | - * @param $page_basename |
|
860 | - * @param $page_path |
|
861 | - * @param array $config |
|
862 | - * @return void |
|
863 | - * @throws EE_Error |
|
864 | - */ |
|
865 | - public static function register_ee_admin_page($page_basename, $page_path, $config = array()) |
|
866 | - { |
|
867 | - EE_Error::doing_it_wrong( |
|
868 | - __METHOD__, |
|
869 | - sprintf( |
|
870 | - esc_html__( |
|
871 | - 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
872 | - 'event_espresso' |
|
873 | - ), |
|
874 | - $page_basename |
|
875 | - ), |
|
876 | - '4.3' |
|
877 | - ); |
|
878 | - if (class_exists('EE_Register_Admin_Page')) { |
|
879 | - $config['page_path'] = $page_path; |
|
880 | - } |
|
881 | - EE_Register_Admin_Page::register($page_basename, $config); |
|
882 | - } |
|
883 | - |
|
884 | - |
|
885 | - /** |
|
886 | - * @deprecated 4.8.41 |
|
887 | - * @param int $post_ID |
|
888 | - * @param \WP_Post $post |
|
889 | - * @return void |
|
890 | - */ |
|
891 | - public static function parse_post_content_on_save($post_ID, $post) |
|
892 | - { |
|
893 | - EE_Error::doing_it_wrong( |
|
894 | - __METHOD__, |
|
895 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
896 | - '4.8.41' |
|
897 | - ); |
|
898 | - } |
|
899 | - |
|
900 | - |
|
901 | - /** |
|
902 | - * @deprecated 4.8.41 |
|
903 | - * @param $option |
|
904 | - * @param $old_value |
|
905 | - * @param $value |
|
906 | - * @return void |
|
907 | - */ |
|
908 | - public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
909 | - { |
|
910 | - EE_Error::doing_it_wrong( |
|
911 | - __METHOD__, |
|
912 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
913 | - '4.8.41' |
|
914 | - ); |
|
915 | - } |
|
916 | - |
|
917 | - |
|
918 | - |
|
919 | - /** |
|
920 | - * @deprecated 4.9.27 |
|
921 | - * @return void |
|
922 | - */ |
|
923 | - public function get_persistent_admin_notices() |
|
924 | - { |
|
925 | - EE_Error::doing_it_wrong( |
|
926 | - __METHOD__, |
|
927 | - sprintf( |
|
928 | - __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
929 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
930 | - ), |
|
931 | - '4.9.27' |
|
932 | - ); |
|
933 | - } |
|
934 | - |
|
935 | - |
|
936 | - |
|
937 | - /** |
|
938 | - * @deprecated 4.9.27 |
|
939 | - * @throws InvalidInterfaceException |
|
940 | - * @throws InvalidDataTypeException |
|
941 | - * @throws DomainException |
|
942 | - */ |
|
943 | - public function dismiss_ee_nag_notice_callback() |
|
944 | - { |
|
945 | - EE_Error::doing_it_wrong( |
|
946 | - __METHOD__, |
|
947 | - sprintf( |
|
948 | - __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
949 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
950 | - ), |
|
951 | - '4.9.27' |
|
952 | - ); |
|
953 | - $this->persistent_admin_notice_manager->dismissNotice(); |
|
954 | - } |
|
488 | + } |
|
489 | + |
|
490 | + |
|
491 | + /** |
|
492 | + * Returns an array of event archive nav items. |
|
493 | + * |
|
494 | + * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
495 | + * method we use for getting the extra nav menu items |
|
496 | + * @return array |
|
497 | + */ |
|
498 | + private function _get_extra_nav_menu_pages_items() |
|
499 | + { |
|
500 | + $menuitems[] = array( |
|
501 | + 'title' => esc_html__('Event List', 'event_espresso'), |
|
502 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
503 | + 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
504 | + ); |
|
505 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
506 | + } |
|
507 | + |
|
508 | + |
|
509 | + /** |
|
510 | + * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
511 | + * the properties and converts it to the menu item object. |
|
512 | + * |
|
513 | + * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
514 | + * @param $menu_item_values |
|
515 | + * @return stdClass |
|
516 | + */ |
|
517 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
518 | + { |
|
519 | + $menu_item = new stdClass(); |
|
520 | + $keys = array( |
|
521 | + 'ID' => 0, |
|
522 | + 'db_id' => 0, |
|
523 | + 'menu_item_parent' => 0, |
|
524 | + 'object_id' => -1, |
|
525 | + 'post_parent' => 0, |
|
526 | + 'type' => 'custom', |
|
527 | + 'object' => '', |
|
528 | + 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
529 | + 'title' => '', |
|
530 | + 'url' => '', |
|
531 | + 'target' => '', |
|
532 | + 'attr_title' => '', |
|
533 | + 'description' => '', |
|
534 | + 'classes' => array(), |
|
535 | + 'xfn' => '', |
|
536 | + ); |
|
537 | + |
|
538 | + foreach ($keys as $key => $value) { |
|
539 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
540 | + } |
|
541 | + return $menu_item; |
|
542 | + } |
|
543 | + |
|
544 | + |
|
545 | + /** |
|
546 | + * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
547 | + * EE_Admin_Page route is called. |
|
548 | + * |
|
549 | + * @return void |
|
550 | + */ |
|
551 | + public function route_admin_request() |
|
552 | + { |
|
553 | + } |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
558 | + * |
|
559 | + * @return void |
|
560 | + */ |
|
561 | + public function wp_loaded() |
|
562 | + { |
|
563 | + } |
|
564 | + |
|
565 | + |
|
566 | + /** |
|
567 | + * admin_init |
|
568 | + * |
|
569 | + * @return void |
|
570 | + * @throws EE_Error |
|
571 | + * @throws InvalidArgumentException |
|
572 | + * @throws InvalidDataTypeException |
|
573 | + * @throws InvalidInterfaceException |
|
574 | + * @throws ReflectionException |
|
575 | + */ |
|
576 | + public function admin_init() |
|
577 | + { |
|
578 | + |
|
579 | + /** |
|
580 | + * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
581 | + * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
582 | + * - check if doing post processing. |
|
583 | + * - check if doing post processing of one of EE CPTs |
|
584 | + * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
585 | + */ |
|
586 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
587 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
588 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
589 | + } |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
594 | + * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
595 | + * Pages" tab in the EE General Settings Admin page. |
|
596 | + * This is for user-proofing. |
|
597 | + */ |
|
598 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
599 | + } |
|
600 | + |
|
601 | + |
|
602 | + /** |
|
603 | + * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
604 | + * |
|
605 | + * @param string $output Current output. |
|
606 | + * @return string |
|
607 | + * @throws InvalidArgumentException |
|
608 | + * @throws InvalidDataTypeException |
|
609 | + * @throws InvalidInterfaceException |
|
610 | + */ |
|
611 | + public function modify_dropdown_pages($output) |
|
612 | + { |
|
613 | + //get critical pages |
|
614 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
615 | + |
|
616 | + //split current output by line break for easier parsing. |
|
617 | + $split_output = explode("\n", $output); |
|
618 | + |
|
619 | + //loop through to remove any critical pages from the array. |
|
620 | + foreach ($critical_pages as $page_id) { |
|
621 | + $needle = 'value="' . $page_id . '"'; |
|
622 | + foreach ($split_output as $key => $haystack) { |
|
623 | + if (strpos($haystack, $needle) !== false) { |
|
624 | + unset($split_output[$key]); |
|
625 | + } |
|
626 | + } |
|
627 | + } |
|
628 | + //replace output with the new contents |
|
629 | + return implode("\n", $split_output); |
|
630 | + } |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * enqueue all admin scripts that need loaded for admin pages |
|
635 | + * |
|
636 | + * @return void |
|
637 | + */ |
|
638 | + public function enqueue_admin_scripts() |
|
639 | + { |
|
640 | + // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
|
641 | + // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script |
|
642 | + // calls. |
|
643 | + wp_enqueue_script( |
|
644 | + 'ee-inject-wp', |
|
645 | + EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
646 | + array('jquery'), |
|
647 | + EVENT_ESPRESSO_VERSION, |
|
648 | + true |
|
649 | + ); |
|
650 | + // register cookie script for future dependencies |
|
651 | + wp_register_script( |
|
652 | + 'jquery-cookie', |
|
653 | + EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
654 | + array('jquery'), |
|
655 | + '2.1', |
|
656 | + true |
|
657 | + ); |
|
658 | + //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again |
|
659 | + // via: add_filter('FHEE_load_joyride', '__return_true' ); |
|
660 | + if (apply_filters('FHEE_load_joyride', false)) { |
|
661 | + //joyride style |
|
662 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
663 | + wp_register_style( |
|
664 | + 'ee-joyride-css', |
|
665 | + EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
666 | + array('joyride-css'), |
|
667 | + EVENT_ESPRESSO_VERSION |
|
668 | + ); |
|
669 | + wp_register_script( |
|
670 | + 'joyride-modernizr', |
|
671 | + EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
672 | + array(), |
|
673 | + '2.1', |
|
674 | + true |
|
675 | + ); |
|
676 | + //joyride JS |
|
677 | + wp_register_script( |
|
678 | + 'jquery-joyride', |
|
679 | + EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
680 | + array('jquery-cookie', 'joyride-modernizr'), |
|
681 | + '2.1', |
|
682 | + true |
|
683 | + ); |
|
684 | + // wanna go for a joyride? |
|
685 | + wp_enqueue_style('ee-joyride-css'); |
|
686 | + wp_enqueue_script('jquery-joyride'); |
|
687 | + } |
|
688 | + } |
|
689 | + |
|
690 | + |
|
691 | + /** |
|
692 | + * display_admin_notices |
|
693 | + * |
|
694 | + * @return void |
|
695 | + */ |
|
696 | + public function display_admin_notices() |
|
697 | + { |
|
698 | + echo EE_Error::get_notices(); |
|
699 | + } |
|
700 | + |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * @param array $elements |
|
705 | + * @return array |
|
706 | + * @throws EE_Error |
|
707 | + * @throws InvalidArgumentException |
|
708 | + * @throws InvalidDataTypeException |
|
709 | + * @throws InvalidInterfaceException |
|
710 | + */ |
|
711 | + public function dashboard_glance_items($elements) |
|
712 | + { |
|
713 | + $elements = is_array($elements) ? $elements : array($elements); |
|
714 | + $events = EEM_Event::instance()->count(); |
|
715 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
716 | + array('page' => 'espresso_events'), |
|
717 | + admin_url('admin.php') |
|
718 | + ); |
|
719 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
720 | + $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
721 | + $registrations = EEM_Registration::instance()->count( |
|
722 | + array( |
|
723 | + array( |
|
724 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
725 | + ), |
|
726 | + ) |
|
727 | + ); |
|
728 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
729 | + array('page' => 'espresso_registrations'), |
|
730 | + admin_url('admin.php') |
|
731 | + ); |
|
732 | + $items['registrations']['text'] = sprintf( |
|
733 | + _n('%s Registration', '%s Registrations', $registrations), |
|
734 | + number_format_i18n($registrations) |
|
735 | + ); |
|
736 | + $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
737 | + |
|
738 | + $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
739 | + |
|
740 | + foreach ($items as $type => $item_properties) { |
|
741 | + $elements[] = sprintf( |
|
742 | + '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
743 | + $item_properties['url'], |
|
744 | + $item_properties['title'], |
|
745 | + $item_properties['text'] |
|
746 | + ); |
|
747 | + } |
|
748 | + return $elements; |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + /** |
|
753 | + * check_for_invalid_datetime_formats |
|
754 | + * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
755 | + * their selected format can be parsed by PHP |
|
756 | + * |
|
757 | + * @param $value |
|
758 | + * @param $option |
|
759 | + * @throws EE_Error |
|
760 | + * @return string |
|
761 | + */ |
|
762 | + public function check_for_invalid_datetime_formats($value, $option) |
|
763 | + { |
|
764 | + // check for date_format or time_format |
|
765 | + switch ($option) { |
|
766 | + case 'date_format': |
|
767 | + $date_time_format = $value . ' ' . get_option('time_format'); |
|
768 | + break; |
|
769 | + case 'time_format': |
|
770 | + $date_time_format = get_option('date_format') . ' ' . $value; |
|
771 | + break; |
|
772 | + default: |
|
773 | + $date_time_format = false; |
|
774 | + } |
|
775 | + // do we have a date_time format to check ? |
|
776 | + if ($date_time_format) { |
|
777 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
778 | + |
|
779 | + if (is_array($error_msg)) { |
|
780 | + $msg = '<p>' |
|
781 | + . sprintf( |
|
782 | + esc_html__( |
|
783 | + 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
784 | + 'event_espresso' |
|
785 | + ), |
|
786 | + date($date_time_format), |
|
787 | + $date_time_format |
|
788 | + ) |
|
789 | + . '</p><p><ul>'; |
|
790 | + |
|
791 | + |
|
792 | + foreach ($error_msg as $error) { |
|
793 | + $msg .= '<li>' . $error . '</li>'; |
|
794 | + } |
|
795 | + |
|
796 | + $msg .= '</ul></p><p>' |
|
797 | + . sprintf( |
|
798 | + esc_html__( |
|
799 | + '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
800 | + 'event_espresso' |
|
801 | + ), |
|
802 | + '<span style="color:#D54E21;">', |
|
803 | + '</span>' |
|
804 | + ) |
|
805 | + . '</p>'; |
|
806 | + |
|
807 | + // trigger WP settings error |
|
808 | + add_settings_error( |
|
809 | + 'date_format', |
|
810 | + 'date_format', |
|
811 | + $msg |
|
812 | + ); |
|
813 | + |
|
814 | + // set format to something valid |
|
815 | + switch ($option) { |
|
816 | + case 'date_format': |
|
817 | + $value = 'F j, Y'; |
|
818 | + break; |
|
819 | + case 'time_format': |
|
820 | + $value = 'g:i a'; |
|
821 | + break; |
|
822 | + } |
|
823 | + } |
|
824 | + } |
|
825 | + return $value; |
|
826 | + } |
|
827 | + |
|
828 | + |
|
829 | + /** |
|
830 | + * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
831 | + * |
|
832 | + * @param $content |
|
833 | + * @return string |
|
834 | + */ |
|
835 | + public function its_eSpresso($content) |
|
836 | + { |
|
837 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
838 | + } |
|
839 | + |
|
840 | + |
|
841 | + /** |
|
842 | + * espresso_admin_footer |
|
843 | + * |
|
844 | + * @return string |
|
845 | + */ |
|
846 | + public function espresso_admin_footer() |
|
847 | + { |
|
848 | + return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
849 | + } |
|
850 | + |
|
851 | + |
|
852 | + /** |
|
853 | + * static method for registering ee admin page. |
|
854 | + * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
855 | + * |
|
856 | + * @since 4.3.0 |
|
857 | + * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
858 | + * @see EE_Register_Admin_Page::register() |
|
859 | + * @param $page_basename |
|
860 | + * @param $page_path |
|
861 | + * @param array $config |
|
862 | + * @return void |
|
863 | + * @throws EE_Error |
|
864 | + */ |
|
865 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) |
|
866 | + { |
|
867 | + EE_Error::doing_it_wrong( |
|
868 | + __METHOD__, |
|
869 | + sprintf( |
|
870 | + esc_html__( |
|
871 | + 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
872 | + 'event_espresso' |
|
873 | + ), |
|
874 | + $page_basename |
|
875 | + ), |
|
876 | + '4.3' |
|
877 | + ); |
|
878 | + if (class_exists('EE_Register_Admin_Page')) { |
|
879 | + $config['page_path'] = $page_path; |
|
880 | + } |
|
881 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
882 | + } |
|
883 | + |
|
884 | + |
|
885 | + /** |
|
886 | + * @deprecated 4.8.41 |
|
887 | + * @param int $post_ID |
|
888 | + * @param \WP_Post $post |
|
889 | + * @return void |
|
890 | + */ |
|
891 | + public static function parse_post_content_on_save($post_ID, $post) |
|
892 | + { |
|
893 | + EE_Error::doing_it_wrong( |
|
894 | + __METHOD__, |
|
895 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
896 | + '4.8.41' |
|
897 | + ); |
|
898 | + } |
|
899 | + |
|
900 | + |
|
901 | + /** |
|
902 | + * @deprecated 4.8.41 |
|
903 | + * @param $option |
|
904 | + * @param $old_value |
|
905 | + * @param $value |
|
906 | + * @return void |
|
907 | + */ |
|
908 | + public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
909 | + { |
|
910 | + EE_Error::doing_it_wrong( |
|
911 | + __METHOD__, |
|
912 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
913 | + '4.8.41' |
|
914 | + ); |
|
915 | + } |
|
916 | + |
|
917 | + |
|
918 | + |
|
919 | + /** |
|
920 | + * @deprecated 4.9.27 |
|
921 | + * @return void |
|
922 | + */ |
|
923 | + public function get_persistent_admin_notices() |
|
924 | + { |
|
925 | + EE_Error::doing_it_wrong( |
|
926 | + __METHOD__, |
|
927 | + sprintf( |
|
928 | + __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
929 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
930 | + ), |
|
931 | + '4.9.27' |
|
932 | + ); |
|
933 | + } |
|
934 | + |
|
935 | + |
|
936 | + |
|
937 | + /** |
|
938 | + * @deprecated 4.9.27 |
|
939 | + * @throws InvalidInterfaceException |
|
940 | + * @throws InvalidDataTypeException |
|
941 | + * @throws DomainException |
|
942 | + */ |
|
943 | + public function dismiss_ee_nag_notice_callback() |
|
944 | + { |
|
945 | + EE_Error::doing_it_wrong( |
|
946 | + __METHOD__, |
|
947 | + sprintf( |
|
948 | + __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
949 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
950 | + ), |
|
951 | + '4.9.27' |
|
952 | + ); |
|
953 | + $this->persistent_admin_notice_manager->dismissNotice(); |
|
954 | + } |
|
955 | 955 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public static function instance() |
41 | 41 | { |
42 | 42 | // check if class object is instantiated |
43 | - if (! self::$_instance instanceof EE_Admin) { |
|
43 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
44 | 44 | self::$_instance = new self(); |
45 | 45 | } |
46 | 46 | return self::$_instance; |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | */ |
101 | 101 | private function _define_all_constants() |
102 | 102 | { |
103 | - if (! defined('EE_ADMIN_URL')) { |
|
104 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
105 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
106 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
107 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
103 | + if ( ! defined('EE_ADMIN_URL')) { |
|
104 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
105 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
106 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS); |
|
107 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
108 | 108 | define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
109 | 109 | } |
110 | 110 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | // set $main_file in stone |
123 | 123 | static $main_file; |
124 | 124 | // if $main_file is not set yet |
125 | - if (! $main_file) { |
|
125 | + if ( ! $main_file) { |
|
126 | 126 | $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
127 | 127 | } |
128 | 128 | if ($plugin === $main_file) { |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
176 | 176 | { |
177 | 177 | return array( |
178 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
179 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
180 | - 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
178 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
179 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
180 | + 'support' => EE_ADMIN_PAGES.'support'.DS, |
|
181 | 181 | ); |
182 | 182 | } |
183 | 183 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
220 | 220 | } |
221 | 221 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
222 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
222 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
223 | 223 | try { |
224 | 224 | //this loads the controller for the admin pages which will setup routing etc |
225 | 225 | EE_Registry::instance()->load_core('Admin_Page_Loader'); |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | '</strong>', |
268 | 268 | '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
269 | 269 | '</a>', |
270 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
270 | + '<a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
271 | 271 | array( |
272 | 272 | 'page' => 'espresso_maintenance_settings', |
273 | 273 | 'action' => 'datetime_tools' |
274 | 274 | ), |
275 | 275 | admin_url('admin.php') |
276 | - ) . '">' |
|
276 | + ).'">' |
|
277 | 277 | ), |
278 | 278 | false, |
279 | 279 | 'manage_options', |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | public function enable_hidden_ee_nav_menu_metaboxes() |
322 | 322 | { |
323 | 323 | global $wp_meta_boxes, $pagenow; |
324 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
324 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
325 | 325 | return; |
326 | 326 | } |
327 | 327 | $user = wp_get_current_user(); |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | */ |
393 | 393 | public function modify_edit_post_link($link, $id) |
394 | 394 | { |
395 | - if (! $post = get_post($id)) { |
|
395 | + if ( ! $post = get_post($id)) { |
|
396 | 396 | return $link; |
397 | 397 | } |
398 | 398 | if ($post->post_type === 'espresso_attendees') { |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | //loop through to remove any critical pages from the array. |
620 | 620 | foreach ($critical_pages as $page_id) { |
621 | - $needle = 'value="' . $page_id . '"'; |
|
621 | + $needle = 'value="'.$page_id.'"'; |
|
622 | 622 | foreach ($split_output as $key => $haystack) { |
623 | 623 | if (strpos($haystack, $needle) !== false) { |
624 | 624 | unset($split_output[$key]); |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | // calls. |
643 | 643 | wp_enqueue_script( |
644 | 644 | 'ee-inject-wp', |
645 | - EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
645 | + EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', |
|
646 | 646 | array('jquery'), |
647 | 647 | EVENT_ESPRESSO_VERSION, |
648 | 648 | true |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | // register cookie script for future dependencies |
651 | 651 | wp_register_script( |
652 | 652 | 'jquery-cookie', |
653 | - EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
653 | + EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', |
|
654 | 654 | array('jquery'), |
655 | 655 | '2.1', |
656 | 656 | true |
@@ -659,16 +659,16 @@ discard block |
||
659 | 659 | // via: add_filter('FHEE_load_joyride', '__return_true' ); |
660 | 660 | if (apply_filters('FHEE_load_joyride', false)) { |
661 | 661 | //joyride style |
662 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
662 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
663 | 663 | wp_register_style( |
664 | 664 | 'ee-joyride-css', |
665 | - EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
665 | + EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', |
|
666 | 666 | array('joyride-css'), |
667 | 667 | EVENT_ESPRESSO_VERSION |
668 | 668 | ); |
669 | 669 | wp_register_script( |
670 | 670 | 'joyride-modernizr', |
671 | - EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
671 | + EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', |
|
672 | 672 | array(), |
673 | 673 | '2.1', |
674 | 674 | true |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | //joyride JS |
677 | 677 | wp_register_script( |
678 | 678 | 'jquery-joyride', |
679 | - EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
679 | + EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', |
|
680 | 680 | array('jquery-cookie', 'joyride-modernizr'), |
681 | 681 | '2.1', |
682 | 682 | true |
@@ -725,21 +725,21 @@ discard block |
||
725 | 725 | ), |
726 | 726 | ) |
727 | 727 | ); |
728 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
728 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
729 | 729 | array('page' => 'espresso_registrations'), |
730 | 730 | admin_url('admin.php') |
731 | 731 | ); |
732 | - $items['registrations']['text'] = sprintf( |
|
732 | + $items['registrations']['text'] = sprintf( |
|
733 | 733 | _n('%s Registration', '%s Registrations', $registrations), |
734 | 734 | number_format_i18n($registrations) |
735 | 735 | ); |
736 | 736 | $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
737 | 737 | |
738 | - $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
738 | + $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
739 | 739 | |
740 | 740 | foreach ($items as $type => $item_properties) { |
741 | 741 | $elements[] = sprintf( |
742 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
742 | + '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', |
|
743 | 743 | $item_properties['url'], |
744 | 744 | $item_properties['title'], |
745 | 745 | $item_properties['text'] |
@@ -764,10 +764,10 @@ discard block |
||
764 | 764 | // check for date_format or time_format |
765 | 765 | switch ($option) { |
766 | 766 | case 'date_format': |
767 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
767 | + $date_time_format = $value.' '.get_option('time_format'); |
|
768 | 768 | break; |
769 | 769 | case 'time_format': |
770 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
770 | + $date_time_format = get_option('date_format').' '.$value; |
|
771 | 771 | break; |
772 | 772 | default: |
773 | 773 | $date_time_format = false; |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | |
791 | 791 | |
792 | 792 | foreach ($error_msg as $error) { |
793 | - $msg .= '<li>' . $error . '</li>'; |
|
793 | + $msg .= '<li>'.$error.'</li>'; |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | $msg .= '</ul></p><p>' |