@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | public function set_settings($settings_array) |
188 | 188 | { |
189 | 189 | foreach ($settings_array as $name => $value) { |
190 | - $property_name = "_" . $name; |
|
190 | + $property_name = "_".$name; |
|
191 | 191 | $this->{$property_name} = $value; |
192 | 192 | } |
193 | 193 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) |
253 | 253 | { |
254 | - if (! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
254 | + if ( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
255 | 255 | throw new InvalidEntityException( |
256 | 256 | is_object($gateway_data_formatter) |
257 | 257 | ? get_class($gateway_data_formatter) |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | */ |
271 | 271 | protected function _get_gateway_formatter() |
272 | 272 | { |
273 | - if (! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
273 | + if ( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
274 | 274 | throw new InvalidEntityException( |
275 | 275 | is_object($this->_gateway_data_formatter) |
276 | 276 | ? get_class($this->_gateway_data_formatter) |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function set_unsupported_character_remover(FormatterInterface $formatter) |
293 | 293 | { |
294 | - if (! $formatter instanceof FormatterInterface) { |
|
294 | + if ( ! $formatter instanceof FormatterInterface) { |
|
295 | 295 | throw new InvalidEntityException( |
296 | 296 | is_object($formatter) |
297 | 297 | ? get_class($formatter) |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | protected function _get_unsupported_character_remover() |
312 | 312 | { |
313 | - if (! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
313 | + if ( ! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
314 | 314 | throw new InvalidEntityException( |
315 | 315 | is_object($this->_unsupported_character_remover) |
316 | 316 | ? get_class($this->_unsupported_character_remover) |
@@ -23,492 +23,492 @@ |
||
23 | 23 | */ |
24 | 24 | abstract class EE_Gateway |
25 | 25 | { |
26 | - /** |
|
27 | - * a constant used as a possible value for $_currencies_supported to indicate |
|
28 | - * that ALL currencies are supported by this gateway |
|
29 | - */ |
|
30 | - const all_currencies_supported = 'all_currencies_supported'; |
|
31 | - /** |
|
32 | - * Where values are 3-letter currency codes |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - protected $_currencies_supported = array(); |
|
37 | - /** |
|
38 | - * Whether or not this gateway can support SENDING a refund request (ie, initiated by |
|
39 | - * admin in EE's wp-admin page) |
|
40 | - * |
|
41 | - * @var boolean |
|
42 | - */ |
|
43 | - protected $_supports_sending_refunds = false; |
|
44 | - |
|
45 | - /** |
|
46 | - * Whether or not this gateway can support RECEIVING a refund request from the payment |
|
47 | - * provider (ie, initiated by admin on the payment prover's website who sends an IPN to EE) |
|
48 | - * |
|
49 | - * @var boolean |
|
50 | - */ |
|
51 | - protected $_supports_receiving_refunds = false; |
|
52 | - /** |
|
53 | - * Model for querying for existing payments |
|
54 | - * |
|
55 | - * @var EEMI_Payment |
|
56 | - */ |
|
57 | - protected $_pay_model; |
|
58 | - |
|
59 | - /** |
|
60 | - * Model used for adding to the payments log |
|
61 | - * |
|
62 | - * @var EEMI_Payment_Log |
|
63 | - */ |
|
64 | - protected $_pay_log; |
|
65 | - |
|
66 | - /** |
|
67 | - * Used for formatting some input to gateways |
|
68 | - * |
|
69 | - * @var EEHI_Template |
|
70 | - */ |
|
71 | - protected $_template; |
|
72 | - |
|
73 | - /** |
|
74 | - * Concrete class that implements EEHI_Money, used by most gateways |
|
75 | - * |
|
76 | - * @var EEHI_Money |
|
77 | - */ |
|
78 | - protected $_money; |
|
79 | - |
|
80 | - /** |
|
81 | - * Concrete class that implements EEHI_Line_Item, used for manipulating the line item tree |
|
82 | - * |
|
83 | - * @var EEHI_Line_Item |
|
84 | - */ |
|
85 | - protected $_line_item; |
|
86 | - |
|
87 | - /** |
|
88 | - * @var GatewayDataFormatterInterface |
|
89 | - */ |
|
90 | - protected $_gateway_data_formatter; |
|
91 | - |
|
92 | - /** |
|
93 | - * @var FormatterInterface |
|
94 | - */ |
|
95 | - protected $_unsupported_character_remover; |
|
96 | - |
|
97 | - /** |
|
98 | - * The ID of the payment method using this gateway |
|
99 | - * |
|
100 | - * @var int |
|
101 | - */ |
|
102 | - protected $_ID; |
|
103 | - |
|
104 | - /** |
|
105 | - * @var $_debug_mode boolean whether to send requests to teh sandbox site or not |
|
106 | - */ |
|
107 | - protected $_debug_mode; |
|
108 | - /** |
|
109 | - * |
|
110 | - * @var string $_name name to show for this payment method |
|
111 | - */ |
|
112 | - protected $_name; |
|
113 | - /** |
|
114 | - * |
|
115 | - * @var string name to show fir this payment method to admin-type users |
|
116 | - */ |
|
117 | - protected $_admin_name; |
|
118 | - |
|
119 | - /** |
|
120 | - * @return EE_Gateway |
|
121 | - */ |
|
122 | - public function __construct() |
|
123 | - { |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * We don't want to serialize models as they often have circular structures |
|
128 | - * (eg a payment model has a reference to each payment model object; and most |
|
129 | - * payments have a transaction, most transactions have a payment method; |
|
130 | - * most payment methods have a payment method type; most payment method types |
|
131 | - * have a gateway. And if a gateway serializes its models, we start at the |
|
132 | - * beginning again) |
|
133 | - * |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - public function __sleep() |
|
137 | - { |
|
138 | - $properties = get_object_vars($this); |
|
139 | - unset($properties['_pay_model'], $properties['_pay_log']); |
|
140 | - return array_keys($properties); |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Returns whether or not this gateway should support SENDING refunds |
|
145 | - * see $_supports_sending_refunds |
|
146 | - * |
|
147 | - * @return boolean |
|
148 | - */ |
|
149 | - public function supports_sending_refunds() |
|
150 | - { |
|
151 | - return $this->_supports_sending_refunds; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Returns whether or not this gateway should support RECEIVING refunds |
|
156 | - * see $_supports_receiving_refunds |
|
157 | - * |
|
158 | - * @return boolean |
|
159 | - */ |
|
160 | - public function supports_receiving_refunds() |
|
161 | - { |
|
162 | - return $this->_supports_receiving_refunds; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * Tries to refund the payment specified, taking into account the extra |
|
168 | - * refund info. Note that if the gateway's _supports_sending_refunds is false, |
|
169 | - * this should just throw an exception. |
|
170 | - * |
|
171 | - * @param EE_Payment $payment |
|
172 | - * @param array $refund_info |
|
173 | - * @return EE_Payment for the refund |
|
174 | - * @throws EE_Error |
|
175 | - */ |
|
176 | - public function do_direct_refund(EE_Payment $payment, $refund_info = null) |
|
177 | - { |
|
178 | - return null; |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * Sets the payment method's settings so the gateway knows where to send the request |
|
184 | - * etc |
|
185 | - * |
|
186 | - * @param array $settings_array |
|
187 | - */ |
|
188 | - public function set_settings($settings_array) |
|
189 | - { |
|
190 | - foreach ($settings_array as $name => $value) { |
|
191 | - $property_name = "_" . $name; |
|
192 | - $this->{$property_name} = $value; |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * See this class description |
|
198 | - * |
|
199 | - * @param EEMI_Payment $payment_model |
|
200 | - */ |
|
201 | - public function set_payment_model($payment_model) |
|
202 | - { |
|
203 | - $this->_pay_model = $payment_model; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * See this class description |
|
208 | - * |
|
209 | - * @param EEMI_Payment_Log $payment_log_model |
|
210 | - */ |
|
211 | - public function set_payment_log($payment_log_model) |
|
212 | - { |
|
213 | - $this->_pay_log = $payment_log_model; |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * See this class description |
|
218 | - * |
|
219 | - * @param EEHI_Template $template_helper |
|
220 | - */ |
|
221 | - public function set_template_helper($template_helper) |
|
222 | - { |
|
223 | - $this->_template = $template_helper; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * See this class description |
|
228 | - * |
|
229 | - * @param EEHI_Line_Item $line_item_helper |
|
230 | - */ |
|
231 | - public function set_line_item_helper($line_item_helper) |
|
232 | - { |
|
233 | - $this->_line_item = $line_item_helper; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * See this class description |
|
238 | - * |
|
239 | - * @param EEHI_Money $money_helper |
|
240 | - */ |
|
241 | - public function set_money_helper($money_helper) |
|
242 | - { |
|
243 | - $this->_money = $money_helper; |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * Sets the gateway data formatter helper |
|
249 | - * |
|
250 | - * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
251 | - * @throws InvalidEntityException if it's not set properly |
|
252 | - */ |
|
253 | - public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) |
|
254 | - { |
|
255 | - if (! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
256 | - throw new InvalidEntityException( |
|
257 | - is_object($gateway_data_formatter) |
|
258 | - ? get_class($gateway_data_formatter) |
|
259 | - : esc_html__('Not an object', 'event_espresso'), |
|
260 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
261 | - ); |
|
262 | - } |
|
263 | - $this->_gateway_data_formatter = $gateway_data_formatter; |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * Gets the gateway data formatter |
|
268 | - * |
|
269 | - * @return GatewayDataFormatterInterface |
|
270 | - * @throws InvalidEntityException if it's not set properly |
|
271 | - */ |
|
272 | - protected function _get_gateway_formatter() |
|
273 | - { |
|
274 | - if (! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
275 | - throw new InvalidEntityException( |
|
276 | - is_object($this->_gateway_data_formatter) |
|
277 | - ? get_class($this->_gateway_data_formatter) |
|
278 | - : esc_html__('Not an object', 'event_espresso'), |
|
279 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
280 | - ); |
|
281 | - } |
|
282 | - return $this->_gateway_data_formatter; |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * Sets the helper which will remove unsupported characters for most gateways |
|
288 | - * |
|
289 | - * @param FormatterInterface $formatter |
|
290 | - * @return FormatterInterface |
|
291 | - * @throws InvalidEntityException |
|
292 | - */ |
|
293 | - public function set_unsupported_character_remover(FormatterInterface $formatter) |
|
294 | - { |
|
295 | - if (! $formatter instanceof FormatterInterface) { |
|
296 | - throw new InvalidEntityException( |
|
297 | - is_object($formatter) |
|
298 | - ? get_class($formatter) |
|
299 | - : esc_html__('Not an object', 'event_espresso'), |
|
300 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
301 | - ); |
|
302 | - } |
|
303 | - $this->_unsupported_character_remover = $formatter; |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
308 | - * |
|
309 | - * @return FormatterInterface |
|
310 | - * @throws InvalidEntityException |
|
311 | - */ |
|
312 | - protected function _get_unsupported_character_remover() |
|
313 | - { |
|
314 | - if (! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
315 | - throw new InvalidEntityException( |
|
316 | - is_object($this->_unsupported_character_remover) |
|
317 | - ? get_class($this->_unsupported_character_remover) |
|
318 | - : esc_html__('Not an object', 'event_espresso'), |
|
319 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
320 | - ); |
|
321 | - } |
|
322 | - return $this->_unsupported_character_remover; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @param $message |
|
328 | - * @param $payment |
|
329 | - */ |
|
330 | - public function log($message, $payment) |
|
331 | - { |
|
332 | - if ($payment instanceof EEI_Payment) { |
|
333 | - $type = 'Payment'; |
|
334 | - $id = $payment->ID(); |
|
335 | - } else { |
|
336 | - $type = 'Payment_Method'; |
|
337 | - $id = $this->_ID; |
|
338 | - } |
|
339 | - // only log if we're going to store it for longer than the minimum time |
|
340 | - $admin_config = LoaderFactory::getLoader()->load('EE_Admin_Config'); |
|
341 | - if ($admin_config->gateway_log_lifespan !== '1 second') { |
|
342 | - $this->_pay_log->gateway_log($message, $id, $type); |
|
343 | - } |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Formats the amount so it can generally be sent to gateways |
|
348 | - * |
|
349 | - * @param float $amount |
|
350 | - * @return string |
|
351 | - * @deprecated since 4.9.31 insetad use |
|
352 | - * EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
353 | - */ |
|
354 | - public function format_currency($amount) |
|
355 | - { |
|
356 | - return $this->_get_gateway_formatter()->formatCurrency($amount); |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Returns either an array of all the currency codes supported, |
|
361 | - * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
|
362 | - * |
|
363 | - * @return mixed array or string |
|
364 | - */ |
|
365 | - public function currencies_supported() |
|
366 | - { |
|
367 | - return $this->_currencies_supported; |
|
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * Returns what a simple summing of items and taxes for this transaction. This |
|
372 | - * can be used to determine if some more complex line items, like promotions, |
|
373 | - * surcharges, or cancellations occurred (in which case we might want to forget |
|
374 | - * about creating an itemized list of purchases and instead only send the total due) |
|
375 | - * |
|
376 | - * @param EE_Transaction $transaction |
|
377 | - * @return float |
|
378 | - */ |
|
379 | - protected function _sum_items_and_taxes(EE_Transaction $transaction) |
|
380 | - { |
|
381 | - $total_line_item = $transaction->total_line_item(); |
|
382 | - $total = 0; |
|
383 | - foreach ($total_line_item->get_items() as $item_line_item) { |
|
384 | - $total += max($item_line_item->total(), 0); |
|
385 | - } |
|
386 | - foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
387 | - $total += max($tax_line_item->total(), 0); |
|
388 | - } |
|
389 | - return $total; |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * Determines whether or not we can easily itemize the transaction using only |
|
394 | - * items and taxes (ie, no promotions or surcharges or cancellations needed) |
|
395 | - * |
|
396 | - * @param EEI_Payment $payment |
|
397 | - * @return boolean |
|
398 | - */ |
|
399 | - protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) |
|
400 | - { |
|
401 | - return $this->_money->compare_floats( |
|
402 | - $this->_sum_items_and_taxes($payment->transaction()), |
|
403 | - $payment->transaction()->total() |
|
404 | - ) |
|
405 | - && $this->_money->compare_floats( |
|
406 | - $payment->amount(), |
|
407 | - $payment->transaction()->total() |
|
408 | - ); |
|
409 | - } |
|
410 | - |
|
411 | - /** |
|
412 | - * Handles updating the transaction and any other related data based on the payment. |
|
413 | - * You may be tempted to do this as part of do_direct_payment or handle_payment_update, |
|
414 | - * but doing so on those functions might be too early. It's possible that the changes |
|
415 | - * you make to teh transaction or registration or line items may just get overwritten |
|
416 | - * at that point. Instead, you should store any info you need on the payment during those |
|
417 | - * functions, and use that information at this step, which client code will decide |
|
418 | - * for you when it should be called. |
|
419 | - * |
|
420 | - * @param EE_Payment $payment |
|
421 | - * @return void |
|
422 | - */ |
|
423 | - public function update_txn_based_on_payment($payment) |
|
424 | - { |
|
425 | - // maybe update the transaction or line items or registrations |
|
426 | - // but most gateways don't need to do this, because they only update the payment |
|
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * Gets the first event for this payment (it's possible that it could be for multiple) |
|
431 | - * |
|
432 | - * @param EEI_Payment $payment |
|
433 | - * @return EEI_Event|null |
|
434 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
435 | - */ |
|
436 | - protected function _get_first_event_for_payment(EEI_Payment $payment) |
|
437 | - { |
|
438 | - return $payment->get_first_event(); |
|
439 | - } |
|
440 | - |
|
441 | - /** |
|
442 | - * Gets the name of the first event for which is being paid |
|
443 | - * |
|
444 | - * @param EEI_Payment $payment |
|
445 | - * @return string |
|
446 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
447 | - */ |
|
448 | - protected function _get_first_event_name_for_payment(EEI_Payment $payment) |
|
449 | - { |
|
450 | - return $payment->get_first_event_name(); |
|
451 | - } |
|
452 | - |
|
453 | - /** |
|
454 | - * Gets the text to use for a gateway's line item name when this is a partial payment |
|
455 | - * |
|
456 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
457 | - * @param EE_Payment $payment |
|
458 | - * @return string |
|
459 | - */ |
|
460 | - protected function _format_partial_payment_line_item_name(EEI_Payment $payment) |
|
461 | - { |
|
462 | - return $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment); |
|
463 | - } |
|
464 | - |
|
465 | - /** |
|
466 | - * Gets the text to use for a gateway's line item description when this is a partial payment |
|
467 | - * |
|
468 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
469 | - * @param EEI_Payment $payment |
|
470 | - * @return string |
|
471 | - */ |
|
472 | - protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) |
|
473 | - { |
|
474 | - return $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc($payment); |
|
475 | - } |
|
476 | - |
|
477 | - /** |
|
478 | - * Gets the name to use for a line item when sending line items to the gateway |
|
479 | - * |
|
480 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
481 | - * @param EEI_Line_Item $line_item |
|
482 | - * @param EEI_Payment $payment |
|
483 | - * @return string |
|
484 | - */ |
|
485 | - protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
486 | - { |
|
487 | - return $this->_get_gateway_formatter()->formatLineItemName($line_item, $payment); |
|
488 | - } |
|
489 | - |
|
490 | - /** |
|
491 | - * Gets the description to use for a line item when sending line items to the gateway |
|
492 | - * |
|
493 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
494 | - * @param EEI_Line_Item $line_item |
|
495 | - * @param EEI_Payment $payment |
|
496 | - * @return string |
|
497 | - */ |
|
498 | - protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
499 | - { |
|
500 | - return $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment); |
|
501 | - } |
|
502 | - |
|
503 | - /** |
|
504 | - * Gets the order description that should generlly be sent to gateways |
|
505 | - * |
|
506 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
507 | - * @param EEI_Payment $payment |
|
508 | - * @return type |
|
509 | - */ |
|
510 | - protected function _format_order_description(EEI_Payment $payment) |
|
511 | - { |
|
512 | - return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
|
513 | - } |
|
26 | + /** |
|
27 | + * a constant used as a possible value for $_currencies_supported to indicate |
|
28 | + * that ALL currencies are supported by this gateway |
|
29 | + */ |
|
30 | + const all_currencies_supported = 'all_currencies_supported'; |
|
31 | + /** |
|
32 | + * Where values are 3-letter currency codes |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + protected $_currencies_supported = array(); |
|
37 | + /** |
|
38 | + * Whether or not this gateway can support SENDING a refund request (ie, initiated by |
|
39 | + * admin in EE's wp-admin page) |
|
40 | + * |
|
41 | + * @var boolean |
|
42 | + */ |
|
43 | + protected $_supports_sending_refunds = false; |
|
44 | + |
|
45 | + /** |
|
46 | + * Whether or not this gateway can support RECEIVING a refund request from the payment |
|
47 | + * provider (ie, initiated by admin on the payment prover's website who sends an IPN to EE) |
|
48 | + * |
|
49 | + * @var boolean |
|
50 | + */ |
|
51 | + protected $_supports_receiving_refunds = false; |
|
52 | + /** |
|
53 | + * Model for querying for existing payments |
|
54 | + * |
|
55 | + * @var EEMI_Payment |
|
56 | + */ |
|
57 | + protected $_pay_model; |
|
58 | + |
|
59 | + /** |
|
60 | + * Model used for adding to the payments log |
|
61 | + * |
|
62 | + * @var EEMI_Payment_Log |
|
63 | + */ |
|
64 | + protected $_pay_log; |
|
65 | + |
|
66 | + /** |
|
67 | + * Used for formatting some input to gateways |
|
68 | + * |
|
69 | + * @var EEHI_Template |
|
70 | + */ |
|
71 | + protected $_template; |
|
72 | + |
|
73 | + /** |
|
74 | + * Concrete class that implements EEHI_Money, used by most gateways |
|
75 | + * |
|
76 | + * @var EEHI_Money |
|
77 | + */ |
|
78 | + protected $_money; |
|
79 | + |
|
80 | + /** |
|
81 | + * Concrete class that implements EEHI_Line_Item, used for manipulating the line item tree |
|
82 | + * |
|
83 | + * @var EEHI_Line_Item |
|
84 | + */ |
|
85 | + protected $_line_item; |
|
86 | + |
|
87 | + /** |
|
88 | + * @var GatewayDataFormatterInterface |
|
89 | + */ |
|
90 | + protected $_gateway_data_formatter; |
|
91 | + |
|
92 | + /** |
|
93 | + * @var FormatterInterface |
|
94 | + */ |
|
95 | + protected $_unsupported_character_remover; |
|
96 | + |
|
97 | + /** |
|
98 | + * The ID of the payment method using this gateway |
|
99 | + * |
|
100 | + * @var int |
|
101 | + */ |
|
102 | + protected $_ID; |
|
103 | + |
|
104 | + /** |
|
105 | + * @var $_debug_mode boolean whether to send requests to teh sandbox site or not |
|
106 | + */ |
|
107 | + protected $_debug_mode; |
|
108 | + /** |
|
109 | + * |
|
110 | + * @var string $_name name to show for this payment method |
|
111 | + */ |
|
112 | + protected $_name; |
|
113 | + /** |
|
114 | + * |
|
115 | + * @var string name to show fir this payment method to admin-type users |
|
116 | + */ |
|
117 | + protected $_admin_name; |
|
118 | + |
|
119 | + /** |
|
120 | + * @return EE_Gateway |
|
121 | + */ |
|
122 | + public function __construct() |
|
123 | + { |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * We don't want to serialize models as they often have circular structures |
|
128 | + * (eg a payment model has a reference to each payment model object; and most |
|
129 | + * payments have a transaction, most transactions have a payment method; |
|
130 | + * most payment methods have a payment method type; most payment method types |
|
131 | + * have a gateway. And if a gateway serializes its models, we start at the |
|
132 | + * beginning again) |
|
133 | + * |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + public function __sleep() |
|
137 | + { |
|
138 | + $properties = get_object_vars($this); |
|
139 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
140 | + return array_keys($properties); |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Returns whether or not this gateway should support SENDING refunds |
|
145 | + * see $_supports_sending_refunds |
|
146 | + * |
|
147 | + * @return boolean |
|
148 | + */ |
|
149 | + public function supports_sending_refunds() |
|
150 | + { |
|
151 | + return $this->_supports_sending_refunds; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Returns whether or not this gateway should support RECEIVING refunds |
|
156 | + * see $_supports_receiving_refunds |
|
157 | + * |
|
158 | + * @return boolean |
|
159 | + */ |
|
160 | + public function supports_receiving_refunds() |
|
161 | + { |
|
162 | + return $this->_supports_receiving_refunds; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * Tries to refund the payment specified, taking into account the extra |
|
168 | + * refund info. Note that if the gateway's _supports_sending_refunds is false, |
|
169 | + * this should just throw an exception. |
|
170 | + * |
|
171 | + * @param EE_Payment $payment |
|
172 | + * @param array $refund_info |
|
173 | + * @return EE_Payment for the refund |
|
174 | + * @throws EE_Error |
|
175 | + */ |
|
176 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) |
|
177 | + { |
|
178 | + return null; |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * Sets the payment method's settings so the gateway knows where to send the request |
|
184 | + * etc |
|
185 | + * |
|
186 | + * @param array $settings_array |
|
187 | + */ |
|
188 | + public function set_settings($settings_array) |
|
189 | + { |
|
190 | + foreach ($settings_array as $name => $value) { |
|
191 | + $property_name = "_" . $name; |
|
192 | + $this->{$property_name} = $value; |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * See this class description |
|
198 | + * |
|
199 | + * @param EEMI_Payment $payment_model |
|
200 | + */ |
|
201 | + public function set_payment_model($payment_model) |
|
202 | + { |
|
203 | + $this->_pay_model = $payment_model; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * See this class description |
|
208 | + * |
|
209 | + * @param EEMI_Payment_Log $payment_log_model |
|
210 | + */ |
|
211 | + public function set_payment_log($payment_log_model) |
|
212 | + { |
|
213 | + $this->_pay_log = $payment_log_model; |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * See this class description |
|
218 | + * |
|
219 | + * @param EEHI_Template $template_helper |
|
220 | + */ |
|
221 | + public function set_template_helper($template_helper) |
|
222 | + { |
|
223 | + $this->_template = $template_helper; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * See this class description |
|
228 | + * |
|
229 | + * @param EEHI_Line_Item $line_item_helper |
|
230 | + */ |
|
231 | + public function set_line_item_helper($line_item_helper) |
|
232 | + { |
|
233 | + $this->_line_item = $line_item_helper; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * See this class description |
|
238 | + * |
|
239 | + * @param EEHI_Money $money_helper |
|
240 | + */ |
|
241 | + public function set_money_helper($money_helper) |
|
242 | + { |
|
243 | + $this->_money = $money_helper; |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * Sets the gateway data formatter helper |
|
249 | + * |
|
250 | + * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
251 | + * @throws InvalidEntityException if it's not set properly |
|
252 | + */ |
|
253 | + public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) |
|
254 | + { |
|
255 | + if (! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
256 | + throw new InvalidEntityException( |
|
257 | + is_object($gateway_data_formatter) |
|
258 | + ? get_class($gateway_data_formatter) |
|
259 | + : esc_html__('Not an object', 'event_espresso'), |
|
260 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
261 | + ); |
|
262 | + } |
|
263 | + $this->_gateway_data_formatter = $gateway_data_formatter; |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * Gets the gateway data formatter |
|
268 | + * |
|
269 | + * @return GatewayDataFormatterInterface |
|
270 | + * @throws InvalidEntityException if it's not set properly |
|
271 | + */ |
|
272 | + protected function _get_gateway_formatter() |
|
273 | + { |
|
274 | + if (! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
275 | + throw new InvalidEntityException( |
|
276 | + is_object($this->_gateway_data_formatter) |
|
277 | + ? get_class($this->_gateway_data_formatter) |
|
278 | + : esc_html__('Not an object', 'event_espresso'), |
|
279 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
280 | + ); |
|
281 | + } |
|
282 | + return $this->_gateway_data_formatter; |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * Sets the helper which will remove unsupported characters for most gateways |
|
288 | + * |
|
289 | + * @param FormatterInterface $formatter |
|
290 | + * @return FormatterInterface |
|
291 | + * @throws InvalidEntityException |
|
292 | + */ |
|
293 | + public function set_unsupported_character_remover(FormatterInterface $formatter) |
|
294 | + { |
|
295 | + if (! $formatter instanceof FormatterInterface) { |
|
296 | + throw new InvalidEntityException( |
|
297 | + is_object($formatter) |
|
298 | + ? get_class($formatter) |
|
299 | + : esc_html__('Not an object', 'event_espresso'), |
|
300 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
301 | + ); |
|
302 | + } |
|
303 | + $this->_unsupported_character_remover = $formatter; |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
308 | + * |
|
309 | + * @return FormatterInterface |
|
310 | + * @throws InvalidEntityException |
|
311 | + */ |
|
312 | + protected function _get_unsupported_character_remover() |
|
313 | + { |
|
314 | + if (! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
315 | + throw new InvalidEntityException( |
|
316 | + is_object($this->_unsupported_character_remover) |
|
317 | + ? get_class($this->_unsupported_character_remover) |
|
318 | + : esc_html__('Not an object', 'event_espresso'), |
|
319 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
320 | + ); |
|
321 | + } |
|
322 | + return $this->_unsupported_character_remover; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @param $message |
|
328 | + * @param $payment |
|
329 | + */ |
|
330 | + public function log($message, $payment) |
|
331 | + { |
|
332 | + if ($payment instanceof EEI_Payment) { |
|
333 | + $type = 'Payment'; |
|
334 | + $id = $payment->ID(); |
|
335 | + } else { |
|
336 | + $type = 'Payment_Method'; |
|
337 | + $id = $this->_ID; |
|
338 | + } |
|
339 | + // only log if we're going to store it for longer than the minimum time |
|
340 | + $admin_config = LoaderFactory::getLoader()->load('EE_Admin_Config'); |
|
341 | + if ($admin_config->gateway_log_lifespan !== '1 second') { |
|
342 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
343 | + } |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Formats the amount so it can generally be sent to gateways |
|
348 | + * |
|
349 | + * @param float $amount |
|
350 | + * @return string |
|
351 | + * @deprecated since 4.9.31 insetad use |
|
352 | + * EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
353 | + */ |
|
354 | + public function format_currency($amount) |
|
355 | + { |
|
356 | + return $this->_get_gateway_formatter()->formatCurrency($amount); |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Returns either an array of all the currency codes supported, |
|
361 | + * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
|
362 | + * |
|
363 | + * @return mixed array or string |
|
364 | + */ |
|
365 | + public function currencies_supported() |
|
366 | + { |
|
367 | + return $this->_currencies_supported; |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * Returns what a simple summing of items and taxes for this transaction. This |
|
372 | + * can be used to determine if some more complex line items, like promotions, |
|
373 | + * surcharges, or cancellations occurred (in which case we might want to forget |
|
374 | + * about creating an itemized list of purchases and instead only send the total due) |
|
375 | + * |
|
376 | + * @param EE_Transaction $transaction |
|
377 | + * @return float |
|
378 | + */ |
|
379 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) |
|
380 | + { |
|
381 | + $total_line_item = $transaction->total_line_item(); |
|
382 | + $total = 0; |
|
383 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
384 | + $total += max($item_line_item->total(), 0); |
|
385 | + } |
|
386 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
387 | + $total += max($tax_line_item->total(), 0); |
|
388 | + } |
|
389 | + return $total; |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * Determines whether or not we can easily itemize the transaction using only |
|
394 | + * items and taxes (ie, no promotions or surcharges or cancellations needed) |
|
395 | + * |
|
396 | + * @param EEI_Payment $payment |
|
397 | + * @return boolean |
|
398 | + */ |
|
399 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) |
|
400 | + { |
|
401 | + return $this->_money->compare_floats( |
|
402 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
403 | + $payment->transaction()->total() |
|
404 | + ) |
|
405 | + && $this->_money->compare_floats( |
|
406 | + $payment->amount(), |
|
407 | + $payment->transaction()->total() |
|
408 | + ); |
|
409 | + } |
|
410 | + |
|
411 | + /** |
|
412 | + * Handles updating the transaction and any other related data based on the payment. |
|
413 | + * You may be tempted to do this as part of do_direct_payment or handle_payment_update, |
|
414 | + * but doing so on those functions might be too early. It's possible that the changes |
|
415 | + * you make to teh transaction or registration or line items may just get overwritten |
|
416 | + * at that point. Instead, you should store any info you need on the payment during those |
|
417 | + * functions, and use that information at this step, which client code will decide |
|
418 | + * for you when it should be called. |
|
419 | + * |
|
420 | + * @param EE_Payment $payment |
|
421 | + * @return void |
|
422 | + */ |
|
423 | + public function update_txn_based_on_payment($payment) |
|
424 | + { |
|
425 | + // maybe update the transaction or line items or registrations |
|
426 | + // but most gateways don't need to do this, because they only update the payment |
|
427 | + } |
|
428 | + |
|
429 | + /** |
|
430 | + * Gets the first event for this payment (it's possible that it could be for multiple) |
|
431 | + * |
|
432 | + * @param EEI_Payment $payment |
|
433 | + * @return EEI_Event|null |
|
434 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
435 | + */ |
|
436 | + protected function _get_first_event_for_payment(EEI_Payment $payment) |
|
437 | + { |
|
438 | + return $payment->get_first_event(); |
|
439 | + } |
|
440 | + |
|
441 | + /** |
|
442 | + * Gets the name of the first event for which is being paid |
|
443 | + * |
|
444 | + * @param EEI_Payment $payment |
|
445 | + * @return string |
|
446 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
447 | + */ |
|
448 | + protected function _get_first_event_name_for_payment(EEI_Payment $payment) |
|
449 | + { |
|
450 | + return $payment->get_first_event_name(); |
|
451 | + } |
|
452 | + |
|
453 | + /** |
|
454 | + * Gets the text to use for a gateway's line item name when this is a partial payment |
|
455 | + * |
|
456 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
457 | + * @param EE_Payment $payment |
|
458 | + * @return string |
|
459 | + */ |
|
460 | + protected function _format_partial_payment_line_item_name(EEI_Payment $payment) |
|
461 | + { |
|
462 | + return $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment); |
|
463 | + } |
|
464 | + |
|
465 | + /** |
|
466 | + * Gets the text to use for a gateway's line item description when this is a partial payment |
|
467 | + * |
|
468 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
469 | + * @param EEI_Payment $payment |
|
470 | + * @return string |
|
471 | + */ |
|
472 | + protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) |
|
473 | + { |
|
474 | + return $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc($payment); |
|
475 | + } |
|
476 | + |
|
477 | + /** |
|
478 | + * Gets the name to use for a line item when sending line items to the gateway |
|
479 | + * |
|
480 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
481 | + * @param EEI_Line_Item $line_item |
|
482 | + * @param EEI_Payment $payment |
|
483 | + * @return string |
|
484 | + */ |
|
485 | + protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
486 | + { |
|
487 | + return $this->_get_gateway_formatter()->formatLineItemName($line_item, $payment); |
|
488 | + } |
|
489 | + |
|
490 | + /** |
|
491 | + * Gets the description to use for a line item when sending line items to the gateway |
|
492 | + * |
|
493 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
494 | + * @param EEI_Line_Item $line_item |
|
495 | + * @param EEI_Payment $payment |
|
496 | + * @return string |
|
497 | + */ |
|
498 | + protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) |
|
499 | + { |
|
500 | + return $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment); |
|
501 | + } |
|
502 | + |
|
503 | + /** |
|
504 | + * Gets the order description that should generlly be sent to gateways |
|
505 | + * |
|
506 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
507 | + * @param EEI_Payment $payment |
|
508 | + * @return type |
|
509 | + */ |
|
510 | + protected function _format_order_description(EEI_Payment $payment) |
|
511 | + { |
|
512 | + return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
|
513 | + } |
|
514 | 514 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | public static function instance() |
147 | 147 | { |
148 | 148 | // check if class object is instantiated, and instantiated properly |
149 | - if (! self::$_instance instanceof EE_Config) { |
|
149 | + if ( ! self::$_instance instanceof EE_Config) { |
|
150 | 150 | self::$_instance = new self(); |
151 | 151 | } |
152 | 152 | return self::$_instance; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $this |
285 | 285 | ); |
286 | 286 | if (is_object($settings) && property_exists($this, $config)) { |
287 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
287 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
288 | 288 | // call configs populate method to ensure any defaults are set for empty values. |
289 | 289 | if (method_exists($settings, 'populate')) { |
290 | 290 | $this->{$config}->populate(); |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | break; |
558 | 558 | // TEST #2 : check that settings section exists |
559 | 559 | case 2: |
560 | - if (! isset($this->{$section})) { |
|
560 | + if ( ! isset($this->{$section})) { |
|
561 | 561 | if ($display_errors) { |
562 | 562 | throw new EE_Error( |
563 | 563 | sprintf( |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | break; |
572 | 572 | // TEST #3 : check that section is the proper format |
573 | 573 | case 3: |
574 | - if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
574 | + if ( ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
575 | 575 | ) { |
576 | 576 | if ($display_errors) { |
577 | 577 | throw new EE_Error( |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | break; |
618 | 618 | // TEST #6 : verify config class is accessible |
619 | 619 | case 6: |
620 | - if (! class_exists($config_class)) { |
|
620 | + if ( ! class_exists($config_class)) { |
|
621 | 621 | if ($display_errors) { |
622 | 622 | throw new EE_Error( |
623 | 623 | sprintf( |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | break; |
635 | 635 | // TEST #7 : check that config has even been set |
636 | 636 | case 7: |
637 | - if (! isset($this->{$section}->{$name})) { |
|
637 | + if ( ! isset($this->{$section}->{$name})) { |
|
638 | 638 | if ($display_errors) { |
639 | 639 | throw new EE_Error( |
640 | 640 | sprintf( |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | break; |
653 | 653 | // TEST #8 : check that config is the requested type |
654 | 654 | case 8: |
655 | - if (! $this->{$section}->{$name} instanceof $config_class) { |
|
655 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
656 | 656 | if ($display_errors) { |
657 | 657 | throw new EE_Error( |
658 | 658 | sprintf( |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | break; |
672 | 672 | // TEST #9 : verify config object |
673 | 673 | case 9: |
674 | - if (! $config_obj instanceof EE_Config_Base) { |
|
674 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
675 | 675 | if ($display_errors) { |
676 | 676 | throw new EE_Error( |
677 | 677 | sprintf( |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | */ |
704 | 704 | private function _generate_config_option_name($section = '', $name = '') |
705 | 705 | { |
706 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
706 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | { |
721 | 721 | return ! empty($config_class) |
722 | 722 | ? $config_class |
723 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
723 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | |
@@ -739,17 +739,17 @@ discard block |
||
739 | 739 | // ensure config class is set to something |
740 | 740 | $config_class = $this->_set_config_class($config_class, $name); |
741 | 741 | // run tests 1-4, 6, and 7 to verify all config params are set and valid |
742 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
742 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
743 | 743 | return null; |
744 | 744 | } |
745 | 745 | $config_option_name = $this->_generate_config_option_name($section, $name); |
746 | 746 | // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
747 | - if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
748 | - $this->_addon_option_names[ $config_option_name ] = $config_class; |
|
747 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
748 | + $this->_addon_option_names[$config_option_name] = $config_class; |
|
749 | 749 | $this->update_addon_option_names(); |
750 | 750 | } |
751 | 751 | // verify the incoming config object but suppress errors |
752 | - if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
752 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
753 | 753 | $config_obj = new $config_class(); |
754 | 754 | } |
755 | 755 | if (get_option($config_option_name)) { |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | // get class name of the incoming object |
797 | 797 | $config_class = get_class($config_obj); |
798 | 798 | // run tests 1-5 and 9 to verify config |
799 | - if (! $this->_verify_config_params( |
|
799 | + if ( ! $this->_verify_config_params( |
|
800 | 800 | $section, |
801 | 801 | $name, |
802 | 802 | $config_class, |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | } |
809 | 809 | $config_option_name = $this->_generate_config_option_name($section, $name); |
810 | 810 | // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
811 | - if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
811 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
812 | 812 | // save new config to db |
813 | 813 | if ($this->set_config($section, $name, $config_class, $config_obj)) { |
814 | 814 | return true; |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | 'event_espresso' |
835 | 835 | ), |
836 | 836 | $config_class, |
837 | - 'EE_Config->' . $section . '->' . $name |
|
837 | + 'EE_Config->'.$section.'->'.$name |
|
838 | 838 | ), |
839 | 839 | __FILE__, |
840 | 840 | __FUNCTION__, |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | // ensure config class is set to something |
861 | 861 | $config_class = $this->_set_config_class($config_class, $name); |
862 | 862 | // run tests 1-4, 6 and 7 to verify that all params have been set |
863 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
863 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
864 | 864 | return null; |
865 | 865 | } |
866 | 866 | // now test if the requested config object exists, but suppress errors |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | // retrieve the wp-option for this config class. |
906 | 906 | $config_option = maybe_unserialize(get_option($config_option_name, array())); |
907 | 907 | if (empty($config_option)) { |
908 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
908 | + EE_Config::log($config_option_name.'-NOT-FOUND'); |
|
909 | 909 | } |
910 | 910 | return $config_option; |
911 | 911 | } |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | // copy incoming $_REQUEST and sanitize it so we can save it |
924 | 924 | $_request = $_REQUEST; |
925 | 925 | array_walk_recursive($_request, 'sanitize_text_field'); |
926 | - $config_log[ (string) microtime(true) ] = array( |
|
926 | + $config_log[(string) microtime(true)] = array( |
|
927 | 927 | 'config_name' => $config_option_name, |
928 | 928 | 'request' => $_request, |
929 | 929 | ); |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | */ |
939 | 939 | public static function trim_log() |
940 | 940 | { |
941 | - if (! EE_Config::logging_enabled()) { |
|
941 | + if ( ! EE_Config::logging_enabled()) { |
|
942 | 942 | return; |
943 | 943 | } |
944 | 944 | $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | public static function get_page_for_posts() |
963 | 963 | { |
964 | 964 | $page_for_posts = get_option('page_for_posts'); |
965 | - if (! $page_for_posts) { |
|
965 | + if ( ! $page_for_posts) { |
|
966 | 966 | return 'posts'; |
967 | 967 | } |
968 | 968 | /** @type WPDB $wpdb */ |
@@ -1012,20 +1012,20 @@ discard block |
||
1012 | 1012 | { |
1013 | 1013 | // only init widgets on admin pages when not in complete maintenance, and |
1014 | 1014 | // on frontend when not in any maintenance mode |
1015 | - if (! EE_Maintenance_Mode::instance()->level() |
|
1015 | + if ( ! EE_Maintenance_Mode::instance()->level() |
|
1016 | 1016 | || ( |
1017 | 1017 | is_admin() |
1018 | 1018 | && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
1019 | 1019 | ) |
1020 | 1020 | ) { |
1021 | 1021 | // grab list of installed widgets |
1022 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1022 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
1023 | 1023 | // filter list of modules to register |
1024 | 1024 | $widgets_to_register = apply_filters( |
1025 | 1025 | 'FHEE__EE_Config__register_widgets__widgets_to_register', |
1026 | 1026 | $widgets_to_register |
1027 | 1027 | ); |
1028 | - if (! empty($widgets_to_register)) { |
|
1028 | + if ( ! empty($widgets_to_register)) { |
|
1029 | 1029 | // cycle thru widget folders |
1030 | 1030 | foreach ($widgets_to_register as $widget_path) { |
1031 | 1031 | // add to list of installed widget modules |
@@ -1075,31 +1075,31 @@ discard block |
||
1075 | 1075 | // create classname from widget directory name |
1076 | 1076 | $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
1077 | 1077 | // add class prefix |
1078 | - $widget_class = 'EEW_' . $widget; |
|
1078 | + $widget_class = 'EEW_'.$widget; |
|
1079 | 1079 | // does the widget exist ? |
1080 | - if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1080 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
1081 | 1081 | $msg = sprintf( |
1082 | 1082 | __( |
1083 | 1083 | 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
1084 | 1084 | 'event_espresso' |
1085 | 1085 | ), |
1086 | 1086 | $widget_class, |
1087 | - $widget_path . DS . $widget_class . $widget_ext |
|
1087 | + $widget_path.DS.$widget_class.$widget_ext |
|
1088 | 1088 | ); |
1089 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1089 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1090 | 1090 | return; |
1091 | 1091 | } |
1092 | 1092 | // load the widget class file |
1093 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1093 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
1094 | 1094 | // verify that class exists |
1095 | - if (! class_exists($widget_class)) { |
|
1095 | + if ( ! class_exists($widget_class)) { |
|
1096 | 1096 | $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
1097 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1097 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1098 | 1098 | return; |
1099 | 1099 | } |
1100 | 1100 | register_widget($widget_class); |
1101 | 1101 | // add to array of registered widgets |
1102 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1102 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | |
@@ -1112,18 +1112,18 @@ discard block |
||
1112 | 1112 | private function _register_modules() |
1113 | 1113 | { |
1114 | 1114 | // grab list of installed modules |
1115 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1115 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
1116 | 1116 | // filter list of modules to register |
1117 | 1117 | $modules_to_register = apply_filters( |
1118 | 1118 | 'FHEE__EE_Config__register_modules__modules_to_register', |
1119 | 1119 | $modules_to_register |
1120 | 1120 | ); |
1121 | - if (! empty($modules_to_register)) { |
|
1121 | + if ( ! empty($modules_to_register)) { |
|
1122 | 1122 | // loop through folders |
1123 | 1123 | foreach ($modules_to_register as $module_path) { |
1124 | 1124 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
1125 | - if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1126 | - && $module_path !== EE_MODULES . 'gateways' |
|
1125 | + if ($module_path !== EE_MODULES.'zzz-copy-this-module-template' |
|
1126 | + && $module_path !== EE_MODULES.'gateways' |
|
1127 | 1127 | ) { |
1128 | 1128 | // add to list of installed modules |
1129 | 1129 | EE_Config::register_module($module_path); |
@@ -1160,25 +1160,25 @@ discard block |
||
1160 | 1160 | // remove last segment |
1161 | 1161 | array_pop($module_path); |
1162 | 1162 | // glue it back together |
1163 | - $module_path = implode(DS, $module_path) . DS; |
|
1163 | + $module_path = implode(DS, $module_path).DS; |
|
1164 | 1164 | // take first segment from file name pieces and sanitize it |
1165 | 1165 | $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
1166 | 1166 | // ensure class prefix is added |
1167 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1167 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
1168 | 1168 | } else { |
1169 | 1169 | // we need to generate the filename based off of the folder name |
1170 | 1170 | // grab and sanitize module name |
1171 | 1171 | $module = strtolower(basename($module_path)); |
1172 | 1172 | $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
1173 | 1173 | // like trailingslashit() |
1174 | - $module_path = rtrim($module_path, DS) . DS; |
|
1174 | + $module_path = rtrim($module_path, DS).DS; |
|
1175 | 1175 | // create classname from module directory name |
1176 | 1176 | $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
1177 | 1177 | // add class prefix |
1178 | - $module_class = 'EED_' . $module; |
|
1178 | + $module_class = 'EED_'.$module; |
|
1179 | 1179 | } |
1180 | 1180 | // does the module exist ? |
1181 | - if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1181 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
1182 | 1182 | $msg = sprintf( |
1183 | 1183 | __( |
1184 | 1184 | 'The requested %s module file could not be found or is not readable due to file permissions.', |
@@ -1186,19 +1186,19 @@ discard block |
||
1186 | 1186 | ), |
1187 | 1187 | $module |
1188 | 1188 | ); |
1189 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1189 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1190 | 1190 | return false; |
1191 | 1191 | } |
1192 | 1192 | // load the module class file |
1193 | - require_once($module_path . $module_class . $module_ext); |
|
1193 | + require_once($module_path.$module_class.$module_ext); |
|
1194 | 1194 | // verify that class exists |
1195 | - if (! class_exists($module_class)) { |
|
1195 | + if ( ! class_exists($module_class)) { |
|
1196 | 1196 | $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
1197 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1197 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1198 | 1198 | return false; |
1199 | 1199 | } |
1200 | 1200 | // add to array of registered modules |
1201 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1201 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
1202 | 1202 | do_action( |
1203 | 1203 | 'AHEE__EE_Config__register_module__complete', |
1204 | 1204 | $module_class, |
@@ -1249,26 +1249,26 @@ discard block |
||
1249 | 1249 | { |
1250 | 1250 | do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
1251 | 1251 | $module = str_replace('EED_', '', $module); |
1252 | - $module_class = 'EED_' . $module; |
|
1253 | - if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1252 | + $module_class = 'EED_'.$module; |
|
1253 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1254 | 1254 | $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
1255 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1255 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1256 | 1256 | return false; |
1257 | 1257 | } |
1258 | 1258 | if (empty($route)) { |
1259 | 1259 | $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
1260 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1260 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1261 | 1261 | return false; |
1262 | 1262 | } |
1263 | - if (! method_exists('EED_' . $module, $method_name)) { |
|
1263 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
1264 | 1264 | $msg = sprintf( |
1265 | 1265 | __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
1266 | 1266 | $route |
1267 | 1267 | ); |
1268 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1268 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1269 | 1269 | return false; |
1270 | 1270 | } |
1271 | - EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name); |
|
1271 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
1272 | 1272 | return true; |
1273 | 1273 | } |
1274 | 1274 | |
@@ -1285,8 +1285,8 @@ discard block |
||
1285 | 1285 | { |
1286 | 1286 | do_action('AHEE__EE_Config__get_route__begin', $route); |
1287 | 1287 | $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
1288 | - if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) { |
|
1289 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1288 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1289 | + return EE_Config::$_module_route_map[$key][$route]; |
|
1290 | 1290 | } |
1291 | 1291 | return null; |
1292 | 1292 | } |
@@ -1318,47 +1318,47 @@ discard block |
||
1318 | 1318 | public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
1319 | 1319 | { |
1320 | 1320 | do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
1321 | - if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1321 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1322 | 1322 | $msg = sprintf( |
1323 | 1323 | __('The module route %s for this forward has not been registered.', 'event_espresso'), |
1324 | 1324 | $route |
1325 | 1325 | ); |
1326 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1326 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1327 | 1327 | return false; |
1328 | 1328 | } |
1329 | 1329 | if (empty($forward)) { |
1330 | 1330 | $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
1331 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1331 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1332 | 1332 | return false; |
1333 | 1333 | } |
1334 | 1334 | if (is_array($forward)) { |
1335 | - if (! isset($forward[1])) { |
|
1335 | + if ( ! isset($forward[1])) { |
|
1336 | 1336 | $msg = sprintf( |
1337 | 1337 | __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
1338 | 1338 | $route |
1339 | 1339 | ); |
1340 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1340 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1341 | 1341 | return false; |
1342 | 1342 | } |
1343 | - if (! method_exists($forward[0], $forward[1])) { |
|
1343 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
1344 | 1344 | $msg = sprintf( |
1345 | 1345 | __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
1346 | 1346 | $forward[1], |
1347 | 1347 | $route |
1348 | 1348 | ); |
1349 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1349 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1350 | 1350 | return false; |
1351 | 1351 | } |
1352 | - } elseif (! function_exists($forward)) { |
|
1352 | + } elseif ( ! function_exists($forward)) { |
|
1353 | 1353 | $msg = sprintf( |
1354 | 1354 | __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
1355 | 1355 | $forward, |
1356 | 1356 | $route |
1357 | 1357 | ); |
1358 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1358 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1359 | 1359 | return false; |
1360 | 1360 | } |
1361 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward; |
|
1361 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1362 | 1362 | return true; |
1363 | 1363 | } |
1364 | 1364 | |
@@ -1376,10 +1376,10 @@ discard block |
||
1376 | 1376 | public static function get_forward($route = null, $status = 0, $key = 'ee') |
1377 | 1377 | { |
1378 | 1378 | do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
1379 | - if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) { |
|
1379 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1380 | 1380 | return apply_filters( |
1381 | 1381 | 'FHEE__EE_Config__get_forward', |
1382 | - EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], |
|
1382 | + EE_Config::$_module_forward_map[$key][$route][$status], |
|
1383 | 1383 | $route, |
1384 | 1384 | $status |
1385 | 1385 | ); |
@@ -1403,15 +1403,15 @@ discard block |
||
1403 | 1403 | public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
1404 | 1404 | { |
1405 | 1405 | do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
1406 | - if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1406 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1407 | 1407 | $msg = sprintf( |
1408 | 1408 | __('The module route %s for this view has not been registered.', 'event_espresso'), |
1409 | 1409 | $route |
1410 | 1410 | ); |
1411 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1411 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1412 | 1412 | return false; |
1413 | 1413 | } |
1414 | - if (! is_readable($view)) { |
|
1414 | + if ( ! is_readable($view)) { |
|
1415 | 1415 | $msg = sprintf( |
1416 | 1416 | __( |
1417 | 1417 | 'The %s view file could not be found or is not readable due to file permissions.', |
@@ -1419,10 +1419,10 @@ discard block |
||
1419 | 1419 | ), |
1420 | 1420 | $view |
1421 | 1421 | ); |
1422 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1422 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1423 | 1423 | return false; |
1424 | 1424 | } |
1425 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view; |
|
1425 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1426 | 1426 | return true; |
1427 | 1427 | } |
1428 | 1428 | |
@@ -1440,10 +1440,10 @@ discard block |
||
1440 | 1440 | public static function get_view($route = null, $status = 0, $key = 'ee') |
1441 | 1441 | { |
1442 | 1442 | do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
1443 | - if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) { |
|
1443 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1444 | 1444 | return apply_filters( |
1445 | 1445 | 'FHEE__EE_Config__get_view', |
1446 | - EE_Config::$_module_view_map[ $key ][ $route ][ $status ], |
|
1446 | + EE_Config::$_module_view_map[$key][$route][$status], |
|
1447 | 1447 | $route, |
1448 | 1448 | $status |
1449 | 1449 | ); |
@@ -1470,7 +1470,7 @@ discard block |
||
1470 | 1470 | public static function getLegacyShortcodesManager() |
1471 | 1471 | { |
1472 | 1472 | |
1473 | - if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1473 | + if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1474 | 1474 | EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
1475 | 1475 | EE_Registry::instance() |
1476 | 1476 | ); |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | */ |
1518 | 1518 | public function get_pretty($property) |
1519 | 1519 | { |
1520 | - if (! property_exists($this, $property)) { |
|
1520 | + if ( ! property_exists($this, $property)) { |
|
1521 | 1521 | throw new EE_Error( |
1522 | 1522 | sprintf( |
1523 | 1523 | __( |
@@ -1745,11 +1745,11 @@ discard block |
||
1745 | 1745 | */ |
1746 | 1746 | public function reg_page_url() |
1747 | 1747 | { |
1748 | - if (! $this->reg_page_url) { |
|
1748 | + if ( ! $this->reg_page_url) { |
|
1749 | 1749 | $this->reg_page_url = add_query_arg( |
1750 | 1750 | array('uts' => time()), |
1751 | 1751 | get_permalink($this->reg_page_id) |
1752 | - ) . '#checkout'; |
|
1752 | + ).'#checkout'; |
|
1753 | 1753 | } |
1754 | 1754 | return $this->reg_page_url; |
1755 | 1755 | } |
@@ -1765,7 +1765,7 @@ discard block |
||
1765 | 1765 | */ |
1766 | 1766 | public function txn_page_url($query_args = array()) |
1767 | 1767 | { |
1768 | - if (! $this->txn_page_url) { |
|
1768 | + if ( ! $this->txn_page_url) { |
|
1769 | 1769 | $this->txn_page_url = get_permalink($this->txn_page_id); |
1770 | 1770 | } |
1771 | 1771 | if ($query_args) { |
@@ -1786,7 +1786,7 @@ discard block |
||
1786 | 1786 | */ |
1787 | 1787 | public function thank_you_page_url($query_args = array()) |
1788 | 1788 | { |
1789 | - if (! $this->thank_you_page_url) { |
|
1789 | + if ( ! $this->thank_you_page_url) { |
|
1790 | 1790 | $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
1791 | 1791 | } |
1792 | 1792 | if ($query_args) { |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | */ |
1806 | 1806 | public function cancel_page_url() |
1807 | 1807 | { |
1808 | - if (! $this->cancel_page_url) { |
|
1808 | + if ( ! $this->cancel_page_url) { |
|
1809 | 1809 | $this->cancel_page_url = get_permalink($this->cancel_page_id); |
1810 | 1810 | } |
1811 | 1811 | return $this->cancel_page_url; |
@@ -1840,7 +1840,7 @@ discard block |
||
1840 | 1840 | return get_option('ee_ueip_optin', false); |
1841 | 1841 | } |
1842 | 1842 | // is this already cached for this request? If so use it. |
1843 | - if (! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1843 | + if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1844 | 1844 | return EE_Core_Config::$ee_ueip_option; |
1845 | 1845 | } |
1846 | 1846 | global $wpdb; |
@@ -1848,13 +1848,13 @@ discard block |
||
1848 | 1848 | $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
1849 | 1849 | $option = 'ee_ueip_optin'; |
1850 | 1850 | // set correct table for query |
1851 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1851 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options'; |
|
1852 | 1852 | // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
1853 | 1853 | // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
1854 | 1854 | // re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
1855 | 1855 | // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
1856 | 1856 | // for the purpose of caching. |
1857 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1857 | + $pre = apply_filters('pre_option_'.$option, false, $option); |
|
1858 | 1858 | if (false !== $pre) { |
1859 | 1859 | EE_Core_Config::$ee_ueip_option = $pre; |
1860 | 1860 | return EE_Core_Config::$ee_ueip_option; |
@@ -1868,9 +1868,9 @@ discard block |
||
1868 | 1868 | if (is_object($row)) { |
1869 | 1869 | $value = $row->option_value; |
1870 | 1870 | } else { // option does not exist so use default. |
1871 | - return apply_filters('default_option_' . $option, false, $option); |
|
1871 | + return apply_filters('default_option_'.$option, false, $option); |
|
1872 | 1872 | } |
1873 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1873 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option); |
|
1874 | 1874 | return EE_Core_Config::$ee_ueip_option; |
1875 | 1875 | } |
1876 | 1876 | |
@@ -2148,37 +2148,37 @@ discard block |
||
2148 | 2148 | // but override if requested |
2149 | 2149 | $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
2150 | 2150 | // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
2151 | - if (! empty($CNT_ISO) |
|
2151 | + if ( ! empty($CNT_ISO) |
|
2152 | 2152 | && EE_Maintenance_Mode::instance()->models_can_query() |
2153 | 2153 | && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
2154 | 2154 | ) { |
2155 | 2155 | // retrieve the country settings from the db, just in case they have been customized |
2156 | 2156 | $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
2157 | 2157 | if ($country instanceof EE_Country) { |
2158 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2159 | - $this->name = $country->currency_name_single(); // Dollar |
|
2160 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2161 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2158 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2159 | + $this->name = $country->currency_name_single(); // Dollar |
|
2160 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2161 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2162 | 2162 | $this->sign_b4 = $country->currency_sign_before( |
2163 | - ); // currency sign before or after: $TRUE or FALSE$ |
|
2164 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2163 | + ); // currency sign before or after: $TRUE or FALSE$ |
|
2164 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2165 | 2165 | $this->dec_mrk = $country->currency_decimal_mark( |
2166 | - ); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2166 | + ); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2167 | 2167 | $this->thsnds = $country->currency_thousands_separator( |
2168 | - ); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2168 | + ); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2169 | 2169 | } |
2170 | 2170 | } |
2171 | 2171 | // fallback to hardcoded defaults, in case the above failed |
2172 | 2172 | if (empty($this->code)) { |
2173 | 2173 | // set default currency settings |
2174 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2175 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2176 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2177 | - $this->sign = '$'; // currency sign: $ |
|
2178 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2179 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2180 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2181 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2174 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2175 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2176 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2177 | + $this->sign = '$'; // currency sign: $ |
|
2178 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2179 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2180 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2181 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2182 | 2182 | } |
2183 | 2183 | } |
2184 | 2184 | } |
@@ -2530,7 +2530,7 @@ discard block |
||
2530 | 2530 | public function log_file_name($reset = false) |
2531 | 2531 | { |
2532 | 2532 | if (empty($this->log_file_name) || $reset) { |
2533 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2533 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt'; |
|
2534 | 2534 | EE_Config::instance()->update_espresso_config(false, false); |
2535 | 2535 | } |
2536 | 2536 | return $this->log_file_name; |
@@ -2544,7 +2544,7 @@ discard block |
||
2544 | 2544 | public function debug_file_name($reset = false) |
2545 | 2545 | { |
2546 | 2546 | if (empty($this->debug_file_name) || $reset) { |
2547 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2547 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt'; |
|
2548 | 2548 | EE_Config::instance()->update_espresso_config(false, false); |
2549 | 2549 | } |
2550 | 2550 | return $this->debug_file_name; |
@@ -2750,21 +2750,21 @@ discard block |
||
2750 | 2750 | $this->use_google_maps = true; |
2751 | 2751 | $this->google_map_api_key = ''; |
2752 | 2752 | // for event details pages (reg page) |
2753 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2754 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2755 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2756 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2757 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2758 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2759 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2753 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2754 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2755 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2756 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2757 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2758 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2759 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2760 | 2760 | // for event list pages |
2761 | - $this->event_list_map_width = 300; // ee_map_width |
|
2762 | - $this->event_list_map_height = 185; // ee_map_height |
|
2763 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2764 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2765 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2766 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2767 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2761 | + $this->event_list_map_width = 300; // ee_map_width |
|
2762 | + $this->event_list_map_height = 185; // ee_map_height |
|
2763 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2764 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2765 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2766 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2767 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2768 | 2768 | } |
2769 | 2769 | } |
2770 | 2770 | |
@@ -3060,7 +3060,7 @@ discard block |
||
3060 | 3060 | */ |
3061 | 3061 | public function max_input_vars_limit_check($input_count = 0) |
3062 | 3062 | { |
3063 | - if (! empty($this->php->max_input_vars) |
|
3063 | + if ( ! empty($this->php->max_input_vars) |
|
3064 | 3064 | && ($input_count >= $this->php->max_input_vars) |
3065 | 3065 | && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
3066 | 3066 | ) { |
@@ -13,2412 +13,2412 @@ discard block |
||
13 | 13 | final class EE_Config implements ResettableInterface |
14 | 14 | { |
15 | 15 | |
16 | - const OPTION_NAME = 'ee_config'; |
|
17 | - |
|
18 | - const LOG_NAME = 'ee_config_log'; |
|
19 | - |
|
20 | - const LOG_LENGTH = 100; |
|
21 | - |
|
22 | - const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * instance of the EE_Config object |
|
27 | - * |
|
28 | - * @var EE_Config $_instance |
|
29 | - * @access private |
|
30 | - */ |
|
31 | - private static $_instance; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var boolean $_logging_enabled |
|
35 | - */ |
|
36 | - private static $_logging_enabled = false; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
40 | - */ |
|
41 | - private $legacy_shortcodes_manager; |
|
42 | - |
|
43 | - /** |
|
44 | - * An StdClass whose property names are addon slugs, |
|
45 | - * and values are their config classes |
|
46 | - * |
|
47 | - * @var StdClass |
|
48 | - */ |
|
49 | - public $addons; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var EE_Admin_Config |
|
53 | - */ |
|
54 | - public $admin; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var EE_Core_Config |
|
58 | - */ |
|
59 | - public $core; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var EE_Currency_Config |
|
63 | - */ |
|
64 | - public $currency; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var EE_Organization_Config |
|
68 | - */ |
|
69 | - public $organization; |
|
70 | - |
|
71 | - /** |
|
72 | - * @var EE_Registration_Config |
|
73 | - */ |
|
74 | - public $registration; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var EE_Template_Config |
|
78 | - */ |
|
79 | - public $template_settings; |
|
80 | - |
|
81 | - /** |
|
82 | - * Holds EE environment values. |
|
83 | - * |
|
84 | - * @var EE_Environment_Config |
|
85 | - */ |
|
86 | - public $environment; |
|
87 | - |
|
88 | - /** |
|
89 | - * settings pertaining to Google maps |
|
90 | - * |
|
91 | - * @var EE_Map_Config |
|
92 | - */ |
|
93 | - public $map_settings; |
|
94 | - |
|
95 | - /** |
|
96 | - * settings pertaining to Taxes |
|
97 | - * |
|
98 | - * @var EE_Tax_Config |
|
99 | - */ |
|
100 | - public $tax_settings; |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * Settings pertaining to global messages settings. |
|
105 | - * |
|
106 | - * @var EE_Messages_Config |
|
107 | - */ |
|
108 | - public $messages; |
|
109 | - |
|
110 | - /** |
|
111 | - * @deprecated |
|
112 | - * @var EE_Gateway_Config |
|
113 | - */ |
|
114 | - public $gateway; |
|
115 | - |
|
116 | - /** |
|
117 | - * @var array $_addon_option_names |
|
118 | - * @access private |
|
119 | - */ |
|
120 | - private $_addon_option_names = array(); |
|
121 | - |
|
122 | - /** |
|
123 | - * @var array $_module_route_map |
|
124 | - * @access private |
|
125 | - */ |
|
126 | - private static $_module_route_map = array(); |
|
127 | - |
|
128 | - /** |
|
129 | - * @var array $_module_forward_map |
|
130 | - * @access private |
|
131 | - */ |
|
132 | - private static $_module_forward_map = array(); |
|
133 | - |
|
134 | - /** |
|
135 | - * @var array $_module_view_map |
|
136 | - * @access private |
|
137 | - */ |
|
138 | - private static $_module_view_map = array(); |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @singleton method used to instantiate class object |
|
143 | - * @access public |
|
144 | - * @return EE_Config instance |
|
145 | - */ |
|
146 | - public static function instance() |
|
147 | - { |
|
148 | - // check if class object is instantiated, and instantiated properly |
|
149 | - if (! self::$_instance instanceof EE_Config) { |
|
150 | - self::$_instance = new self(); |
|
151 | - } |
|
152 | - return self::$_instance; |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * Resets the config |
|
158 | - * |
|
159 | - * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
160 | - * (default) leaves the database alone, and merely resets the EE_Config object to |
|
161 | - * reflect its state in the database |
|
162 | - * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
163 | - * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
164 | - * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
165 | - * site was put into maintenance mode) |
|
166 | - * @return EE_Config |
|
167 | - */ |
|
168 | - public static function reset($hard_reset = false, $reinstantiate = true) |
|
169 | - { |
|
170 | - if (self::$_instance instanceof EE_Config) { |
|
171 | - if ($hard_reset) { |
|
172 | - self::$_instance->legacy_shortcodes_manager = null; |
|
173 | - self::$_instance->_addon_option_names = array(); |
|
174 | - self::$_instance->_initialize_config(); |
|
175 | - self::$_instance->update_espresso_config(); |
|
176 | - } |
|
177 | - self::$_instance->update_addon_option_names(); |
|
178 | - } |
|
179 | - self::$_instance = null; |
|
180 | - // we don't need to reset the static properties imo because those should |
|
181 | - // only change when a module is added or removed. Currently we don't |
|
182 | - // support removing a module during a request when it previously existed |
|
183 | - if ($reinstantiate) { |
|
184 | - return self::instance(); |
|
185 | - } else { |
|
186 | - return null; |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * class constructor |
|
193 | - * |
|
194 | - * @access private |
|
195 | - */ |
|
196 | - private function __construct() |
|
197 | - { |
|
198 | - do_action('AHEE__EE_Config__construct__begin', $this); |
|
199 | - EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
200 | - // setup empty config classes |
|
201 | - $this->_initialize_config(); |
|
202 | - // load existing EE site settings |
|
203 | - $this->_load_core_config(); |
|
204 | - // confirm everything loaded correctly and set filtered defaults if not |
|
205 | - $this->_verify_config(); |
|
206 | - // register shortcodes and modules |
|
207 | - add_action( |
|
208 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
209 | - array($this, 'register_shortcodes_and_modules'), |
|
210 | - 999 |
|
211 | - ); |
|
212 | - // initialize shortcodes and modules |
|
213 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
214 | - // register widgets |
|
215 | - add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
216 | - // shutdown |
|
217 | - add_action('shutdown', array($this, 'shutdown'), 10); |
|
218 | - // construct__end hook |
|
219 | - do_action('AHEE__EE_Config__construct__end', $this); |
|
220 | - // hardcoded hack |
|
221 | - $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - /** |
|
226 | - * @return boolean |
|
227 | - */ |
|
228 | - public static function logging_enabled() |
|
229 | - { |
|
230 | - return self::$_logging_enabled; |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * use to get the current theme if needed from static context |
|
236 | - * |
|
237 | - * @return string current theme set. |
|
238 | - */ |
|
239 | - public static function get_current_theme() |
|
240 | - { |
|
241 | - return isset(self::$_instance->template_settings->current_espresso_theme) |
|
242 | - ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * _initialize_config |
|
248 | - * |
|
249 | - * @access private |
|
250 | - * @return void |
|
251 | - */ |
|
252 | - private function _initialize_config() |
|
253 | - { |
|
254 | - EE_Config::trim_log(); |
|
255 | - // set defaults |
|
256 | - $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
257 | - $this->addons = new stdClass(); |
|
258 | - // set _module_route_map |
|
259 | - EE_Config::$_module_route_map = array(); |
|
260 | - // set _module_forward_map |
|
261 | - EE_Config::$_module_forward_map = array(); |
|
262 | - // set _module_view_map |
|
263 | - EE_Config::$_module_view_map = array(); |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * load core plugin configuration |
|
269 | - * |
|
270 | - * @access private |
|
271 | - * @return void |
|
272 | - */ |
|
273 | - private function _load_core_config() |
|
274 | - { |
|
275 | - // load_core_config__start hook |
|
276 | - do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
277 | - $espresso_config = $this->get_espresso_config(); |
|
278 | - foreach ($espresso_config as $config => $settings) { |
|
279 | - // load_core_config__start hook |
|
280 | - $settings = apply_filters( |
|
281 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
282 | - $settings, |
|
283 | - $config, |
|
284 | - $this |
|
285 | - ); |
|
286 | - if (is_object($settings) && property_exists($this, $config)) { |
|
287 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
288 | - // call configs populate method to ensure any defaults are set for empty values. |
|
289 | - if (method_exists($settings, 'populate')) { |
|
290 | - $this->{$config}->populate(); |
|
291 | - } |
|
292 | - if (method_exists($settings, 'do_hooks')) { |
|
293 | - $this->{$config}->do_hooks(); |
|
294 | - } |
|
295 | - } |
|
296 | - } |
|
297 | - if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
298 | - $this->update_espresso_config(); |
|
299 | - } |
|
300 | - // load_core_config__end hook |
|
301 | - do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * _verify_config |
|
307 | - * |
|
308 | - * @access protected |
|
309 | - * @return void |
|
310 | - */ |
|
311 | - protected function _verify_config() |
|
312 | - { |
|
313 | - $this->core = $this->core instanceof EE_Core_Config |
|
314 | - ? $this->core |
|
315 | - : new EE_Core_Config(); |
|
316 | - $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
317 | - $this->organization = $this->organization instanceof EE_Organization_Config |
|
318 | - ? $this->organization |
|
319 | - : new EE_Organization_Config(); |
|
320 | - $this->organization = apply_filters( |
|
321 | - 'FHEE__EE_Config___initialize_config__organization', |
|
322 | - $this->organization |
|
323 | - ); |
|
324 | - $this->currency = $this->currency instanceof EE_Currency_Config |
|
325 | - ? $this->currency |
|
326 | - : new EE_Currency_Config(); |
|
327 | - $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
328 | - $this->registration = $this->registration instanceof EE_Registration_Config |
|
329 | - ? $this->registration |
|
330 | - : new EE_Registration_Config(); |
|
331 | - $this->registration = apply_filters( |
|
332 | - 'FHEE__EE_Config___initialize_config__registration', |
|
333 | - $this->registration |
|
334 | - ); |
|
335 | - $this->admin = $this->admin instanceof EE_Admin_Config |
|
336 | - ? $this->admin |
|
337 | - : new EE_Admin_Config(); |
|
338 | - $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
339 | - $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
340 | - ? $this->template_settings |
|
341 | - : new EE_Template_Config(); |
|
342 | - $this->template_settings = apply_filters( |
|
343 | - 'FHEE__EE_Config___initialize_config__template_settings', |
|
344 | - $this->template_settings |
|
345 | - ); |
|
346 | - $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
347 | - ? $this->map_settings |
|
348 | - : new EE_Map_Config(); |
|
349 | - $this->map_settings = apply_filters( |
|
350 | - 'FHEE__EE_Config___initialize_config__map_settings', |
|
351 | - $this->map_settings |
|
352 | - ); |
|
353 | - $this->environment = $this->environment instanceof EE_Environment_Config |
|
354 | - ? $this->environment |
|
355 | - : new EE_Environment_Config(); |
|
356 | - $this->environment = apply_filters( |
|
357 | - 'FHEE__EE_Config___initialize_config__environment', |
|
358 | - $this->environment |
|
359 | - ); |
|
360 | - $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
361 | - ? $this->tax_settings |
|
362 | - : new EE_Tax_Config(); |
|
363 | - $this->tax_settings = apply_filters( |
|
364 | - 'FHEE__EE_Config___initialize_config__tax_settings', |
|
365 | - $this->tax_settings |
|
366 | - ); |
|
367 | - $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
368 | - $this->messages = $this->messages instanceof EE_Messages_Config |
|
369 | - ? $this->messages |
|
370 | - : new EE_Messages_Config(); |
|
371 | - $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
372 | - ? $this->gateway |
|
373 | - : new EE_Gateway_Config(); |
|
374 | - $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
375 | - $this->legacy_shortcodes_manager = null; |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * get_espresso_config |
|
381 | - * |
|
382 | - * @access public |
|
383 | - * @return array of espresso config stuff |
|
384 | - */ |
|
385 | - public function get_espresso_config() |
|
386 | - { |
|
387 | - // grab espresso configuration |
|
388 | - return apply_filters( |
|
389 | - 'FHEE__EE_Config__get_espresso_config__CFG', |
|
390 | - get_option(EE_Config::OPTION_NAME, array()) |
|
391 | - ); |
|
392 | - } |
|
393 | - |
|
394 | - |
|
395 | - /** |
|
396 | - * double_check_config_comparison |
|
397 | - * |
|
398 | - * @access public |
|
399 | - * @param string $option |
|
400 | - * @param $old_value |
|
401 | - * @param $value |
|
402 | - */ |
|
403 | - public function double_check_config_comparison($option = '', $old_value, $value) |
|
404 | - { |
|
405 | - // make sure we're checking the ee config |
|
406 | - if ($option === EE_Config::OPTION_NAME) { |
|
407 | - // run a loose comparison of the old value against the new value for type and properties, |
|
408 | - // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
409 | - if ($value != $old_value) { |
|
410 | - // if they are NOT the same, then remove the hook, |
|
411 | - // which means the subsequent update results will be based solely on the update query results |
|
412 | - // the reason we do this is because, as stated above, |
|
413 | - // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
414 | - // this happens PRIOR to serialization and any subsequent update. |
|
415 | - // If values are found to match their previous old value, |
|
416 | - // then WP bails before performing any update. |
|
417 | - // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
418 | - // it just pulled from the db, with the one being passed to it (which will not match). |
|
419 | - // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
420 | - // MySQL MAY ALSO NOT perform the update because |
|
421 | - // the string it sees in the db looks the same as the new one it has been passed!!! |
|
422 | - // This results in the query returning an "affected rows" value of ZERO, |
|
423 | - // which gets returned immediately by WP update_option and looks like an error. |
|
424 | - remove_action('update_option', array($this, 'check_config_updated')); |
|
425 | - } |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * update_espresso_config |
|
432 | - * |
|
433 | - * @access public |
|
434 | - */ |
|
435 | - protected function _reset_espresso_addon_config() |
|
436 | - { |
|
437 | - $this->_addon_option_names = array(); |
|
438 | - foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
439 | - $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
440 | - if ($addon_config_obj instanceof EE_Config_Base) { |
|
441 | - $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
442 | - } |
|
443 | - $this->addons->{$addon_name} = null; |
|
444 | - } |
|
445 | - } |
|
446 | - |
|
447 | - |
|
448 | - /** |
|
449 | - * update_espresso_config |
|
450 | - * |
|
451 | - * @access public |
|
452 | - * @param bool $add_success |
|
453 | - * @param bool $add_error |
|
454 | - * @return bool |
|
455 | - */ |
|
456 | - public function update_espresso_config($add_success = false, $add_error = true) |
|
457 | - { |
|
458 | - // don't allow config updates during WP heartbeats |
|
459 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
460 | - return false; |
|
461 | - } |
|
462 | - // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
463 | - // $clone = clone( self::$_instance ); |
|
464 | - // self::$_instance = NULL; |
|
465 | - do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
466 | - $this->_reset_espresso_addon_config(); |
|
467 | - // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
468 | - // but BEFORE the actual update occurs |
|
469 | - add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
470 | - // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
471 | - $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
472 | - $this->legacy_shortcodes_manager = null; |
|
473 | - // now update "ee_config" |
|
474 | - $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
475 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
476 | - EE_Config::log(EE_Config::OPTION_NAME); |
|
477 | - // if not saved... check if the hook we just added still exists; |
|
478 | - // if it does, it means one of two things: |
|
479 | - // that update_option bailed at the($value === $old_value) conditional, |
|
480 | - // or... |
|
481 | - // the db update query returned 0 rows affected |
|
482 | - // (probably because the data value was the same from it's perspective) |
|
483 | - // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
484 | - // but just means no update occurred, so don't display an error to the user. |
|
485 | - // BUT... if update_option returns FALSE, AND the hook is missing, |
|
486 | - // then it means that something truly went wrong |
|
487 | - $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
488 | - // remove our action since we don't want it in the system anymore |
|
489 | - remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
490 | - do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
491 | - // self::$_instance = $clone; |
|
492 | - // unset( $clone ); |
|
493 | - // if config remains the same or was updated successfully |
|
494 | - if ($saved) { |
|
495 | - if ($add_success) { |
|
496 | - EE_Error::add_success( |
|
497 | - __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
498 | - __FILE__, |
|
499 | - __FUNCTION__, |
|
500 | - __LINE__ |
|
501 | - ); |
|
502 | - } |
|
503 | - return true; |
|
504 | - } else { |
|
505 | - if ($add_error) { |
|
506 | - EE_Error::add_error( |
|
507 | - __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
508 | - __FILE__, |
|
509 | - __FUNCTION__, |
|
510 | - __LINE__ |
|
511 | - ); |
|
512 | - } |
|
513 | - return false; |
|
514 | - } |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * _verify_config_params |
|
520 | - * |
|
521 | - * @access private |
|
522 | - * @param string $section |
|
523 | - * @param string $name |
|
524 | - * @param string $config_class |
|
525 | - * @param EE_Config_Base $config_obj |
|
526 | - * @param array $tests_to_run |
|
527 | - * @param bool $display_errors |
|
528 | - * @return bool TRUE on success, FALSE on fail |
|
529 | - */ |
|
530 | - private function _verify_config_params( |
|
531 | - $section = '', |
|
532 | - $name = '', |
|
533 | - $config_class = '', |
|
534 | - $config_obj = null, |
|
535 | - $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
536 | - $display_errors = true |
|
537 | - ) { |
|
538 | - try { |
|
539 | - foreach ($tests_to_run as $test) { |
|
540 | - switch ($test) { |
|
541 | - // TEST #1 : check that section was set |
|
542 | - case 1: |
|
543 | - if (empty($section)) { |
|
544 | - if ($display_errors) { |
|
545 | - throw new EE_Error( |
|
546 | - sprintf( |
|
547 | - __( |
|
548 | - 'No configuration section has been provided while attempting to save "%s".', |
|
549 | - 'event_espresso' |
|
550 | - ), |
|
551 | - $config_class |
|
552 | - ) |
|
553 | - ); |
|
554 | - } |
|
555 | - return false; |
|
556 | - } |
|
557 | - break; |
|
558 | - // TEST #2 : check that settings section exists |
|
559 | - case 2: |
|
560 | - if (! isset($this->{$section})) { |
|
561 | - if ($display_errors) { |
|
562 | - throw new EE_Error( |
|
563 | - sprintf( |
|
564 | - __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
565 | - $section |
|
566 | - ) |
|
567 | - ); |
|
568 | - } |
|
569 | - return false; |
|
570 | - } |
|
571 | - break; |
|
572 | - // TEST #3 : check that section is the proper format |
|
573 | - case 3: |
|
574 | - if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
575 | - ) { |
|
576 | - if ($display_errors) { |
|
577 | - throw new EE_Error( |
|
578 | - sprintf( |
|
579 | - __( |
|
580 | - 'The "%s" configuration settings have not been formatted correctly.', |
|
581 | - 'event_espresso' |
|
582 | - ), |
|
583 | - $section |
|
584 | - ) |
|
585 | - ); |
|
586 | - } |
|
587 | - return false; |
|
588 | - } |
|
589 | - break; |
|
590 | - // TEST #4 : check that config section name has been set |
|
591 | - case 4: |
|
592 | - if (empty($name)) { |
|
593 | - if ($display_errors) { |
|
594 | - throw new EE_Error( |
|
595 | - __( |
|
596 | - 'No name has been provided for the specific configuration section.', |
|
597 | - 'event_espresso' |
|
598 | - ) |
|
599 | - ); |
|
600 | - } |
|
601 | - return false; |
|
602 | - } |
|
603 | - break; |
|
604 | - // TEST #5 : check that a config class name has been set |
|
605 | - case 5: |
|
606 | - if (empty($config_class)) { |
|
607 | - if ($display_errors) { |
|
608 | - throw new EE_Error( |
|
609 | - __( |
|
610 | - 'No class name has been provided for the specific configuration section.', |
|
611 | - 'event_espresso' |
|
612 | - ) |
|
613 | - ); |
|
614 | - } |
|
615 | - return false; |
|
616 | - } |
|
617 | - break; |
|
618 | - // TEST #6 : verify config class is accessible |
|
619 | - case 6: |
|
620 | - if (! class_exists($config_class)) { |
|
621 | - if ($display_errors) { |
|
622 | - throw new EE_Error( |
|
623 | - sprintf( |
|
624 | - __( |
|
625 | - 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
626 | - 'event_espresso' |
|
627 | - ), |
|
628 | - $config_class |
|
629 | - ) |
|
630 | - ); |
|
631 | - } |
|
632 | - return false; |
|
633 | - } |
|
634 | - break; |
|
635 | - // TEST #7 : check that config has even been set |
|
636 | - case 7: |
|
637 | - if (! isset($this->{$section}->{$name})) { |
|
638 | - if ($display_errors) { |
|
639 | - throw new EE_Error( |
|
640 | - sprintf( |
|
641 | - __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
642 | - $section, |
|
643 | - $name |
|
644 | - ) |
|
645 | - ); |
|
646 | - } |
|
647 | - return false; |
|
648 | - } else { |
|
649 | - // and make sure it's not serialized |
|
650 | - $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
651 | - } |
|
652 | - break; |
|
653 | - // TEST #8 : check that config is the requested type |
|
654 | - case 8: |
|
655 | - if (! $this->{$section}->{$name} instanceof $config_class) { |
|
656 | - if ($display_errors) { |
|
657 | - throw new EE_Error( |
|
658 | - sprintf( |
|
659 | - __( |
|
660 | - 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
661 | - 'event_espresso' |
|
662 | - ), |
|
663 | - $section, |
|
664 | - $name, |
|
665 | - $config_class |
|
666 | - ) |
|
667 | - ); |
|
668 | - } |
|
669 | - return false; |
|
670 | - } |
|
671 | - break; |
|
672 | - // TEST #9 : verify config object |
|
673 | - case 9: |
|
674 | - if (! $config_obj instanceof EE_Config_Base) { |
|
675 | - if ($display_errors) { |
|
676 | - throw new EE_Error( |
|
677 | - sprintf( |
|
678 | - __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
679 | - print_r($config_obj, true) |
|
680 | - ) |
|
681 | - ); |
|
682 | - } |
|
683 | - return false; |
|
684 | - } |
|
685 | - break; |
|
686 | - } |
|
687 | - } |
|
688 | - } catch (EE_Error $e) { |
|
689 | - $e->get_error(); |
|
690 | - } |
|
691 | - // you have successfully run the gauntlet |
|
692 | - return true; |
|
693 | - } |
|
694 | - |
|
695 | - |
|
696 | - /** |
|
697 | - * _generate_config_option_name |
|
698 | - * |
|
699 | - * @access protected |
|
700 | - * @param string $section |
|
701 | - * @param string $name |
|
702 | - * @return string |
|
703 | - */ |
|
704 | - private function _generate_config_option_name($section = '', $name = '') |
|
705 | - { |
|
706 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
707 | - } |
|
708 | - |
|
709 | - |
|
710 | - /** |
|
711 | - * _set_config_class |
|
712 | - * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
713 | - * |
|
714 | - * @access private |
|
715 | - * @param string $config_class |
|
716 | - * @param string $name |
|
717 | - * @return string |
|
718 | - */ |
|
719 | - private function _set_config_class($config_class = '', $name = '') |
|
720 | - { |
|
721 | - return ! empty($config_class) |
|
722 | - ? $config_class |
|
723 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
724 | - } |
|
725 | - |
|
726 | - |
|
727 | - /** |
|
728 | - * set_config |
|
729 | - * |
|
730 | - * @access protected |
|
731 | - * @param string $section |
|
732 | - * @param string $name |
|
733 | - * @param string $config_class |
|
734 | - * @param EE_Config_Base $config_obj |
|
735 | - * @return EE_Config_Base |
|
736 | - */ |
|
737 | - public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
738 | - { |
|
739 | - // ensure config class is set to something |
|
740 | - $config_class = $this->_set_config_class($config_class, $name); |
|
741 | - // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
742 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
743 | - return null; |
|
744 | - } |
|
745 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
746 | - // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
747 | - if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
748 | - $this->_addon_option_names[ $config_option_name ] = $config_class; |
|
749 | - $this->update_addon_option_names(); |
|
750 | - } |
|
751 | - // verify the incoming config object but suppress errors |
|
752 | - if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
753 | - $config_obj = new $config_class(); |
|
754 | - } |
|
755 | - if (get_option($config_option_name)) { |
|
756 | - EE_Config::log($config_option_name); |
|
757 | - update_option($config_option_name, $config_obj); |
|
758 | - $this->{$section}->{$name} = $config_obj; |
|
759 | - return $this->{$section}->{$name}; |
|
760 | - } else { |
|
761 | - // create a wp-option for this config |
|
762 | - if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
763 | - $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
764 | - return $this->{$section}->{$name}; |
|
765 | - } else { |
|
766 | - EE_Error::add_error( |
|
767 | - sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
768 | - __FILE__, |
|
769 | - __FUNCTION__, |
|
770 | - __LINE__ |
|
771 | - ); |
|
772 | - return null; |
|
773 | - } |
|
774 | - } |
|
775 | - } |
|
776 | - |
|
777 | - |
|
778 | - /** |
|
779 | - * update_config |
|
780 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
781 | - * |
|
782 | - * @access public |
|
783 | - * @param string $section |
|
784 | - * @param string $name |
|
785 | - * @param EE_Config_Base|string $config_obj |
|
786 | - * @param bool $throw_errors |
|
787 | - * @return bool |
|
788 | - */ |
|
789 | - public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
790 | - { |
|
791 | - // don't allow config updates during WP heartbeats |
|
792 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
793 | - return false; |
|
794 | - } |
|
795 | - $config_obj = maybe_unserialize($config_obj); |
|
796 | - // get class name of the incoming object |
|
797 | - $config_class = get_class($config_obj); |
|
798 | - // run tests 1-5 and 9 to verify config |
|
799 | - if (! $this->_verify_config_params( |
|
800 | - $section, |
|
801 | - $name, |
|
802 | - $config_class, |
|
803 | - $config_obj, |
|
804 | - array(1, 2, 3, 4, 7, 9) |
|
805 | - ) |
|
806 | - ) { |
|
807 | - return false; |
|
808 | - } |
|
809 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
810 | - // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
811 | - if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
812 | - // save new config to db |
|
813 | - if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
814 | - return true; |
|
815 | - } |
|
816 | - } else { |
|
817 | - // first check if the record already exists |
|
818 | - $existing_config = get_option($config_option_name); |
|
819 | - $config_obj = serialize($config_obj); |
|
820 | - // just return if db record is already up to date (NOT type safe comparison) |
|
821 | - if ($existing_config == $config_obj) { |
|
822 | - $this->{$section}->{$name} = $config_obj; |
|
823 | - return true; |
|
824 | - } elseif (update_option($config_option_name, $config_obj)) { |
|
825 | - EE_Config::log($config_option_name); |
|
826 | - // update wp-option for this config class |
|
827 | - $this->{$section}->{$name} = $config_obj; |
|
828 | - return true; |
|
829 | - } elseif ($throw_errors) { |
|
830 | - EE_Error::add_error( |
|
831 | - sprintf( |
|
832 | - __( |
|
833 | - 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
834 | - 'event_espresso' |
|
835 | - ), |
|
836 | - $config_class, |
|
837 | - 'EE_Config->' . $section . '->' . $name |
|
838 | - ), |
|
839 | - __FILE__, |
|
840 | - __FUNCTION__, |
|
841 | - __LINE__ |
|
842 | - ); |
|
843 | - } |
|
844 | - } |
|
845 | - return false; |
|
846 | - } |
|
847 | - |
|
848 | - |
|
849 | - /** |
|
850 | - * get_config |
|
851 | - * |
|
852 | - * @access public |
|
853 | - * @param string $section |
|
854 | - * @param string $name |
|
855 | - * @param string $config_class |
|
856 | - * @return mixed EE_Config_Base | NULL |
|
857 | - */ |
|
858 | - public function get_config($section = '', $name = '', $config_class = '') |
|
859 | - { |
|
860 | - // ensure config class is set to something |
|
861 | - $config_class = $this->_set_config_class($config_class, $name); |
|
862 | - // run tests 1-4, 6 and 7 to verify that all params have been set |
|
863 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
864 | - return null; |
|
865 | - } |
|
866 | - // now test if the requested config object exists, but suppress errors |
|
867 | - if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
868 | - // config already exists, so pass it back |
|
869 | - return $this->{$section}->{$name}; |
|
870 | - } |
|
871 | - // load config option from db if it exists |
|
872 | - $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
873 | - // verify the newly retrieved config object, but suppress errors |
|
874 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
875 | - // config is good, so set it and pass it back |
|
876 | - $this->{$section}->{$name} = $config_obj; |
|
877 | - return $this->{$section}->{$name}; |
|
878 | - } |
|
879 | - // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
880 | - $config_obj = $this->set_config($section, $name, $config_class); |
|
881 | - // verify the newly created config object |
|
882 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
883 | - return $this->{$section}->{$name}; |
|
884 | - } else { |
|
885 | - EE_Error::add_error( |
|
886 | - sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
887 | - __FILE__, |
|
888 | - __FUNCTION__, |
|
889 | - __LINE__ |
|
890 | - ); |
|
891 | - } |
|
892 | - return null; |
|
893 | - } |
|
894 | - |
|
895 | - |
|
896 | - /** |
|
897 | - * get_config_option |
|
898 | - * |
|
899 | - * @access public |
|
900 | - * @param string $config_option_name |
|
901 | - * @return mixed EE_Config_Base | FALSE |
|
902 | - */ |
|
903 | - public function get_config_option($config_option_name = '') |
|
904 | - { |
|
905 | - // retrieve the wp-option for this config class. |
|
906 | - $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
907 | - if (empty($config_option)) { |
|
908 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
909 | - } |
|
910 | - return $config_option; |
|
911 | - } |
|
912 | - |
|
913 | - |
|
914 | - /** |
|
915 | - * log |
|
916 | - * |
|
917 | - * @param string $config_option_name |
|
918 | - */ |
|
919 | - public static function log($config_option_name = '') |
|
920 | - { |
|
921 | - if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
922 | - $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
923 | - // copy incoming $_REQUEST and sanitize it so we can save it |
|
924 | - $_request = $_REQUEST; |
|
925 | - array_walk_recursive($_request, 'sanitize_text_field'); |
|
926 | - $config_log[ (string) microtime(true) ] = array( |
|
927 | - 'config_name' => $config_option_name, |
|
928 | - 'request' => $_request, |
|
929 | - ); |
|
930 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
931 | - } |
|
932 | - } |
|
933 | - |
|
934 | - |
|
935 | - /** |
|
936 | - * trim_log |
|
937 | - * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
938 | - */ |
|
939 | - public static function trim_log() |
|
940 | - { |
|
941 | - if (! EE_Config::logging_enabled()) { |
|
942 | - return; |
|
943 | - } |
|
944 | - $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
945 | - $log_length = count($config_log); |
|
946 | - if ($log_length > EE_Config::LOG_LENGTH) { |
|
947 | - ksort($config_log); |
|
948 | - $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
949 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
950 | - } |
|
951 | - } |
|
952 | - |
|
953 | - |
|
954 | - /** |
|
955 | - * get_page_for_posts |
|
956 | - * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
957 | - * wp-option "page_for_posts", or "posts" if no page is selected |
|
958 | - * |
|
959 | - * @access public |
|
960 | - * @return string |
|
961 | - */ |
|
962 | - public static function get_page_for_posts() |
|
963 | - { |
|
964 | - $page_for_posts = get_option('page_for_posts'); |
|
965 | - if (! $page_for_posts) { |
|
966 | - return 'posts'; |
|
967 | - } |
|
968 | - /** @type WPDB $wpdb */ |
|
969 | - global $wpdb; |
|
970 | - $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
971 | - return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
972 | - } |
|
973 | - |
|
974 | - |
|
975 | - /** |
|
976 | - * register_shortcodes_and_modules. |
|
977 | - * At this point, it's too early to tell if we're maintenance mode or not. |
|
978 | - * In fact, this is where we give modules a chance to let core know they exist |
|
979 | - * so they can help trigger maintenance mode if it's needed |
|
980 | - * |
|
981 | - * @access public |
|
982 | - * @return void |
|
983 | - */ |
|
984 | - public function register_shortcodes_and_modules() |
|
985 | - { |
|
986 | - // allow modules to set hooks for the rest of the system |
|
987 | - EE_Registry::instance()->modules = $this->_register_modules(); |
|
988 | - } |
|
989 | - |
|
990 | - |
|
991 | - /** |
|
992 | - * initialize_shortcodes_and_modules |
|
993 | - * meaning they can start adding their hooks to get stuff done |
|
994 | - * |
|
995 | - * @access public |
|
996 | - * @return void |
|
997 | - */ |
|
998 | - public function initialize_shortcodes_and_modules() |
|
999 | - { |
|
1000 | - // allow modules to set hooks for the rest of the system |
|
1001 | - $this->_initialize_modules(); |
|
1002 | - } |
|
1003 | - |
|
1004 | - |
|
1005 | - /** |
|
1006 | - * widgets_init |
|
1007 | - * |
|
1008 | - * @access private |
|
1009 | - * @return void |
|
1010 | - */ |
|
1011 | - public function widgets_init() |
|
1012 | - { |
|
1013 | - // only init widgets on admin pages when not in complete maintenance, and |
|
1014 | - // on frontend when not in any maintenance mode |
|
1015 | - if (! EE_Maintenance_Mode::instance()->level() |
|
1016 | - || ( |
|
1017 | - is_admin() |
|
1018 | - && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1019 | - ) |
|
1020 | - ) { |
|
1021 | - // grab list of installed widgets |
|
1022 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1023 | - // filter list of modules to register |
|
1024 | - $widgets_to_register = apply_filters( |
|
1025 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1026 | - $widgets_to_register |
|
1027 | - ); |
|
1028 | - if (! empty($widgets_to_register)) { |
|
1029 | - // cycle thru widget folders |
|
1030 | - foreach ($widgets_to_register as $widget_path) { |
|
1031 | - // add to list of installed widget modules |
|
1032 | - EE_Config::register_ee_widget($widget_path); |
|
1033 | - } |
|
1034 | - } |
|
1035 | - // filter list of installed modules |
|
1036 | - EE_Registry::instance()->widgets = apply_filters( |
|
1037 | - 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1038 | - EE_Registry::instance()->widgets |
|
1039 | - ); |
|
1040 | - } |
|
1041 | - } |
|
1042 | - |
|
1043 | - |
|
1044 | - /** |
|
1045 | - * register_ee_widget - makes core aware of this widget |
|
1046 | - * |
|
1047 | - * @access public |
|
1048 | - * @param string $widget_path - full path up to and including widget folder |
|
1049 | - * @return void |
|
1050 | - */ |
|
1051 | - public static function register_ee_widget($widget_path = null) |
|
1052 | - { |
|
1053 | - do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1054 | - $widget_ext = '.widget.php'; |
|
1055 | - // make all separators match |
|
1056 | - $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1057 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1058 | - if (strpos($widget_path, $widget_ext) !== false) { |
|
1059 | - // grab and shortcode file name from directory name and break apart at dots |
|
1060 | - $file_name = explode('.', basename($widget_path)); |
|
1061 | - // take first segment from file name pieces and remove class prefix if it exists |
|
1062 | - $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1063 | - // sanitize shortcode directory name |
|
1064 | - $widget = sanitize_key($widget); |
|
1065 | - // now we need to rebuild the shortcode path |
|
1066 | - $widget_path = explode(DS, $widget_path); |
|
1067 | - // remove last segment |
|
1068 | - array_pop($widget_path); |
|
1069 | - // glue it back together |
|
1070 | - $widget_path = implode(DS, $widget_path); |
|
1071 | - } else { |
|
1072 | - // grab and sanitize widget directory name |
|
1073 | - $widget = sanitize_key(basename($widget_path)); |
|
1074 | - } |
|
1075 | - // create classname from widget directory name |
|
1076 | - $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1077 | - // add class prefix |
|
1078 | - $widget_class = 'EEW_' . $widget; |
|
1079 | - // does the widget exist ? |
|
1080 | - if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1081 | - $msg = sprintf( |
|
1082 | - __( |
|
1083 | - 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1084 | - 'event_espresso' |
|
1085 | - ), |
|
1086 | - $widget_class, |
|
1087 | - $widget_path . DS . $widget_class . $widget_ext |
|
1088 | - ); |
|
1089 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1090 | - return; |
|
1091 | - } |
|
1092 | - // load the widget class file |
|
1093 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1094 | - // verify that class exists |
|
1095 | - if (! class_exists($widget_class)) { |
|
1096 | - $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1097 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1098 | - return; |
|
1099 | - } |
|
1100 | - register_widget($widget_class); |
|
1101 | - // add to array of registered widgets |
|
1102 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1103 | - } |
|
1104 | - |
|
1105 | - |
|
1106 | - /** |
|
1107 | - * _register_modules |
|
1108 | - * |
|
1109 | - * @access private |
|
1110 | - * @return array |
|
1111 | - */ |
|
1112 | - private function _register_modules() |
|
1113 | - { |
|
1114 | - // grab list of installed modules |
|
1115 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1116 | - // filter list of modules to register |
|
1117 | - $modules_to_register = apply_filters( |
|
1118 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1119 | - $modules_to_register |
|
1120 | - ); |
|
1121 | - if (! empty($modules_to_register)) { |
|
1122 | - // loop through folders |
|
1123 | - foreach ($modules_to_register as $module_path) { |
|
1124 | - /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1125 | - if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1126 | - && $module_path !== EE_MODULES . 'gateways' |
|
1127 | - ) { |
|
1128 | - // add to list of installed modules |
|
1129 | - EE_Config::register_module($module_path); |
|
1130 | - } |
|
1131 | - } |
|
1132 | - } |
|
1133 | - // filter list of installed modules |
|
1134 | - return apply_filters( |
|
1135 | - 'FHEE__EE_Config___register_modules__installed_modules', |
|
1136 | - EE_Registry::instance()->modules |
|
1137 | - ); |
|
1138 | - } |
|
1139 | - |
|
1140 | - |
|
1141 | - /** |
|
1142 | - * register_module - makes core aware of this module |
|
1143 | - * |
|
1144 | - * @access public |
|
1145 | - * @param string $module_path - full path up to and including module folder |
|
1146 | - * @return bool |
|
1147 | - */ |
|
1148 | - public static function register_module($module_path = null) |
|
1149 | - { |
|
1150 | - do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1151 | - $module_ext = '.module.php'; |
|
1152 | - // make all separators match |
|
1153 | - $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1154 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1155 | - if (strpos($module_path, $module_ext) !== false) { |
|
1156 | - // grab and shortcode file name from directory name and break apart at dots |
|
1157 | - $module_file = explode('.', basename($module_path)); |
|
1158 | - // now we need to rebuild the shortcode path |
|
1159 | - $module_path = explode(DS, $module_path); |
|
1160 | - // remove last segment |
|
1161 | - array_pop($module_path); |
|
1162 | - // glue it back together |
|
1163 | - $module_path = implode(DS, $module_path) . DS; |
|
1164 | - // take first segment from file name pieces and sanitize it |
|
1165 | - $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1166 | - // ensure class prefix is added |
|
1167 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1168 | - } else { |
|
1169 | - // we need to generate the filename based off of the folder name |
|
1170 | - // grab and sanitize module name |
|
1171 | - $module = strtolower(basename($module_path)); |
|
1172 | - $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1173 | - // like trailingslashit() |
|
1174 | - $module_path = rtrim($module_path, DS) . DS; |
|
1175 | - // create classname from module directory name |
|
1176 | - $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1177 | - // add class prefix |
|
1178 | - $module_class = 'EED_' . $module; |
|
1179 | - } |
|
1180 | - // does the module exist ? |
|
1181 | - if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1182 | - $msg = sprintf( |
|
1183 | - __( |
|
1184 | - 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1185 | - 'event_espresso' |
|
1186 | - ), |
|
1187 | - $module |
|
1188 | - ); |
|
1189 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1190 | - return false; |
|
1191 | - } |
|
1192 | - // load the module class file |
|
1193 | - require_once($module_path . $module_class . $module_ext); |
|
1194 | - // verify that class exists |
|
1195 | - if (! class_exists($module_class)) { |
|
1196 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1197 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1198 | - return false; |
|
1199 | - } |
|
1200 | - // add to array of registered modules |
|
1201 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1202 | - do_action( |
|
1203 | - 'AHEE__EE_Config__register_module__complete', |
|
1204 | - $module_class, |
|
1205 | - EE_Registry::instance()->modules->{$module_class} |
|
1206 | - ); |
|
1207 | - return true; |
|
1208 | - } |
|
1209 | - |
|
1210 | - |
|
1211 | - /** |
|
1212 | - * _initialize_modules |
|
1213 | - * allow modules to set hooks for the rest of the system |
|
1214 | - * |
|
1215 | - * @access private |
|
1216 | - * @return void |
|
1217 | - */ |
|
1218 | - private function _initialize_modules() |
|
1219 | - { |
|
1220 | - // cycle thru shortcode folders |
|
1221 | - foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1222 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1223 | - // which set hooks ? |
|
1224 | - if (is_admin()) { |
|
1225 | - // fire immediately |
|
1226 | - call_user_func(array($module_class, 'set_hooks_admin')); |
|
1227 | - } else { |
|
1228 | - // delay until other systems are online |
|
1229 | - add_action( |
|
1230 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1231 | - array($module_class, 'set_hooks') |
|
1232 | - ); |
|
1233 | - } |
|
1234 | - } |
|
1235 | - } |
|
1236 | - |
|
1237 | - |
|
1238 | - /** |
|
1239 | - * register_route - adds module method routes to route_map |
|
1240 | - * |
|
1241 | - * @access public |
|
1242 | - * @param string $route - "pretty" public alias for module method |
|
1243 | - * @param string $module - module name (classname without EED_ prefix) |
|
1244 | - * @param string $method_name - the actual module method to be routed to |
|
1245 | - * @param string $key - url param key indicating a route is being called |
|
1246 | - * @return bool |
|
1247 | - */ |
|
1248 | - public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1249 | - { |
|
1250 | - do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1251 | - $module = str_replace('EED_', '', $module); |
|
1252 | - $module_class = 'EED_' . $module; |
|
1253 | - if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1254 | - $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1255 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1256 | - return false; |
|
1257 | - } |
|
1258 | - if (empty($route)) { |
|
1259 | - $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1260 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1261 | - return false; |
|
1262 | - } |
|
1263 | - if (! method_exists('EED_' . $module, $method_name)) { |
|
1264 | - $msg = sprintf( |
|
1265 | - __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1266 | - $route |
|
1267 | - ); |
|
1268 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1269 | - return false; |
|
1270 | - } |
|
1271 | - EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name); |
|
1272 | - return true; |
|
1273 | - } |
|
1274 | - |
|
1275 | - |
|
1276 | - /** |
|
1277 | - * get_route - get module method route |
|
1278 | - * |
|
1279 | - * @access public |
|
1280 | - * @param string $route - "pretty" public alias for module method |
|
1281 | - * @param string $key - url param key indicating a route is being called |
|
1282 | - * @return string |
|
1283 | - */ |
|
1284 | - public static function get_route($route = null, $key = 'ee') |
|
1285 | - { |
|
1286 | - do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1287 | - $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
1288 | - if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) { |
|
1289 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1290 | - } |
|
1291 | - return null; |
|
1292 | - } |
|
1293 | - |
|
1294 | - |
|
1295 | - /** |
|
1296 | - * get_routes - get ALL module method routes |
|
1297 | - * |
|
1298 | - * @access public |
|
1299 | - * @return array |
|
1300 | - */ |
|
1301 | - public static function get_routes() |
|
1302 | - { |
|
1303 | - return EE_Config::$_module_route_map; |
|
1304 | - } |
|
1305 | - |
|
1306 | - |
|
1307 | - /** |
|
1308 | - * register_forward - allows modules to forward request to another module for further processing |
|
1309 | - * |
|
1310 | - * @access public |
|
1311 | - * @param string $route - "pretty" public alias for module method |
|
1312 | - * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1313 | - * class, allows different forwards to be served based on status |
|
1314 | - * @param array|string $forward - function name or array( class, method ) |
|
1315 | - * @param string $key - url param key indicating a route is being called |
|
1316 | - * @return bool |
|
1317 | - */ |
|
1318 | - public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1319 | - { |
|
1320 | - do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1321 | - if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1322 | - $msg = sprintf( |
|
1323 | - __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1324 | - $route |
|
1325 | - ); |
|
1326 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1327 | - return false; |
|
1328 | - } |
|
1329 | - if (empty($forward)) { |
|
1330 | - $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1331 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1332 | - return false; |
|
1333 | - } |
|
1334 | - if (is_array($forward)) { |
|
1335 | - if (! isset($forward[1])) { |
|
1336 | - $msg = sprintf( |
|
1337 | - __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1338 | - $route |
|
1339 | - ); |
|
1340 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1341 | - return false; |
|
1342 | - } |
|
1343 | - if (! method_exists($forward[0], $forward[1])) { |
|
1344 | - $msg = sprintf( |
|
1345 | - __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1346 | - $forward[1], |
|
1347 | - $route |
|
1348 | - ); |
|
1349 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1350 | - return false; |
|
1351 | - } |
|
1352 | - } elseif (! function_exists($forward)) { |
|
1353 | - $msg = sprintf( |
|
1354 | - __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1355 | - $forward, |
|
1356 | - $route |
|
1357 | - ); |
|
1358 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1359 | - return false; |
|
1360 | - } |
|
1361 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward; |
|
1362 | - return true; |
|
1363 | - } |
|
1364 | - |
|
1365 | - |
|
1366 | - /** |
|
1367 | - * get_forward - get forwarding route |
|
1368 | - * |
|
1369 | - * @access public |
|
1370 | - * @param string $route - "pretty" public alias for module method |
|
1371 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1372 | - * allows different forwards to be served based on status |
|
1373 | - * @param string $key - url param key indicating a route is being called |
|
1374 | - * @return string |
|
1375 | - */ |
|
1376 | - public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1377 | - { |
|
1378 | - do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1379 | - if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) { |
|
1380 | - return apply_filters( |
|
1381 | - 'FHEE__EE_Config__get_forward', |
|
1382 | - EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], |
|
1383 | - $route, |
|
1384 | - $status |
|
1385 | - ); |
|
1386 | - } |
|
1387 | - return null; |
|
1388 | - } |
|
1389 | - |
|
1390 | - |
|
1391 | - /** |
|
1392 | - * register_forward - allows modules to specify different view templates for different method routes and status |
|
1393 | - * results |
|
1394 | - * |
|
1395 | - * @access public |
|
1396 | - * @param string $route - "pretty" public alias for module method |
|
1397 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1398 | - * allows different views to be served based on status |
|
1399 | - * @param string $view |
|
1400 | - * @param string $key - url param key indicating a route is being called |
|
1401 | - * @return bool |
|
1402 | - */ |
|
1403 | - public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1404 | - { |
|
1405 | - do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1406 | - if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1407 | - $msg = sprintf( |
|
1408 | - __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1409 | - $route |
|
1410 | - ); |
|
1411 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1412 | - return false; |
|
1413 | - } |
|
1414 | - if (! is_readable($view)) { |
|
1415 | - $msg = sprintf( |
|
1416 | - __( |
|
1417 | - 'The %s view file could not be found or is not readable due to file permissions.', |
|
1418 | - 'event_espresso' |
|
1419 | - ), |
|
1420 | - $view |
|
1421 | - ); |
|
1422 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1423 | - return false; |
|
1424 | - } |
|
1425 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view; |
|
1426 | - return true; |
|
1427 | - } |
|
1428 | - |
|
1429 | - |
|
1430 | - /** |
|
1431 | - * get_view - get view for route and status |
|
1432 | - * |
|
1433 | - * @access public |
|
1434 | - * @param string $route - "pretty" public alias for module method |
|
1435 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1436 | - * allows different views to be served based on status |
|
1437 | - * @param string $key - url param key indicating a route is being called |
|
1438 | - * @return string |
|
1439 | - */ |
|
1440 | - public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1441 | - { |
|
1442 | - do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1443 | - if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) { |
|
1444 | - return apply_filters( |
|
1445 | - 'FHEE__EE_Config__get_view', |
|
1446 | - EE_Config::$_module_view_map[ $key ][ $route ][ $status ], |
|
1447 | - $route, |
|
1448 | - $status |
|
1449 | - ); |
|
1450 | - } |
|
1451 | - return null; |
|
1452 | - } |
|
1453 | - |
|
1454 | - |
|
1455 | - public function update_addon_option_names() |
|
1456 | - { |
|
1457 | - update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1458 | - } |
|
1459 | - |
|
1460 | - |
|
1461 | - public function shutdown() |
|
1462 | - { |
|
1463 | - $this->update_addon_option_names(); |
|
1464 | - } |
|
1465 | - |
|
1466 | - |
|
1467 | - /** |
|
1468 | - * @return LegacyShortcodesManager |
|
1469 | - */ |
|
1470 | - public static function getLegacyShortcodesManager() |
|
1471 | - { |
|
1472 | - |
|
1473 | - if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1474 | - EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
1475 | - EE_Registry::instance() |
|
1476 | - ); |
|
1477 | - } |
|
1478 | - return EE_Config::instance()->legacy_shortcodes_manager; |
|
1479 | - } |
|
1480 | - |
|
1481 | - |
|
1482 | - /** |
|
1483 | - * register_shortcode - makes core aware of this shortcode |
|
1484 | - * |
|
1485 | - * @deprecated 4.9.26 |
|
1486 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
1487 | - * @return bool |
|
1488 | - */ |
|
1489 | - public static function register_shortcode($shortcode_path = null) |
|
1490 | - { |
|
1491 | - EE_Error::doing_it_wrong( |
|
1492 | - __METHOD__, |
|
1493 | - __( |
|
1494 | - 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
1495 | - 'event_espresso' |
|
1496 | - ), |
|
1497 | - '4.9.26' |
|
1498 | - ); |
|
1499 | - return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
1500 | - } |
|
1501 | -} |
|
1502 | - |
|
1503 | -/** |
|
1504 | - * Base class used for config classes. These classes should generally not have |
|
1505 | - * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1506 | - * basically, they should just be well-defined stdClasses |
|
1507 | - */ |
|
1508 | -class EE_Config_Base |
|
1509 | -{ |
|
1510 | - |
|
1511 | - /** |
|
1512 | - * Utility function for escaping the value of a property and returning. |
|
1513 | - * |
|
1514 | - * @param string $property property name (checks to see if exists). |
|
1515 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1516 | - * @throws \EE_Error |
|
1517 | - */ |
|
1518 | - public function get_pretty($property) |
|
1519 | - { |
|
1520 | - if (! property_exists($this, $property)) { |
|
1521 | - throw new EE_Error( |
|
1522 | - sprintf( |
|
1523 | - __( |
|
1524 | - '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1525 | - 'event_espresso' |
|
1526 | - ), |
|
1527 | - get_class($this), |
|
1528 | - $property |
|
1529 | - ) |
|
1530 | - ); |
|
1531 | - } |
|
1532 | - // just handling escaping of strings for now. |
|
1533 | - if (is_string($this->{$property})) { |
|
1534 | - return stripslashes($this->{$property}); |
|
1535 | - } |
|
1536 | - return $this->{$property}; |
|
1537 | - } |
|
1538 | - |
|
1539 | - |
|
1540 | - public function populate() |
|
1541 | - { |
|
1542 | - // grab defaults via a new instance of this class. |
|
1543 | - $class_name = get_class($this); |
|
1544 | - $defaults = new $class_name; |
|
1545 | - // loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1546 | - // default from our $defaults object. |
|
1547 | - foreach (get_object_vars($defaults) as $property => $value) { |
|
1548 | - if ($this->{$property} === null) { |
|
1549 | - $this->{$property} = $value; |
|
1550 | - } |
|
1551 | - } |
|
1552 | - // cleanup |
|
1553 | - unset($defaults); |
|
1554 | - } |
|
1555 | - |
|
1556 | - |
|
1557 | - /** |
|
1558 | - * __isset |
|
1559 | - * |
|
1560 | - * @param $a |
|
1561 | - * @return bool |
|
1562 | - */ |
|
1563 | - public function __isset($a) |
|
1564 | - { |
|
1565 | - return false; |
|
1566 | - } |
|
1567 | - |
|
1568 | - |
|
1569 | - /** |
|
1570 | - * __unset |
|
1571 | - * |
|
1572 | - * @param $a |
|
1573 | - * @return bool |
|
1574 | - */ |
|
1575 | - public function __unset($a) |
|
1576 | - { |
|
1577 | - return false; |
|
1578 | - } |
|
1579 | - |
|
1580 | - |
|
1581 | - /** |
|
1582 | - * __clone |
|
1583 | - */ |
|
1584 | - public function __clone() |
|
1585 | - { |
|
1586 | - } |
|
1587 | - |
|
1588 | - |
|
1589 | - /** |
|
1590 | - * __wakeup |
|
1591 | - */ |
|
1592 | - public function __wakeup() |
|
1593 | - { |
|
1594 | - } |
|
1595 | - |
|
1596 | - |
|
1597 | - /** |
|
1598 | - * __destruct |
|
1599 | - */ |
|
1600 | - public function __destruct() |
|
1601 | - { |
|
1602 | - } |
|
1603 | -} |
|
1604 | - |
|
1605 | - |
|
1606 | -/** |
|
1607 | - * Class for defining what's in the EE_Config relating to registration settings |
|
1608 | - */ |
|
1609 | -class EE_Core_Config extends EE_Config_Base |
|
1610 | -{ |
|
1611 | - |
|
1612 | - public $current_blog_id; |
|
1613 | - |
|
1614 | - public $ee_ueip_optin; |
|
1615 | - |
|
1616 | - public $ee_ueip_has_notified; |
|
1617 | - |
|
1618 | - /** |
|
1619 | - * Not to be confused with the 4 critical page variables (See |
|
1620 | - * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1621 | - * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1622 | - * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1623 | - * |
|
1624 | - * @var array |
|
1625 | - */ |
|
1626 | - public $post_shortcodes; |
|
1627 | - |
|
1628 | - public $module_route_map; |
|
1629 | - |
|
1630 | - public $module_forward_map; |
|
1631 | - |
|
1632 | - public $module_view_map; |
|
1633 | - |
|
1634 | - /** |
|
1635 | - * The next 4 vars are the IDs of critical EE pages. |
|
1636 | - * |
|
1637 | - * @var int |
|
1638 | - */ |
|
1639 | - public $reg_page_id; |
|
1640 | - |
|
1641 | - public $txn_page_id; |
|
1642 | - |
|
1643 | - public $thank_you_page_id; |
|
1644 | - |
|
1645 | - public $cancel_page_id; |
|
1646 | - |
|
1647 | - /** |
|
1648 | - * The next 4 vars are the URLs of critical EE pages. |
|
1649 | - * |
|
1650 | - * @var int |
|
1651 | - */ |
|
1652 | - public $reg_page_url; |
|
1653 | - |
|
1654 | - public $txn_page_url; |
|
1655 | - |
|
1656 | - public $thank_you_page_url; |
|
1657 | - |
|
1658 | - public $cancel_page_url; |
|
1659 | - |
|
1660 | - /** |
|
1661 | - * The next vars relate to the custom slugs for EE CPT routes |
|
1662 | - */ |
|
1663 | - public $event_cpt_slug; |
|
1664 | - |
|
1665 | - |
|
1666 | - /** |
|
1667 | - * This caches the _ee_ueip_option in case this config is reset in the same |
|
1668 | - * request across blog switches in a multisite context. |
|
1669 | - * Avoids extra queries to the db for this option. |
|
1670 | - * |
|
1671 | - * @var bool |
|
1672 | - */ |
|
1673 | - public static $ee_ueip_option; |
|
1674 | - |
|
1675 | - |
|
1676 | - /** |
|
1677 | - * class constructor |
|
1678 | - * |
|
1679 | - * @access public |
|
1680 | - */ |
|
1681 | - public function __construct() |
|
1682 | - { |
|
1683 | - // set default organization settings |
|
1684 | - $this->current_blog_id = get_current_blog_id(); |
|
1685 | - $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1686 | - $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1687 | - $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1688 | - $this->post_shortcodes = array(); |
|
1689 | - $this->module_route_map = array(); |
|
1690 | - $this->module_forward_map = array(); |
|
1691 | - $this->module_view_map = array(); |
|
1692 | - // critical EE page IDs |
|
1693 | - $this->reg_page_id = 0; |
|
1694 | - $this->txn_page_id = 0; |
|
1695 | - $this->thank_you_page_id = 0; |
|
1696 | - $this->cancel_page_id = 0; |
|
1697 | - // critical EE page URLs |
|
1698 | - $this->reg_page_url = ''; |
|
1699 | - $this->txn_page_url = ''; |
|
1700 | - $this->thank_you_page_url = ''; |
|
1701 | - $this->cancel_page_url = ''; |
|
1702 | - // cpt slugs |
|
1703 | - $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1704 | - // ueip constant check |
|
1705 | - if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1706 | - $this->ee_ueip_optin = false; |
|
1707 | - $this->ee_ueip_has_notified = true; |
|
1708 | - } |
|
1709 | - } |
|
1710 | - |
|
1711 | - |
|
1712 | - /** |
|
1713 | - * @return array |
|
1714 | - */ |
|
1715 | - public function get_critical_pages_array() |
|
1716 | - { |
|
1717 | - return array( |
|
1718 | - $this->reg_page_id, |
|
1719 | - $this->txn_page_id, |
|
1720 | - $this->thank_you_page_id, |
|
1721 | - $this->cancel_page_id, |
|
1722 | - ); |
|
1723 | - } |
|
1724 | - |
|
1725 | - |
|
1726 | - /** |
|
1727 | - * @return array |
|
1728 | - */ |
|
1729 | - public function get_critical_pages_shortcodes_array() |
|
1730 | - { |
|
1731 | - return array( |
|
1732 | - $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1733 | - $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1734 | - $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1735 | - $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1736 | - ); |
|
1737 | - } |
|
1738 | - |
|
1739 | - |
|
1740 | - /** |
|
1741 | - * gets/returns URL for EE reg_page |
|
1742 | - * |
|
1743 | - * @access public |
|
1744 | - * @return string |
|
1745 | - */ |
|
1746 | - public function reg_page_url() |
|
1747 | - { |
|
1748 | - if (! $this->reg_page_url) { |
|
1749 | - $this->reg_page_url = add_query_arg( |
|
1750 | - array('uts' => time()), |
|
1751 | - get_permalink($this->reg_page_id) |
|
1752 | - ) . '#checkout'; |
|
1753 | - } |
|
1754 | - return $this->reg_page_url; |
|
1755 | - } |
|
1756 | - |
|
1757 | - |
|
1758 | - /** |
|
1759 | - * gets/returns URL for EE txn_page |
|
1760 | - * |
|
1761 | - * @param array $query_args like what gets passed to |
|
1762 | - * add_query_arg() as the first argument |
|
1763 | - * @access public |
|
1764 | - * @return string |
|
1765 | - */ |
|
1766 | - public function txn_page_url($query_args = array()) |
|
1767 | - { |
|
1768 | - if (! $this->txn_page_url) { |
|
1769 | - $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1770 | - } |
|
1771 | - if ($query_args) { |
|
1772 | - return add_query_arg($query_args, $this->txn_page_url); |
|
1773 | - } else { |
|
1774 | - return $this->txn_page_url; |
|
1775 | - } |
|
1776 | - } |
|
1777 | - |
|
1778 | - |
|
1779 | - /** |
|
1780 | - * gets/returns URL for EE thank_you_page |
|
1781 | - * |
|
1782 | - * @param array $query_args like what gets passed to |
|
1783 | - * add_query_arg() as the first argument |
|
1784 | - * @access public |
|
1785 | - * @return string |
|
1786 | - */ |
|
1787 | - public function thank_you_page_url($query_args = array()) |
|
1788 | - { |
|
1789 | - if (! $this->thank_you_page_url) { |
|
1790 | - $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1791 | - } |
|
1792 | - if ($query_args) { |
|
1793 | - return add_query_arg($query_args, $this->thank_you_page_url); |
|
1794 | - } else { |
|
1795 | - return $this->thank_you_page_url; |
|
1796 | - } |
|
1797 | - } |
|
1798 | - |
|
1799 | - |
|
1800 | - /** |
|
1801 | - * gets/returns URL for EE cancel_page |
|
1802 | - * |
|
1803 | - * @access public |
|
1804 | - * @return string |
|
1805 | - */ |
|
1806 | - public function cancel_page_url() |
|
1807 | - { |
|
1808 | - if (! $this->cancel_page_url) { |
|
1809 | - $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1810 | - } |
|
1811 | - return $this->cancel_page_url; |
|
1812 | - } |
|
1813 | - |
|
1814 | - |
|
1815 | - /** |
|
1816 | - * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1817 | - * |
|
1818 | - * @since 4.7.5 |
|
1819 | - */ |
|
1820 | - protected function _reset_urls() |
|
1821 | - { |
|
1822 | - $this->reg_page_url = ''; |
|
1823 | - $this->txn_page_url = ''; |
|
1824 | - $this->cancel_page_url = ''; |
|
1825 | - $this->thank_you_page_url = ''; |
|
1826 | - } |
|
1827 | - |
|
1828 | - |
|
1829 | - /** |
|
1830 | - * Used to return what the optin value is set for the EE User Experience Program. |
|
1831 | - * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1832 | - * on the main site only. |
|
1833 | - * |
|
1834 | - * @return mixed|void |
|
1835 | - */ |
|
1836 | - protected function _get_main_ee_ueip_optin() |
|
1837 | - { |
|
1838 | - // if this is the main site then we can just bypass our direct query. |
|
1839 | - if (is_main_site()) { |
|
1840 | - return get_option('ee_ueip_optin', false); |
|
1841 | - } |
|
1842 | - // is this already cached for this request? If so use it. |
|
1843 | - if (! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1844 | - return EE_Core_Config::$ee_ueip_option; |
|
1845 | - } |
|
1846 | - global $wpdb; |
|
1847 | - $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1848 | - $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1849 | - $option = 'ee_ueip_optin'; |
|
1850 | - // set correct table for query |
|
1851 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1852 | - // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1853 | - // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1854 | - // re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1855 | - // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1856 | - // for the purpose of caching. |
|
1857 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1858 | - if (false !== $pre) { |
|
1859 | - EE_Core_Config::$ee_ueip_option = $pre; |
|
1860 | - return EE_Core_Config::$ee_ueip_option; |
|
1861 | - } |
|
1862 | - $row = $wpdb->get_row( |
|
1863 | - $wpdb->prepare( |
|
1864 | - "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
1865 | - $option |
|
1866 | - ) |
|
1867 | - ); |
|
1868 | - if (is_object($row)) { |
|
1869 | - $value = $row->option_value; |
|
1870 | - } else { // option does not exist so use default. |
|
1871 | - return apply_filters('default_option_' . $option, false, $option); |
|
1872 | - } |
|
1873 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1874 | - return EE_Core_Config::$ee_ueip_option; |
|
1875 | - } |
|
1876 | - |
|
1877 | - /** |
|
1878 | - * Utility function for escaping the value of a property and returning. |
|
1879 | - * |
|
1880 | - * @param string $property property name (checks to see if exists). |
|
1881 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1882 | - * @throws \EE_Error |
|
1883 | - */ |
|
1884 | - public function get_pretty($property) |
|
1885 | - { |
|
1886 | - if ($property === 'ee_ueip_optin') { |
|
1887 | - return $this->ee_ueip_optin ? 'yes' : 'no'; |
|
1888 | - } |
|
1889 | - return parent::get_pretty($property); |
|
1890 | - } |
|
1891 | - |
|
1892 | - |
|
1893 | - /** |
|
1894 | - * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
1895 | - * on the object. |
|
1896 | - * |
|
1897 | - * @return array |
|
1898 | - */ |
|
1899 | - public function __sleep() |
|
1900 | - { |
|
1901 | - // reset all url properties |
|
1902 | - $this->_reset_urls(); |
|
1903 | - // return what to save to db |
|
1904 | - return array_keys(get_object_vars($this)); |
|
1905 | - } |
|
1906 | -} |
|
1907 | - |
|
1908 | - |
|
1909 | -/** |
|
1910 | - * Config class for storing info on the Organization |
|
1911 | - */ |
|
1912 | -class EE_Organization_Config extends EE_Config_Base |
|
1913 | -{ |
|
1914 | - |
|
1915 | - /** |
|
1916 | - * @var string $name |
|
1917 | - * eg EE4.1 |
|
1918 | - */ |
|
1919 | - public $name; |
|
1920 | - |
|
1921 | - /** |
|
1922 | - * @var string $address_1 |
|
1923 | - * eg 123 Onna Road |
|
1924 | - */ |
|
1925 | - public $address_1; |
|
1926 | - |
|
1927 | - /** |
|
1928 | - * @var string $address_2 |
|
1929 | - * eg PO Box 123 |
|
1930 | - */ |
|
1931 | - public $address_2; |
|
1932 | - |
|
1933 | - /** |
|
1934 | - * @var string $city |
|
1935 | - * eg Inna City |
|
1936 | - */ |
|
1937 | - public $city; |
|
1938 | - |
|
1939 | - /** |
|
1940 | - * @var int $STA_ID |
|
1941 | - * eg 4 |
|
1942 | - */ |
|
1943 | - public $STA_ID; |
|
1944 | - |
|
1945 | - /** |
|
1946 | - * @var string $CNT_ISO |
|
1947 | - * eg US |
|
1948 | - */ |
|
1949 | - public $CNT_ISO; |
|
1950 | - |
|
1951 | - /** |
|
1952 | - * @var string $zip |
|
1953 | - * eg 12345 or V1A 2B3 |
|
1954 | - */ |
|
1955 | - public $zip; |
|
1956 | - |
|
1957 | - /** |
|
1958 | - * @var string $email |
|
1959 | - * eg [email protected] |
|
1960 | - */ |
|
1961 | - public $email; |
|
1962 | - |
|
1963 | - |
|
1964 | - /** |
|
1965 | - * @var string $phone |
|
1966 | - * eg. 111-111-1111 |
|
1967 | - */ |
|
1968 | - public $phone; |
|
1969 | - |
|
1970 | - |
|
1971 | - /** |
|
1972 | - * @var string $vat |
|
1973 | - * VAT/Tax Number |
|
1974 | - */ |
|
1975 | - public $vat; |
|
1976 | - |
|
1977 | - /** |
|
1978 | - * @var string $logo_url |
|
1979 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
1980 | - */ |
|
1981 | - public $logo_url; |
|
1982 | - |
|
1983 | - |
|
1984 | - /** |
|
1985 | - * The below are all various properties for holding links to organization social network profiles |
|
1986 | - * |
|
1987 | - * @var string |
|
1988 | - */ |
|
1989 | - /** |
|
1990 | - * facebook (facebook.com/profile.name) |
|
1991 | - * |
|
1992 | - * @var string |
|
1993 | - */ |
|
1994 | - public $facebook; |
|
1995 | - |
|
1996 | - |
|
1997 | - /** |
|
1998 | - * twitter (twitter.com/twitter_handle) |
|
1999 | - * |
|
2000 | - * @var string |
|
2001 | - */ |
|
2002 | - public $twitter; |
|
2003 | - |
|
2004 | - |
|
2005 | - /** |
|
2006 | - * linkedin (linkedin.com/in/profile_name) |
|
2007 | - * |
|
2008 | - * @var string |
|
2009 | - */ |
|
2010 | - public $linkedin; |
|
2011 | - |
|
2012 | - |
|
2013 | - /** |
|
2014 | - * pinterest (www.pinterest.com/profile_name) |
|
2015 | - * |
|
2016 | - * @var string |
|
2017 | - */ |
|
2018 | - public $pinterest; |
|
2019 | - |
|
2020 | - |
|
2021 | - /** |
|
2022 | - * google+ (google.com/+profileName) |
|
2023 | - * |
|
2024 | - * @var string |
|
2025 | - */ |
|
2026 | - public $google; |
|
2027 | - |
|
2028 | - |
|
2029 | - /** |
|
2030 | - * instagram (instagram.com/handle) |
|
2031 | - * |
|
2032 | - * @var string |
|
2033 | - */ |
|
2034 | - public $instagram; |
|
2035 | - |
|
2036 | - |
|
2037 | - /** |
|
2038 | - * class constructor |
|
2039 | - * |
|
2040 | - * @access public |
|
2041 | - */ |
|
2042 | - public function __construct() |
|
2043 | - { |
|
2044 | - // set default organization settings |
|
2045 | - // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
2046 | - $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
2047 | - $this->address_1 = '123 Onna Road'; |
|
2048 | - $this->address_2 = 'PO Box 123'; |
|
2049 | - $this->city = 'Inna City'; |
|
2050 | - $this->STA_ID = 4; |
|
2051 | - $this->CNT_ISO = 'US'; |
|
2052 | - $this->zip = '12345'; |
|
2053 | - $this->email = get_bloginfo('admin_email'); |
|
2054 | - $this->phone = ''; |
|
2055 | - $this->vat = '123456789'; |
|
2056 | - $this->logo_url = ''; |
|
2057 | - $this->facebook = ''; |
|
2058 | - $this->twitter = ''; |
|
2059 | - $this->linkedin = ''; |
|
2060 | - $this->pinterest = ''; |
|
2061 | - $this->google = ''; |
|
2062 | - $this->instagram = ''; |
|
2063 | - } |
|
2064 | -} |
|
2065 | - |
|
2066 | - |
|
2067 | -/** |
|
2068 | - * Class for defining what's in the EE_Config relating to currency |
|
2069 | - */ |
|
2070 | -class EE_Currency_Config extends EE_Config_Base |
|
2071 | -{ |
|
2072 | - |
|
2073 | - /** |
|
2074 | - * @var string $code |
|
2075 | - * eg 'US' |
|
2076 | - */ |
|
2077 | - public $code; |
|
2078 | - |
|
2079 | - /** |
|
2080 | - * @var string $name |
|
2081 | - * eg 'Dollar' |
|
2082 | - */ |
|
2083 | - public $name; |
|
2084 | - |
|
2085 | - /** |
|
2086 | - * plural name |
|
2087 | - * |
|
2088 | - * @var string $plural |
|
2089 | - * eg 'Dollars' |
|
2090 | - */ |
|
2091 | - public $plural; |
|
2092 | - |
|
2093 | - /** |
|
2094 | - * currency sign |
|
2095 | - * |
|
2096 | - * @var string $sign |
|
2097 | - * eg '$' |
|
2098 | - */ |
|
2099 | - public $sign; |
|
2100 | - |
|
2101 | - /** |
|
2102 | - * Whether the currency sign should come before the number or not |
|
2103 | - * |
|
2104 | - * @var boolean $sign_b4 |
|
2105 | - */ |
|
2106 | - public $sign_b4; |
|
2107 | - |
|
2108 | - /** |
|
2109 | - * How many digits should come after the decimal place |
|
2110 | - * |
|
2111 | - * @var int $dec_plc |
|
2112 | - */ |
|
2113 | - public $dec_plc; |
|
2114 | - |
|
2115 | - /** |
|
2116 | - * Symbol to use for decimal mark |
|
2117 | - * |
|
2118 | - * @var string $dec_mrk |
|
2119 | - * eg '.' |
|
2120 | - */ |
|
2121 | - public $dec_mrk; |
|
2122 | - |
|
2123 | - /** |
|
2124 | - * Symbol to use for thousands |
|
2125 | - * |
|
2126 | - * @var string $thsnds |
|
2127 | - * eg ',' |
|
2128 | - */ |
|
2129 | - public $thsnds; |
|
16 | + const OPTION_NAME = 'ee_config'; |
|
17 | + |
|
18 | + const LOG_NAME = 'ee_config_log'; |
|
19 | + |
|
20 | + const LOG_LENGTH = 100; |
|
21 | + |
|
22 | + const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * instance of the EE_Config object |
|
27 | + * |
|
28 | + * @var EE_Config $_instance |
|
29 | + * @access private |
|
30 | + */ |
|
31 | + private static $_instance; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var boolean $_logging_enabled |
|
35 | + */ |
|
36 | + private static $_logging_enabled = false; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
40 | + */ |
|
41 | + private $legacy_shortcodes_manager; |
|
42 | + |
|
43 | + /** |
|
44 | + * An StdClass whose property names are addon slugs, |
|
45 | + * and values are their config classes |
|
46 | + * |
|
47 | + * @var StdClass |
|
48 | + */ |
|
49 | + public $addons; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var EE_Admin_Config |
|
53 | + */ |
|
54 | + public $admin; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var EE_Core_Config |
|
58 | + */ |
|
59 | + public $core; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var EE_Currency_Config |
|
63 | + */ |
|
64 | + public $currency; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var EE_Organization_Config |
|
68 | + */ |
|
69 | + public $organization; |
|
70 | + |
|
71 | + /** |
|
72 | + * @var EE_Registration_Config |
|
73 | + */ |
|
74 | + public $registration; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var EE_Template_Config |
|
78 | + */ |
|
79 | + public $template_settings; |
|
80 | + |
|
81 | + /** |
|
82 | + * Holds EE environment values. |
|
83 | + * |
|
84 | + * @var EE_Environment_Config |
|
85 | + */ |
|
86 | + public $environment; |
|
87 | + |
|
88 | + /** |
|
89 | + * settings pertaining to Google maps |
|
90 | + * |
|
91 | + * @var EE_Map_Config |
|
92 | + */ |
|
93 | + public $map_settings; |
|
94 | + |
|
95 | + /** |
|
96 | + * settings pertaining to Taxes |
|
97 | + * |
|
98 | + * @var EE_Tax_Config |
|
99 | + */ |
|
100 | + public $tax_settings; |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * Settings pertaining to global messages settings. |
|
105 | + * |
|
106 | + * @var EE_Messages_Config |
|
107 | + */ |
|
108 | + public $messages; |
|
109 | + |
|
110 | + /** |
|
111 | + * @deprecated |
|
112 | + * @var EE_Gateway_Config |
|
113 | + */ |
|
114 | + public $gateway; |
|
115 | + |
|
116 | + /** |
|
117 | + * @var array $_addon_option_names |
|
118 | + * @access private |
|
119 | + */ |
|
120 | + private $_addon_option_names = array(); |
|
121 | + |
|
122 | + /** |
|
123 | + * @var array $_module_route_map |
|
124 | + * @access private |
|
125 | + */ |
|
126 | + private static $_module_route_map = array(); |
|
127 | + |
|
128 | + /** |
|
129 | + * @var array $_module_forward_map |
|
130 | + * @access private |
|
131 | + */ |
|
132 | + private static $_module_forward_map = array(); |
|
133 | + |
|
134 | + /** |
|
135 | + * @var array $_module_view_map |
|
136 | + * @access private |
|
137 | + */ |
|
138 | + private static $_module_view_map = array(); |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @singleton method used to instantiate class object |
|
143 | + * @access public |
|
144 | + * @return EE_Config instance |
|
145 | + */ |
|
146 | + public static function instance() |
|
147 | + { |
|
148 | + // check if class object is instantiated, and instantiated properly |
|
149 | + if (! self::$_instance instanceof EE_Config) { |
|
150 | + self::$_instance = new self(); |
|
151 | + } |
|
152 | + return self::$_instance; |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * Resets the config |
|
158 | + * |
|
159 | + * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
160 | + * (default) leaves the database alone, and merely resets the EE_Config object to |
|
161 | + * reflect its state in the database |
|
162 | + * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
163 | + * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
164 | + * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
165 | + * site was put into maintenance mode) |
|
166 | + * @return EE_Config |
|
167 | + */ |
|
168 | + public static function reset($hard_reset = false, $reinstantiate = true) |
|
169 | + { |
|
170 | + if (self::$_instance instanceof EE_Config) { |
|
171 | + if ($hard_reset) { |
|
172 | + self::$_instance->legacy_shortcodes_manager = null; |
|
173 | + self::$_instance->_addon_option_names = array(); |
|
174 | + self::$_instance->_initialize_config(); |
|
175 | + self::$_instance->update_espresso_config(); |
|
176 | + } |
|
177 | + self::$_instance->update_addon_option_names(); |
|
178 | + } |
|
179 | + self::$_instance = null; |
|
180 | + // we don't need to reset the static properties imo because those should |
|
181 | + // only change when a module is added or removed. Currently we don't |
|
182 | + // support removing a module during a request when it previously existed |
|
183 | + if ($reinstantiate) { |
|
184 | + return self::instance(); |
|
185 | + } else { |
|
186 | + return null; |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * class constructor |
|
193 | + * |
|
194 | + * @access private |
|
195 | + */ |
|
196 | + private function __construct() |
|
197 | + { |
|
198 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
199 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
200 | + // setup empty config classes |
|
201 | + $this->_initialize_config(); |
|
202 | + // load existing EE site settings |
|
203 | + $this->_load_core_config(); |
|
204 | + // confirm everything loaded correctly and set filtered defaults if not |
|
205 | + $this->_verify_config(); |
|
206 | + // register shortcodes and modules |
|
207 | + add_action( |
|
208 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
209 | + array($this, 'register_shortcodes_and_modules'), |
|
210 | + 999 |
|
211 | + ); |
|
212 | + // initialize shortcodes and modules |
|
213 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
214 | + // register widgets |
|
215 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
216 | + // shutdown |
|
217 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
218 | + // construct__end hook |
|
219 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
220 | + // hardcoded hack |
|
221 | + $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + /** |
|
226 | + * @return boolean |
|
227 | + */ |
|
228 | + public static function logging_enabled() |
|
229 | + { |
|
230 | + return self::$_logging_enabled; |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * use to get the current theme if needed from static context |
|
236 | + * |
|
237 | + * @return string current theme set. |
|
238 | + */ |
|
239 | + public static function get_current_theme() |
|
240 | + { |
|
241 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
242 | + ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * _initialize_config |
|
248 | + * |
|
249 | + * @access private |
|
250 | + * @return void |
|
251 | + */ |
|
252 | + private function _initialize_config() |
|
253 | + { |
|
254 | + EE_Config::trim_log(); |
|
255 | + // set defaults |
|
256 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
257 | + $this->addons = new stdClass(); |
|
258 | + // set _module_route_map |
|
259 | + EE_Config::$_module_route_map = array(); |
|
260 | + // set _module_forward_map |
|
261 | + EE_Config::$_module_forward_map = array(); |
|
262 | + // set _module_view_map |
|
263 | + EE_Config::$_module_view_map = array(); |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * load core plugin configuration |
|
269 | + * |
|
270 | + * @access private |
|
271 | + * @return void |
|
272 | + */ |
|
273 | + private function _load_core_config() |
|
274 | + { |
|
275 | + // load_core_config__start hook |
|
276 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
277 | + $espresso_config = $this->get_espresso_config(); |
|
278 | + foreach ($espresso_config as $config => $settings) { |
|
279 | + // load_core_config__start hook |
|
280 | + $settings = apply_filters( |
|
281 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
282 | + $settings, |
|
283 | + $config, |
|
284 | + $this |
|
285 | + ); |
|
286 | + if (is_object($settings) && property_exists($this, $config)) { |
|
287 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
288 | + // call configs populate method to ensure any defaults are set for empty values. |
|
289 | + if (method_exists($settings, 'populate')) { |
|
290 | + $this->{$config}->populate(); |
|
291 | + } |
|
292 | + if (method_exists($settings, 'do_hooks')) { |
|
293 | + $this->{$config}->do_hooks(); |
|
294 | + } |
|
295 | + } |
|
296 | + } |
|
297 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
298 | + $this->update_espresso_config(); |
|
299 | + } |
|
300 | + // load_core_config__end hook |
|
301 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * _verify_config |
|
307 | + * |
|
308 | + * @access protected |
|
309 | + * @return void |
|
310 | + */ |
|
311 | + protected function _verify_config() |
|
312 | + { |
|
313 | + $this->core = $this->core instanceof EE_Core_Config |
|
314 | + ? $this->core |
|
315 | + : new EE_Core_Config(); |
|
316 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
317 | + $this->organization = $this->organization instanceof EE_Organization_Config |
|
318 | + ? $this->organization |
|
319 | + : new EE_Organization_Config(); |
|
320 | + $this->organization = apply_filters( |
|
321 | + 'FHEE__EE_Config___initialize_config__organization', |
|
322 | + $this->organization |
|
323 | + ); |
|
324 | + $this->currency = $this->currency instanceof EE_Currency_Config |
|
325 | + ? $this->currency |
|
326 | + : new EE_Currency_Config(); |
|
327 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
328 | + $this->registration = $this->registration instanceof EE_Registration_Config |
|
329 | + ? $this->registration |
|
330 | + : new EE_Registration_Config(); |
|
331 | + $this->registration = apply_filters( |
|
332 | + 'FHEE__EE_Config___initialize_config__registration', |
|
333 | + $this->registration |
|
334 | + ); |
|
335 | + $this->admin = $this->admin instanceof EE_Admin_Config |
|
336 | + ? $this->admin |
|
337 | + : new EE_Admin_Config(); |
|
338 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
339 | + $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
340 | + ? $this->template_settings |
|
341 | + : new EE_Template_Config(); |
|
342 | + $this->template_settings = apply_filters( |
|
343 | + 'FHEE__EE_Config___initialize_config__template_settings', |
|
344 | + $this->template_settings |
|
345 | + ); |
|
346 | + $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
347 | + ? $this->map_settings |
|
348 | + : new EE_Map_Config(); |
|
349 | + $this->map_settings = apply_filters( |
|
350 | + 'FHEE__EE_Config___initialize_config__map_settings', |
|
351 | + $this->map_settings |
|
352 | + ); |
|
353 | + $this->environment = $this->environment instanceof EE_Environment_Config |
|
354 | + ? $this->environment |
|
355 | + : new EE_Environment_Config(); |
|
356 | + $this->environment = apply_filters( |
|
357 | + 'FHEE__EE_Config___initialize_config__environment', |
|
358 | + $this->environment |
|
359 | + ); |
|
360 | + $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
361 | + ? $this->tax_settings |
|
362 | + : new EE_Tax_Config(); |
|
363 | + $this->tax_settings = apply_filters( |
|
364 | + 'FHEE__EE_Config___initialize_config__tax_settings', |
|
365 | + $this->tax_settings |
|
366 | + ); |
|
367 | + $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
368 | + $this->messages = $this->messages instanceof EE_Messages_Config |
|
369 | + ? $this->messages |
|
370 | + : new EE_Messages_Config(); |
|
371 | + $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
372 | + ? $this->gateway |
|
373 | + : new EE_Gateway_Config(); |
|
374 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
375 | + $this->legacy_shortcodes_manager = null; |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * get_espresso_config |
|
381 | + * |
|
382 | + * @access public |
|
383 | + * @return array of espresso config stuff |
|
384 | + */ |
|
385 | + public function get_espresso_config() |
|
386 | + { |
|
387 | + // grab espresso configuration |
|
388 | + return apply_filters( |
|
389 | + 'FHEE__EE_Config__get_espresso_config__CFG', |
|
390 | + get_option(EE_Config::OPTION_NAME, array()) |
|
391 | + ); |
|
392 | + } |
|
393 | + |
|
394 | + |
|
395 | + /** |
|
396 | + * double_check_config_comparison |
|
397 | + * |
|
398 | + * @access public |
|
399 | + * @param string $option |
|
400 | + * @param $old_value |
|
401 | + * @param $value |
|
402 | + */ |
|
403 | + public function double_check_config_comparison($option = '', $old_value, $value) |
|
404 | + { |
|
405 | + // make sure we're checking the ee config |
|
406 | + if ($option === EE_Config::OPTION_NAME) { |
|
407 | + // run a loose comparison of the old value against the new value for type and properties, |
|
408 | + // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
409 | + if ($value != $old_value) { |
|
410 | + // if they are NOT the same, then remove the hook, |
|
411 | + // which means the subsequent update results will be based solely on the update query results |
|
412 | + // the reason we do this is because, as stated above, |
|
413 | + // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
414 | + // this happens PRIOR to serialization and any subsequent update. |
|
415 | + // If values are found to match their previous old value, |
|
416 | + // then WP bails before performing any update. |
|
417 | + // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
418 | + // it just pulled from the db, with the one being passed to it (which will not match). |
|
419 | + // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
420 | + // MySQL MAY ALSO NOT perform the update because |
|
421 | + // the string it sees in the db looks the same as the new one it has been passed!!! |
|
422 | + // This results in the query returning an "affected rows" value of ZERO, |
|
423 | + // which gets returned immediately by WP update_option and looks like an error. |
|
424 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
425 | + } |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * update_espresso_config |
|
432 | + * |
|
433 | + * @access public |
|
434 | + */ |
|
435 | + protected function _reset_espresso_addon_config() |
|
436 | + { |
|
437 | + $this->_addon_option_names = array(); |
|
438 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
439 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
440 | + if ($addon_config_obj instanceof EE_Config_Base) { |
|
441 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
442 | + } |
|
443 | + $this->addons->{$addon_name} = null; |
|
444 | + } |
|
445 | + } |
|
446 | + |
|
447 | + |
|
448 | + /** |
|
449 | + * update_espresso_config |
|
450 | + * |
|
451 | + * @access public |
|
452 | + * @param bool $add_success |
|
453 | + * @param bool $add_error |
|
454 | + * @return bool |
|
455 | + */ |
|
456 | + public function update_espresso_config($add_success = false, $add_error = true) |
|
457 | + { |
|
458 | + // don't allow config updates during WP heartbeats |
|
459 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
460 | + return false; |
|
461 | + } |
|
462 | + // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
463 | + // $clone = clone( self::$_instance ); |
|
464 | + // self::$_instance = NULL; |
|
465 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
466 | + $this->_reset_espresso_addon_config(); |
|
467 | + // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
468 | + // but BEFORE the actual update occurs |
|
469 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
470 | + // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
471 | + $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
472 | + $this->legacy_shortcodes_manager = null; |
|
473 | + // now update "ee_config" |
|
474 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
475 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
476 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
477 | + // if not saved... check if the hook we just added still exists; |
|
478 | + // if it does, it means one of two things: |
|
479 | + // that update_option bailed at the($value === $old_value) conditional, |
|
480 | + // or... |
|
481 | + // the db update query returned 0 rows affected |
|
482 | + // (probably because the data value was the same from it's perspective) |
|
483 | + // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
484 | + // but just means no update occurred, so don't display an error to the user. |
|
485 | + // BUT... if update_option returns FALSE, AND the hook is missing, |
|
486 | + // then it means that something truly went wrong |
|
487 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
488 | + // remove our action since we don't want it in the system anymore |
|
489 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
490 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
491 | + // self::$_instance = $clone; |
|
492 | + // unset( $clone ); |
|
493 | + // if config remains the same or was updated successfully |
|
494 | + if ($saved) { |
|
495 | + if ($add_success) { |
|
496 | + EE_Error::add_success( |
|
497 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
498 | + __FILE__, |
|
499 | + __FUNCTION__, |
|
500 | + __LINE__ |
|
501 | + ); |
|
502 | + } |
|
503 | + return true; |
|
504 | + } else { |
|
505 | + if ($add_error) { |
|
506 | + EE_Error::add_error( |
|
507 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
508 | + __FILE__, |
|
509 | + __FUNCTION__, |
|
510 | + __LINE__ |
|
511 | + ); |
|
512 | + } |
|
513 | + return false; |
|
514 | + } |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * _verify_config_params |
|
520 | + * |
|
521 | + * @access private |
|
522 | + * @param string $section |
|
523 | + * @param string $name |
|
524 | + * @param string $config_class |
|
525 | + * @param EE_Config_Base $config_obj |
|
526 | + * @param array $tests_to_run |
|
527 | + * @param bool $display_errors |
|
528 | + * @return bool TRUE on success, FALSE on fail |
|
529 | + */ |
|
530 | + private function _verify_config_params( |
|
531 | + $section = '', |
|
532 | + $name = '', |
|
533 | + $config_class = '', |
|
534 | + $config_obj = null, |
|
535 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
536 | + $display_errors = true |
|
537 | + ) { |
|
538 | + try { |
|
539 | + foreach ($tests_to_run as $test) { |
|
540 | + switch ($test) { |
|
541 | + // TEST #1 : check that section was set |
|
542 | + case 1: |
|
543 | + if (empty($section)) { |
|
544 | + if ($display_errors) { |
|
545 | + throw new EE_Error( |
|
546 | + sprintf( |
|
547 | + __( |
|
548 | + 'No configuration section has been provided while attempting to save "%s".', |
|
549 | + 'event_espresso' |
|
550 | + ), |
|
551 | + $config_class |
|
552 | + ) |
|
553 | + ); |
|
554 | + } |
|
555 | + return false; |
|
556 | + } |
|
557 | + break; |
|
558 | + // TEST #2 : check that settings section exists |
|
559 | + case 2: |
|
560 | + if (! isset($this->{$section})) { |
|
561 | + if ($display_errors) { |
|
562 | + throw new EE_Error( |
|
563 | + sprintf( |
|
564 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
565 | + $section |
|
566 | + ) |
|
567 | + ); |
|
568 | + } |
|
569 | + return false; |
|
570 | + } |
|
571 | + break; |
|
572 | + // TEST #3 : check that section is the proper format |
|
573 | + case 3: |
|
574 | + if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
575 | + ) { |
|
576 | + if ($display_errors) { |
|
577 | + throw new EE_Error( |
|
578 | + sprintf( |
|
579 | + __( |
|
580 | + 'The "%s" configuration settings have not been formatted correctly.', |
|
581 | + 'event_espresso' |
|
582 | + ), |
|
583 | + $section |
|
584 | + ) |
|
585 | + ); |
|
586 | + } |
|
587 | + return false; |
|
588 | + } |
|
589 | + break; |
|
590 | + // TEST #4 : check that config section name has been set |
|
591 | + case 4: |
|
592 | + if (empty($name)) { |
|
593 | + if ($display_errors) { |
|
594 | + throw new EE_Error( |
|
595 | + __( |
|
596 | + 'No name has been provided for the specific configuration section.', |
|
597 | + 'event_espresso' |
|
598 | + ) |
|
599 | + ); |
|
600 | + } |
|
601 | + return false; |
|
602 | + } |
|
603 | + break; |
|
604 | + // TEST #5 : check that a config class name has been set |
|
605 | + case 5: |
|
606 | + if (empty($config_class)) { |
|
607 | + if ($display_errors) { |
|
608 | + throw new EE_Error( |
|
609 | + __( |
|
610 | + 'No class name has been provided for the specific configuration section.', |
|
611 | + 'event_espresso' |
|
612 | + ) |
|
613 | + ); |
|
614 | + } |
|
615 | + return false; |
|
616 | + } |
|
617 | + break; |
|
618 | + // TEST #6 : verify config class is accessible |
|
619 | + case 6: |
|
620 | + if (! class_exists($config_class)) { |
|
621 | + if ($display_errors) { |
|
622 | + throw new EE_Error( |
|
623 | + sprintf( |
|
624 | + __( |
|
625 | + 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
626 | + 'event_espresso' |
|
627 | + ), |
|
628 | + $config_class |
|
629 | + ) |
|
630 | + ); |
|
631 | + } |
|
632 | + return false; |
|
633 | + } |
|
634 | + break; |
|
635 | + // TEST #7 : check that config has even been set |
|
636 | + case 7: |
|
637 | + if (! isset($this->{$section}->{$name})) { |
|
638 | + if ($display_errors) { |
|
639 | + throw new EE_Error( |
|
640 | + sprintf( |
|
641 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
642 | + $section, |
|
643 | + $name |
|
644 | + ) |
|
645 | + ); |
|
646 | + } |
|
647 | + return false; |
|
648 | + } else { |
|
649 | + // and make sure it's not serialized |
|
650 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
651 | + } |
|
652 | + break; |
|
653 | + // TEST #8 : check that config is the requested type |
|
654 | + case 8: |
|
655 | + if (! $this->{$section}->{$name} instanceof $config_class) { |
|
656 | + if ($display_errors) { |
|
657 | + throw new EE_Error( |
|
658 | + sprintf( |
|
659 | + __( |
|
660 | + 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
661 | + 'event_espresso' |
|
662 | + ), |
|
663 | + $section, |
|
664 | + $name, |
|
665 | + $config_class |
|
666 | + ) |
|
667 | + ); |
|
668 | + } |
|
669 | + return false; |
|
670 | + } |
|
671 | + break; |
|
672 | + // TEST #9 : verify config object |
|
673 | + case 9: |
|
674 | + if (! $config_obj instanceof EE_Config_Base) { |
|
675 | + if ($display_errors) { |
|
676 | + throw new EE_Error( |
|
677 | + sprintf( |
|
678 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
679 | + print_r($config_obj, true) |
|
680 | + ) |
|
681 | + ); |
|
682 | + } |
|
683 | + return false; |
|
684 | + } |
|
685 | + break; |
|
686 | + } |
|
687 | + } |
|
688 | + } catch (EE_Error $e) { |
|
689 | + $e->get_error(); |
|
690 | + } |
|
691 | + // you have successfully run the gauntlet |
|
692 | + return true; |
|
693 | + } |
|
694 | + |
|
695 | + |
|
696 | + /** |
|
697 | + * _generate_config_option_name |
|
698 | + * |
|
699 | + * @access protected |
|
700 | + * @param string $section |
|
701 | + * @param string $name |
|
702 | + * @return string |
|
703 | + */ |
|
704 | + private function _generate_config_option_name($section = '', $name = '') |
|
705 | + { |
|
706 | + return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
707 | + } |
|
708 | + |
|
709 | + |
|
710 | + /** |
|
711 | + * _set_config_class |
|
712 | + * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
713 | + * |
|
714 | + * @access private |
|
715 | + * @param string $config_class |
|
716 | + * @param string $name |
|
717 | + * @return string |
|
718 | + */ |
|
719 | + private function _set_config_class($config_class = '', $name = '') |
|
720 | + { |
|
721 | + return ! empty($config_class) |
|
722 | + ? $config_class |
|
723 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
724 | + } |
|
725 | + |
|
726 | + |
|
727 | + /** |
|
728 | + * set_config |
|
729 | + * |
|
730 | + * @access protected |
|
731 | + * @param string $section |
|
732 | + * @param string $name |
|
733 | + * @param string $config_class |
|
734 | + * @param EE_Config_Base $config_obj |
|
735 | + * @return EE_Config_Base |
|
736 | + */ |
|
737 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
738 | + { |
|
739 | + // ensure config class is set to something |
|
740 | + $config_class = $this->_set_config_class($config_class, $name); |
|
741 | + // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
742 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
743 | + return null; |
|
744 | + } |
|
745 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
746 | + // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
747 | + if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
748 | + $this->_addon_option_names[ $config_option_name ] = $config_class; |
|
749 | + $this->update_addon_option_names(); |
|
750 | + } |
|
751 | + // verify the incoming config object but suppress errors |
|
752 | + if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
753 | + $config_obj = new $config_class(); |
|
754 | + } |
|
755 | + if (get_option($config_option_name)) { |
|
756 | + EE_Config::log($config_option_name); |
|
757 | + update_option($config_option_name, $config_obj); |
|
758 | + $this->{$section}->{$name} = $config_obj; |
|
759 | + return $this->{$section}->{$name}; |
|
760 | + } else { |
|
761 | + // create a wp-option for this config |
|
762 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
763 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
764 | + return $this->{$section}->{$name}; |
|
765 | + } else { |
|
766 | + EE_Error::add_error( |
|
767 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
768 | + __FILE__, |
|
769 | + __FUNCTION__, |
|
770 | + __LINE__ |
|
771 | + ); |
|
772 | + return null; |
|
773 | + } |
|
774 | + } |
|
775 | + } |
|
776 | + |
|
777 | + |
|
778 | + /** |
|
779 | + * update_config |
|
780 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
781 | + * |
|
782 | + * @access public |
|
783 | + * @param string $section |
|
784 | + * @param string $name |
|
785 | + * @param EE_Config_Base|string $config_obj |
|
786 | + * @param bool $throw_errors |
|
787 | + * @return bool |
|
788 | + */ |
|
789 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
790 | + { |
|
791 | + // don't allow config updates during WP heartbeats |
|
792 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
793 | + return false; |
|
794 | + } |
|
795 | + $config_obj = maybe_unserialize($config_obj); |
|
796 | + // get class name of the incoming object |
|
797 | + $config_class = get_class($config_obj); |
|
798 | + // run tests 1-5 and 9 to verify config |
|
799 | + if (! $this->_verify_config_params( |
|
800 | + $section, |
|
801 | + $name, |
|
802 | + $config_class, |
|
803 | + $config_obj, |
|
804 | + array(1, 2, 3, 4, 7, 9) |
|
805 | + ) |
|
806 | + ) { |
|
807 | + return false; |
|
808 | + } |
|
809 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
810 | + // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
811 | + if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
812 | + // save new config to db |
|
813 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
814 | + return true; |
|
815 | + } |
|
816 | + } else { |
|
817 | + // first check if the record already exists |
|
818 | + $existing_config = get_option($config_option_name); |
|
819 | + $config_obj = serialize($config_obj); |
|
820 | + // just return if db record is already up to date (NOT type safe comparison) |
|
821 | + if ($existing_config == $config_obj) { |
|
822 | + $this->{$section}->{$name} = $config_obj; |
|
823 | + return true; |
|
824 | + } elseif (update_option($config_option_name, $config_obj)) { |
|
825 | + EE_Config::log($config_option_name); |
|
826 | + // update wp-option for this config class |
|
827 | + $this->{$section}->{$name} = $config_obj; |
|
828 | + return true; |
|
829 | + } elseif ($throw_errors) { |
|
830 | + EE_Error::add_error( |
|
831 | + sprintf( |
|
832 | + __( |
|
833 | + 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
834 | + 'event_espresso' |
|
835 | + ), |
|
836 | + $config_class, |
|
837 | + 'EE_Config->' . $section . '->' . $name |
|
838 | + ), |
|
839 | + __FILE__, |
|
840 | + __FUNCTION__, |
|
841 | + __LINE__ |
|
842 | + ); |
|
843 | + } |
|
844 | + } |
|
845 | + return false; |
|
846 | + } |
|
847 | + |
|
848 | + |
|
849 | + /** |
|
850 | + * get_config |
|
851 | + * |
|
852 | + * @access public |
|
853 | + * @param string $section |
|
854 | + * @param string $name |
|
855 | + * @param string $config_class |
|
856 | + * @return mixed EE_Config_Base | NULL |
|
857 | + */ |
|
858 | + public function get_config($section = '', $name = '', $config_class = '') |
|
859 | + { |
|
860 | + // ensure config class is set to something |
|
861 | + $config_class = $this->_set_config_class($config_class, $name); |
|
862 | + // run tests 1-4, 6 and 7 to verify that all params have been set |
|
863 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
864 | + return null; |
|
865 | + } |
|
866 | + // now test if the requested config object exists, but suppress errors |
|
867 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
868 | + // config already exists, so pass it back |
|
869 | + return $this->{$section}->{$name}; |
|
870 | + } |
|
871 | + // load config option from db if it exists |
|
872 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
873 | + // verify the newly retrieved config object, but suppress errors |
|
874 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
875 | + // config is good, so set it and pass it back |
|
876 | + $this->{$section}->{$name} = $config_obj; |
|
877 | + return $this->{$section}->{$name}; |
|
878 | + } |
|
879 | + // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
880 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
881 | + // verify the newly created config object |
|
882 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
883 | + return $this->{$section}->{$name}; |
|
884 | + } else { |
|
885 | + EE_Error::add_error( |
|
886 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
887 | + __FILE__, |
|
888 | + __FUNCTION__, |
|
889 | + __LINE__ |
|
890 | + ); |
|
891 | + } |
|
892 | + return null; |
|
893 | + } |
|
894 | + |
|
895 | + |
|
896 | + /** |
|
897 | + * get_config_option |
|
898 | + * |
|
899 | + * @access public |
|
900 | + * @param string $config_option_name |
|
901 | + * @return mixed EE_Config_Base | FALSE |
|
902 | + */ |
|
903 | + public function get_config_option($config_option_name = '') |
|
904 | + { |
|
905 | + // retrieve the wp-option for this config class. |
|
906 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
907 | + if (empty($config_option)) { |
|
908 | + EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
909 | + } |
|
910 | + return $config_option; |
|
911 | + } |
|
912 | + |
|
913 | + |
|
914 | + /** |
|
915 | + * log |
|
916 | + * |
|
917 | + * @param string $config_option_name |
|
918 | + */ |
|
919 | + public static function log($config_option_name = '') |
|
920 | + { |
|
921 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
922 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
923 | + // copy incoming $_REQUEST and sanitize it so we can save it |
|
924 | + $_request = $_REQUEST; |
|
925 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
926 | + $config_log[ (string) microtime(true) ] = array( |
|
927 | + 'config_name' => $config_option_name, |
|
928 | + 'request' => $_request, |
|
929 | + ); |
|
930 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
931 | + } |
|
932 | + } |
|
933 | + |
|
934 | + |
|
935 | + /** |
|
936 | + * trim_log |
|
937 | + * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
938 | + */ |
|
939 | + public static function trim_log() |
|
940 | + { |
|
941 | + if (! EE_Config::logging_enabled()) { |
|
942 | + return; |
|
943 | + } |
|
944 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
945 | + $log_length = count($config_log); |
|
946 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
947 | + ksort($config_log); |
|
948 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
949 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
950 | + } |
|
951 | + } |
|
952 | + |
|
953 | + |
|
954 | + /** |
|
955 | + * get_page_for_posts |
|
956 | + * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
957 | + * wp-option "page_for_posts", or "posts" if no page is selected |
|
958 | + * |
|
959 | + * @access public |
|
960 | + * @return string |
|
961 | + */ |
|
962 | + public static function get_page_for_posts() |
|
963 | + { |
|
964 | + $page_for_posts = get_option('page_for_posts'); |
|
965 | + if (! $page_for_posts) { |
|
966 | + return 'posts'; |
|
967 | + } |
|
968 | + /** @type WPDB $wpdb */ |
|
969 | + global $wpdb; |
|
970 | + $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
971 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
972 | + } |
|
973 | + |
|
974 | + |
|
975 | + /** |
|
976 | + * register_shortcodes_and_modules. |
|
977 | + * At this point, it's too early to tell if we're maintenance mode or not. |
|
978 | + * In fact, this is where we give modules a chance to let core know they exist |
|
979 | + * so they can help trigger maintenance mode if it's needed |
|
980 | + * |
|
981 | + * @access public |
|
982 | + * @return void |
|
983 | + */ |
|
984 | + public function register_shortcodes_and_modules() |
|
985 | + { |
|
986 | + // allow modules to set hooks for the rest of the system |
|
987 | + EE_Registry::instance()->modules = $this->_register_modules(); |
|
988 | + } |
|
989 | + |
|
990 | + |
|
991 | + /** |
|
992 | + * initialize_shortcodes_and_modules |
|
993 | + * meaning they can start adding their hooks to get stuff done |
|
994 | + * |
|
995 | + * @access public |
|
996 | + * @return void |
|
997 | + */ |
|
998 | + public function initialize_shortcodes_and_modules() |
|
999 | + { |
|
1000 | + // allow modules to set hooks for the rest of the system |
|
1001 | + $this->_initialize_modules(); |
|
1002 | + } |
|
1003 | + |
|
1004 | + |
|
1005 | + /** |
|
1006 | + * widgets_init |
|
1007 | + * |
|
1008 | + * @access private |
|
1009 | + * @return void |
|
1010 | + */ |
|
1011 | + public function widgets_init() |
|
1012 | + { |
|
1013 | + // only init widgets on admin pages when not in complete maintenance, and |
|
1014 | + // on frontend when not in any maintenance mode |
|
1015 | + if (! EE_Maintenance_Mode::instance()->level() |
|
1016 | + || ( |
|
1017 | + is_admin() |
|
1018 | + && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1019 | + ) |
|
1020 | + ) { |
|
1021 | + // grab list of installed widgets |
|
1022 | + $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1023 | + // filter list of modules to register |
|
1024 | + $widgets_to_register = apply_filters( |
|
1025 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1026 | + $widgets_to_register |
|
1027 | + ); |
|
1028 | + if (! empty($widgets_to_register)) { |
|
1029 | + // cycle thru widget folders |
|
1030 | + foreach ($widgets_to_register as $widget_path) { |
|
1031 | + // add to list of installed widget modules |
|
1032 | + EE_Config::register_ee_widget($widget_path); |
|
1033 | + } |
|
1034 | + } |
|
1035 | + // filter list of installed modules |
|
1036 | + EE_Registry::instance()->widgets = apply_filters( |
|
1037 | + 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1038 | + EE_Registry::instance()->widgets |
|
1039 | + ); |
|
1040 | + } |
|
1041 | + } |
|
1042 | + |
|
1043 | + |
|
1044 | + /** |
|
1045 | + * register_ee_widget - makes core aware of this widget |
|
1046 | + * |
|
1047 | + * @access public |
|
1048 | + * @param string $widget_path - full path up to and including widget folder |
|
1049 | + * @return void |
|
1050 | + */ |
|
1051 | + public static function register_ee_widget($widget_path = null) |
|
1052 | + { |
|
1053 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1054 | + $widget_ext = '.widget.php'; |
|
1055 | + // make all separators match |
|
1056 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1057 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1058 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
1059 | + // grab and shortcode file name from directory name and break apart at dots |
|
1060 | + $file_name = explode('.', basename($widget_path)); |
|
1061 | + // take first segment from file name pieces and remove class prefix if it exists |
|
1062 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1063 | + // sanitize shortcode directory name |
|
1064 | + $widget = sanitize_key($widget); |
|
1065 | + // now we need to rebuild the shortcode path |
|
1066 | + $widget_path = explode(DS, $widget_path); |
|
1067 | + // remove last segment |
|
1068 | + array_pop($widget_path); |
|
1069 | + // glue it back together |
|
1070 | + $widget_path = implode(DS, $widget_path); |
|
1071 | + } else { |
|
1072 | + // grab and sanitize widget directory name |
|
1073 | + $widget = sanitize_key(basename($widget_path)); |
|
1074 | + } |
|
1075 | + // create classname from widget directory name |
|
1076 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1077 | + // add class prefix |
|
1078 | + $widget_class = 'EEW_' . $widget; |
|
1079 | + // does the widget exist ? |
|
1080 | + if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1081 | + $msg = sprintf( |
|
1082 | + __( |
|
1083 | + 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1084 | + 'event_espresso' |
|
1085 | + ), |
|
1086 | + $widget_class, |
|
1087 | + $widget_path . DS . $widget_class . $widget_ext |
|
1088 | + ); |
|
1089 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1090 | + return; |
|
1091 | + } |
|
1092 | + // load the widget class file |
|
1093 | + require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1094 | + // verify that class exists |
|
1095 | + if (! class_exists($widget_class)) { |
|
1096 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1097 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1098 | + return; |
|
1099 | + } |
|
1100 | + register_widget($widget_class); |
|
1101 | + // add to array of registered widgets |
|
1102 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1103 | + } |
|
1104 | + |
|
1105 | + |
|
1106 | + /** |
|
1107 | + * _register_modules |
|
1108 | + * |
|
1109 | + * @access private |
|
1110 | + * @return array |
|
1111 | + */ |
|
1112 | + private function _register_modules() |
|
1113 | + { |
|
1114 | + // grab list of installed modules |
|
1115 | + $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1116 | + // filter list of modules to register |
|
1117 | + $modules_to_register = apply_filters( |
|
1118 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1119 | + $modules_to_register |
|
1120 | + ); |
|
1121 | + if (! empty($modules_to_register)) { |
|
1122 | + // loop through folders |
|
1123 | + foreach ($modules_to_register as $module_path) { |
|
1124 | + /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1125 | + if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1126 | + && $module_path !== EE_MODULES . 'gateways' |
|
1127 | + ) { |
|
1128 | + // add to list of installed modules |
|
1129 | + EE_Config::register_module($module_path); |
|
1130 | + } |
|
1131 | + } |
|
1132 | + } |
|
1133 | + // filter list of installed modules |
|
1134 | + return apply_filters( |
|
1135 | + 'FHEE__EE_Config___register_modules__installed_modules', |
|
1136 | + EE_Registry::instance()->modules |
|
1137 | + ); |
|
1138 | + } |
|
1139 | + |
|
1140 | + |
|
1141 | + /** |
|
1142 | + * register_module - makes core aware of this module |
|
1143 | + * |
|
1144 | + * @access public |
|
1145 | + * @param string $module_path - full path up to and including module folder |
|
1146 | + * @return bool |
|
1147 | + */ |
|
1148 | + public static function register_module($module_path = null) |
|
1149 | + { |
|
1150 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1151 | + $module_ext = '.module.php'; |
|
1152 | + // make all separators match |
|
1153 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1154 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1155 | + if (strpos($module_path, $module_ext) !== false) { |
|
1156 | + // grab and shortcode file name from directory name and break apart at dots |
|
1157 | + $module_file = explode('.', basename($module_path)); |
|
1158 | + // now we need to rebuild the shortcode path |
|
1159 | + $module_path = explode(DS, $module_path); |
|
1160 | + // remove last segment |
|
1161 | + array_pop($module_path); |
|
1162 | + // glue it back together |
|
1163 | + $module_path = implode(DS, $module_path) . DS; |
|
1164 | + // take first segment from file name pieces and sanitize it |
|
1165 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1166 | + // ensure class prefix is added |
|
1167 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1168 | + } else { |
|
1169 | + // we need to generate the filename based off of the folder name |
|
1170 | + // grab and sanitize module name |
|
1171 | + $module = strtolower(basename($module_path)); |
|
1172 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1173 | + // like trailingslashit() |
|
1174 | + $module_path = rtrim($module_path, DS) . DS; |
|
1175 | + // create classname from module directory name |
|
1176 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1177 | + // add class prefix |
|
1178 | + $module_class = 'EED_' . $module; |
|
1179 | + } |
|
1180 | + // does the module exist ? |
|
1181 | + if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1182 | + $msg = sprintf( |
|
1183 | + __( |
|
1184 | + 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1185 | + 'event_espresso' |
|
1186 | + ), |
|
1187 | + $module |
|
1188 | + ); |
|
1189 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1190 | + return false; |
|
1191 | + } |
|
1192 | + // load the module class file |
|
1193 | + require_once($module_path . $module_class . $module_ext); |
|
1194 | + // verify that class exists |
|
1195 | + if (! class_exists($module_class)) { |
|
1196 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1197 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1198 | + return false; |
|
1199 | + } |
|
1200 | + // add to array of registered modules |
|
1201 | + EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1202 | + do_action( |
|
1203 | + 'AHEE__EE_Config__register_module__complete', |
|
1204 | + $module_class, |
|
1205 | + EE_Registry::instance()->modules->{$module_class} |
|
1206 | + ); |
|
1207 | + return true; |
|
1208 | + } |
|
1209 | + |
|
1210 | + |
|
1211 | + /** |
|
1212 | + * _initialize_modules |
|
1213 | + * allow modules to set hooks for the rest of the system |
|
1214 | + * |
|
1215 | + * @access private |
|
1216 | + * @return void |
|
1217 | + */ |
|
1218 | + private function _initialize_modules() |
|
1219 | + { |
|
1220 | + // cycle thru shortcode folders |
|
1221 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1222 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1223 | + // which set hooks ? |
|
1224 | + if (is_admin()) { |
|
1225 | + // fire immediately |
|
1226 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1227 | + } else { |
|
1228 | + // delay until other systems are online |
|
1229 | + add_action( |
|
1230 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1231 | + array($module_class, 'set_hooks') |
|
1232 | + ); |
|
1233 | + } |
|
1234 | + } |
|
1235 | + } |
|
1236 | + |
|
1237 | + |
|
1238 | + /** |
|
1239 | + * register_route - adds module method routes to route_map |
|
1240 | + * |
|
1241 | + * @access public |
|
1242 | + * @param string $route - "pretty" public alias for module method |
|
1243 | + * @param string $module - module name (classname without EED_ prefix) |
|
1244 | + * @param string $method_name - the actual module method to be routed to |
|
1245 | + * @param string $key - url param key indicating a route is being called |
|
1246 | + * @return bool |
|
1247 | + */ |
|
1248 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1249 | + { |
|
1250 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1251 | + $module = str_replace('EED_', '', $module); |
|
1252 | + $module_class = 'EED_' . $module; |
|
1253 | + if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1254 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1255 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1256 | + return false; |
|
1257 | + } |
|
1258 | + if (empty($route)) { |
|
1259 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1260 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1261 | + return false; |
|
1262 | + } |
|
1263 | + if (! method_exists('EED_' . $module, $method_name)) { |
|
1264 | + $msg = sprintf( |
|
1265 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1266 | + $route |
|
1267 | + ); |
|
1268 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1269 | + return false; |
|
1270 | + } |
|
1271 | + EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name); |
|
1272 | + return true; |
|
1273 | + } |
|
1274 | + |
|
1275 | + |
|
1276 | + /** |
|
1277 | + * get_route - get module method route |
|
1278 | + * |
|
1279 | + * @access public |
|
1280 | + * @param string $route - "pretty" public alias for module method |
|
1281 | + * @param string $key - url param key indicating a route is being called |
|
1282 | + * @return string |
|
1283 | + */ |
|
1284 | + public static function get_route($route = null, $key = 'ee') |
|
1285 | + { |
|
1286 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1287 | + $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
1288 | + if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) { |
|
1289 | + return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1290 | + } |
|
1291 | + return null; |
|
1292 | + } |
|
1293 | + |
|
1294 | + |
|
1295 | + /** |
|
1296 | + * get_routes - get ALL module method routes |
|
1297 | + * |
|
1298 | + * @access public |
|
1299 | + * @return array |
|
1300 | + */ |
|
1301 | + public static function get_routes() |
|
1302 | + { |
|
1303 | + return EE_Config::$_module_route_map; |
|
1304 | + } |
|
1305 | + |
|
1306 | + |
|
1307 | + /** |
|
1308 | + * register_forward - allows modules to forward request to another module for further processing |
|
1309 | + * |
|
1310 | + * @access public |
|
1311 | + * @param string $route - "pretty" public alias for module method |
|
1312 | + * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1313 | + * class, allows different forwards to be served based on status |
|
1314 | + * @param array|string $forward - function name or array( class, method ) |
|
1315 | + * @param string $key - url param key indicating a route is being called |
|
1316 | + * @return bool |
|
1317 | + */ |
|
1318 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1319 | + { |
|
1320 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1321 | + if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1322 | + $msg = sprintf( |
|
1323 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1324 | + $route |
|
1325 | + ); |
|
1326 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1327 | + return false; |
|
1328 | + } |
|
1329 | + if (empty($forward)) { |
|
1330 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1331 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1332 | + return false; |
|
1333 | + } |
|
1334 | + if (is_array($forward)) { |
|
1335 | + if (! isset($forward[1])) { |
|
1336 | + $msg = sprintf( |
|
1337 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1338 | + $route |
|
1339 | + ); |
|
1340 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1341 | + return false; |
|
1342 | + } |
|
1343 | + if (! method_exists($forward[0], $forward[1])) { |
|
1344 | + $msg = sprintf( |
|
1345 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1346 | + $forward[1], |
|
1347 | + $route |
|
1348 | + ); |
|
1349 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1350 | + return false; |
|
1351 | + } |
|
1352 | + } elseif (! function_exists($forward)) { |
|
1353 | + $msg = sprintf( |
|
1354 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1355 | + $forward, |
|
1356 | + $route |
|
1357 | + ); |
|
1358 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1359 | + return false; |
|
1360 | + } |
|
1361 | + EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward; |
|
1362 | + return true; |
|
1363 | + } |
|
1364 | + |
|
1365 | + |
|
1366 | + /** |
|
1367 | + * get_forward - get forwarding route |
|
1368 | + * |
|
1369 | + * @access public |
|
1370 | + * @param string $route - "pretty" public alias for module method |
|
1371 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1372 | + * allows different forwards to be served based on status |
|
1373 | + * @param string $key - url param key indicating a route is being called |
|
1374 | + * @return string |
|
1375 | + */ |
|
1376 | + public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1377 | + { |
|
1378 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1379 | + if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) { |
|
1380 | + return apply_filters( |
|
1381 | + 'FHEE__EE_Config__get_forward', |
|
1382 | + EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], |
|
1383 | + $route, |
|
1384 | + $status |
|
1385 | + ); |
|
1386 | + } |
|
1387 | + return null; |
|
1388 | + } |
|
1389 | + |
|
1390 | + |
|
1391 | + /** |
|
1392 | + * register_forward - allows modules to specify different view templates for different method routes and status |
|
1393 | + * results |
|
1394 | + * |
|
1395 | + * @access public |
|
1396 | + * @param string $route - "pretty" public alias for module method |
|
1397 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1398 | + * allows different views to be served based on status |
|
1399 | + * @param string $view |
|
1400 | + * @param string $key - url param key indicating a route is being called |
|
1401 | + * @return bool |
|
1402 | + */ |
|
1403 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1404 | + { |
|
1405 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1406 | + if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
1407 | + $msg = sprintf( |
|
1408 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1409 | + $route |
|
1410 | + ); |
|
1411 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1412 | + return false; |
|
1413 | + } |
|
1414 | + if (! is_readable($view)) { |
|
1415 | + $msg = sprintf( |
|
1416 | + __( |
|
1417 | + 'The %s view file could not be found or is not readable due to file permissions.', |
|
1418 | + 'event_espresso' |
|
1419 | + ), |
|
1420 | + $view |
|
1421 | + ); |
|
1422 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1423 | + return false; |
|
1424 | + } |
|
1425 | + EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view; |
|
1426 | + return true; |
|
1427 | + } |
|
1428 | + |
|
1429 | + |
|
1430 | + /** |
|
1431 | + * get_view - get view for route and status |
|
1432 | + * |
|
1433 | + * @access public |
|
1434 | + * @param string $route - "pretty" public alias for module method |
|
1435 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1436 | + * allows different views to be served based on status |
|
1437 | + * @param string $key - url param key indicating a route is being called |
|
1438 | + * @return string |
|
1439 | + */ |
|
1440 | + public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1441 | + { |
|
1442 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1443 | + if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) { |
|
1444 | + return apply_filters( |
|
1445 | + 'FHEE__EE_Config__get_view', |
|
1446 | + EE_Config::$_module_view_map[ $key ][ $route ][ $status ], |
|
1447 | + $route, |
|
1448 | + $status |
|
1449 | + ); |
|
1450 | + } |
|
1451 | + return null; |
|
1452 | + } |
|
1453 | + |
|
1454 | + |
|
1455 | + public function update_addon_option_names() |
|
1456 | + { |
|
1457 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1458 | + } |
|
1459 | + |
|
1460 | + |
|
1461 | + public function shutdown() |
|
1462 | + { |
|
1463 | + $this->update_addon_option_names(); |
|
1464 | + } |
|
1465 | + |
|
1466 | + |
|
1467 | + /** |
|
1468 | + * @return LegacyShortcodesManager |
|
1469 | + */ |
|
1470 | + public static function getLegacyShortcodesManager() |
|
1471 | + { |
|
1472 | + |
|
1473 | + if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
1474 | + EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
1475 | + EE_Registry::instance() |
|
1476 | + ); |
|
1477 | + } |
|
1478 | + return EE_Config::instance()->legacy_shortcodes_manager; |
|
1479 | + } |
|
1480 | + |
|
1481 | + |
|
1482 | + /** |
|
1483 | + * register_shortcode - makes core aware of this shortcode |
|
1484 | + * |
|
1485 | + * @deprecated 4.9.26 |
|
1486 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
1487 | + * @return bool |
|
1488 | + */ |
|
1489 | + public static function register_shortcode($shortcode_path = null) |
|
1490 | + { |
|
1491 | + EE_Error::doing_it_wrong( |
|
1492 | + __METHOD__, |
|
1493 | + __( |
|
1494 | + 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
1495 | + 'event_espresso' |
|
1496 | + ), |
|
1497 | + '4.9.26' |
|
1498 | + ); |
|
1499 | + return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
1500 | + } |
|
1501 | +} |
|
2130 | 1502 | |
1503 | +/** |
|
1504 | + * Base class used for config classes. These classes should generally not have |
|
1505 | + * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1506 | + * basically, they should just be well-defined stdClasses |
|
1507 | + */ |
|
1508 | +class EE_Config_Base |
|
1509 | +{ |
|
2131 | 1510 | |
2132 | - /** |
|
2133 | - * class constructor |
|
2134 | - * |
|
2135 | - * @access public |
|
2136 | - * @param string $CNT_ISO |
|
2137 | - * @throws \EE_Error |
|
2138 | - */ |
|
2139 | - public function __construct($CNT_ISO = '') |
|
2140 | - { |
|
2141 | - /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2142 | - $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2143 | - // get country code from organization settings or use default |
|
2144 | - $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2145 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2146 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2147 | - : ''; |
|
2148 | - // but override if requested |
|
2149 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2150 | - // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2151 | - if (! empty($CNT_ISO) |
|
2152 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
2153 | - && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2154 | - ) { |
|
2155 | - // retrieve the country settings from the db, just in case they have been customized |
|
2156 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2157 | - if ($country instanceof EE_Country) { |
|
2158 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2159 | - $this->name = $country->currency_name_single(); // Dollar |
|
2160 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2161 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2162 | - $this->sign_b4 = $country->currency_sign_before( |
|
2163 | - ); // currency sign before or after: $TRUE or FALSE$ |
|
2164 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2165 | - $this->dec_mrk = $country->currency_decimal_mark( |
|
2166 | - ); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2167 | - $this->thsnds = $country->currency_thousands_separator( |
|
2168 | - ); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2169 | - } |
|
2170 | - } |
|
2171 | - // fallback to hardcoded defaults, in case the above failed |
|
2172 | - if (empty($this->code)) { |
|
2173 | - // set default currency settings |
|
2174 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2175 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2176 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2177 | - $this->sign = '$'; // currency sign: $ |
|
2178 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2179 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2180 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2181 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2182 | - } |
|
2183 | - } |
|
1511 | + /** |
|
1512 | + * Utility function for escaping the value of a property and returning. |
|
1513 | + * |
|
1514 | + * @param string $property property name (checks to see if exists). |
|
1515 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1516 | + * @throws \EE_Error |
|
1517 | + */ |
|
1518 | + public function get_pretty($property) |
|
1519 | + { |
|
1520 | + if (! property_exists($this, $property)) { |
|
1521 | + throw new EE_Error( |
|
1522 | + sprintf( |
|
1523 | + __( |
|
1524 | + '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1525 | + 'event_espresso' |
|
1526 | + ), |
|
1527 | + get_class($this), |
|
1528 | + $property |
|
1529 | + ) |
|
1530 | + ); |
|
1531 | + } |
|
1532 | + // just handling escaping of strings for now. |
|
1533 | + if (is_string($this->{$property})) { |
|
1534 | + return stripslashes($this->{$property}); |
|
1535 | + } |
|
1536 | + return $this->{$property}; |
|
1537 | + } |
|
1538 | + |
|
1539 | + |
|
1540 | + public function populate() |
|
1541 | + { |
|
1542 | + // grab defaults via a new instance of this class. |
|
1543 | + $class_name = get_class($this); |
|
1544 | + $defaults = new $class_name; |
|
1545 | + // loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1546 | + // default from our $defaults object. |
|
1547 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1548 | + if ($this->{$property} === null) { |
|
1549 | + $this->{$property} = $value; |
|
1550 | + } |
|
1551 | + } |
|
1552 | + // cleanup |
|
1553 | + unset($defaults); |
|
1554 | + } |
|
1555 | + |
|
1556 | + |
|
1557 | + /** |
|
1558 | + * __isset |
|
1559 | + * |
|
1560 | + * @param $a |
|
1561 | + * @return bool |
|
1562 | + */ |
|
1563 | + public function __isset($a) |
|
1564 | + { |
|
1565 | + return false; |
|
1566 | + } |
|
1567 | + |
|
1568 | + |
|
1569 | + /** |
|
1570 | + * __unset |
|
1571 | + * |
|
1572 | + * @param $a |
|
1573 | + * @return bool |
|
1574 | + */ |
|
1575 | + public function __unset($a) |
|
1576 | + { |
|
1577 | + return false; |
|
1578 | + } |
|
1579 | + |
|
1580 | + |
|
1581 | + /** |
|
1582 | + * __clone |
|
1583 | + */ |
|
1584 | + public function __clone() |
|
1585 | + { |
|
1586 | + } |
|
1587 | + |
|
1588 | + |
|
1589 | + /** |
|
1590 | + * __wakeup |
|
1591 | + */ |
|
1592 | + public function __wakeup() |
|
1593 | + { |
|
1594 | + } |
|
1595 | + |
|
1596 | + |
|
1597 | + /** |
|
1598 | + * __destruct |
|
1599 | + */ |
|
1600 | + public function __destruct() |
|
1601 | + { |
|
1602 | + } |
|
2184 | 1603 | } |
2185 | 1604 | |
2186 | 1605 | |
2187 | 1606 | /** |
2188 | 1607 | * Class for defining what's in the EE_Config relating to registration settings |
2189 | 1608 | */ |
2190 | -class EE_Registration_Config extends EE_Config_Base |
|
1609 | +class EE_Core_Config extends EE_Config_Base |
|
2191 | 1610 | { |
2192 | 1611 | |
2193 | - /** |
|
2194 | - * Default registration status |
|
2195 | - * |
|
2196 | - * @var string $default_STS_ID |
|
2197 | - * eg 'RPP' |
|
2198 | - */ |
|
2199 | - public $default_STS_ID; |
|
2200 | - |
|
2201 | - |
|
2202 | - /** |
|
2203 | - * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
2204 | - * registrations) |
|
2205 | - * |
|
2206 | - * @var int |
|
2207 | - */ |
|
2208 | - public $default_maximum_number_of_tickets; |
|
2209 | - |
|
2210 | - |
|
2211 | - /** |
|
2212 | - * level of validation to apply to email addresses |
|
2213 | - * |
|
2214 | - * @var string $email_validation_level |
|
2215 | - * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2216 | - */ |
|
2217 | - public $email_validation_level; |
|
2218 | - |
|
2219 | - /** |
|
2220 | - * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2221 | - * |
|
2222 | - * @var boolean $show_pending_payment_options |
|
2223 | - */ |
|
2224 | - public $show_pending_payment_options; |
|
2225 | - |
|
2226 | - /** |
|
2227 | - * Whether to skip the registration confirmation page |
|
2228 | - * |
|
2229 | - * @var boolean $skip_reg_confirmation |
|
2230 | - */ |
|
2231 | - public $skip_reg_confirmation; |
|
2232 | - |
|
2233 | - /** |
|
2234 | - * an array of SPCO reg steps where: |
|
2235 | - * the keys denotes the reg step order |
|
2236 | - * each element consists of an array with the following elements: |
|
2237 | - * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2238 | - * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2239 | - * "slug" => the URL param used to trigger the reg step |
|
2240 | - * |
|
2241 | - * @var array $reg_steps |
|
2242 | - */ |
|
2243 | - public $reg_steps; |
|
2244 | - |
|
2245 | - /** |
|
2246 | - * Whether registration confirmation should be the last page of SPCO |
|
2247 | - * |
|
2248 | - * @var boolean $reg_confirmation_last |
|
2249 | - */ |
|
2250 | - public $reg_confirmation_last; |
|
2251 | - |
|
2252 | - /** |
|
2253 | - * Whether or not to enable the EE Bot Trap |
|
2254 | - * |
|
2255 | - * @var boolean $use_bot_trap |
|
2256 | - */ |
|
2257 | - public $use_bot_trap; |
|
2258 | - |
|
2259 | - /** |
|
2260 | - * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2261 | - * |
|
2262 | - * @var boolean $use_encryption |
|
2263 | - */ |
|
2264 | - public $use_encryption; |
|
2265 | - |
|
2266 | - /** |
|
2267 | - * Whether or not to use ReCaptcha |
|
2268 | - * |
|
2269 | - * @var boolean $use_captcha |
|
2270 | - */ |
|
2271 | - public $use_captcha; |
|
2272 | - |
|
2273 | - /** |
|
2274 | - * ReCaptcha Theme |
|
2275 | - * |
|
2276 | - * @var string $recaptcha_theme |
|
2277 | - * options: 'dark', 'light', 'invisible' |
|
2278 | - */ |
|
2279 | - public $recaptcha_theme; |
|
2280 | - |
|
2281 | - /** |
|
2282 | - * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
2283 | - * |
|
2284 | - * @var string $recaptcha_badge |
|
2285 | - * options: 'bottomright', 'bottomleft', 'inline' |
|
2286 | - */ |
|
2287 | - public $recaptcha_badge; |
|
2288 | - |
|
2289 | - /** |
|
2290 | - * ReCaptcha Type |
|
2291 | - * |
|
2292 | - * @var string $recaptcha_type |
|
2293 | - * options: 'audio', 'image' |
|
2294 | - */ |
|
2295 | - public $recaptcha_type; |
|
2296 | - |
|
2297 | - /** |
|
2298 | - * ReCaptcha language |
|
2299 | - * |
|
2300 | - * @var string $recaptcha_language |
|
2301 | - * eg 'en' |
|
2302 | - */ |
|
2303 | - public $recaptcha_language; |
|
2304 | - |
|
2305 | - /** |
|
2306 | - * ReCaptcha public key |
|
2307 | - * |
|
2308 | - * @var string $recaptcha_publickey |
|
2309 | - */ |
|
2310 | - public $recaptcha_publickey; |
|
2311 | - |
|
2312 | - /** |
|
2313 | - * ReCaptcha private key |
|
2314 | - * |
|
2315 | - * @var string $recaptcha_privatekey |
|
2316 | - */ |
|
2317 | - public $recaptcha_privatekey; |
|
2318 | - |
|
2319 | - /** |
|
2320 | - * array of form names protected by ReCaptcha |
|
2321 | - * |
|
2322 | - * @var array $recaptcha_protected_forms |
|
2323 | - */ |
|
2324 | - public $recaptcha_protected_forms; |
|
2325 | - |
|
2326 | - /** |
|
2327 | - * ReCaptcha width |
|
2328 | - * |
|
2329 | - * @var int $recaptcha_width |
|
2330 | - * @deprecated |
|
2331 | - */ |
|
2332 | - public $recaptcha_width; |
|
2333 | - |
|
2334 | - /** |
|
2335 | - * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2336 | - * |
|
2337 | - * @var boolean $track_invalid_checkout_access |
|
2338 | - */ |
|
2339 | - protected $track_invalid_checkout_access = true; |
|
2340 | - |
|
1612 | + public $current_blog_id; |
|
1613 | + |
|
1614 | + public $ee_ueip_optin; |
|
1615 | + |
|
1616 | + public $ee_ueip_has_notified; |
|
1617 | + |
|
1618 | + /** |
|
1619 | + * Not to be confused with the 4 critical page variables (See |
|
1620 | + * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1621 | + * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1622 | + * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1623 | + * |
|
1624 | + * @var array |
|
1625 | + */ |
|
1626 | + public $post_shortcodes; |
|
1627 | + |
|
1628 | + public $module_route_map; |
|
1629 | + |
|
1630 | + public $module_forward_map; |
|
1631 | + |
|
1632 | + public $module_view_map; |
|
1633 | + |
|
1634 | + /** |
|
1635 | + * The next 4 vars are the IDs of critical EE pages. |
|
1636 | + * |
|
1637 | + * @var int |
|
1638 | + */ |
|
1639 | + public $reg_page_id; |
|
1640 | + |
|
1641 | + public $txn_page_id; |
|
1642 | + |
|
1643 | + public $thank_you_page_id; |
|
1644 | + |
|
1645 | + public $cancel_page_id; |
|
1646 | + |
|
1647 | + /** |
|
1648 | + * The next 4 vars are the URLs of critical EE pages. |
|
1649 | + * |
|
1650 | + * @var int |
|
1651 | + */ |
|
1652 | + public $reg_page_url; |
|
1653 | + |
|
1654 | + public $txn_page_url; |
|
1655 | + |
|
1656 | + public $thank_you_page_url; |
|
1657 | + |
|
1658 | + public $cancel_page_url; |
|
1659 | + |
|
1660 | + /** |
|
1661 | + * The next vars relate to the custom slugs for EE CPT routes |
|
1662 | + */ |
|
1663 | + public $event_cpt_slug; |
|
1664 | + |
|
1665 | + |
|
1666 | + /** |
|
1667 | + * This caches the _ee_ueip_option in case this config is reset in the same |
|
1668 | + * request across blog switches in a multisite context. |
|
1669 | + * Avoids extra queries to the db for this option. |
|
1670 | + * |
|
1671 | + * @var bool |
|
1672 | + */ |
|
1673 | + public static $ee_ueip_option; |
|
1674 | + |
|
1675 | + |
|
1676 | + /** |
|
1677 | + * class constructor |
|
1678 | + * |
|
1679 | + * @access public |
|
1680 | + */ |
|
1681 | + public function __construct() |
|
1682 | + { |
|
1683 | + // set default organization settings |
|
1684 | + $this->current_blog_id = get_current_blog_id(); |
|
1685 | + $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1686 | + $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1687 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1688 | + $this->post_shortcodes = array(); |
|
1689 | + $this->module_route_map = array(); |
|
1690 | + $this->module_forward_map = array(); |
|
1691 | + $this->module_view_map = array(); |
|
1692 | + // critical EE page IDs |
|
1693 | + $this->reg_page_id = 0; |
|
1694 | + $this->txn_page_id = 0; |
|
1695 | + $this->thank_you_page_id = 0; |
|
1696 | + $this->cancel_page_id = 0; |
|
1697 | + // critical EE page URLs |
|
1698 | + $this->reg_page_url = ''; |
|
1699 | + $this->txn_page_url = ''; |
|
1700 | + $this->thank_you_page_url = ''; |
|
1701 | + $this->cancel_page_url = ''; |
|
1702 | + // cpt slugs |
|
1703 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1704 | + // ueip constant check |
|
1705 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1706 | + $this->ee_ueip_optin = false; |
|
1707 | + $this->ee_ueip_has_notified = true; |
|
1708 | + } |
|
1709 | + } |
|
1710 | + |
|
1711 | + |
|
1712 | + /** |
|
1713 | + * @return array |
|
1714 | + */ |
|
1715 | + public function get_critical_pages_array() |
|
1716 | + { |
|
1717 | + return array( |
|
1718 | + $this->reg_page_id, |
|
1719 | + $this->txn_page_id, |
|
1720 | + $this->thank_you_page_id, |
|
1721 | + $this->cancel_page_id, |
|
1722 | + ); |
|
1723 | + } |
|
1724 | + |
|
1725 | + |
|
1726 | + /** |
|
1727 | + * @return array |
|
1728 | + */ |
|
1729 | + public function get_critical_pages_shortcodes_array() |
|
1730 | + { |
|
1731 | + return array( |
|
1732 | + $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1733 | + $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1734 | + $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1735 | + $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1736 | + ); |
|
1737 | + } |
|
1738 | + |
|
1739 | + |
|
1740 | + /** |
|
1741 | + * gets/returns URL for EE reg_page |
|
1742 | + * |
|
1743 | + * @access public |
|
1744 | + * @return string |
|
1745 | + */ |
|
1746 | + public function reg_page_url() |
|
1747 | + { |
|
1748 | + if (! $this->reg_page_url) { |
|
1749 | + $this->reg_page_url = add_query_arg( |
|
1750 | + array('uts' => time()), |
|
1751 | + get_permalink($this->reg_page_id) |
|
1752 | + ) . '#checkout'; |
|
1753 | + } |
|
1754 | + return $this->reg_page_url; |
|
1755 | + } |
|
1756 | + |
|
1757 | + |
|
1758 | + /** |
|
1759 | + * gets/returns URL for EE txn_page |
|
1760 | + * |
|
1761 | + * @param array $query_args like what gets passed to |
|
1762 | + * add_query_arg() as the first argument |
|
1763 | + * @access public |
|
1764 | + * @return string |
|
1765 | + */ |
|
1766 | + public function txn_page_url($query_args = array()) |
|
1767 | + { |
|
1768 | + if (! $this->txn_page_url) { |
|
1769 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1770 | + } |
|
1771 | + if ($query_args) { |
|
1772 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1773 | + } else { |
|
1774 | + return $this->txn_page_url; |
|
1775 | + } |
|
1776 | + } |
|
1777 | + |
|
1778 | + |
|
1779 | + /** |
|
1780 | + * gets/returns URL for EE thank_you_page |
|
1781 | + * |
|
1782 | + * @param array $query_args like what gets passed to |
|
1783 | + * add_query_arg() as the first argument |
|
1784 | + * @access public |
|
1785 | + * @return string |
|
1786 | + */ |
|
1787 | + public function thank_you_page_url($query_args = array()) |
|
1788 | + { |
|
1789 | + if (! $this->thank_you_page_url) { |
|
1790 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1791 | + } |
|
1792 | + if ($query_args) { |
|
1793 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1794 | + } else { |
|
1795 | + return $this->thank_you_page_url; |
|
1796 | + } |
|
1797 | + } |
|
1798 | + |
|
1799 | + |
|
1800 | + /** |
|
1801 | + * gets/returns URL for EE cancel_page |
|
1802 | + * |
|
1803 | + * @access public |
|
1804 | + * @return string |
|
1805 | + */ |
|
1806 | + public function cancel_page_url() |
|
1807 | + { |
|
1808 | + if (! $this->cancel_page_url) { |
|
1809 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1810 | + } |
|
1811 | + return $this->cancel_page_url; |
|
1812 | + } |
|
1813 | + |
|
1814 | + |
|
1815 | + /** |
|
1816 | + * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1817 | + * |
|
1818 | + * @since 4.7.5 |
|
1819 | + */ |
|
1820 | + protected function _reset_urls() |
|
1821 | + { |
|
1822 | + $this->reg_page_url = ''; |
|
1823 | + $this->txn_page_url = ''; |
|
1824 | + $this->cancel_page_url = ''; |
|
1825 | + $this->thank_you_page_url = ''; |
|
1826 | + } |
|
1827 | + |
|
1828 | + |
|
1829 | + /** |
|
1830 | + * Used to return what the optin value is set for the EE User Experience Program. |
|
1831 | + * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1832 | + * on the main site only. |
|
1833 | + * |
|
1834 | + * @return mixed|void |
|
1835 | + */ |
|
1836 | + protected function _get_main_ee_ueip_optin() |
|
1837 | + { |
|
1838 | + // if this is the main site then we can just bypass our direct query. |
|
1839 | + if (is_main_site()) { |
|
1840 | + return get_option('ee_ueip_optin', false); |
|
1841 | + } |
|
1842 | + // is this already cached for this request? If so use it. |
|
1843 | + if (! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1844 | + return EE_Core_Config::$ee_ueip_option; |
|
1845 | + } |
|
1846 | + global $wpdb; |
|
1847 | + $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1848 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1849 | + $option = 'ee_ueip_optin'; |
|
1850 | + // set correct table for query |
|
1851 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1852 | + // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1853 | + // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1854 | + // re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1855 | + // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1856 | + // for the purpose of caching. |
|
1857 | + $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1858 | + if (false !== $pre) { |
|
1859 | + EE_Core_Config::$ee_ueip_option = $pre; |
|
1860 | + return EE_Core_Config::$ee_ueip_option; |
|
1861 | + } |
|
1862 | + $row = $wpdb->get_row( |
|
1863 | + $wpdb->prepare( |
|
1864 | + "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
1865 | + $option |
|
1866 | + ) |
|
1867 | + ); |
|
1868 | + if (is_object($row)) { |
|
1869 | + $value = $row->option_value; |
|
1870 | + } else { // option does not exist so use default. |
|
1871 | + return apply_filters('default_option_' . $option, false, $option); |
|
1872 | + } |
|
1873 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
1874 | + return EE_Core_Config::$ee_ueip_option; |
|
1875 | + } |
|
1876 | + |
|
1877 | + /** |
|
1878 | + * Utility function for escaping the value of a property and returning. |
|
1879 | + * |
|
1880 | + * @param string $property property name (checks to see if exists). |
|
1881 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1882 | + * @throws \EE_Error |
|
1883 | + */ |
|
1884 | + public function get_pretty($property) |
|
1885 | + { |
|
1886 | + if ($property === 'ee_ueip_optin') { |
|
1887 | + return $this->ee_ueip_optin ? 'yes' : 'no'; |
|
1888 | + } |
|
1889 | + return parent::get_pretty($property); |
|
1890 | + } |
|
1891 | + |
|
1892 | + |
|
1893 | + /** |
|
1894 | + * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
1895 | + * on the object. |
|
1896 | + * |
|
1897 | + * @return array |
|
1898 | + */ |
|
1899 | + public function __sleep() |
|
1900 | + { |
|
1901 | + // reset all url properties |
|
1902 | + $this->_reset_urls(); |
|
1903 | + // return what to save to db |
|
1904 | + return array_keys(get_object_vars($this)); |
|
1905 | + } |
|
1906 | +} |
|
2341 | 1907 | |
2342 | - /** |
|
2343 | - * class constructor |
|
2344 | - * |
|
2345 | - * @access public |
|
2346 | - */ |
|
2347 | - public function __construct() |
|
2348 | - { |
|
2349 | - // set default registration settings |
|
2350 | - $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2351 | - $this->email_validation_level = 'wp_default'; |
|
2352 | - $this->show_pending_payment_options = true; |
|
2353 | - $this->skip_reg_confirmation = true; |
|
2354 | - $this->reg_steps = array(); |
|
2355 | - $this->reg_confirmation_last = false; |
|
2356 | - $this->use_bot_trap = true; |
|
2357 | - $this->use_encryption = true; |
|
2358 | - $this->use_captcha = false; |
|
2359 | - $this->recaptcha_theme = 'light'; |
|
2360 | - $this->recaptcha_badge = 'bottomleft'; |
|
2361 | - $this->recaptcha_type = 'image'; |
|
2362 | - $this->recaptcha_language = 'en'; |
|
2363 | - $this->recaptcha_publickey = null; |
|
2364 | - $this->recaptcha_privatekey = null; |
|
2365 | - $this->recaptcha_protected_forms = array(); |
|
2366 | - $this->recaptcha_width = 500; |
|
2367 | - $this->default_maximum_number_of_tickets = 10; |
|
2368 | - } |
|
2369 | - |
|
2370 | - |
|
2371 | - /** |
|
2372 | - * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2373 | - * |
|
2374 | - * @since 4.8.8.rc.019 |
|
2375 | - */ |
|
2376 | - public function do_hooks() |
|
2377 | - { |
|
2378 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2379 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
2380 | - } |
|
2381 | 1908 | |
1909 | +/** |
|
1910 | + * Config class for storing info on the Organization |
|
1911 | + */ |
|
1912 | +class EE_Organization_Config extends EE_Config_Base |
|
1913 | +{ |
|
2382 | 1914 | |
2383 | - /** |
|
2384 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the |
|
2385 | - * EVT_default_registration_status field matches the config setting for default_STS_ID. |
|
2386 | - */ |
|
2387 | - public function set_default_reg_status_on_EEM_Event() |
|
2388 | - { |
|
2389 | - EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2390 | - } |
|
1915 | + /** |
|
1916 | + * @var string $name |
|
1917 | + * eg EE4.1 |
|
1918 | + */ |
|
1919 | + public $name; |
|
1920 | + |
|
1921 | + /** |
|
1922 | + * @var string $address_1 |
|
1923 | + * eg 123 Onna Road |
|
1924 | + */ |
|
1925 | + public $address_1; |
|
1926 | + |
|
1927 | + /** |
|
1928 | + * @var string $address_2 |
|
1929 | + * eg PO Box 123 |
|
1930 | + */ |
|
1931 | + public $address_2; |
|
1932 | + |
|
1933 | + /** |
|
1934 | + * @var string $city |
|
1935 | + * eg Inna City |
|
1936 | + */ |
|
1937 | + public $city; |
|
1938 | + |
|
1939 | + /** |
|
1940 | + * @var int $STA_ID |
|
1941 | + * eg 4 |
|
1942 | + */ |
|
1943 | + public $STA_ID; |
|
1944 | + |
|
1945 | + /** |
|
1946 | + * @var string $CNT_ISO |
|
1947 | + * eg US |
|
1948 | + */ |
|
1949 | + public $CNT_ISO; |
|
1950 | + |
|
1951 | + /** |
|
1952 | + * @var string $zip |
|
1953 | + * eg 12345 or V1A 2B3 |
|
1954 | + */ |
|
1955 | + public $zip; |
|
1956 | + |
|
1957 | + /** |
|
1958 | + * @var string $email |
|
1959 | + * eg [email protected] |
|
1960 | + */ |
|
1961 | + public $email; |
|
1962 | + |
|
1963 | + |
|
1964 | + /** |
|
1965 | + * @var string $phone |
|
1966 | + * eg. 111-111-1111 |
|
1967 | + */ |
|
1968 | + public $phone; |
|
1969 | + |
|
1970 | + |
|
1971 | + /** |
|
1972 | + * @var string $vat |
|
1973 | + * VAT/Tax Number |
|
1974 | + */ |
|
1975 | + public $vat; |
|
1976 | + |
|
1977 | + /** |
|
1978 | + * @var string $logo_url |
|
1979 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
1980 | + */ |
|
1981 | + public $logo_url; |
|
1982 | + |
|
1983 | + |
|
1984 | + /** |
|
1985 | + * The below are all various properties for holding links to organization social network profiles |
|
1986 | + * |
|
1987 | + * @var string |
|
1988 | + */ |
|
1989 | + /** |
|
1990 | + * facebook (facebook.com/profile.name) |
|
1991 | + * |
|
1992 | + * @var string |
|
1993 | + */ |
|
1994 | + public $facebook; |
|
1995 | + |
|
1996 | + |
|
1997 | + /** |
|
1998 | + * twitter (twitter.com/twitter_handle) |
|
1999 | + * |
|
2000 | + * @var string |
|
2001 | + */ |
|
2002 | + public $twitter; |
|
2003 | + |
|
2004 | + |
|
2005 | + /** |
|
2006 | + * linkedin (linkedin.com/in/profile_name) |
|
2007 | + * |
|
2008 | + * @var string |
|
2009 | + */ |
|
2010 | + public $linkedin; |
|
2011 | + |
|
2012 | + |
|
2013 | + /** |
|
2014 | + * pinterest (www.pinterest.com/profile_name) |
|
2015 | + * |
|
2016 | + * @var string |
|
2017 | + */ |
|
2018 | + public $pinterest; |
|
2019 | + |
|
2020 | + |
|
2021 | + /** |
|
2022 | + * google+ (google.com/+profileName) |
|
2023 | + * |
|
2024 | + * @var string |
|
2025 | + */ |
|
2026 | + public $google; |
|
2027 | + |
|
2028 | + |
|
2029 | + /** |
|
2030 | + * instagram (instagram.com/handle) |
|
2031 | + * |
|
2032 | + * @var string |
|
2033 | + */ |
|
2034 | + public $instagram; |
|
2035 | + |
|
2036 | + |
|
2037 | + /** |
|
2038 | + * class constructor |
|
2039 | + * |
|
2040 | + * @access public |
|
2041 | + */ |
|
2042 | + public function __construct() |
|
2043 | + { |
|
2044 | + // set default organization settings |
|
2045 | + // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
2046 | + $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
2047 | + $this->address_1 = '123 Onna Road'; |
|
2048 | + $this->address_2 = 'PO Box 123'; |
|
2049 | + $this->city = 'Inna City'; |
|
2050 | + $this->STA_ID = 4; |
|
2051 | + $this->CNT_ISO = 'US'; |
|
2052 | + $this->zip = '12345'; |
|
2053 | + $this->email = get_bloginfo('admin_email'); |
|
2054 | + $this->phone = ''; |
|
2055 | + $this->vat = '123456789'; |
|
2056 | + $this->logo_url = ''; |
|
2057 | + $this->facebook = ''; |
|
2058 | + $this->twitter = ''; |
|
2059 | + $this->linkedin = ''; |
|
2060 | + $this->pinterest = ''; |
|
2061 | + $this->google = ''; |
|
2062 | + $this->instagram = ''; |
|
2063 | + } |
|
2064 | +} |
|
2391 | 2065 | |
2392 | 2066 | |
2393 | - /** |
|
2394 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
2395 | - * for Events matches the config setting for default_maximum_number_of_tickets |
|
2396 | - */ |
|
2397 | - public function set_default_max_ticket_on_EEM_Event() |
|
2398 | - { |
|
2399 | - EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
2400 | - } |
|
2067 | +/** |
|
2068 | + * Class for defining what's in the EE_Config relating to currency |
|
2069 | + */ |
|
2070 | +class EE_Currency_Config extends EE_Config_Base |
|
2071 | +{ |
|
2401 | 2072 | |
2073 | + /** |
|
2074 | + * @var string $code |
|
2075 | + * eg 'US' |
|
2076 | + */ |
|
2077 | + public $code; |
|
2078 | + |
|
2079 | + /** |
|
2080 | + * @var string $name |
|
2081 | + * eg 'Dollar' |
|
2082 | + */ |
|
2083 | + public $name; |
|
2084 | + |
|
2085 | + /** |
|
2086 | + * plural name |
|
2087 | + * |
|
2088 | + * @var string $plural |
|
2089 | + * eg 'Dollars' |
|
2090 | + */ |
|
2091 | + public $plural; |
|
2092 | + |
|
2093 | + /** |
|
2094 | + * currency sign |
|
2095 | + * |
|
2096 | + * @var string $sign |
|
2097 | + * eg '$' |
|
2098 | + */ |
|
2099 | + public $sign; |
|
2100 | + |
|
2101 | + /** |
|
2102 | + * Whether the currency sign should come before the number or not |
|
2103 | + * |
|
2104 | + * @var boolean $sign_b4 |
|
2105 | + */ |
|
2106 | + public $sign_b4; |
|
2107 | + |
|
2108 | + /** |
|
2109 | + * How many digits should come after the decimal place |
|
2110 | + * |
|
2111 | + * @var int $dec_plc |
|
2112 | + */ |
|
2113 | + public $dec_plc; |
|
2114 | + |
|
2115 | + /** |
|
2116 | + * Symbol to use for decimal mark |
|
2117 | + * |
|
2118 | + * @var string $dec_mrk |
|
2119 | + * eg '.' |
|
2120 | + */ |
|
2121 | + public $dec_mrk; |
|
2122 | + |
|
2123 | + /** |
|
2124 | + * Symbol to use for thousands |
|
2125 | + * |
|
2126 | + * @var string $thsnds |
|
2127 | + * eg ',' |
|
2128 | + */ |
|
2129 | + public $thsnds; |
|
2130 | + |
|
2131 | + |
|
2132 | + /** |
|
2133 | + * class constructor |
|
2134 | + * |
|
2135 | + * @access public |
|
2136 | + * @param string $CNT_ISO |
|
2137 | + * @throws \EE_Error |
|
2138 | + */ |
|
2139 | + public function __construct($CNT_ISO = '') |
|
2140 | + { |
|
2141 | + /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2142 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2143 | + // get country code from organization settings or use default |
|
2144 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2145 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2146 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2147 | + : ''; |
|
2148 | + // but override if requested |
|
2149 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2150 | + // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2151 | + if (! empty($CNT_ISO) |
|
2152 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
2153 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2154 | + ) { |
|
2155 | + // retrieve the country settings from the db, just in case they have been customized |
|
2156 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2157 | + if ($country instanceof EE_Country) { |
|
2158 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2159 | + $this->name = $country->currency_name_single(); // Dollar |
|
2160 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2161 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2162 | + $this->sign_b4 = $country->currency_sign_before( |
|
2163 | + ); // currency sign before or after: $TRUE or FALSE$ |
|
2164 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2165 | + $this->dec_mrk = $country->currency_decimal_mark( |
|
2166 | + ); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2167 | + $this->thsnds = $country->currency_thousands_separator( |
|
2168 | + ); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2169 | + } |
|
2170 | + } |
|
2171 | + // fallback to hardcoded defaults, in case the above failed |
|
2172 | + if (empty($this->code)) { |
|
2173 | + // set default currency settings |
|
2174 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2175 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2176 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2177 | + $this->sign = '$'; // currency sign: $ |
|
2178 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2179 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2180 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2181 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2182 | + } |
|
2183 | + } |
|
2184 | +} |
|
2402 | 2185 | |
2403 | - /** |
|
2404 | - * @return boolean |
|
2405 | - */ |
|
2406 | - public function track_invalid_checkout_access() |
|
2407 | - { |
|
2408 | - return $this->track_invalid_checkout_access; |
|
2409 | - } |
|
2410 | 2186 | |
2187 | +/** |
|
2188 | + * Class for defining what's in the EE_Config relating to registration settings |
|
2189 | + */ |
|
2190 | +class EE_Registration_Config extends EE_Config_Base |
|
2191 | +{ |
|
2411 | 2192 | |
2412 | - /** |
|
2413 | - * @param boolean $track_invalid_checkout_access |
|
2414 | - */ |
|
2415 | - public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2416 | - { |
|
2417 | - $this->track_invalid_checkout_access = filter_var( |
|
2418 | - $track_invalid_checkout_access, |
|
2419 | - FILTER_VALIDATE_BOOLEAN |
|
2420 | - ); |
|
2421 | - } |
|
2193 | + /** |
|
2194 | + * Default registration status |
|
2195 | + * |
|
2196 | + * @var string $default_STS_ID |
|
2197 | + * eg 'RPP' |
|
2198 | + */ |
|
2199 | + public $default_STS_ID; |
|
2200 | + |
|
2201 | + |
|
2202 | + /** |
|
2203 | + * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
2204 | + * registrations) |
|
2205 | + * |
|
2206 | + * @var int |
|
2207 | + */ |
|
2208 | + public $default_maximum_number_of_tickets; |
|
2209 | + |
|
2210 | + |
|
2211 | + /** |
|
2212 | + * level of validation to apply to email addresses |
|
2213 | + * |
|
2214 | + * @var string $email_validation_level |
|
2215 | + * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2216 | + */ |
|
2217 | + public $email_validation_level; |
|
2218 | + |
|
2219 | + /** |
|
2220 | + * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2221 | + * |
|
2222 | + * @var boolean $show_pending_payment_options |
|
2223 | + */ |
|
2224 | + public $show_pending_payment_options; |
|
2225 | + |
|
2226 | + /** |
|
2227 | + * Whether to skip the registration confirmation page |
|
2228 | + * |
|
2229 | + * @var boolean $skip_reg_confirmation |
|
2230 | + */ |
|
2231 | + public $skip_reg_confirmation; |
|
2232 | + |
|
2233 | + /** |
|
2234 | + * an array of SPCO reg steps where: |
|
2235 | + * the keys denotes the reg step order |
|
2236 | + * each element consists of an array with the following elements: |
|
2237 | + * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2238 | + * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2239 | + * "slug" => the URL param used to trigger the reg step |
|
2240 | + * |
|
2241 | + * @var array $reg_steps |
|
2242 | + */ |
|
2243 | + public $reg_steps; |
|
2244 | + |
|
2245 | + /** |
|
2246 | + * Whether registration confirmation should be the last page of SPCO |
|
2247 | + * |
|
2248 | + * @var boolean $reg_confirmation_last |
|
2249 | + */ |
|
2250 | + public $reg_confirmation_last; |
|
2251 | + |
|
2252 | + /** |
|
2253 | + * Whether or not to enable the EE Bot Trap |
|
2254 | + * |
|
2255 | + * @var boolean $use_bot_trap |
|
2256 | + */ |
|
2257 | + public $use_bot_trap; |
|
2258 | + |
|
2259 | + /** |
|
2260 | + * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2261 | + * |
|
2262 | + * @var boolean $use_encryption |
|
2263 | + */ |
|
2264 | + public $use_encryption; |
|
2265 | + |
|
2266 | + /** |
|
2267 | + * Whether or not to use ReCaptcha |
|
2268 | + * |
|
2269 | + * @var boolean $use_captcha |
|
2270 | + */ |
|
2271 | + public $use_captcha; |
|
2272 | + |
|
2273 | + /** |
|
2274 | + * ReCaptcha Theme |
|
2275 | + * |
|
2276 | + * @var string $recaptcha_theme |
|
2277 | + * options: 'dark', 'light', 'invisible' |
|
2278 | + */ |
|
2279 | + public $recaptcha_theme; |
|
2280 | + |
|
2281 | + /** |
|
2282 | + * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
2283 | + * |
|
2284 | + * @var string $recaptcha_badge |
|
2285 | + * options: 'bottomright', 'bottomleft', 'inline' |
|
2286 | + */ |
|
2287 | + public $recaptcha_badge; |
|
2288 | + |
|
2289 | + /** |
|
2290 | + * ReCaptcha Type |
|
2291 | + * |
|
2292 | + * @var string $recaptcha_type |
|
2293 | + * options: 'audio', 'image' |
|
2294 | + */ |
|
2295 | + public $recaptcha_type; |
|
2296 | + |
|
2297 | + /** |
|
2298 | + * ReCaptcha language |
|
2299 | + * |
|
2300 | + * @var string $recaptcha_language |
|
2301 | + * eg 'en' |
|
2302 | + */ |
|
2303 | + public $recaptcha_language; |
|
2304 | + |
|
2305 | + /** |
|
2306 | + * ReCaptcha public key |
|
2307 | + * |
|
2308 | + * @var string $recaptcha_publickey |
|
2309 | + */ |
|
2310 | + public $recaptcha_publickey; |
|
2311 | + |
|
2312 | + /** |
|
2313 | + * ReCaptcha private key |
|
2314 | + * |
|
2315 | + * @var string $recaptcha_privatekey |
|
2316 | + */ |
|
2317 | + public $recaptcha_privatekey; |
|
2318 | + |
|
2319 | + /** |
|
2320 | + * array of form names protected by ReCaptcha |
|
2321 | + * |
|
2322 | + * @var array $recaptcha_protected_forms |
|
2323 | + */ |
|
2324 | + public $recaptcha_protected_forms; |
|
2325 | + |
|
2326 | + /** |
|
2327 | + * ReCaptcha width |
|
2328 | + * |
|
2329 | + * @var int $recaptcha_width |
|
2330 | + * @deprecated |
|
2331 | + */ |
|
2332 | + public $recaptcha_width; |
|
2333 | + |
|
2334 | + /** |
|
2335 | + * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2336 | + * |
|
2337 | + * @var boolean $track_invalid_checkout_access |
|
2338 | + */ |
|
2339 | + protected $track_invalid_checkout_access = true; |
|
2340 | + |
|
2341 | + |
|
2342 | + /** |
|
2343 | + * class constructor |
|
2344 | + * |
|
2345 | + * @access public |
|
2346 | + */ |
|
2347 | + public function __construct() |
|
2348 | + { |
|
2349 | + // set default registration settings |
|
2350 | + $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2351 | + $this->email_validation_level = 'wp_default'; |
|
2352 | + $this->show_pending_payment_options = true; |
|
2353 | + $this->skip_reg_confirmation = true; |
|
2354 | + $this->reg_steps = array(); |
|
2355 | + $this->reg_confirmation_last = false; |
|
2356 | + $this->use_bot_trap = true; |
|
2357 | + $this->use_encryption = true; |
|
2358 | + $this->use_captcha = false; |
|
2359 | + $this->recaptcha_theme = 'light'; |
|
2360 | + $this->recaptcha_badge = 'bottomleft'; |
|
2361 | + $this->recaptcha_type = 'image'; |
|
2362 | + $this->recaptcha_language = 'en'; |
|
2363 | + $this->recaptcha_publickey = null; |
|
2364 | + $this->recaptcha_privatekey = null; |
|
2365 | + $this->recaptcha_protected_forms = array(); |
|
2366 | + $this->recaptcha_width = 500; |
|
2367 | + $this->default_maximum_number_of_tickets = 10; |
|
2368 | + } |
|
2369 | + |
|
2370 | + |
|
2371 | + /** |
|
2372 | + * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2373 | + * |
|
2374 | + * @since 4.8.8.rc.019 |
|
2375 | + */ |
|
2376 | + public function do_hooks() |
|
2377 | + { |
|
2378 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2379 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
2380 | + } |
|
2381 | + |
|
2382 | + |
|
2383 | + /** |
|
2384 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the |
|
2385 | + * EVT_default_registration_status field matches the config setting for default_STS_ID. |
|
2386 | + */ |
|
2387 | + public function set_default_reg_status_on_EEM_Event() |
|
2388 | + { |
|
2389 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2390 | + } |
|
2391 | + |
|
2392 | + |
|
2393 | + /** |
|
2394 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
2395 | + * for Events matches the config setting for default_maximum_number_of_tickets |
|
2396 | + */ |
|
2397 | + public function set_default_max_ticket_on_EEM_Event() |
|
2398 | + { |
|
2399 | + EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
2400 | + } |
|
2401 | + |
|
2402 | + |
|
2403 | + /** |
|
2404 | + * @return boolean |
|
2405 | + */ |
|
2406 | + public function track_invalid_checkout_access() |
|
2407 | + { |
|
2408 | + return $this->track_invalid_checkout_access; |
|
2409 | + } |
|
2410 | + |
|
2411 | + |
|
2412 | + /** |
|
2413 | + * @param boolean $track_invalid_checkout_access |
|
2414 | + */ |
|
2415 | + public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2416 | + { |
|
2417 | + $this->track_invalid_checkout_access = filter_var( |
|
2418 | + $track_invalid_checkout_access, |
|
2419 | + FILTER_VALIDATE_BOOLEAN |
|
2420 | + ); |
|
2421 | + } |
|
2422 | 2422 | } |
2423 | 2423 | |
2424 | 2424 | |
@@ -2428,175 +2428,175 @@ discard block |
||
2428 | 2428 | class EE_Admin_Config extends EE_Config_Base |
2429 | 2429 | { |
2430 | 2430 | |
2431 | - /** |
|
2432 | - * @var boolean $use_personnel_manager |
|
2433 | - */ |
|
2434 | - public $use_personnel_manager; |
|
2435 | - |
|
2436 | - /** |
|
2437 | - * @var boolean $use_dashboard_widget |
|
2438 | - */ |
|
2439 | - public $use_dashboard_widget; |
|
2440 | - |
|
2441 | - /** |
|
2442 | - * @var int $events_in_dashboard |
|
2443 | - */ |
|
2444 | - public $events_in_dashboard; |
|
2445 | - |
|
2446 | - /** |
|
2447 | - * @var boolean $use_event_timezones |
|
2448 | - */ |
|
2449 | - public $use_event_timezones; |
|
2450 | - |
|
2451 | - /** |
|
2452 | - * @var boolean $use_full_logging |
|
2453 | - */ |
|
2454 | - public $use_full_logging; |
|
2455 | - |
|
2456 | - /** |
|
2457 | - * @var string $log_file_name |
|
2458 | - */ |
|
2459 | - public $log_file_name; |
|
2460 | - |
|
2461 | - /** |
|
2462 | - * @var string $debug_file_name |
|
2463 | - */ |
|
2464 | - public $debug_file_name; |
|
2465 | - |
|
2466 | - /** |
|
2467 | - * @var boolean $use_remote_logging |
|
2468 | - */ |
|
2469 | - public $use_remote_logging; |
|
2470 | - |
|
2471 | - /** |
|
2472 | - * @var string $remote_logging_url |
|
2473 | - */ |
|
2474 | - public $remote_logging_url; |
|
2475 | - |
|
2476 | - /** |
|
2477 | - * @var boolean $show_reg_footer |
|
2478 | - */ |
|
2479 | - public $show_reg_footer; |
|
2480 | - |
|
2481 | - /** |
|
2482 | - * @var string $affiliate_id |
|
2483 | - */ |
|
2484 | - public $affiliate_id; |
|
2485 | - |
|
2486 | - /** |
|
2487 | - * help tours on or off (global setting) |
|
2488 | - * |
|
2489 | - * @var boolean |
|
2490 | - */ |
|
2491 | - public $help_tour_activation; |
|
2492 | - |
|
2493 | - public $gateway_log_lifespan = '1 week'; |
|
2494 | - |
|
2495 | - /** |
|
2496 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
2497 | - * but is incompatible with some server configuration errors |
|
2498 | - * if you get "500 internal server errors" during registration, try turning this on |
|
2499 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2500 | - * |
|
2501 | - * @var boolean $encode_session_data |
|
2502 | - */ |
|
2503 | - private $encode_session_data = false; |
|
2504 | - |
|
2505 | - |
|
2506 | - /** |
|
2507 | - * class constructor |
|
2508 | - * |
|
2509 | - * @access public |
|
2510 | - */ |
|
2511 | - public function __construct() |
|
2512 | - { |
|
2513 | - // set default general admin settings |
|
2514 | - $this->use_personnel_manager = true; |
|
2515 | - $this->use_dashboard_widget = true; |
|
2516 | - $this->events_in_dashboard = 30; |
|
2517 | - $this->use_event_timezones = false; |
|
2518 | - $this->use_full_logging = false; |
|
2519 | - $this->use_remote_logging = false; |
|
2520 | - $this->remote_logging_url = null; |
|
2521 | - $this->show_reg_footer = true; |
|
2522 | - $this->affiliate_id = 'default'; |
|
2523 | - $this->help_tour_activation = true; |
|
2524 | - $this->encode_session_data = false; |
|
2525 | - $this->gateway_log_lifespan = '1 week'; |
|
2526 | - } |
|
2527 | - |
|
2528 | - |
|
2529 | - /** |
|
2530 | - * @param bool $reset |
|
2531 | - * @return string |
|
2532 | - */ |
|
2533 | - public function log_file_name($reset = false) |
|
2534 | - { |
|
2535 | - if (empty($this->log_file_name) || $reset) { |
|
2536 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2537 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2538 | - } |
|
2539 | - return $this->log_file_name; |
|
2540 | - } |
|
2541 | - |
|
2542 | - |
|
2543 | - /** |
|
2544 | - * @param bool $reset |
|
2545 | - * @return string |
|
2546 | - */ |
|
2547 | - public function debug_file_name($reset = false) |
|
2548 | - { |
|
2549 | - if (empty($this->debug_file_name) || $reset) { |
|
2550 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2551 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2552 | - } |
|
2553 | - return $this->debug_file_name; |
|
2554 | - } |
|
2555 | - |
|
2556 | - |
|
2557 | - /** |
|
2558 | - * @return string |
|
2559 | - */ |
|
2560 | - public function affiliate_id() |
|
2561 | - { |
|
2562 | - return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2563 | - } |
|
2564 | - |
|
2565 | - |
|
2566 | - /** |
|
2567 | - * @return boolean |
|
2568 | - */ |
|
2569 | - public function encode_session_data() |
|
2570 | - { |
|
2571 | - return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2572 | - } |
|
2573 | - |
|
2574 | - |
|
2575 | - /** |
|
2576 | - * @param boolean $encode_session_data |
|
2577 | - */ |
|
2578 | - public function set_encode_session_data($encode_session_data) |
|
2579 | - { |
|
2580 | - $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2581 | - } |
|
2582 | - |
|
2583 | - |
|
2584 | - /** |
|
2585 | - * Gets the options to make availalbe for the gateway log lifespan |
|
2586 | - * @return array |
|
2587 | - */ |
|
2588 | - public function gatewayLogLifespanOptions() |
|
2589 | - { |
|
2590 | - return (array) apply_filters( |
|
2591 | - 'FHEE_EE_Admin_Config__gatewayLogLifespanOptions', |
|
2592 | - array( |
|
2593 | - '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'), |
|
2594 | - '1 day' => esc_html__('A Day', 'event_espresso'), |
|
2595 | - '1 week' => esc_html__('A Week', 'event_espresso'), |
|
2596 | - '5 weeks' => esc_html__('5 Weeks', 'event_espresso') |
|
2597 | - ) |
|
2598 | - ); |
|
2599 | - } |
|
2431 | + /** |
|
2432 | + * @var boolean $use_personnel_manager |
|
2433 | + */ |
|
2434 | + public $use_personnel_manager; |
|
2435 | + |
|
2436 | + /** |
|
2437 | + * @var boolean $use_dashboard_widget |
|
2438 | + */ |
|
2439 | + public $use_dashboard_widget; |
|
2440 | + |
|
2441 | + /** |
|
2442 | + * @var int $events_in_dashboard |
|
2443 | + */ |
|
2444 | + public $events_in_dashboard; |
|
2445 | + |
|
2446 | + /** |
|
2447 | + * @var boolean $use_event_timezones |
|
2448 | + */ |
|
2449 | + public $use_event_timezones; |
|
2450 | + |
|
2451 | + /** |
|
2452 | + * @var boolean $use_full_logging |
|
2453 | + */ |
|
2454 | + public $use_full_logging; |
|
2455 | + |
|
2456 | + /** |
|
2457 | + * @var string $log_file_name |
|
2458 | + */ |
|
2459 | + public $log_file_name; |
|
2460 | + |
|
2461 | + /** |
|
2462 | + * @var string $debug_file_name |
|
2463 | + */ |
|
2464 | + public $debug_file_name; |
|
2465 | + |
|
2466 | + /** |
|
2467 | + * @var boolean $use_remote_logging |
|
2468 | + */ |
|
2469 | + public $use_remote_logging; |
|
2470 | + |
|
2471 | + /** |
|
2472 | + * @var string $remote_logging_url |
|
2473 | + */ |
|
2474 | + public $remote_logging_url; |
|
2475 | + |
|
2476 | + /** |
|
2477 | + * @var boolean $show_reg_footer |
|
2478 | + */ |
|
2479 | + public $show_reg_footer; |
|
2480 | + |
|
2481 | + /** |
|
2482 | + * @var string $affiliate_id |
|
2483 | + */ |
|
2484 | + public $affiliate_id; |
|
2485 | + |
|
2486 | + /** |
|
2487 | + * help tours on or off (global setting) |
|
2488 | + * |
|
2489 | + * @var boolean |
|
2490 | + */ |
|
2491 | + public $help_tour_activation; |
|
2492 | + |
|
2493 | + public $gateway_log_lifespan = '1 week'; |
|
2494 | + |
|
2495 | + /** |
|
2496 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
2497 | + * but is incompatible with some server configuration errors |
|
2498 | + * if you get "500 internal server errors" during registration, try turning this on |
|
2499 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2500 | + * |
|
2501 | + * @var boolean $encode_session_data |
|
2502 | + */ |
|
2503 | + private $encode_session_data = false; |
|
2504 | + |
|
2505 | + |
|
2506 | + /** |
|
2507 | + * class constructor |
|
2508 | + * |
|
2509 | + * @access public |
|
2510 | + */ |
|
2511 | + public function __construct() |
|
2512 | + { |
|
2513 | + // set default general admin settings |
|
2514 | + $this->use_personnel_manager = true; |
|
2515 | + $this->use_dashboard_widget = true; |
|
2516 | + $this->events_in_dashboard = 30; |
|
2517 | + $this->use_event_timezones = false; |
|
2518 | + $this->use_full_logging = false; |
|
2519 | + $this->use_remote_logging = false; |
|
2520 | + $this->remote_logging_url = null; |
|
2521 | + $this->show_reg_footer = true; |
|
2522 | + $this->affiliate_id = 'default'; |
|
2523 | + $this->help_tour_activation = true; |
|
2524 | + $this->encode_session_data = false; |
|
2525 | + $this->gateway_log_lifespan = '1 week'; |
|
2526 | + } |
|
2527 | + |
|
2528 | + |
|
2529 | + /** |
|
2530 | + * @param bool $reset |
|
2531 | + * @return string |
|
2532 | + */ |
|
2533 | + public function log_file_name($reset = false) |
|
2534 | + { |
|
2535 | + if (empty($this->log_file_name) || $reset) { |
|
2536 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2537 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2538 | + } |
|
2539 | + return $this->log_file_name; |
|
2540 | + } |
|
2541 | + |
|
2542 | + |
|
2543 | + /** |
|
2544 | + * @param bool $reset |
|
2545 | + * @return string |
|
2546 | + */ |
|
2547 | + public function debug_file_name($reset = false) |
|
2548 | + { |
|
2549 | + if (empty($this->debug_file_name) || $reset) { |
|
2550 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2551 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2552 | + } |
|
2553 | + return $this->debug_file_name; |
|
2554 | + } |
|
2555 | + |
|
2556 | + |
|
2557 | + /** |
|
2558 | + * @return string |
|
2559 | + */ |
|
2560 | + public function affiliate_id() |
|
2561 | + { |
|
2562 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2563 | + } |
|
2564 | + |
|
2565 | + |
|
2566 | + /** |
|
2567 | + * @return boolean |
|
2568 | + */ |
|
2569 | + public function encode_session_data() |
|
2570 | + { |
|
2571 | + return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2572 | + } |
|
2573 | + |
|
2574 | + |
|
2575 | + /** |
|
2576 | + * @param boolean $encode_session_data |
|
2577 | + */ |
|
2578 | + public function set_encode_session_data($encode_session_data) |
|
2579 | + { |
|
2580 | + $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2581 | + } |
|
2582 | + |
|
2583 | + |
|
2584 | + /** |
|
2585 | + * Gets the options to make availalbe for the gateway log lifespan |
|
2586 | + * @return array |
|
2587 | + */ |
|
2588 | + public function gatewayLogLifespanOptions() |
|
2589 | + { |
|
2590 | + return (array) apply_filters( |
|
2591 | + 'FHEE_EE_Admin_Config__gatewayLogLifespanOptions', |
|
2592 | + array( |
|
2593 | + '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'), |
|
2594 | + '1 day' => esc_html__('A Day', 'event_espresso'), |
|
2595 | + '1 week' => esc_html__('A Week', 'event_espresso'), |
|
2596 | + '5 weeks' => esc_html__('5 Weeks', 'event_espresso') |
|
2597 | + ) |
|
2598 | + ); |
|
2599 | + } |
|
2600 | 2600 | } |
2601 | 2601 | |
2602 | 2602 | |
@@ -2606,70 +2606,70 @@ discard block |
||
2606 | 2606 | class EE_Template_Config extends EE_Config_Base |
2607 | 2607 | { |
2608 | 2608 | |
2609 | - /** |
|
2610 | - * @var boolean $enable_default_style |
|
2611 | - */ |
|
2612 | - public $enable_default_style; |
|
2613 | - |
|
2614 | - /** |
|
2615 | - * @var string $custom_style_sheet |
|
2616 | - */ |
|
2617 | - public $custom_style_sheet; |
|
2618 | - |
|
2619 | - /** |
|
2620 | - * @var boolean $display_address_in_regform |
|
2621 | - */ |
|
2622 | - public $display_address_in_regform; |
|
2623 | - |
|
2624 | - /** |
|
2625 | - * @var int $display_description_on_multi_reg_page |
|
2626 | - */ |
|
2627 | - public $display_description_on_multi_reg_page; |
|
2628 | - |
|
2629 | - /** |
|
2630 | - * @var boolean $use_custom_templates |
|
2631 | - */ |
|
2632 | - public $use_custom_templates; |
|
2633 | - |
|
2634 | - /** |
|
2635 | - * @var string $current_espresso_theme |
|
2636 | - */ |
|
2637 | - public $current_espresso_theme; |
|
2638 | - |
|
2639 | - /** |
|
2640 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2641 | - */ |
|
2642 | - public $EED_Ticket_Selector; |
|
2643 | - |
|
2644 | - /** |
|
2645 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
2646 | - */ |
|
2647 | - public $EED_Event_Single; |
|
2648 | - |
|
2649 | - /** |
|
2650 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2651 | - */ |
|
2652 | - public $EED_Events_Archive; |
|
2653 | - |
|
2654 | - |
|
2655 | - /** |
|
2656 | - * class constructor |
|
2657 | - * |
|
2658 | - * @access public |
|
2659 | - */ |
|
2660 | - public function __construct() |
|
2661 | - { |
|
2662 | - // set default template settings |
|
2663 | - $this->enable_default_style = true; |
|
2664 | - $this->custom_style_sheet = null; |
|
2665 | - $this->display_address_in_regform = true; |
|
2666 | - $this->display_description_on_multi_reg_page = false; |
|
2667 | - $this->use_custom_templates = false; |
|
2668 | - $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2669 | - $this->EED_Event_Single = null; |
|
2670 | - $this->EED_Events_Archive = null; |
|
2671 | - $this->EED_Ticket_Selector = null; |
|
2672 | - } |
|
2609 | + /** |
|
2610 | + * @var boolean $enable_default_style |
|
2611 | + */ |
|
2612 | + public $enable_default_style; |
|
2613 | + |
|
2614 | + /** |
|
2615 | + * @var string $custom_style_sheet |
|
2616 | + */ |
|
2617 | + public $custom_style_sheet; |
|
2618 | + |
|
2619 | + /** |
|
2620 | + * @var boolean $display_address_in_regform |
|
2621 | + */ |
|
2622 | + public $display_address_in_regform; |
|
2623 | + |
|
2624 | + /** |
|
2625 | + * @var int $display_description_on_multi_reg_page |
|
2626 | + */ |
|
2627 | + public $display_description_on_multi_reg_page; |
|
2628 | + |
|
2629 | + /** |
|
2630 | + * @var boolean $use_custom_templates |
|
2631 | + */ |
|
2632 | + public $use_custom_templates; |
|
2633 | + |
|
2634 | + /** |
|
2635 | + * @var string $current_espresso_theme |
|
2636 | + */ |
|
2637 | + public $current_espresso_theme; |
|
2638 | + |
|
2639 | + /** |
|
2640 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2641 | + */ |
|
2642 | + public $EED_Ticket_Selector; |
|
2643 | + |
|
2644 | + /** |
|
2645 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
2646 | + */ |
|
2647 | + public $EED_Event_Single; |
|
2648 | + |
|
2649 | + /** |
|
2650 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2651 | + */ |
|
2652 | + public $EED_Events_Archive; |
|
2653 | + |
|
2654 | + |
|
2655 | + /** |
|
2656 | + * class constructor |
|
2657 | + * |
|
2658 | + * @access public |
|
2659 | + */ |
|
2660 | + public function __construct() |
|
2661 | + { |
|
2662 | + // set default template settings |
|
2663 | + $this->enable_default_style = true; |
|
2664 | + $this->custom_style_sheet = null; |
|
2665 | + $this->display_address_in_regform = true; |
|
2666 | + $this->display_description_on_multi_reg_page = false; |
|
2667 | + $this->use_custom_templates = false; |
|
2668 | + $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2669 | + $this->EED_Event_Single = null; |
|
2670 | + $this->EED_Events_Archive = null; |
|
2671 | + $this->EED_Ticket_Selector = null; |
|
2672 | + } |
|
2673 | 2673 | } |
2674 | 2674 | |
2675 | 2675 | |
@@ -2679,114 +2679,114 @@ discard block |
||
2679 | 2679 | class EE_Map_Config extends EE_Config_Base |
2680 | 2680 | { |
2681 | 2681 | |
2682 | - /** |
|
2683 | - * @var boolean $use_google_maps |
|
2684 | - */ |
|
2685 | - public $use_google_maps; |
|
2686 | - |
|
2687 | - /** |
|
2688 | - * @var string $api_key |
|
2689 | - */ |
|
2690 | - public $google_map_api_key; |
|
2691 | - |
|
2692 | - /** |
|
2693 | - * @var int $event_details_map_width |
|
2694 | - */ |
|
2695 | - public $event_details_map_width; |
|
2696 | - |
|
2697 | - /** |
|
2698 | - * @var int $event_details_map_height |
|
2699 | - */ |
|
2700 | - public $event_details_map_height; |
|
2701 | - |
|
2702 | - /** |
|
2703 | - * @var int $event_details_map_zoom |
|
2704 | - */ |
|
2705 | - public $event_details_map_zoom; |
|
2706 | - |
|
2707 | - /** |
|
2708 | - * @var boolean $event_details_display_nav |
|
2709 | - */ |
|
2710 | - public $event_details_display_nav; |
|
2711 | - |
|
2712 | - /** |
|
2713 | - * @var boolean $event_details_nav_size |
|
2714 | - */ |
|
2715 | - public $event_details_nav_size; |
|
2716 | - |
|
2717 | - /** |
|
2718 | - * @var string $event_details_control_type |
|
2719 | - */ |
|
2720 | - public $event_details_control_type; |
|
2721 | - |
|
2722 | - /** |
|
2723 | - * @var string $event_details_map_align |
|
2724 | - */ |
|
2725 | - public $event_details_map_align; |
|
2726 | - |
|
2727 | - /** |
|
2728 | - * @var int $event_list_map_width |
|
2729 | - */ |
|
2730 | - public $event_list_map_width; |
|
2731 | - |
|
2732 | - /** |
|
2733 | - * @var int $event_list_map_height |
|
2734 | - */ |
|
2735 | - public $event_list_map_height; |
|
2736 | - |
|
2737 | - /** |
|
2738 | - * @var int $event_list_map_zoom |
|
2739 | - */ |
|
2740 | - public $event_list_map_zoom; |
|
2741 | - |
|
2742 | - /** |
|
2743 | - * @var boolean $event_list_display_nav |
|
2744 | - */ |
|
2745 | - public $event_list_display_nav; |
|
2746 | - |
|
2747 | - /** |
|
2748 | - * @var boolean $event_list_nav_size |
|
2749 | - */ |
|
2750 | - public $event_list_nav_size; |
|
2751 | - |
|
2752 | - /** |
|
2753 | - * @var string $event_list_control_type |
|
2754 | - */ |
|
2755 | - public $event_list_control_type; |
|
2756 | - |
|
2757 | - /** |
|
2758 | - * @var string $event_list_map_align |
|
2759 | - */ |
|
2760 | - public $event_list_map_align; |
|
2761 | - |
|
2762 | - |
|
2763 | - /** |
|
2764 | - * class constructor |
|
2765 | - * |
|
2766 | - * @access public |
|
2767 | - */ |
|
2768 | - public function __construct() |
|
2769 | - { |
|
2770 | - // set default map settings |
|
2771 | - $this->use_google_maps = true; |
|
2772 | - $this->google_map_api_key = ''; |
|
2773 | - // for event details pages (reg page) |
|
2774 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2775 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2776 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2777 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2778 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2779 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2780 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2781 | - // for event list pages |
|
2782 | - $this->event_list_map_width = 300; // ee_map_width |
|
2783 | - $this->event_list_map_height = 185; // ee_map_height |
|
2784 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2785 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2786 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2787 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2788 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2789 | - } |
|
2682 | + /** |
|
2683 | + * @var boolean $use_google_maps |
|
2684 | + */ |
|
2685 | + public $use_google_maps; |
|
2686 | + |
|
2687 | + /** |
|
2688 | + * @var string $api_key |
|
2689 | + */ |
|
2690 | + public $google_map_api_key; |
|
2691 | + |
|
2692 | + /** |
|
2693 | + * @var int $event_details_map_width |
|
2694 | + */ |
|
2695 | + public $event_details_map_width; |
|
2696 | + |
|
2697 | + /** |
|
2698 | + * @var int $event_details_map_height |
|
2699 | + */ |
|
2700 | + public $event_details_map_height; |
|
2701 | + |
|
2702 | + /** |
|
2703 | + * @var int $event_details_map_zoom |
|
2704 | + */ |
|
2705 | + public $event_details_map_zoom; |
|
2706 | + |
|
2707 | + /** |
|
2708 | + * @var boolean $event_details_display_nav |
|
2709 | + */ |
|
2710 | + public $event_details_display_nav; |
|
2711 | + |
|
2712 | + /** |
|
2713 | + * @var boolean $event_details_nav_size |
|
2714 | + */ |
|
2715 | + public $event_details_nav_size; |
|
2716 | + |
|
2717 | + /** |
|
2718 | + * @var string $event_details_control_type |
|
2719 | + */ |
|
2720 | + public $event_details_control_type; |
|
2721 | + |
|
2722 | + /** |
|
2723 | + * @var string $event_details_map_align |
|
2724 | + */ |
|
2725 | + public $event_details_map_align; |
|
2726 | + |
|
2727 | + /** |
|
2728 | + * @var int $event_list_map_width |
|
2729 | + */ |
|
2730 | + public $event_list_map_width; |
|
2731 | + |
|
2732 | + /** |
|
2733 | + * @var int $event_list_map_height |
|
2734 | + */ |
|
2735 | + public $event_list_map_height; |
|
2736 | + |
|
2737 | + /** |
|
2738 | + * @var int $event_list_map_zoom |
|
2739 | + */ |
|
2740 | + public $event_list_map_zoom; |
|
2741 | + |
|
2742 | + /** |
|
2743 | + * @var boolean $event_list_display_nav |
|
2744 | + */ |
|
2745 | + public $event_list_display_nav; |
|
2746 | + |
|
2747 | + /** |
|
2748 | + * @var boolean $event_list_nav_size |
|
2749 | + */ |
|
2750 | + public $event_list_nav_size; |
|
2751 | + |
|
2752 | + /** |
|
2753 | + * @var string $event_list_control_type |
|
2754 | + */ |
|
2755 | + public $event_list_control_type; |
|
2756 | + |
|
2757 | + /** |
|
2758 | + * @var string $event_list_map_align |
|
2759 | + */ |
|
2760 | + public $event_list_map_align; |
|
2761 | + |
|
2762 | + |
|
2763 | + /** |
|
2764 | + * class constructor |
|
2765 | + * |
|
2766 | + * @access public |
|
2767 | + */ |
|
2768 | + public function __construct() |
|
2769 | + { |
|
2770 | + // set default map settings |
|
2771 | + $this->use_google_maps = true; |
|
2772 | + $this->google_map_api_key = ''; |
|
2773 | + // for event details pages (reg page) |
|
2774 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2775 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2776 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2777 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2778 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2779 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2780 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2781 | + // for event list pages |
|
2782 | + $this->event_list_map_width = 300; // ee_map_width |
|
2783 | + $this->event_list_map_height = 185; // ee_map_height |
|
2784 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2785 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2786 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2787 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2788 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2789 | + } |
|
2790 | 2790 | } |
2791 | 2791 | |
2792 | 2792 | |
@@ -2796,46 +2796,46 @@ discard block |
||
2796 | 2796 | class EE_Events_Archive_Config extends EE_Config_Base |
2797 | 2797 | { |
2798 | 2798 | |
2799 | - public $display_status_banner; |
|
2799 | + public $display_status_banner; |
|
2800 | 2800 | |
2801 | - public $display_description; |
|
2801 | + public $display_description; |
|
2802 | 2802 | |
2803 | - public $display_ticket_selector; |
|
2803 | + public $display_ticket_selector; |
|
2804 | 2804 | |
2805 | - public $display_datetimes; |
|
2805 | + public $display_datetimes; |
|
2806 | 2806 | |
2807 | - public $display_venue; |
|
2807 | + public $display_venue; |
|
2808 | 2808 | |
2809 | - public $display_expired_events; |
|
2809 | + public $display_expired_events; |
|
2810 | 2810 | |
2811 | - public $use_sortable_display_order; |
|
2811 | + public $use_sortable_display_order; |
|
2812 | 2812 | |
2813 | - public $display_order_tickets; |
|
2813 | + public $display_order_tickets; |
|
2814 | 2814 | |
2815 | - public $display_order_datetimes; |
|
2815 | + public $display_order_datetimes; |
|
2816 | 2816 | |
2817 | - public $display_order_event; |
|
2817 | + public $display_order_event; |
|
2818 | 2818 | |
2819 | - public $display_order_venue; |
|
2819 | + public $display_order_venue; |
|
2820 | 2820 | |
2821 | 2821 | |
2822 | - /** |
|
2823 | - * class constructor |
|
2824 | - */ |
|
2825 | - public function __construct() |
|
2826 | - { |
|
2827 | - $this->display_status_banner = 0; |
|
2828 | - $this->display_description = 1; |
|
2829 | - $this->display_ticket_selector = 0; |
|
2830 | - $this->display_datetimes = 1; |
|
2831 | - $this->display_venue = 0; |
|
2832 | - $this->display_expired_events = 0; |
|
2833 | - $this->use_sortable_display_order = false; |
|
2834 | - $this->display_order_tickets = 100; |
|
2835 | - $this->display_order_datetimes = 110; |
|
2836 | - $this->display_order_event = 120; |
|
2837 | - $this->display_order_venue = 130; |
|
2838 | - } |
|
2822 | + /** |
|
2823 | + * class constructor |
|
2824 | + */ |
|
2825 | + public function __construct() |
|
2826 | + { |
|
2827 | + $this->display_status_banner = 0; |
|
2828 | + $this->display_description = 1; |
|
2829 | + $this->display_ticket_selector = 0; |
|
2830 | + $this->display_datetimes = 1; |
|
2831 | + $this->display_venue = 0; |
|
2832 | + $this->display_expired_events = 0; |
|
2833 | + $this->use_sortable_display_order = false; |
|
2834 | + $this->display_order_tickets = 100; |
|
2835 | + $this->display_order_datetimes = 110; |
|
2836 | + $this->display_order_event = 120; |
|
2837 | + $this->display_order_venue = 130; |
|
2838 | + } |
|
2839 | 2839 | } |
2840 | 2840 | |
2841 | 2841 | |
@@ -2845,34 +2845,34 @@ discard block |
||
2845 | 2845 | class EE_Event_Single_Config extends EE_Config_Base |
2846 | 2846 | { |
2847 | 2847 | |
2848 | - public $display_status_banner_single; |
|
2848 | + public $display_status_banner_single; |
|
2849 | 2849 | |
2850 | - public $display_venue; |
|
2850 | + public $display_venue; |
|
2851 | 2851 | |
2852 | - public $use_sortable_display_order; |
|
2852 | + public $use_sortable_display_order; |
|
2853 | 2853 | |
2854 | - public $display_order_tickets; |
|
2854 | + public $display_order_tickets; |
|
2855 | 2855 | |
2856 | - public $display_order_datetimes; |
|
2856 | + public $display_order_datetimes; |
|
2857 | 2857 | |
2858 | - public $display_order_event; |
|
2858 | + public $display_order_event; |
|
2859 | 2859 | |
2860 | - public $display_order_venue; |
|
2860 | + public $display_order_venue; |
|
2861 | 2861 | |
2862 | 2862 | |
2863 | - /** |
|
2864 | - * class constructor |
|
2865 | - */ |
|
2866 | - public function __construct() |
|
2867 | - { |
|
2868 | - $this->display_status_banner_single = 0; |
|
2869 | - $this->display_venue = 1; |
|
2870 | - $this->use_sortable_display_order = false; |
|
2871 | - $this->display_order_tickets = 100; |
|
2872 | - $this->display_order_datetimes = 110; |
|
2873 | - $this->display_order_event = 120; |
|
2874 | - $this->display_order_venue = 130; |
|
2875 | - } |
|
2863 | + /** |
|
2864 | + * class constructor |
|
2865 | + */ |
|
2866 | + public function __construct() |
|
2867 | + { |
|
2868 | + $this->display_status_banner_single = 0; |
|
2869 | + $this->display_venue = 1; |
|
2870 | + $this->use_sortable_display_order = false; |
|
2871 | + $this->display_order_tickets = 100; |
|
2872 | + $this->display_order_datetimes = 110; |
|
2873 | + $this->display_order_event = 120; |
|
2874 | + $this->display_order_venue = 130; |
|
2875 | + } |
|
2876 | 2876 | } |
2877 | 2877 | |
2878 | 2878 | |
@@ -2882,146 +2882,146 @@ discard block |
||
2882 | 2882 | class EE_Ticket_Selector_Config extends EE_Config_Base |
2883 | 2883 | { |
2884 | 2884 | |
2885 | - /** |
|
2886 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2887 | - */ |
|
2888 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2889 | - |
|
2890 | - /** |
|
2891 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2892 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2893 | - */ |
|
2894 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2895 | - |
|
2896 | - /** |
|
2897 | - * @var boolean $show_ticket_sale_columns |
|
2898 | - */ |
|
2899 | - public $show_ticket_sale_columns; |
|
2900 | - |
|
2901 | - /** |
|
2902 | - * @var boolean $show_ticket_details |
|
2903 | - */ |
|
2904 | - public $show_ticket_details; |
|
2905 | - |
|
2906 | - /** |
|
2907 | - * @var boolean $show_expired_tickets |
|
2908 | - */ |
|
2909 | - public $show_expired_tickets; |
|
2910 | - |
|
2911 | - /** |
|
2912 | - * whether or not to display a dropdown box populated with event datetimes |
|
2913 | - * that toggles which tickets are displayed for a ticket selector. |
|
2914 | - * uses one of the *_DATETIME_SELECTOR constants defined above |
|
2915 | - * |
|
2916 | - * @var string $show_datetime_selector |
|
2917 | - */ |
|
2918 | - private $show_datetime_selector = 'no_datetime_selector'; |
|
2919 | - |
|
2920 | - /** |
|
2921 | - * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
2922 | - * |
|
2923 | - * @var int $datetime_selector_threshold |
|
2924 | - */ |
|
2925 | - private $datetime_selector_threshold = 3; |
|
2926 | - |
|
2927 | - |
|
2928 | - /** |
|
2929 | - * class constructor |
|
2930 | - */ |
|
2931 | - public function __construct() |
|
2932 | - { |
|
2933 | - $this->show_ticket_sale_columns = true; |
|
2934 | - $this->show_ticket_details = true; |
|
2935 | - $this->show_expired_tickets = true; |
|
2936 | - $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
2937 | - $this->datetime_selector_threshold = 3; |
|
2938 | - } |
|
2939 | - |
|
2940 | - |
|
2941 | - /** |
|
2942 | - * returns true if a datetime selector should be displayed |
|
2943 | - * |
|
2944 | - * @param array $datetimes |
|
2945 | - * @return bool |
|
2946 | - */ |
|
2947 | - public function showDatetimeSelector(array $datetimes) |
|
2948 | - { |
|
2949 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2950 | - return ! ( |
|
2951 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
2952 | - || ( |
|
2953 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
2954 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
2955 | - ) |
|
2956 | - ); |
|
2957 | - } |
|
2958 | - |
|
2959 | - |
|
2960 | - /** |
|
2961 | - * @return string |
|
2962 | - */ |
|
2963 | - public function getShowDatetimeSelector() |
|
2964 | - { |
|
2965 | - return $this->show_datetime_selector; |
|
2966 | - } |
|
2967 | - |
|
2968 | - |
|
2969 | - /** |
|
2970 | - * @param bool $keys_only |
|
2971 | - * @return array |
|
2972 | - */ |
|
2973 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
2974 | - { |
|
2975 | - return $keys_only |
|
2976 | - ? array( |
|
2977 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
2978 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
2979 | - ) |
|
2980 | - : array( |
|
2981 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2982 | - 'Do not show date & time filter', |
|
2983 | - 'event_espresso' |
|
2984 | - ), |
|
2985 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2986 | - 'Maybe show date & time filter', |
|
2987 | - 'event_espresso' |
|
2988 | - ), |
|
2989 | - ); |
|
2990 | - } |
|
2991 | - |
|
2992 | - |
|
2993 | - /** |
|
2994 | - * @param string $show_datetime_selector |
|
2995 | - */ |
|
2996 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
2997 | - { |
|
2998 | - $this->show_datetime_selector = in_array( |
|
2999 | - $show_datetime_selector, |
|
3000 | - $this->getShowDatetimeSelectorOptions(), |
|
3001 | - true |
|
3002 | - ) |
|
3003 | - ? $show_datetime_selector |
|
3004 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3005 | - } |
|
3006 | - |
|
3007 | - |
|
3008 | - /** |
|
3009 | - * @return int |
|
3010 | - */ |
|
3011 | - public function getDatetimeSelectorThreshold() |
|
3012 | - { |
|
3013 | - return $this->datetime_selector_threshold; |
|
3014 | - } |
|
3015 | - |
|
3016 | - |
|
3017 | - /** |
|
3018 | - * @param int $datetime_selector_threshold |
|
3019 | - */ |
|
3020 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3021 | - { |
|
3022 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3023 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3024 | - } |
|
2885 | + /** |
|
2886 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2887 | + */ |
|
2888 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2889 | + |
|
2890 | + /** |
|
2891 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2892 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2893 | + */ |
|
2894 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2895 | + |
|
2896 | + /** |
|
2897 | + * @var boolean $show_ticket_sale_columns |
|
2898 | + */ |
|
2899 | + public $show_ticket_sale_columns; |
|
2900 | + |
|
2901 | + /** |
|
2902 | + * @var boolean $show_ticket_details |
|
2903 | + */ |
|
2904 | + public $show_ticket_details; |
|
2905 | + |
|
2906 | + /** |
|
2907 | + * @var boolean $show_expired_tickets |
|
2908 | + */ |
|
2909 | + public $show_expired_tickets; |
|
2910 | + |
|
2911 | + /** |
|
2912 | + * whether or not to display a dropdown box populated with event datetimes |
|
2913 | + * that toggles which tickets are displayed for a ticket selector. |
|
2914 | + * uses one of the *_DATETIME_SELECTOR constants defined above |
|
2915 | + * |
|
2916 | + * @var string $show_datetime_selector |
|
2917 | + */ |
|
2918 | + private $show_datetime_selector = 'no_datetime_selector'; |
|
2919 | + |
|
2920 | + /** |
|
2921 | + * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
2922 | + * |
|
2923 | + * @var int $datetime_selector_threshold |
|
2924 | + */ |
|
2925 | + private $datetime_selector_threshold = 3; |
|
2926 | + |
|
2927 | + |
|
2928 | + /** |
|
2929 | + * class constructor |
|
2930 | + */ |
|
2931 | + public function __construct() |
|
2932 | + { |
|
2933 | + $this->show_ticket_sale_columns = true; |
|
2934 | + $this->show_ticket_details = true; |
|
2935 | + $this->show_expired_tickets = true; |
|
2936 | + $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
2937 | + $this->datetime_selector_threshold = 3; |
|
2938 | + } |
|
2939 | + |
|
2940 | + |
|
2941 | + /** |
|
2942 | + * returns true if a datetime selector should be displayed |
|
2943 | + * |
|
2944 | + * @param array $datetimes |
|
2945 | + * @return bool |
|
2946 | + */ |
|
2947 | + public function showDatetimeSelector(array $datetimes) |
|
2948 | + { |
|
2949 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2950 | + return ! ( |
|
2951 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
2952 | + || ( |
|
2953 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
2954 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
2955 | + ) |
|
2956 | + ); |
|
2957 | + } |
|
2958 | + |
|
2959 | + |
|
2960 | + /** |
|
2961 | + * @return string |
|
2962 | + */ |
|
2963 | + public function getShowDatetimeSelector() |
|
2964 | + { |
|
2965 | + return $this->show_datetime_selector; |
|
2966 | + } |
|
2967 | + |
|
2968 | + |
|
2969 | + /** |
|
2970 | + * @param bool $keys_only |
|
2971 | + * @return array |
|
2972 | + */ |
|
2973 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
2974 | + { |
|
2975 | + return $keys_only |
|
2976 | + ? array( |
|
2977 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
2978 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
2979 | + ) |
|
2980 | + : array( |
|
2981 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2982 | + 'Do not show date & time filter', |
|
2983 | + 'event_espresso' |
|
2984 | + ), |
|
2985 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2986 | + 'Maybe show date & time filter', |
|
2987 | + 'event_espresso' |
|
2988 | + ), |
|
2989 | + ); |
|
2990 | + } |
|
2991 | + |
|
2992 | + |
|
2993 | + /** |
|
2994 | + * @param string $show_datetime_selector |
|
2995 | + */ |
|
2996 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
2997 | + { |
|
2998 | + $this->show_datetime_selector = in_array( |
|
2999 | + $show_datetime_selector, |
|
3000 | + $this->getShowDatetimeSelectorOptions(), |
|
3001 | + true |
|
3002 | + ) |
|
3003 | + ? $show_datetime_selector |
|
3004 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3005 | + } |
|
3006 | + |
|
3007 | + |
|
3008 | + /** |
|
3009 | + * @return int |
|
3010 | + */ |
|
3011 | + public function getDatetimeSelectorThreshold() |
|
3012 | + { |
|
3013 | + return $this->datetime_selector_threshold; |
|
3014 | + } |
|
3015 | + |
|
3016 | + |
|
3017 | + /** |
|
3018 | + * @param int $datetime_selector_threshold |
|
3019 | + */ |
|
3020 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3021 | + { |
|
3022 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3023 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3024 | + } |
|
3025 | 3025 | } |
3026 | 3026 | |
3027 | 3027 | |
@@ -3035,81 +3035,81 @@ discard block |
||
3035 | 3035 | class EE_Environment_Config extends EE_Config_Base |
3036 | 3036 | { |
3037 | 3037 | |
3038 | - /** |
|
3039 | - * Hold any php environment variables that we want to track. |
|
3040 | - * |
|
3041 | - * @var stdClass; |
|
3042 | - */ |
|
3043 | - public $php; |
|
3044 | - |
|
3045 | - |
|
3046 | - /** |
|
3047 | - * constructor |
|
3048 | - */ |
|
3049 | - public function __construct() |
|
3050 | - { |
|
3051 | - $this->php = new stdClass(); |
|
3052 | - $this->_set_php_values(); |
|
3053 | - } |
|
3054 | - |
|
3055 | - |
|
3056 | - /** |
|
3057 | - * This sets the php environment variables. |
|
3058 | - * |
|
3059 | - * @since 4.4.0 |
|
3060 | - * @return void |
|
3061 | - */ |
|
3062 | - protected function _set_php_values() |
|
3063 | - { |
|
3064 | - $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3065 | - $this->php->version = phpversion(); |
|
3066 | - } |
|
3067 | - |
|
3068 | - |
|
3069 | - /** |
|
3070 | - * helper method for determining whether input_count is |
|
3071 | - * reaching the potential maximum the server can handle |
|
3072 | - * according to max_input_vars |
|
3073 | - * |
|
3074 | - * @param int $input_count the count of input vars. |
|
3075 | - * @return array { |
|
3076 | - * An array that represents whether available space and if no available space the error |
|
3077 | - * message. |
|
3078 | - * @type bool $has_space whether more inputs can be added. |
|
3079 | - * @type string $msg Any message to be displayed. |
|
3080 | - * } |
|
3081 | - */ |
|
3082 | - public function max_input_vars_limit_check($input_count = 0) |
|
3083 | - { |
|
3084 | - if (! empty($this->php->max_input_vars) |
|
3085 | - && ($input_count >= $this->php->max_input_vars) |
|
3086 | - && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3087 | - ) { |
|
3088 | - return sprintf( |
|
3089 | - __( |
|
3090 | - 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3091 | - 'event_espresso' |
|
3092 | - ), |
|
3093 | - '<br>', |
|
3094 | - $input_count, |
|
3095 | - $this->php->max_input_vars |
|
3096 | - ); |
|
3097 | - } else { |
|
3098 | - return ''; |
|
3099 | - } |
|
3100 | - } |
|
3101 | - |
|
3102 | - |
|
3103 | - /** |
|
3104 | - * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3105 | - * |
|
3106 | - * @since 4.4.1 |
|
3107 | - * @return void |
|
3108 | - */ |
|
3109 | - public function recheck_values() |
|
3110 | - { |
|
3111 | - $this->_set_php_values(); |
|
3112 | - } |
|
3038 | + /** |
|
3039 | + * Hold any php environment variables that we want to track. |
|
3040 | + * |
|
3041 | + * @var stdClass; |
|
3042 | + */ |
|
3043 | + public $php; |
|
3044 | + |
|
3045 | + |
|
3046 | + /** |
|
3047 | + * constructor |
|
3048 | + */ |
|
3049 | + public function __construct() |
|
3050 | + { |
|
3051 | + $this->php = new stdClass(); |
|
3052 | + $this->_set_php_values(); |
|
3053 | + } |
|
3054 | + |
|
3055 | + |
|
3056 | + /** |
|
3057 | + * This sets the php environment variables. |
|
3058 | + * |
|
3059 | + * @since 4.4.0 |
|
3060 | + * @return void |
|
3061 | + */ |
|
3062 | + protected function _set_php_values() |
|
3063 | + { |
|
3064 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3065 | + $this->php->version = phpversion(); |
|
3066 | + } |
|
3067 | + |
|
3068 | + |
|
3069 | + /** |
|
3070 | + * helper method for determining whether input_count is |
|
3071 | + * reaching the potential maximum the server can handle |
|
3072 | + * according to max_input_vars |
|
3073 | + * |
|
3074 | + * @param int $input_count the count of input vars. |
|
3075 | + * @return array { |
|
3076 | + * An array that represents whether available space and if no available space the error |
|
3077 | + * message. |
|
3078 | + * @type bool $has_space whether more inputs can be added. |
|
3079 | + * @type string $msg Any message to be displayed. |
|
3080 | + * } |
|
3081 | + */ |
|
3082 | + public function max_input_vars_limit_check($input_count = 0) |
|
3083 | + { |
|
3084 | + if (! empty($this->php->max_input_vars) |
|
3085 | + && ($input_count >= $this->php->max_input_vars) |
|
3086 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3087 | + ) { |
|
3088 | + return sprintf( |
|
3089 | + __( |
|
3090 | + 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3091 | + 'event_espresso' |
|
3092 | + ), |
|
3093 | + '<br>', |
|
3094 | + $input_count, |
|
3095 | + $this->php->max_input_vars |
|
3096 | + ); |
|
3097 | + } else { |
|
3098 | + return ''; |
|
3099 | + } |
|
3100 | + } |
|
3101 | + |
|
3102 | + |
|
3103 | + /** |
|
3104 | + * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3105 | + * |
|
3106 | + * @since 4.4.1 |
|
3107 | + * @return void |
|
3108 | + */ |
|
3109 | + public function recheck_values() |
|
3110 | + { |
|
3111 | + $this->_set_php_values(); |
|
3112 | + } |
|
3113 | 3113 | } |
3114 | 3114 | |
3115 | 3115 | |
@@ -3123,21 +3123,21 @@ discard block |
||
3123 | 3123 | class EE_Tax_Config extends EE_Config_Base |
3124 | 3124 | { |
3125 | 3125 | |
3126 | - /* |
|
3126 | + /* |
|
3127 | 3127 | * flag to indicate whether or not to display ticket prices with the taxes included |
3128 | 3128 | * |
3129 | 3129 | * @var boolean $prices_displayed_including_taxes |
3130 | 3130 | */ |
3131 | - public $prices_displayed_including_taxes; |
|
3131 | + public $prices_displayed_including_taxes; |
|
3132 | 3132 | |
3133 | 3133 | |
3134 | - /** |
|
3135 | - * class constructor |
|
3136 | - */ |
|
3137 | - public function __construct() |
|
3138 | - { |
|
3139 | - $this->prices_displayed_including_taxes = true; |
|
3140 | - } |
|
3134 | + /** |
|
3135 | + * class constructor |
|
3136 | + */ |
|
3137 | + public function __construct() |
|
3138 | + { |
|
3139 | + $this->prices_displayed_including_taxes = true; |
|
3140 | + } |
|
3141 | 3141 | } |
3142 | 3142 | |
3143 | 3143 | |
@@ -3152,18 +3152,18 @@ discard block |
||
3152 | 3152 | class EE_Messages_Config extends EE_Config_Base |
3153 | 3153 | { |
3154 | 3154 | |
3155 | - /** |
|
3156 | - * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
3157 | - * A value of 0 represents never deleting. Default is 0. |
|
3158 | - * |
|
3159 | - * @var integer |
|
3160 | - */ |
|
3161 | - public $delete_threshold; |
|
3162 | - |
|
3163 | - public function __construct() |
|
3164 | - { |
|
3165 | - $this->delete_threshold = 0; |
|
3166 | - } |
|
3155 | + /** |
|
3156 | + * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
3157 | + * A value of 0 represents never deleting. Default is 0. |
|
3158 | + * |
|
3159 | + * @var integer |
|
3160 | + */ |
|
3161 | + public $delete_threshold; |
|
3162 | + |
|
3163 | + public function __construct() |
|
3164 | + { |
|
3165 | + $this->delete_threshold = 0; |
|
3166 | + } |
|
3167 | 3167 | } |
3168 | 3168 | |
3169 | 3169 | |
@@ -3175,31 +3175,31 @@ discard block |
||
3175 | 3175 | class EE_Gateway_Config extends EE_Config_Base |
3176 | 3176 | { |
3177 | 3177 | |
3178 | - /** |
|
3179 | - * Array with keys that are payment gateways slugs, and values are arrays |
|
3180 | - * with any config info the gateway wants to store |
|
3181 | - * |
|
3182 | - * @var array |
|
3183 | - */ |
|
3184 | - public $payment_settings; |
|
3185 | - |
|
3186 | - /** |
|
3187 | - * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3188 | - * the gateway is stored in the uploads directory |
|
3189 | - * |
|
3190 | - * @var array |
|
3191 | - */ |
|
3192 | - public $active_gateways; |
|
3193 | - |
|
3194 | - |
|
3195 | - /** |
|
3196 | - * class constructor |
|
3197 | - * |
|
3198 | - * @deprecated |
|
3199 | - */ |
|
3200 | - public function __construct() |
|
3201 | - { |
|
3202 | - $this->payment_settings = array(); |
|
3203 | - $this->active_gateways = array('Invoice' => false); |
|
3204 | - } |
|
3178 | + /** |
|
3179 | + * Array with keys that are payment gateways slugs, and values are arrays |
|
3180 | + * with any config info the gateway wants to store |
|
3181 | + * |
|
3182 | + * @var array |
|
3183 | + */ |
|
3184 | + public $payment_settings; |
|
3185 | + |
|
3186 | + /** |
|
3187 | + * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3188 | + * the gateway is stored in the uploads directory |
|
3189 | + * |
|
3190 | + * @var array |
|
3191 | + */ |
|
3192 | + public $active_gateways; |
|
3193 | + |
|
3194 | + |
|
3195 | + /** |
|
3196 | + * class constructor |
|
3197 | + * |
|
3198 | + * @deprecated |
|
3199 | + */ |
|
3200 | + public function __construct() |
|
3201 | + { |
|
3202 | + $this->payment_settings = array(); |
|
3203 | + $this->active_gateways = array('Invoice' => false); |
|
3204 | + } |
|
3205 | 3205 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | public static function instance(ClassInterfaceCache $class_cache = null) |
123 | 123 | { |
124 | 124 | // check if class object is instantiated, and instantiated properly |
125 | - if (! self::$_instance instanceof EE_Dependency_Map |
|
125 | + if ( ! self::$_instance instanceof EE_Dependency_Map |
|
126 | 126 | && $class_cache instanceof ClassInterfaceCache |
127 | 127 | ) { |
128 | 128 | self::$_instance = new EE_Dependency_Map($class_cache); |
@@ -203,18 +203,18 @@ discard block |
||
203 | 203 | ) { |
204 | 204 | $class = trim($class, '\\'); |
205 | 205 | $registered = false; |
206 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
207 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
206 | + if (empty(self::$_instance->_dependency_map[$class])) { |
|
207 | + self::$_instance->_dependency_map[$class] = array(); |
|
208 | 208 | } |
209 | 209 | // we need to make sure that any aliases used when registering a dependency |
210 | 210 | // get resolved to the correct class name |
211 | 211 | foreach ($dependencies as $dependency => $load_source) { |
212 | 212 | $alias = self::$_instance->getFqnForAlias($dependency); |
213 | 213 | if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
214 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
214 | + || ! isset(self::$_instance->_dependency_map[$class][$alias]) |
|
215 | 215 | ) { |
216 | - unset($dependencies[ $dependency ]); |
|
217 | - $dependencies[ $alias ] = $load_source; |
|
216 | + unset($dependencies[$dependency]); |
|
217 | + $dependencies[$alias] = $load_source; |
|
218 | 218 | $registered = true; |
219 | 219 | } |
220 | 220 | } |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
225 | 225 | // Union is way faster than array_merge() but should be used with caution... |
226 | 226 | // especially with numerically indexed arrays |
227 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
227 | + $dependencies += self::$_instance->_dependency_map[$class]; |
|
228 | 228 | // now we need to ensure that the resulting dependencies |
229 | 229 | // array only has the entries that are required for the class |
230 | 230 | // so first count how many dependencies were originally registered for the class |
231 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
231 | + $dependency_count = count(self::$_instance->_dependency_map[$class]); |
|
232 | 232 | // if that count is non-zero (meaning dependencies were already registered) |
233 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
233 | + self::$_instance->_dependency_map[$class] = $dependency_count |
|
234 | 234 | // then truncate the final array to match that count |
235 | 235 | ? array_slice($dependencies, 0, $dependency_count) |
236 | 236 | // otherwise just take the incoming array because nothing previously existed |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public static function register_class_loader($class_name, $loader = 'load_core') |
249 | 249 | { |
250 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
250 | + if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
251 | 251 | throw new DomainException( |
252 | 252 | esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
253 | 253 | ); |
254 | 254 | } |
255 | 255 | // check that loader is callable or method starts with "load_" and exists in EE_Registry |
256 | - if (! is_callable($loader) |
|
256 | + if ( ! is_callable($loader) |
|
257 | 257 | && ( |
258 | 258 | strpos($loader, 'load_') !== 0 |
259 | 259 | || ! method_exists('EE_Registry', $loader) |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | ); |
271 | 271 | } |
272 | 272 | $class_name = self::$_instance->getFqnForAlias($class_name); |
273 | - if (! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
274 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
273 | + if ( ! isset(self::$_instance->_class_loaders[$class_name])) { |
|
274 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
275 | 275 | return true; |
276 | 276 | } |
277 | 277 | return false; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | if (strpos($class_name, 'EEM_') === 0) { |
300 | 300 | $class_name = 'LEGACY_MODELS'; |
301 | 301 | } |
302 | - return isset($this->_dependency_map[ $class_name ]) ? true : false; |
|
302 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $class_name = 'LEGACY_MODELS'; |
318 | 318 | } |
319 | 319 | $dependency = $this->getFqnForAlias($dependency, $class_name); |
320 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]) |
|
320 | + return isset($this->_dependency_map[$class_name][$dependency]) |
|
321 | 321 | ? true |
322 | 322 | : false; |
323 | 323 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | } |
339 | 339 | $dependency = $this->getFqnForAlias($dependency); |
340 | 340 | return $this->has_dependency_for_class($class_name, $dependency) |
341 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
341 | + ? $this->_dependency_map[$class_name][$dependency] |
|
342 | 342 | : EE_Dependency_Map::not_registered; |
343 | 343 | } |
344 | 344 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | return 'load_model'; |
355 | 355 | } |
356 | 356 | $class_name = $this->getFqnForAlias($class_name); |
357 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
357 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -788,13 +788,13 @@ discard block |
||
788 | 788 | 'EE_Front_Controller' => 'load_core', |
789 | 789 | 'EE_Module_Request_Router' => 'load_core', |
790 | 790 | 'EE_Registry' => 'load_core', |
791 | - 'EE_Request' => function () use (&$legacy_request) { |
|
791 | + 'EE_Request' => function() use (&$legacy_request) { |
|
792 | 792 | return $legacy_request; |
793 | 793 | }, |
794 | - 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
794 | + 'EventEspresso\core\services\request\Request' => function() use (&$request) { |
|
795 | 795 | return $request; |
796 | 796 | }, |
797 | - 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
797 | + 'EventEspresso\core\services\request\Response' => function() use (&$response) { |
|
798 | 798 | return $response; |
799 | 799 | }, |
800 | 800 | 'EE_Base' => 'load_core', |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
819 | 819 | 'EE_Message_Template_Group_Collection' => 'load_lib', |
820 | 820 | 'EE_Payment_Method_Manager' => 'load_lib', |
821 | - 'EE_Messages_Generator' => function () { |
|
821 | + 'EE_Messages_Generator' => function() { |
|
822 | 822 | return EE_Registry::instance()->load_lib( |
823 | 823 | 'Messages_Generator', |
824 | 824 | array(), |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | false |
827 | 827 | ); |
828 | 828 | }, |
829 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
829 | + 'EE_Messages_Template_Defaults' => function($arguments = array()) { |
|
830 | 830 | return EE_Registry::instance()->load_lib( |
831 | 831 | 'Messages_Template_Defaults', |
832 | 832 | $arguments, |
@@ -835,37 +835,37 @@ discard block |
||
835 | 835 | ); |
836 | 836 | }, |
837 | 837 | // load_helper |
838 | - 'EEH_Parse_Shortcodes' => function () { |
|
838 | + 'EEH_Parse_Shortcodes' => function() { |
|
839 | 839 | if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
840 | 840 | return new EEH_Parse_Shortcodes(); |
841 | 841 | } |
842 | 842 | return null; |
843 | 843 | }, |
844 | - 'EE_Template_Config' => function () { |
|
844 | + 'EE_Template_Config' => function() { |
|
845 | 845 | return EE_Config::instance()->template_settings; |
846 | 846 | }, |
847 | - 'EE_Currency_Config' => function () { |
|
847 | + 'EE_Currency_Config' => function() { |
|
848 | 848 | return EE_Config::instance()->currency; |
849 | 849 | }, |
850 | - 'EE_Registration_Config' => function () { |
|
850 | + 'EE_Registration_Config' => function() { |
|
851 | 851 | return EE_Config::instance()->registration; |
852 | 852 | }, |
853 | - 'EE_Core_Config' => function () { |
|
853 | + 'EE_Core_Config' => function() { |
|
854 | 854 | return EE_Config::instance()->core; |
855 | 855 | }, |
856 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
856 | + 'EventEspresso\core\services\loaders\Loader' => function() { |
|
857 | 857 | return LoaderFactory::getLoader(); |
858 | 858 | }, |
859 | - 'EE_Network_Config' => function () { |
|
859 | + 'EE_Network_Config' => function() { |
|
860 | 860 | return EE_Network_Config::instance(); |
861 | 861 | }, |
862 | - 'EE_Config' => function () { |
|
862 | + 'EE_Config' => function() { |
|
863 | 863 | return EE_Config::instance(); |
864 | 864 | }, |
865 | - 'EventEspresso\core\domain\Domain' => function () { |
|
865 | + 'EventEspresso\core\domain\Domain' => function() { |
|
866 | 866 | return DomainFactory::getEventEspressoCoreDomain(); |
867 | 867 | }, |
868 | - 'EE_Admin_Config' => function () { |
|
868 | + 'EE_Admin_Config' => function() { |
|
869 | 869 | return EE_Config::instance()->admin; |
870 | 870 | } |
871 | 871 | ); |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | } |
928 | 928 | $this->class_cache->addAlias($fqn, $alias); |
929 | 929 | } |
930 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
930 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
931 | 931 | $this->class_cache->addAlias( |
932 | 932 | 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
933 | 933 | 'EventEspresso\core\services\notices\NoticeConverterInterface' |
@@ -20,988 +20,988 @@ |
||
20 | 20 | class EE_Dependency_Map |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * This means that the requested class dependency is not present in the dependency map |
|
25 | - */ |
|
26 | - const not_registered = 0; |
|
27 | - |
|
28 | - /** |
|
29 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | - */ |
|
31 | - const load_new_object = 1; |
|
32 | - |
|
33 | - /** |
|
34 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | - */ |
|
37 | - const load_from_cache = 2; |
|
38 | - |
|
39 | - /** |
|
40 | - * When registering a dependency, |
|
41 | - * this indicates to keep any existing dependencies that already exist, |
|
42 | - * and simply discard any new dependencies declared in the incoming data |
|
43 | - */ |
|
44 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | - |
|
46 | - /** |
|
47 | - * When registering a dependency, |
|
48 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | - */ |
|
50 | - const OVERWRITE_DEPENDENCIES = 1; |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @type EE_Dependency_Map $_instance |
|
55 | - */ |
|
56 | - protected static $_instance; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var ClassInterfaceCache $class_cache |
|
60 | - */ |
|
61 | - private $class_cache; |
|
62 | - |
|
63 | - /** |
|
64 | - * @type RequestInterface $request |
|
65 | - */ |
|
66 | - protected $request; |
|
67 | - |
|
68 | - /** |
|
69 | - * @type LegacyRequestInterface $legacy_request |
|
70 | - */ |
|
71 | - protected $legacy_request; |
|
72 | - |
|
73 | - /** |
|
74 | - * @type ResponseInterface $response |
|
75 | - */ |
|
76 | - protected $response; |
|
77 | - |
|
78 | - /** |
|
79 | - * @type LoaderInterface $loader |
|
80 | - */ |
|
81 | - protected $loader; |
|
82 | - |
|
83 | - /** |
|
84 | - * @type array $_dependency_map |
|
85 | - */ |
|
86 | - protected $_dependency_map = array(); |
|
87 | - |
|
88 | - /** |
|
89 | - * @type array $_class_loaders |
|
90 | - */ |
|
91 | - protected $_class_loaders = array(); |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * EE_Dependency_Map constructor. |
|
96 | - * |
|
97 | - * @param ClassInterfaceCache $class_cache |
|
98 | - */ |
|
99 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
100 | - { |
|
101 | - $this->class_cache = $class_cache; |
|
102 | - do_action('EE_Dependency_Map____construct', $this); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public function initialize() |
|
110 | - { |
|
111 | - $this->_register_core_dependencies(); |
|
112 | - $this->_register_core_class_loaders(); |
|
113 | - $this->_register_core_aliases(); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @singleton method used to instantiate class object |
|
119 | - * @param ClassInterfaceCache|null $class_cache |
|
120 | - * @return EE_Dependency_Map |
|
121 | - */ |
|
122 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
123 | - { |
|
124 | - // check if class object is instantiated, and instantiated properly |
|
125 | - if (! self::$_instance instanceof EE_Dependency_Map |
|
126 | - && $class_cache instanceof ClassInterfaceCache |
|
127 | - ) { |
|
128 | - self::$_instance = new EE_Dependency_Map($class_cache); |
|
129 | - } |
|
130 | - return self::$_instance; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param RequestInterface $request |
|
136 | - */ |
|
137 | - public function setRequest(RequestInterface $request) |
|
138 | - { |
|
139 | - $this->request = $request; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @param LegacyRequestInterface $legacy_request |
|
145 | - */ |
|
146 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
147 | - { |
|
148 | - $this->legacy_request = $legacy_request; |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @param ResponseInterface $response |
|
154 | - */ |
|
155 | - public function setResponse(ResponseInterface $response) |
|
156 | - { |
|
157 | - $this->response = $response; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param LoaderInterface $loader |
|
163 | - */ |
|
164 | - public function setLoader(LoaderInterface $loader) |
|
165 | - { |
|
166 | - $this->loader = $loader; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @param string $class |
|
172 | - * @param array $dependencies |
|
173 | - * @param int $overwrite |
|
174 | - * @return bool |
|
175 | - */ |
|
176 | - public static function register_dependencies( |
|
177 | - $class, |
|
178 | - array $dependencies, |
|
179 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
180 | - ) { |
|
181 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
187 | - * to the class specified by the first parameter. |
|
188 | - * IMPORTANT !!! |
|
189 | - * The order of elements in the incoming $dependencies array MUST match |
|
190 | - * the order of the constructor parameters for the class in question. |
|
191 | - * This is especially important when overriding any existing dependencies that are registered. |
|
192 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
193 | - * |
|
194 | - * @param string $class |
|
195 | - * @param array $dependencies |
|
196 | - * @param int $overwrite |
|
197 | - * @return bool |
|
198 | - */ |
|
199 | - public function registerDependencies( |
|
200 | - $class, |
|
201 | - array $dependencies, |
|
202 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
203 | - ) { |
|
204 | - $class = trim($class, '\\'); |
|
205 | - $registered = false; |
|
206 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
207 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
208 | - } |
|
209 | - // we need to make sure that any aliases used when registering a dependency |
|
210 | - // get resolved to the correct class name |
|
211 | - foreach ($dependencies as $dependency => $load_source) { |
|
212 | - $alias = self::$_instance->getFqnForAlias($dependency); |
|
213 | - if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
214 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
215 | - ) { |
|
216 | - unset($dependencies[ $dependency ]); |
|
217 | - $dependencies[ $alias ] = $load_source; |
|
218 | - $registered = true; |
|
219 | - } |
|
220 | - } |
|
221 | - // now add our two lists of dependencies together. |
|
222 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
223 | - // so $dependencies is NOT overwritten because it is listed first |
|
224 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
225 | - // Union is way faster than array_merge() but should be used with caution... |
|
226 | - // especially with numerically indexed arrays |
|
227 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
228 | - // now we need to ensure that the resulting dependencies |
|
229 | - // array only has the entries that are required for the class |
|
230 | - // so first count how many dependencies were originally registered for the class |
|
231 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
232 | - // if that count is non-zero (meaning dependencies were already registered) |
|
233 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
234 | - // then truncate the final array to match that count |
|
235 | - ? array_slice($dependencies, 0, $dependency_count) |
|
236 | - // otherwise just take the incoming array because nothing previously existed |
|
237 | - : $dependencies; |
|
238 | - return $registered; |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * @param string $class_name |
|
244 | - * @param string $loader |
|
245 | - * @return bool |
|
246 | - * @throws DomainException |
|
247 | - */ |
|
248 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
249 | - { |
|
250 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
251 | - throw new DomainException( |
|
252 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
253 | - ); |
|
254 | - } |
|
255 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
256 | - if (! is_callable($loader) |
|
257 | - && ( |
|
258 | - strpos($loader, 'load_') !== 0 |
|
259 | - || ! method_exists('EE_Registry', $loader) |
|
260 | - ) |
|
261 | - ) { |
|
262 | - throw new DomainException( |
|
263 | - sprintf( |
|
264 | - esc_html__( |
|
265 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
266 | - 'event_espresso' |
|
267 | - ), |
|
268 | - $loader |
|
269 | - ) |
|
270 | - ); |
|
271 | - } |
|
272 | - $class_name = self::$_instance->getFqnForAlias($class_name); |
|
273 | - if (! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
274 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
275 | - return true; |
|
276 | - } |
|
277 | - return false; |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * @return array |
|
283 | - */ |
|
284 | - public function dependency_map() |
|
285 | - { |
|
286 | - return $this->_dependency_map; |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
292 | - * |
|
293 | - * @param string $class_name |
|
294 | - * @return boolean |
|
295 | - */ |
|
296 | - public function has($class_name = '') |
|
297 | - { |
|
298 | - // all legacy models have the same dependencies |
|
299 | - if (strpos($class_name, 'EEM_') === 0) { |
|
300 | - $class_name = 'LEGACY_MODELS'; |
|
301 | - } |
|
302 | - return isset($this->_dependency_map[ $class_name ]) ? true : false; |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
308 | - * |
|
309 | - * @param string $class_name |
|
310 | - * @param string $dependency |
|
311 | - * @return bool |
|
312 | - */ |
|
313 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
314 | - { |
|
315 | - // all legacy models have the same dependencies |
|
316 | - if (strpos($class_name, 'EEM_') === 0) { |
|
317 | - $class_name = 'LEGACY_MODELS'; |
|
318 | - } |
|
319 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
320 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]) |
|
321 | - ? true |
|
322 | - : false; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
328 | - * |
|
329 | - * @param string $class_name |
|
330 | - * @param string $dependency |
|
331 | - * @return int |
|
332 | - */ |
|
333 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
334 | - { |
|
335 | - // all legacy models have the same dependencies |
|
336 | - if (strpos($class_name, 'EEM_') === 0) { |
|
337 | - $class_name = 'LEGACY_MODELS'; |
|
338 | - } |
|
339 | - $dependency = $this->getFqnForAlias($dependency); |
|
340 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
341 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
342 | - : EE_Dependency_Map::not_registered; |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * @param string $class_name |
|
348 | - * @return string | Closure |
|
349 | - */ |
|
350 | - public function class_loader($class_name) |
|
351 | - { |
|
352 | - // all legacy models use load_model() |
|
353 | - if (strpos($class_name, 'EEM_') === 0) { |
|
354 | - return 'load_model'; |
|
355 | - } |
|
356 | - $class_name = $this->getFqnForAlias($class_name); |
|
357 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * @return array |
|
363 | - */ |
|
364 | - public function class_loaders() |
|
365 | - { |
|
366 | - return $this->_class_loaders; |
|
367 | - } |
|
368 | - |
|
369 | - |
|
370 | - /** |
|
371 | - * adds an alias for a classname |
|
372 | - * |
|
373 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
374 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
375 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
376 | - */ |
|
377 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
378 | - { |
|
379 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - /** |
|
384 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
385 | - * WHY? |
|
386 | - * Because if a class is type hinting for a concretion, |
|
387 | - * then why would we need to find another class to supply it? |
|
388 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
389 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
390 | - * Don't go looking for some substitute. |
|
391 | - * Whereas if a class is type hinting for an interface... |
|
392 | - * then we need to find an actual class to use. |
|
393 | - * So the interface IS the alias for some other FQN, |
|
394 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
395 | - * represents some other class. |
|
396 | - * |
|
397 | - * @param string $fqn |
|
398 | - * @param string $for_class |
|
399 | - * @return bool |
|
400 | - */ |
|
401 | - public function isAlias($fqn = '', $for_class = '') |
|
402 | - { |
|
403 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
409 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
410 | - * for example: |
|
411 | - * if the following two entries were added to the _aliases array: |
|
412 | - * array( |
|
413 | - * 'interface_alias' => 'some\namespace\interface' |
|
414 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
415 | - * ) |
|
416 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
417 | - * to load an instance of 'some\namespace\classname' |
|
418 | - * |
|
419 | - * @param string $alias |
|
420 | - * @param string $for_class |
|
421 | - * @return string |
|
422 | - */ |
|
423 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
424 | - { |
|
425 | - return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
431 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
432 | - * This is done by using the following class constants: |
|
433 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
434 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
435 | - */ |
|
436 | - protected function _register_core_dependencies() |
|
437 | - { |
|
438 | - $this->_dependency_map = array( |
|
439 | - 'EE_Request_Handler' => array( |
|
440 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
441 | - ), |
|
442 | - 'EE_System' => array( |
|
443 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
444 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
445 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
446 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
447 | - ), |
|
448 | - 'EE_Session' => array( |
|
449 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
450 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
451 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
452 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
453 | - ), |
|
454 | - 'EE_Cart' => array( |
|
455 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
456 | - ), |
|
457 | - 'EE_Front_Controller' => array( |
|
458 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
459 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
460 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
461 | - ), |
|
462 | - 'EE_Messenger_Collection_Loader' => array( |
|
463 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
464 | - ), |
|
465 | - 'EE_Message_Type_Collection_Loader' => array( |
|
466 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
467 | - ), |
|
468 | - 'EE_Message_Resource_Manager' => array( |
|
469 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
470 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
471 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
472 | - ), |
|
473 | - 'EE_Message_Factory' => array( |
|
474 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
475 | - ), |
|
476 | - 'EE_messages' => array( |
|
477 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
478 | - ), |
|
479 | - 'EE_Messages_Generator' => array( |
|
480 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
481 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
483 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
484 | - ), |
|
485 | - 'EE_Messages_Processor' => array( |
|
486 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
487 | - ), |
|
488 | - 'EE_Messages_Queue' => array( |
|
489 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
490 | - ), |
|
491 | - 'EE_Messages_Template_Defaults' => array( |
|
492 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
493 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
494 | - ), |
|
495 | - 'EE_Message_To_Generate_From_Request' => array( |
|
496 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
497 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
498 | - ), |
|
499 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
500 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
501 | - ), |
|
502 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
503 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
504 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
505 | - ), |
|
506 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
507 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
508 | - ), |
|
509 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
510 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
511 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
512 | - ), |
|
513 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
514 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
515 | - ), |
|
516 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
517 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
518 | - ), |
|
519 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
520 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
521 | - ), |
|
522 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
523 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
524 | - ), |
|
525 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
526 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
527 | - ), |
|
528 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
529 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
530 | - ), |
|
531 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
532 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
533 | - ), |
|
534 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
535 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
536 | - ), |
|
537 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
538 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
539 | - ), |
|
540 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
541 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
542 | - ), |
|
543 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
544 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
545 | - ), |
|
546 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
547 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
548 | - ), |
|
549 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
550 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
551 | - ), |
|
552 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
553 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
554 | - ), |
|
555 | - 'EE_Data_Migration_Class_Base' => array( |
|
556 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
557 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
558 | - ), |
|
559 | - 'EE_DMS_Core_4_1_0' => array( |
|
560 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
561 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
562 | - ), |
|
563 | - 'EE_DMS_Core_4_2_0' => array( |
|
564 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
565 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
566 | - ), |
|
567 | - 'EE_DMS_Core_4_3_0' => array( |
|
568 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
569 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
570 | - ), |
|
571 | - 'EE_DMS_Core_4_4_0' => array( |
|
572 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
573 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
574 | - ), |
|
575 | - 'EE_DMS_Core_4_5_0' => array( |
|
576 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
577 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
578 | - ), |
|
579 | - 'EE_DMS_Core_4_6_0' => array( |
|
580 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
581 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
582 | - ), |
|
583 | - 'EE_DMS_Core_4_7_0' => array( |
|
584 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
585 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
586 | - ), |
|
587 | - 'EE_DMS_Core_4_8_0' => array( |
|
588 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
589 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
590 | - ), |
|
591 | - 'EE_DMS_Core_4_9_0' => array( |
|
592 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
593 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
594 | - ), |
|
595 | - 'EventEspresso\core\services\assets\I18nRegistry' => array( |
|
596 | - array(), |
|
597 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
598 | - ), |
|
599 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
600 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
601 | - 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
602 | - ), |
|
603 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
604 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
605 | - ), |
|
606 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
607 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
608 | - ), |
|
609 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
610 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
611 | - ), |
|
612 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
613 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
614 | - ), |
|
615 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
616 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
617 | - ), |
|
618 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
619 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
620 | - ), |
|
621 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
622 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
623 | - ), |
|
624 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
625 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
626 | - ), |
|
627 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
628 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
629 | - ), |
|
630 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
631 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
632 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
633 | - ), |
|
634 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
635 | - null, |
|
636 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
637 | - ), |
|
638 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
639 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
640 | - ), |
|
641 | - 'LEGACY_MODELS' => array( |
|
642 | - null, |
|
643 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
644 | - ), |
|
645 | - 'EE_Module_Request_Router' => array( |
|
646 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
647 | - ), |
|
648 | - 'EE_Registration_Processor' => array( |
|
649 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
650 | - ), |
|
651 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
652 | - null, |
|
653 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
654 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | - ), |
|
656 | - 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
657 | - 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
658 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
659 | - ), |
|
660 | - 'EE_Admin_Transactions_List_Table' => array( |
|
661 | - null, |
|
662 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
663 | - ), |
|
664 | - 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
665 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
666 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
667 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
668 | - ), |
|
669 | - 'EventEspresso\core\domain\services\pue\Config' => array( |
|
670 | - 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
671 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
672 | - ), |
|
673 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
674 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
675 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
676 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
677 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
678 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
679 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
680 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
681 | - ), |
|
682 | - 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
683 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
684 | - ), |
|
685 | - 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
686 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
687 | - ), |
|
688 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
689 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
690 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
691 | - ), |
|
692 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
693 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
694 | - ), |
|
695 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
696 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
697 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
698 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
699 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
700 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
701 | - ), |
|
702 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
703 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
704 | - ), |
|
705 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array( |
|
706 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
707 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
708 | - ), |
|
709 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => array( |
|
710 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
711 | - ), |
|
712 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => array( |
|
713 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
714 | - ), |
|
715 | - 'EE_CPT_Strategy' => array( |
|
716 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
717 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
718 | - ), |
|
719 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => array( |
|
720 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
721 | - ), |
|
722 | - 'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetManager' => array( |
|
723 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
724 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
725 | - ), |
|
726 | - 'EventEspresso\core\services\assets\AssetManager' => array( |
|
727 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
728 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
729 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
730 | - ), |
|
731 | - 'EventEspresso\core\domain\services\assets\CoreAssetManager' => array( |
|
732 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
733 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
734 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
735 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
736 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
737 | - ), |
|
738 | - 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array( |
|
739 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
740 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
741 | - ), |
|
742 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array( |
|
743 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
744 | - ), |
|
745 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array( |
|
746 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
747 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
748 | - ), |
|
749 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array( |
|
750 | - 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
751 | - ), |
|
752 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array( |
|
753 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
754 | - ), |
|
755 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array( |
|
756 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
757 | - ), |
|
758 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array( |
|
759 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
760 | - ), |
|
761 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array( |
|
762 | - 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
763 | - 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
764 | - ), |
|
765 | - ); |
|
766 | - } |
|
767 | - |
|
768 | - |
|
769 | - /** |
|
770 | - * Registers how core classes are loaded. |
|
771 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
772 | - * 'EE_Request_Handler' => 'load_core' |
|
773 | - * 'EE_Messages_Queue' => 'load_lib' |
|
774 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
775 | - * or, if greater control is required, by providing a custom closure. For example: |
|
776 | - * 'Some_Class' => function () { |
|
777 | - * return new Some_Class(); |
|
778 | - * }, |
|
779 | - * This is required for instantiating dependencies |
|
780 | - * where an interface has been type hinted in a class constructor. For example: |
|
781 | - * 'Required_Interface' => function () { |
|
782 | - * return new A_Class_That_Implements_Required_Interface(); |
|
783 | - * }, |
|
784 | - */ |
|
785 | - protected function _register_core_class_loaders() |
|
786 | - { |
|
787 | - // for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
788 | - // be used in a closure. |
|
789 | - $request = &$this->request; |
|
790 | - $response = &$this->response; |
|
791 | - $legacy_request = &$this->legacy_request; |
|
792 | - // $loader = &$this->loader; |
|
793 | - $this->_class_loaders = array( |
|
794 | - // load_core |
|
795 | - 'EE_Capabilities' => 'load_core', |
|
796 | - 'EE_Encryption' => 'load_core', |
|
797 | - 'EE_Front_Controller' => 'load_core', |
|
798 | - 'EE_Module_Request_Router' => 'load_core', |
|
799 | - 'EE_Registry' => 'load_core', |
|
800 | - 'EE_Request' => function () use (&$legacy_request) { |
|
801 | - return $legacy_request; |
|
802 | - }, |
|
803 | - 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
804 | - return $request; |
|
805 | - }, |
|
806 | - 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
807 | - return $response; |
|
808 | - }, |
|
809 | - 'EE_Base' => 'load_core', |
|
810 | - 'EE_Request_Handler' => 'load_core', |
|
811 | - 'EE_Session' => 'load_core', |
|
812 | - 'EE_Cron_Tasks' => 'load_core', |
|
813 | - 'EE_System' => 'load_core', |
|
814 | - 'EE_Maintenance_Mode' => 'load_core', |
|
815 | - 'EE_Register_CPTs' => 'load_core', |
|
816 | - 'EE_Admin' => 'load_core', |
|
817 | - 'EE_CPT_Strategy' => 'load_core', |
|
818 | - // load_lib |
|
819 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
820 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
821 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
822 | - 'EE_Messenger_Collection' => 'load_lib', |
|
823 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
824 | - 'EE_Messages_Processor' => 'load_lib', |
|
825 | - 'EE_Message_Repository' => 'load_lib', |
|
826 | - 'EE_Messages_Queue' => 'load_lib', |
|
827 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
828 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
829 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
830 | - 'EE_Messages_Generator' => function () { |
|
831 | - return EE_Registry::instance()->load_lib( |
|
832 | - 'Messages_Generator', |
|
833 | - array(), |
|
834 | - false, |
|
835 | - false |
|
836 | - ); |
|
837 | - }, |
|
838 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
839 | - return EE_Registry::instance()->load_lib( |
|
840 | - 'Messages_Template_Defaults', |
|
841 | - $arguments, |
|
842 | - false, |
|
843 | - false |
|
844 | - ); |
|
845 | - }, |
|
846 | - // load_helper |
|
847 | - 'EEH_Parse_Shortcodes' => function () { |
|
848 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
849 | - return new EEH_Parse_Shortcodes(); |
|
850 | - } |
|
851 | - return null; |
|
852 | - }, |
|
853 | - 'EE_Template_Config' => function () { |
|
854 | - return EE_Config::instance()->template_settings; |
|
855 | - }, |
|
856 | - 'EE_Currency_Config' => function () { |
|
857 | - return EE_Config::instance()->currency; |
|
858 | - }, |
|
859 | - 'EE_Registration_Config' => function () { |
|
860 | - return EE_Config::instance()->registration; |
|
861 | - }, |
|
862 | - 'EE_Core_Config' => function () { |
|
863 | - return EE_Config::instance()->core; |
|
864 | - }, |
|
865 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
866 | - return LoaderFactory::getLoader(); |
|
867 | - }, |
|
868 | - 'EE_Network_Config' => function () { |
|
869 | - return EE_Network_Config::instance(); |
|
870 | - }, |
|
871 | - 'EE_Config' => function () { |
|
872 | - return EE_Config::instance(); |
|
873 | - }, |
|
874 | - 'EventEspresso\core\domain\Domain' => function () { |
|
875 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
876 | - }, |
|
877 | - 'EE_Admin_Config' => function () { |
|
878 | - return EE_Config::instance()->admin; |
|
879 | - } |
|
880 | - ); |
|
881 | - } |
|
882 | - |
|
883 | - |
|
884 | - /** |
|
885 | - * can be used for supplying alternate names for classes, |
|
886 | - * or for connecting interface names to instantiable classes |
|
887 | - */ |
|
888 | - protected function _register_core_aliases() |
|
889 | - { |
|
890 | - $aliases = array( |
|
891 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
892 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
893 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
894 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
895 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
896 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
897 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
898 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
899 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
900 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
901 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
902 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
903 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
904 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
905 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
906 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
907 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
908 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
909 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
910 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
911 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
912 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
913 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
914 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
915 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
916 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
917 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
918 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
919 | - 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
920 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
921 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
922 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
923 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
924 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
925 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
926 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
927 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
928 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
929 | - ); |
|
930 | - foreach ($aliases as $alias => $fqn) { |
|
931 | - if (is_array($fqn)) { |
|
932 | - foreach ($fqn as $class => $for_class) { |
|
933 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
934 | - } |
|
935 | - continue; |
|
936 | - } |
|
937 | - $this->class_cache->addAlias($fqn, $alias); |
|
938 | - } |
|
939 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
940 | - $this->class_cache->addAlias( |
|
941 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
942 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
943 | - ); |
|
944 | - } |
|
945 | - } |
|
946 | - |
|
947 | - |
|
948 | - /** |
|
949 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
950 | - * request Primarily used by unit tests. |
|
951 | - */ |
|
952 | - public function reset() |
|
953 | - { |
|
954 | - $this->_register_core_class_loaders(); |
|
955 | - $this->_register_core_dependencies(); |
|
956 | - } |
|
957 | - |
|
958 | - |
|
959 | - /** |
|
960 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
961 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
962 | - * WHY? |
|
963 | - * Because if a class is type hinting for a concretion, |
|
964 | - * then why would we need to find another class to supply it? |
|
965 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
966 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
967 | - * Don't go looking for some substitute. |
|
968 | - * Whereas if a class is type hinting for an interface... |
|
969 | - * then we need to find an actual class to use. |
|
970 | - * So the interface IS the alias for some other FQN, |
|
971 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
972 | - * represents some other class. |
|
973 | - * |
|
974 | - * @deprecated $VID:$ |
|
975 | - * @param string $fqn |
|
976 | - * @param string $for_class |
|
977 | - * @return bool |
|
978 | - */ |
|
979 | - public function has_alias($fqn = '', $for_class = '') |
|
980 | - { |
|
981 | - return $this->isAlias($fqn, $for_class); |
|
982 | - } |
|
983 | - |
|
984 | - |
|
985 | - /** |
|
986 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
987 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
988 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
989 | - * for example: |
|
990 | - * if the following two entries were added to the _aliases array: |
|
991 | - * array( |
|
992 | - * 'interface_alias' => 'some\namespace\interface' |
|
993 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
994 | - * ) |
|
995 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
996 | - * to load an instance of 'some\namespace\classname' |
|
997 | - * |
|
998 | - * @deprecated $VID:$ |
|
999 | - * @param string $alias |
|
1000 | - * @param string $for_class |
|
1001 | - * @return string |
|
1002 | - */ |
|
1003 | - public function get_alias($alias = '', $for_class = '') |
|
1004 | - { |
|
1005 | - return $this->getFqnForAlias($alias, $for_class); |
|
1006 | - } |
|
23 | + /** |
|
24 | + * This means that the requested class dependency is not present in the dependency map |
|
25 | + */ |
|
26 | + const not_registered = 0; |
|
27 | + |
|
28 | + /** |
|
29 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | + */ |
|
31 | + const load_new_object = 1; |
|
32 | + |
|
33 | + /** |
|
34 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | + */ |
|
37 | + const load_from_cache = 2; |
|
38 | + |
|
39 | + /** |
|
40 | + * When registering a dependency, |
|
41 | + * this indicates to keep any existing dependencies that already exist, |
|
42 | + * and simply discard any new dependencies declared in the incoming data |
|
43 | + */ |
|
44 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | + |
|
46 | + /** |
|
47 | + * When registering a dependency, |
|
48 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | + */ |
|
50 | + const OVERWRITE_DEPENDENCIES = 1; |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @type EE_Dependency_Map $_instance |
|
55 | + */ |
|
56 | + protected static $_instance; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var ClassInterfaceCache $class_cache |
|
60 | + */ |
|
61 | + private $class_cache; |
|
62 | + |
|
63 | + /** |
|
64 | + * @type RequestInterface $request |
|
65 | + */ |
|
66 | + protected $request; |
|
67 | + |
|
68 | + /** |
|
69 | + * @type LegacyRequestInterface $legacy_request |
|
70 | + */ |
|
71 | + protected $legacy_request; |
|
72 | + |
|
73 | + /** |
|
74 | + * @type ResponseInterface $response |
|
75 | + */ |
|
76 | + protected $response; |
|
77 | + |
|
78 | + /** |
|
79 | + * @type LoaderInterface $loader |
|
80 | + */ |
|
81 | + protected $loader; |
|
82 | + |
|
83 | + /** |
|
84 | + * @type array $_dependency_map |
|
85 | + */ |
|
86 | + protected $_dependency_map = array(); |
|
87 | + |
|
88 | + /** |
|
89 | + * @type array $_class_loaders |
|
90 | + */ |
|
91 | + protected $_class_loaders = array(); |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * EE_Dependency_Map constructor. |
|
96 | + * |
|
97 | + * @param ClassInterfaceCache $class_cache |
|
98 | + */ |
|
99 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
100 | + { |
|
101 | + $this->class_cache = $class_cache; |
|
102 | + do_action('EE_Dependency_Map____construct', $this); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public function initialize() |
|
110 | + { |
|
111 | + $this->_register_core_dependencies(); |
|
112 | + $this->_register_core_class_loaders(); |
|
113 | + $this->_register_core_aliases(); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @singleton method used to instantiate class object |
|
119 | + * @param ClassInterfaceCache|null $class_cache |
|
120 | + * @return EE_Dependency_Map |
|
121 | + */ |
|
122 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
123 | + { |
|
124 | + // check if class object is instantiated, and instantiated properly |
|
125 | + if (! self::$_instance instanceof EE_Dependency_Map |
|
126 | + && $class_cache instanceof ClassInterfaceCache |
|
127 | + ) { |
|
128 | + self::$_instance = new EE_Dependency_Map($class_cache); |
|
129 | + } |
|
130 | + return self::$_instance; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param RequestInterface $request |
|
136 | + */ |
|
137 | + public function setRequest(RequestInterface $request) |
|
138 | + { |
|
139 | + $this->request = $request; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @param LegacyRequestInterface $legacy_request |
|
145 | + */ |
|
146 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
147 | + { |
|
148 | + $this->legacy_request = $legacy_request; |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @param ResponseInterface $response |
|
154 | + */ |
|
155 | + public function setResponse(ResponseInterface $response) |
|
156 | + { |
|
157 | + $this->response = $response; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param LoaderInterface $loader |
|
163 | + */ |
|
164 | + public function setLoader(LoaderInterface $loader) |
|
165 | + { |
|
166 | + $this->loader = $loader; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @param string $class |
|
172 | + * @param array $dependencies |
|
173 | + * @param int $overwrite |
|
174 | + * @return bool |
|
175 | + */ |
|
176 | + public static function register_dependencies( |
|
177 | + $class, |
|
178 | + array $dependencies, |
|
179 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
180 | + ) { |
|
181 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
187 | + * to the class specified by the first parameter. |
|
188 | + * IMPORTANT !!! |
|
189 | + * The order of elements in the incoming $dependencies array MUST match |
|
190 | + * the order of the constructor parameters for the class in question. |
|
191 | + * This is especially important when overriding any existing dependencies that are registered. |
|
192 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
193 | + * |
|
194 | + * @param string $class |
|
195 | + * @param array $dependencies |
|
196 | + * @param int $overwrite |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | + public function registerDependencies( |
|
200 | + $class, |
|
201 | + array $dependencies, |
|
202 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
203 | + ) { |
|
204 | + $class = trim($class, '\\'); |
|
205 | + $registered = false; |
|
206 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
207 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
208 | + } |
|
209 | + // we need to make sure that any aliases used when registering a dependency |
|
210 | + // get resolved to the correct class name |
|
211 | + foreach ($dependencies as $dependency => $load_source) { |
|
212 | + $alias = self::$_instance->getFqnForAlias($dependency); |
|
213 | + if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
214 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
215 | + ) { |
|
216 | + unset($dependencies[ $dependency ]); |
|
217 | + $dependencies[ $alias ] = $load_source; |
|
218 | + $registered = true; |
|
219 | + } |
|
220 | + } |
|
221 | + // now add our two lists of dependencies together. |
|
222 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
223 | + // so $dependencies is NOT overwritten because it is listed first |
|
224 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
225 | + // Union is way faster than array_merge() but should be used with caution... |
|
226 | + // especially with numerically indexed arrays |
|
227 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
228 | + // now we need to ensure that the resulting dependencies |
|
229 | + // array only has the entries that are required for the class |
|
230 | + // so first count how many dependencies were originally registered for the class |
|
231 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
232 | + // if that count is non-zero (meaning dependencies were already registered) |
|
233 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
234 | + // then truncate the final array to match that count |
|
235 | + ? array_slice($dependencies, 0, $dependency_count) |
|
236 | + // otherwise just take the incoming array because nothing previously existed |
|
237 | + : $dependencies; |
|
238 | + return $registered; |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * @param string $class_name |
|
244 | + * @param string $loader |
|
245 | + * @return bool |
|
246 | + * @throws DomainException |
|
247 | + */ |
|
248 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
249 | + { |
|
250 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
251 | + throw new DomainException( |
|
252 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
253 | + ); |
|
254 | + } |
|
255 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
256 | + if (! is_callable($loader) |
|
257 | + && ( |
|
258 | + strpos($loader, 'load_') !== 0 |
|
259 | + || ! method_exists('EE_Registry', $loader) |
|
260 | + ) |
|
261 | + ) { |
|
262 | + throw new DomainException( |
|
263 | + sprintf( |
|
264 | + esc_html__( |
|
265 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
266 | + 'event_espresso' |
|
267 | + ), |
|
268 | + $loader |
|
269 | + ) |
|
270 | + ); |
|
271 | + } |
|
272 | + $class_name = self::$_instance->getFqnForAlias($class_name); |
|
273 | + if (! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
274 | + self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
275 | + return true; |
|
276 | + } |
|
277 | + return false; |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * @return array |
|
283 | + */ |
|
284 | + public function dependency_map() |
|
285 | + { |
|
286 | + return $this->_dependency_map; |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
292 | + * |
|
293 | + * @param string $class_name |
|
294 | + * @return boolean |
|
295 | + */ |
|
296 | + public function has($class_name = '') |
|
297 | + { |
|
298 | + // all legacy models have the same dependencies |
|
299 | + if (strpos($class_name, 'EEM_') === 0) { |
|
300 | + $class_name = 'LEGACY_MODELS'; |
|
301 | + } |
|
302 | + return isset($this->_dependency_map[ $class_name ]) ? true : false; |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
308 | + * |
|
309 | + * @param string $class_name |
|
310 | + * @param string $dependency |
|
311 | + * @return bool |
|
312 | + */ |
|
313 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
314 | + { |
|
315 | + // all legacy models have the same dependencies |
|
316 | + if (strpos($class_name, 'EEM_') === 0) { |
|
317 | + $class_name = 'LEGACY_MODELS'; |
|
318 | + } |
|
319 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
320 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]) |
|
321 | + ? true |
|
322 | + : false; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
328 | + * |
|
329 | + * @param string $class_name |
|
330 | + * @param string $dependency |
|
331 | + * @return int |
|
332 | + */ |
|
333 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
334 | + { |
|
335 | + // all legacy models have the same dependencies |
|
336 | + if (strpos($class_name, 'EEM_') === 0) { |
|
337 | + $class_name = 'LEGACY_MODELS'; |
|
338 | + } |
|
339 | + $dependency = $this->getFqnForAlias($dependency); |
|
340 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
341 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
342 | + : EE_Dependency_Map::not_registered; |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * @param string $class_name |
|
348 | + * @return string | Closure |
|
349 | + */ |
|
350 | + public function class_loader($class_name) |
|
351 | + { |
|
352 | + // all legacy models use load_model() |
|
353 | + if (strpos($class_name, 'EEM_') === 0) { |
|
354 | + return 'load_model'; |
|
355 | + } |
|
356 | + $class_name = $this->getFqnForAlias($class_name); |
|
357 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * @return array |
|
363 | + */ |
|
364 | + public function class_loaders() |
|
365 | + { |
|
366 | + return $this->_class_loaders; |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + /** |
|
371 | + * adds an alias for a classname |
|
372 | + * |
|
373 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
374 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
375 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
376 | + */ |
|
377 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
378 | + { |
|
379 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + /** |
|
384 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
385 | + * WHY? |
|
386 | + * Because if a class is type hinting for a concretion, |
|
387 | + * then why would we need to find another class to supply it? |
|
388 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
389 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
390 | + * Don't go looking for some substitute. |
|
391 | + * Whereas if a class is type hinting for an interface... |
|
392 | + * then we need to find an actual class to use. |
|
393 | + * So the interface IS the alias for some other FQN, |
|
394 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
395 | + * represents some other class. |
|
396 | + * |
|
397 | + * @param string $fqn |
|
398 | + * @param string $for_class |
|
399 | + * @return bool |
|
400 | + */ |
|
401 | + public function isAlias($fqn = '', $for_class = '') |
|
402 | + { |
|
403 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
409 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
410 | + * for example: |
|
411 | + * if the following two entries were added to the _aliases array: |
|
412 | + * array( |
|
413 | + * 'interface_alias' => 'some\namespace\interface' |
|
414 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
415 | + * ) |
|
416 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
417 | + * to load an instance of 'some\namespace\classname' |
|
418 | + * |
|
419 | + * @param string $alias |
|
420 | + * @param string $for_class |
|
421 | + * @return string |
|
422 | + */ |
|
423 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
424 | + { |
|
425 | + return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
431 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
432 | + * This is done by using the following class constants: |
|
433 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
434 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
435 | + */ |
|
436 | + protected function _register_core_dependencies() |
|
437 | + { |
|
438 | + $this->_dependency_map = array( |
|
439 | + 'EE_Request_Handler' => array( |
|
440 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
441 | + ), |
|
442 | + 'EE_System' => array( |
|
443 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
444 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
445 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
446 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
447 | + ), |
|
448 | + 'EE_Session' => array( |
|
449 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
450 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
451 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
452 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
453 | + ), |
|
454 | + 'EE_Cart' => array( |
|
455 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
456 | + ), |
|
457 | + 'EE_Front_Controller' => array( |
|
458 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
459 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
460 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
461 | + ), |
|
462 | + 'EE_Messenger_Collection_Loader' => array( |
|
463 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
464 | + ), |
|
465 | + 'EE_Message_Type_Collection_Loader' => array( |
|
466 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
467 | + ), |
|
468 | + 'EE_Message_Resource_Manager' => array( |
|
469 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
470 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
471 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
472 | + ), |
|
473 | + 'EE_Message_Factory' => array( |
|
474 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
475 | + ), |
|
476 | + 'EE_messages' => array( |
|
477 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
478 | + ), |
|
479 | + 'EE_Messages_Generator' => array( |
|
480 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
481 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
483 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
484 | + ), |
|
485 | + 'EE_Messages_Processor' => array( |
|
486 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
487 | + ), |
|
488 | + 'EE_Messages_Queue' => array( |
|
489 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
490 | + ), |
|
491 | + 'EE_Messages_Template_Defaults' => array( |
|
492 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
493 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
494 | + ), |
|
495 | + 'EE_Message_To_Generate_From_Request' => array( |
|
496 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
497 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
498 | + ), |
|
499 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
500 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
501 | + ), |
|
502 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
503 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
504 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
505 | + ), |
|
506 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
507 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
508 | + ), |
|
509 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
510 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
511 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
512 | + ), |
|
513 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
514 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
515 | + ), |
|
516 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
517 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
518 | + ), |
|
519 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
520 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
521 | + ), |
|
522 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
523 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
524 | + ), |
|
525 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
526 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
527 | + ), |
|
528 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
529 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
530 | + ), |
|
531 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
532 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
533 | + ), |
|
534 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
535 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
536 | + ), |
|
537 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
538 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
539 | + ), |
|
540 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
541 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
542 | + ), |
|
543 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
544 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
545 | + ), |
|
546 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
547 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
548 | + ), |
|
549 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
550 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
551 | + ), |
|
552 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
553 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
554 | + ), |
|
555 | + 'EE_Data_Migration_Class_Base' => array( |
|
556 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
557 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
558 | + ), |
|
559 | + 'EE_DMS_Core_4_1_0' => array( |
|
560 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
561 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
562 | + ), |
|
563 | + 'EE_DMS_Core_4_2_0' => array( |
|
564 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
565 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
566 | + ), |
|
567 | + 'EE_DMS_Core_4_3_0' => array( |
|
568 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
569 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
570 | + ), |
|
571 | + 'EE_DMS_Core_4_4_0' => array( |
|
572 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
573 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
574 | + ), |
|
575 | + 'EE_DMS_Core_4_5_0' => array( |
|
576 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
577 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
578 | + ), |
|
579 | + 'EE_DMS_Core_4_6_0' => array( |
|
580 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
581 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
582 | + ), |
|
583 | + 'EE_DMS_Core_4_7_0' => array( |
|
584 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
585 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
586 | + ), |
|
587 | + 'EE_DMS_Core_4_8_0' => array( |
|
588 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
589 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
590 | + ), |
|
591 | + 'EE_DMS_Core_4_9_0' => array( |
|
592 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
593 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
594 | + ), |
|
595 | + 'EventEspresso\core\services\assets\I18nRegistry' => array( |
|
596 | + array(), |
|
597 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
598 | + ), |
|
599 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
600 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
601 | + 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
602 | + ), |
|
603 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
604 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
605 | + ), |
|
606 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
607 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
608 | + ), |
|
609 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
610 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
611 | + ), |
|
612 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
613 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
614 | + ), |
|
615 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
616 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
617 | + ), |
|
618 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
619 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
620 | + ), |
|
621 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
622 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
623 | + ), |
|
624 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
625 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
626 | + ), |
|
627 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
628 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
629 | + ), |
|
630 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
631 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
632 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
633 | + ), |
|
634 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
635 | + null, |
|
636 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
637 | + ), |
|
638 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
639 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
640 | + ), |
|
641 | + 'LEGACY_MODELS' => array( |
|
642 | + null, |
|
643 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
644 | + ), |
|
645 | + 'EE_Module_Request_Router' => array( |
|
646 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
647 | + ), |
|
648 | + 'EE_Registration_Processor' => array( |
|
649 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
650 | + ), |
|
651 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
652 | + null, |
|
653 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
654 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | + ), |
|
656 | + 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
657 | + 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
658 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
659 | + ), |
|
660 | + 'EE_Admin_Transactions_List_Table' => array( |
|
661 | + null, |
|
662 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
663 | + ), |
|
664 | + 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
665 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
666 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
667 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
668 | + ), |
|
669 | + 'EventEspresso\core\domain\services\pue\Config' => array( |
|
670 | + 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
671 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
672 | + ), |
|
673 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
674 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
675 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
676 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
677 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
678 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
679 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
680 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
681 | + ), |
|
682 | + 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
683 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
684 | + ), |
|
685 | + 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
686 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
687 | + ), |
|
688 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
689 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
690 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
691 | + ), |
|
692 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
693 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
694 | + ), |
|
695 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
696 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
697 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
698 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
699 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
700 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
701 | + ), |
|
702 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
703 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
704 | + ), |
|
705 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array( |
|
706 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
707 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
708 | + ), |
|
709 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => array( |
|
710 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
711 | + ), |
|
712 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => array( |
|
713 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
714 | + ), |
|
715 | + 'EE_CPT_Strategy' => array( |
|
716 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
717 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
718 | + ), |
|
719 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => array( |
|
720 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
721 | + ), |
|
722 | + 'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetManager' => array( |
|
723 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
724 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
725 | + ), |
|
726 | + 'EventEspresso\core\services\assets\AssetManager' => array( |
|
727 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
728 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
729 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
730 | + ), |
|
731 | + 'EventEspresso\core\domain\services\assets\CoreAssetManager' => array( |
|
732 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
733 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
734 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
735 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
736 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
737 | + ), |
|
738 | + 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array( |
|
739 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
740 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
741 | + ), |
|
742 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array( |
|
743 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
744 | + ), |
|
745 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array( |
|
746 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
747 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
748 | + ), |
|
749 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array( |
|
750 | + 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
751 | + ), |
|
752 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array( |
|
753 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
754 | + ), |
|
755 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array( |
|
756 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
757 | + ), |
|
758 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array( |
|
759 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
760 | + ), |
|
761 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array( |
|
762 | + 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
763 | + 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
764 | + ), |
|
765 | + ); |
|
766 | + } |
|
767 | + |
|
768 | + |
|
769 | + /** |
|
770 | + * Registers how core classes are loaded. |
|
771 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
772 | + * 'EE_Request_Handler' => 'load_core' |
|
773 | + * 'EE_Messages_Queue' => 'load_lib' |
|
774 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
775 | + * or, if greater control is required, by providing a custom closure. For example: |
|
776 | + * 'Some_Class' => function () { |
|
777 | + * return new Some_Class(); |
|
778 | + * }, |
|
779 | + * This is required for instantiating dependencies |
|
780 | + * where an interface has been type hinted in a class constructor. For example: |
|
781 | + * 'Required_Interface' => function () { |
|
782 | + * return new A_Class_That_Implements_Required_Interface(); |
|
783 | + * }, |
|
784 | + */ |
|
785 | + protected function _register_core_class_loaders() |
|
786 | + { |
|
787 | + // for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
788 | + // be used in a closure. |
|
789 | + $request = &$this->request; |
|
790 | + $response = &$this->response; |
|
791 | + $legacy_request = &$this->legacy_request; |
|
792 | + // $loader = &$this->loader; |
|
793 | + $this->_class_loaders = array( |
|
794 | + // load_core |
|
795 | + 'EE_Capabilities' => 'load_core', |
|
796 | + 'EE_Encryption' => 'load_core', |
|
797 | + 'EE_Front_Controller' => 'load_core', |
|
798 | + 'EE_Module_Request_Router' => 'load_core', |
|
799 | + 'EE_Registry' => 'load_core', |
|
800 | + 'EE_Request' => function () use (&$legacy_request) { |
|
801 | + return $legacy_request; |
|
802 | + }, |
|
803 | + 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
804 | + return $request; |
|
805 | + }, |
|
806 | + 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
807 | + return $response; |
|
808 | + }, |
|
809 | + 'EE_Base' => 'load_core', |
|
810 | + 'EE_Request_Handler' => 'load_core', |
|
811 | + 'EE_Session' => 'load_core', |
|
812 | + 'EE_Cron_Tasks' => 'load_core', |
|
813 | + 'EE_System' => 'load_core', |
|
814 | + 'EE_Maintenance_Mode' => 'load_core', |
|
815 | + 'EE_Register_CPTs' => 'load_core', |
|
816 | + 'EE_Admin' => 'load_core', |
|
817 | + 'EE_CPT_Strategy' => 'load_core', |
|
818 | + // load_lib |
|
819 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
820 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
821 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
822 | + 'EE_Messenger_Collection' => 'load_lib', |
|
823 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
824 | + 'EE_Messages_Processor' => 'load_lib', |
|
825 | + 'EE_Message_Repository' => 'load_lib', |
|
826 | + 'EE_Messages_Queue' => 'load_lib', |
|
827 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
828 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
829 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
830 | + 'EE_Messages_Generator' => function () { |
|
831 | + return EE_Registry::instance()->load_lib( |
|
832 | + 'Messages_Generator', |
|
833 | + array(), |
|
834 | + false, |
|
835 | + false |
|
836 | + ); |
|
837 | + }, |
|
838 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
839 | + return EE_Registry::instance()->load_lib( |
|
840 | + 'Messages_Template_Defaults', |
|
841 | + $arguments, |
|
842 | + false, |
|
843 | + false |
|
844 | + ); |
|
845 | + }, |
|
846 | + // load_helper |
|
847 | + 'EEH_Parse_Shortcodes' => function () { |
|
848 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
849 | + return new EEH_Parse_Shortcodes(); |
|
850 | + } |
|
851 | + return null; |
|
852 | + }, |
|
853 | + 'EE_Template_Config' => function () { |
|
854 | + return EE_Config::instance()->template_settings; |
|
855 | + }, |
|
856 | + 'EE_Currency_Config' => function () { |
|
857 | + return EE_Config::instance()->currency; |
|
858 | + }, |
|
859 | + 'EE_Registration_Config' => function () { |
|
860 | + return EE_Config::instance()->registration; |
|
861 | + }, |
|
862 | + 'EE_Core_Config' => function () { |
|
863 | + return EE_Config::instance()->core; |
|
864 | + }, |
|
865 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
866 | + return LoaderFactory::getLoader(); |
|
867 | + }, |
|
868 | + 'EE_Network_Config' => function () { |
|
869 | + return EE_Network_Config::instance(); |
|
870 | + }, |
|
871 | + 'EE_Config' => function () { |
|
872 | + return EE_Config::instance(); |
|
873 | + }, |
|
874 | + 'EventEspresso\core\domain\Domain' => function () { |
|
875 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
876 | + }, |
|
877 | + 'EE_Admin_Config' => function () { |
|
878 | + return EE_Config::instance()->admin; |
|
879 | + } |
|
880 | + ); |
|
881 | + } |
|
882 | + |
|
883 | + |
|
884 | + /** |
|
885 | + * can be used for supplying alternate names for classes, |
|
886 | + * or for connecting interface names to instantiable classes |
|
887 | + */ |
|
888 | + protected function _register_core_aliases() |
|
889 | + { |
|
890 | + $aliases = array( |
|
891 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
892 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
893 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
894 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
895 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
896 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
897 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
898 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
899 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
900 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
901 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
902 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
903 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
904 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
905 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
906 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
907 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
908 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
909 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
910 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
911 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
912 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
913 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
914 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
915 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
916 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
917 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
918 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
919 | + 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
920 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
921 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
922 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
923 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
924 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
925 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
926 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
927 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
928 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
929 | + ); |
|
930 | + foreach ($aliases as $alias => $fqn) { |
|
931 | + if (is_array($fqn)) { |
|
932 | + foreach ($fqn as $class => $for_class) { |
|
933 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
934 | + } |
|
935 | + continue; |
|
936 | + } |
|
937 | + $this->class_cache->addAlias($fqn, $alias); |
|
938 | + } |
|
939 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
940 | + $this->class_cache->addAlias( |
|
941 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
942 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
943 | + ); |
|
944 | + } |
|
945 | + } |
|
946 | + |
|
947 | + |
|
948 | + /** |
|
949 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
950 | + * request Primarily used by unit tests. |
|
951 | + */ |
|
952 | + public function reset() |
|
953 | + { |
|
954 | + $this->_register_core_class_loaders(); |
|
955 | + $this->_register_core_dependencies(); |
|
956 | + } |
|
957 | + |
|
958 | + |
|
959 | + /** |
|
960 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
961 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
962 | + * WHY? |
|
963 | + * Because if a class is type hinting for a concretion, |
|
964 | + * then why would we need to find another class to supply it? |
|
965 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
966 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
967 | + * Don't go looking for some substitute. |
|
968 | + * Whereas if a class is type hinting for an interface... |
|
969 | + * then we need to find an actual class to use. |
|
970 | + * So the interface IS the alias for some other FQN, |
|
971 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
972 | + * represents some other class. |
|
973 | + * |
|
974 | + * @deprecated $VID:$ |
|
975 | + * @param string $fqn |
|
976 | + * @param string $for_class |
|
977 | + * @return bool |
|
978 | + */ |
|
979 | + public function has_alias($fqn = '', $for_class = '') |
|
980 | + { |
|
981 | + return $this->isAlias($fqn, $for_class); |
|
982 | + } |
|
983 | + |
|
984 | + |
|
985 | + /** |
|
986 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
987 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
988 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
989 | + * for example: |
|
990 | + * if the following two entries were added to the _aliases array: |
|
991 | + * array( |
|
992 | + * 'interface_alias' => 'some\namespace\interface' |
|
993 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
994 | + * ) |
|
995 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
996 | + * to load an instance of 'some\namespace\classname' |
|
997 | + * |
|
998 | + * @deprecated $VID:$ |
|
999 | + * @param string $alias |
|
1000 | + * @param string $for_class |
|
1001 | + * @return string |
|
1002 | + */ |
|
1003 | + public function get_alias($alias = '', $for_class = '') |
|
1004 | + { |
|
1005 | + return $this->getFqnForAlias($alias, $for_class); |
|
1006 | + } |
|
1007 | 1007 | } |