@@ -214,7 +214,7 @@ |
||
214 | 214 | if($payment instanceof EEI_Payment){ |
215 | 215 | $type='Payment'; |
216 | 216 | $id = $payment->ID(); |
217 | - }else{ |
|
217 | + } else{ |
|
218 | 218 | $type = 'Payment_Method'; |
219 | 219 | $id = $this->_ID; |
220 | 220 | } |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected $_line_item; |
76 | 76 | |
77 | - /** |
|
78 | - * @var GatewayDataFormatterInterface |
|
79 | - */ |
|
80 | - protected $_gateway_data_formatter; |
|
77 | + /** |
|
78 | + * @var GatewayDataFormatterInterface |
|
79 | + */ |
|
80 | + protected $_gateway_data_formatter; |
|
81 | 81 | |
82 | - /** |
|
83 | - * @var FormatterInterface |
|
84 | - */ |
|
85 | - protected $_unsupported_character_remover; |
|
82 | + /** |
|
83 | + * @var FormatterInterface |
|
84 | + */ |
|
85 | + protected $_unsupported_character_remover; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * The ID of the payment method using this gateway |
@@ -211,75 +211,75 @@ discard block |
||
211 | 211 | |
212 | 212 | |
213 | 213 | |
214 | - /** |
|
215 | - * Sets the gateway data formatter helper |
|
216 | - * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
217 | - * @throws InvalidEntityException if it's not set properly |
|
218 | - */ |
|
214 | + /** |
|
215 | + * Sets the gateway data formatter helper |
|
216 | + * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
217 | + * @throws InvalidEntityException if it's not set properly |
|
218 | + */ |
|
219 | 219 | public function set_gateway_data_formatter( GatewayDataFormatterInterface $gateway_data_formatter){ |
220 | - if( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
221 | - throw new InvalidEntityException( |
|
222 | - is_object($gateway_data_formatter) |
|
223 | - ? get_class($gateway_data_formatter) |
|
224 | - : esc_html__('Not an object','event_espresso'), |
|
225 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
226 | - ); |
|
227 | - } |
|
228 | - $this->_gateway_data_formatter = $gateway_data_formatter; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Gets the gateway data formatter |
|
233 | - * @return GatewayDataFormatterInterface |
|
234 | - * @throws InvalidEntityException if it's not set properly |
|
235 | - */ |
|
236 | - protected function _get_gateway_formatter(){ |
|
237 | - if( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
238 | - throw new InvalidEntityException( |
|
239 | - is_object($this->_gateway_data_formatter) |
|
240 | - ? get_class($this->_gateway_data_formatter) |
|
241 | - : esc_html__('Not an object','event_espresso'), |
|
242 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
243 | - ); |
|
244 | - } |
|
245 | - return $this->_gateway_data_formatter; |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * Sets the helper which will remove unsupported characters for most gateways |
|
252 | - * @param FormatterInterface $formatter |
|
253 | - * @return FormatterInterface |
|
254 | - * @throws InvalidEntityException |
|
255 | - */ |
|
256 | - public function set_unsupported_character_remover( FormatterInterface $formatter){ |
|
257 | - if( ! $formatter instanceof FormatterInterface){ |
|
258 | - throw new InvalidEntityException( |
|
259 | - is_object($formatter) |
|
260 | - ? get_class($formatter) |
|
261 | - : esc_html__('Not an object','event_espresso'), |
|
262 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
263 | - ); |
|
264 | - } |
|
265 | - $this->_unsupported_character_remover = $formatter; |
|
266 | - } |
|
267 | - /** |
|
268 | - * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
269 | - * @return FormatterInterface |
|
270 | - * @throws InvalidEntityException |
|
271 | - */ |
|
272 | - protected function _get_unsupported_character_remover(){ |
|
273 | - if( ! $this->_unsupported_character_remover instanceof FormatterInterface){ |
|
274 | - throw new InvalidEntityException( |
|
275 | - is_object($this->_unsupported_character_remover) |
|
276 | - ? get_class($this->_unsupported_character_remover) |
|
277 | - : esc_html__('Not an object','event_espresso'), |
|
278 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
279 | - ); |
|
280 | - } |
|
281 | - return $this->_unsupported_character_remover; |
|
282 | - } |
|
220 | + if( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
221 | + throw new InvalidEntityException( |
|
222 | + is_object($gateway_data_formatter) |
|
223 | + ? get_class($gateway_data_formatter) |
|
224 | + : esc_html__('Not an object','event_espresso'), |
|
225 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
226 | + ); |
|
227 | + } |
|
228 | + $this->_gateway_data_formatter = $gateway_data_formatter; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Gets the gateway data formatter |
|
233 | + * @return GatewayDataFormatterInterface |
|
234 | + * @throws InvalidEntityException if it's not set properly |
|
235 | + */ |
|
236 | + protected function _get_gateway_formatter(){ |
|
237 | + if( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
238 | + throw new InvalidEntityException( |
|
239 | + is_object($this->_gateway_data_formatter) |
|
240 | + ? get_class($this->_gateway_data_formatter) |
|
241 | + : esc_html__('Not an object','event_espresso'), |
|
242 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
243 | + ); |
|
244 | + } |
|
245 | + return $this->_gateway_data_formatter; |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * Sets the helper which will remove unsupported characters for most gateways |
|
252 | + * @param FormatterInterface $formatter |
|
253 | + * @return FormatterInterface |
|
254 | + * @throws InvalidEntityException |
|
255 | + */ |
|
256 | + public function set_unsupported_character_remover( FormatterInterface $formatter){ |
|
257 | + if( ! $formatter instanceof FormatterInterface){ |
|
258 | + throw new InvalidEntityException( |
|
259 | + is_object($formatter) |
|
260 | + ? get_class($formatter) |
|
261 | + : esc_html__('Not an object','event_espresso'), |
|
262 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
263 | + ); |
|
264 | + } |
|
265 | + $this->_unsupported_character_remover = $formatter; |
|
266 | + } |
|
267 | + /** |
|
268 | + * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
269 | + * @return FormatterInterface |
|
270 | + * @throws InvalidEntityException |
|
271 | + */ |
|
272 | + protected function _get_unsupported_character_remover(){ |
|
273 | + if( ! $this->_unsupported_character_remover instanceof FormatterInterface){ |
|
274 | + throw new InvalidEntityException( |
|
275 | + is_object($this->_unsupported_character_remover) |
|
276 | + ? get_class($this->_unsupported_character_remover) |
|
277 | + : esc_html__('Not an object','event_espresso'), |
|
278 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
279 | + ); |
|
280 | + } |
|
281 | + return $this->_unsupported_character_remover; |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | 285 | /** |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * Formats the amount so it can generally be sent to gateways |
301 | 301 | * @param float $amount |
302 | 302 | * @return string |
303 | - * @deprecated since 4.9.31 insetad use EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
303 | + * @deprecated since 4.9.31 insetad use EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
304 | 304 | */ |
305 | 305 | public function format_currency($amount){ |
306 | 306 | return $this->_get_gateway_formatter()->formatCurrency($amount); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * Gets the first event for this payment (it's possible that it could be for multiple) |
371 | 371 | * @param EEI_Payment $payment |
372 | 372 | * @return EEI_Event|null |
373 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
373 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
374 | 374 | */ |
375 | 375 | protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
376 | 376 | return $payment->get_first_event(); |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | * Gets the name of the first event for which is being paid |
381 | 381 | * @param EEI_Payment $payment |
382 | 382 | * @return string |
383 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
383 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
384 | 384 | */ |
385 | 385 | protected function _get_first_event_name_for_payment( EEI_Payment $payment ) { |
386 | 386 | return $payment->get_first_event_name(); |
387 | 387 | } |
388 | 388 | /** |
389 | 389 | * Gets the text to use for a gateway's line item name when this is a partial payment |
390 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
390 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
391 | 391 | * @param EE_Payment $payment |
392 | 392 | * @return string |
393 | 393 | */ |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | /** |
398 | 398 | * Gets the text to use for a gateway's line item description when this is a partial payment |
399 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
399 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
400 | 400 | * @param EEI_Payment $payment |
401 | 401 | * @return string |
402 | 402 | */ |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
408 | - * Gets the name to use for a line item when sending line items to the gateway |
|
409 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
410 | - * @param EEI_Line_Item $line_item |
|
408 | + * Gets the name to use for a line item when sending line items to the gateway |
|
409 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
410 | + * @param EEI_Line_Item $line_item |
|
411 | 411 | * @param EEI_Payment $payment |
412 | 412 | * @return string |
413 | 413 | */ |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Gets the description to use for a line item when sending line items to the gateway |
420 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
420 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
421 | 421 | * @param EEI_Line_Item $line_item |
422 | 422 | * @param EEI_Payment $payment |
423 | 423 | * @return string |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Gets the order description that should generlly be sent to gateways |
431 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
431 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
432 | 432 | * @param EEI_Payment $payment |
433 | 433 | * @return type |
434 | 434 | */ |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @subpackage core/libraries/payment_methods |
21 | 21 | * @author Mike Nelson |
22 | 22 | */ |
23 | -abstract class EE_Gateway{ |
|
23 | +abstract class EE_Gateway { |
|
24 | 24 | /** |
25 | 25 | * a constant used as a possible value for $_currencies_supported to indicate |
26 | 26 | * that ALL currencies are supported by this gateway |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @return EE_Gateway |
110 | 110 | */ |
111 | - public function __construct(){ |
|
111 | + public function __construct() { |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * beginning again) |
121 | 121 | * @return array |
122 | 122 | */ |
123 | - public function __sleep(){ |
|
123 | + public function __sleep() { |
|
124 | 124 | $properties = get_object_vars($this); |
125 | - unset( $properties[ '_pay_model' ], $properties[ '_pay_log' ] ); |
|
125 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
126 | 126 | return array_keys($properties); |
127 | 127 | } |
128 | 128 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * see $_supports_sending_refunds |
131 | 131 | * @return boolean |
132 | 132 | */ |
133 | - public function supports_sending_refunds(){ |
|
133 | + public function supports_sending_refunds() { |
|
134 | 134 | return $this->_supports_sending_refunds; |
135 | 135 | } |
136 | 136 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * see $_supports_receiving_refunds |
139 | 139 | * @return boolean |
140 | 140 | */ |
141 | - public function supports_receiving_refunds(){ |
|
141 | + public function supports_receiving_refunds() { |
|
142 | 142 | return $this->_supports_receiving_refunds; |
143 | 143 | } |
144 | 144 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return EE_Payment for the refund |
154 | 154 | * @throws EE_Error |
155 | 155 | */ |
156 | - public function do_direct_refund( EE_Payment $payment, $refund_info = null ) { |
|
156 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) { |
|
157 | 157 | return NULL; |
158 | 158 | } |
159 | 159 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * etc |
165 | 165 | * @param array $settings_array |
166 | 166 | */ |
167 | - public function set_settings($settings_array){ |
|
168 | - foreach($settings_array as $name => $value){ |
|
167 | + public function set_settings($settings_array) { |
|
168 | + foreach ($settings_array as $name => $value) { |
|
169 | 169 | $property_name = "_".$name; |
170 | 170 | $this->{$property_name} = $value; |
171 | 171 | } |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | * See this class description |
175 | 175 | * @param EEMI_Payment $payment_model |
176 | 176 | */ |
177 | - public function set_payment_model($payment_model){ |
|
177 | + public function set_payment_model($payment_model) { |
|
178 | 178 | $this->_pay_model = $payment_model; |
179 | 179 | } |
180 | 180 | /** |
181 | 181 | * See this class description |
182 | 182 | * @param EEMI_Payment_Log $payment_log_model |
183 | 183 | */ |
184 | - public function set_payment_log($payment_log_model){ |
|
184 | + public function set_payment_log($payment_log_model) { |
|
185 | 185 | $this->_pay_log = $payment_log_model; |
186 | 186 | } |
187 | 187 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * See this class description |
190 | 190 | * @param EEHI_Template $template_helper |
191 | 191 | */ |
192 | - public function set_template_helper($template_helper){ |
|
192 | + public function set_template_helper($template_helper) { |
|
193 | 193 | $this->_template = $template_helper; |
194 | 194 | } |
195 | 195 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * See this class description |
198 | 198 | * @param EEHI_Line_Item $line_item_helper |
199 | 199 | */ |
200 | - public function set_line_item_helper( $line_item_helper ){ |
|
200 | + public function set_line_item_helper($line_item_helper) { |
|
201 | 201 | $this->_line_item = $line_item_helper; |
202 | 202 | } |
203 | 203 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * See this class description |
206 | 206 | * @param EEHI_Money $money_helper |
207 | 207 | */ |
208 | - public function set_money_helper( $money_helper ){ |
|
208 | + public function set_money_helper($money_helper) { |
|
209 | 209 | $this->_money = $money_helper; |
210 | 210 | } |
211 | 211 | |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | * @param GatewayDataFormatterInterface $gateway_data_formatter |
217 | 217 | * @throws InvalidEntityException if it's not set properly |
218 | 218 | */ |
219 | - public function set_gateway_data_formatter( GatewayDataFormatterInterface $gateway_data_formatter){ |
|
220 | - if( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
219 | + public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) { |
|
220 | + if ( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
221 | 221 | throw new InvalidEntityException( |
222 | 222 | is_object($gateway_data_formatter) |
223 | 223 | ? get_class($gateway_data_formatter) |
224 | - : esc_html__('Not an object','event_espresso'), |
|
224 | + : esc_html__('Not an object', 'event_espresso'), |
|
225 | 225 | '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
226 | 226 | ); |
227 | 227 | } |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | * @return GatewayDataFormatterInterface |
234 | 234 | * @throws InvalidEntityException if it's not set properly |
235 | 235 | */ |
236 | - protected function _get_gateway_formatter(){ |
|
237 | - if( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
236 | + protected function _get_gateway_formatter() { |
|
237 | + if ( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
238 | 238 | throw new InvalidEntityException( |
239 | 239 | is_object($this->_gateway_data_formatter) |
240 | 240 | ? get_class($this->_gateway_data_formatter) |
241 | - : esc_html__('Not an object','event_espresso'), |
|
241 | + : esc_html__('Not an object', 'event_espresso'), |
|
242 | 242 | '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
243 | 243 | ); |
244 | 244 | } |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | * @return FormatterInterface |
254 | 254 | * @throws InvalidEntityException |
255 | 255 | */ |
256 | - public function set_unsupported_character_remover( FormatterInterface $formatter){ |
|
257 | - if( ! $formatter instanceof FormatterInterface){ |
|
256 | + public function set_unsupported_character_remover(FormatterInterface $formatter) { |
|
257 | + if ( ! $formatter instanceof FormatterInterface) { |
|
258 | 258 | throw new InvalidEntityException( |
259 | 259 | is_object($formatter) |
260 | 260 | ? get_class($formatter) |
261 | - : esc_html__('Not an object','event_espresso'), |
|
261 | + : esc_html__('Not an object', 'event_espresso'), |
|
262 | 262 | '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
263 | 263 | ); |
264 | 264 | } |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * @return FormatterInterface |
270 | 270 | * @throws InvalidEntityException |
271 | 271 | */ |
272 | - protected function _get_unsupported_character_remover(){ |
|
273 | - if( ! $this->_unsupported_character_remover instanceof FormatterInterface){ |
|
272 | + protected function _get_unsupported_character_remover() { |
|
273 | + if ( ! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
274 | 274 | throw new InvalidEntityException( |
275 | 275 | is_object($this->_unsupported_character_remover) |
276 | 276 | ? get_class($this->_unsupported_character_remover) |
277 | - : esc_html__('Not an object','event_espresso'), |
|
277 | + : esc_html__('Not an object', 'event_espresso'), |
|
278 | 278 | '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
279 | 279 | ); |
280 | 280 | } |
@@ -286,15 +286,15 @@ discard block |
||
286 | 286 | * @param $message |
287 | 287 | * @param $payment |
288 | 288 | */ |
289 | - public function log($message,$payment){ |
|
290 | - if($payment instanceof EEI_Payment){ |
|
291 | - $type='Payment'; |
|
289 | + public function log($message, $payment) { |
|
290 | + if ($payment instanceof EEI_Payment) { |
|
291 | + $type = 'Payment'; |
|
292 | 292 | $id = $payment->ID(); |
293 | - }else{ |
|
293 | + } else { |
|
294 | 294 | $type = 'Payment_Method'; |
295 | 295 | $id = $this->_ID; |
296 | 296 | } |
297 | - $this->_pay_log->gateway_log($message,$id,$type); |
|
297 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
298 | 298 | } |
299 | 299 | /** |
300 | 300 | * Formats the amount so it can generally be sent to gateways |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return string |
303 | 303 | * @deprecated since 4.9.31 insetad use EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
304 | 304 | */ |
305 | - public function format_currency($amount){ |
|
305 | + public function format_currency($amount) { |
|
306 | 306 | return $this->_get_gateway_formatter()->formatCurrency($amount); |
307 | 307 | } |
308 | 308 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
312 | 312 | * @return mixed array or string |
313 | 313 | */ |
314 | - public function currencies_supported(){ |
|
314 | + public function currencies_supported() { |
|
315 | 315 | return $this->_currencies_supported; |
316 | 316 | } |
317 | 317 | |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | * @param EE_Transaction $transaction |
324 | 324 | * @return float |
325 | 325 | */ |
326 | - protected function _sum_items_and_taxes( EE_Transaction $transaction){ |
|
326 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) { |
|
327 | 327 | $total_line_item = $transaction->total_line_item(); |
328 | 328 | $total = 0; |
329 | - foreach($total_line_item->get_items() as $item_line_item ){ |
|
330 | - $total += max( $item_line_item->total(), 0 ); |
|
329 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
330 | + $total += max($item_line_item->total(), 0); |
|
331 | 331 | } |
332 | - foreach($total_line_item->tax_descendants() as $tax_line_item ){ |
|
333 | - $total += max( $tax_line_item->total(), 0 ); |
|
332 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
333 | + $total += max($tax_line_item->total(), 0); |
|
334 | 334 | } |
335 | 335 | return $total; |
336 | 336 | } |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | * @param EEI_Payment $payment |
342 | 342 | * @return boolean |
343 | 343 | */ |
344 | - protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){ |
|
344 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) { |
|
345 | 345 | return $this->_money->compare_floats( |
346 | - $this->_sum_items_and_taxes( $payment->transaction() ), |
|
346 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
347 | 347 | $payment->transaction()->total() ) && |
348 | 348 | $this->_money->compare_floats( |
349 | 349 | $payment->amount(), |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @param EE_Payment $payment |
362 | 362 | * @return void |
363 | 363 | */ |
364 | - public function update_txn_based_on_payment( $payment ){ |
|
364 | + public function update_txn_based_on_payment($payment) { |
|
365 | 365 | //maybe update the transaction or line items or registrations |
366 | 366 | //but most gateways don't need to do this, because they only update the payment |
367 | 367 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @return EEI_Event|null |
373 | 373 | * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
374 | 374 | */ |
375 | - protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
|
375 | + protected function _get_first_event_for_payment(EEI_Payment $payment) { |
|
376 | 376 | return $payment->get_first_event(); |
377 | 377 | } |
378 | 378 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * @return string |
383 | 383 | * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
384 | 384 | */ |
385 | - protected function _get_first_event_name_for_payment( EEI_Payment $payment ) { |
|
385 | + protected function _get_first_event_name_for_payment(EEI_Payment $payment) { |
|
386 | 386 | return $payment->get_first_event_name(); |
387 | 387 | } |
388 | 388 | /** |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @param EE_Payment $payment |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - protected function _format_partial_payment_line_item_name( EEI_Payment $payment ){ |
|
394 | + protected function _format_partial_payment_line_item_name(EEI_Payment $payment) { |
|
395 | 395 | return $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment); |
396 | 396 | } |
397 | 397 | /** |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @param EEI_Payment $payment |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - protected function _format_partial_payment_line_item_desc( EEI_Payment $payment ) { |
|
403 | + protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) { |
|
404 | 404 | return $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc($payment); |
405 | 405 | } |
406 | 406 | |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * @param EEI_Payment $payment |
412 | 412 | * @return string |
413 | 413 | */ |
414 | - protected function _format_line_item_name( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
415 | - return $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment); |
|
414 | + protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
415 | + return $this->_get_gateway_formatter()->formatLineItemName($line_item, $payment); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param EEI_Payment $payment |
423 | 423 | * @return string |
424 | 424 | */ |
425 | - protected function _format_line_item_desc( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
425 | + protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
426 | 426 | return $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment); |
427 | 427 | } |
428 | 428 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param EEI_Payment $payment |
433 | 433 | * @return type |
434 | 434 | */ |
435 | - protected function _format_order_description( EEI_Payment $payment ) { |
|
435 | + protected function _format_order_description(EEI_Payment $payment) { |
|
436 | 436 | return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
437 | 437 | } |
438 | 438 | } |
439 | 439 | \ No newline at end of file |
@@ -430,7 +430,7 @@ |
||
430 | 430 | * Gets the order description that should generlly be sent to gateways |
431 | 431 | * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
432 | 432 | * @param EEI_Payment $payment |
433 | - * @return type |
|
433 | + * @return string |
|
434 | 434 | */ |
435 | 435 | protected function _format_order_description( EEI_Payment $payment ) { |
436 | 436 | return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * ------------------------------------------------------------------------ |
26 | 26 | */ |
27 | -abstract class EE_Onsite_Gateway extends EE_Gateway{ |
|
27 | +abstract class EE_Onsite_Gateway extends EE_Gateway { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @return EE_Onsite_Gateway |
@@ -53,5 +53,5 @@ discard block |
||
53 | 53 | * } unless a child class specifies these array keys are NOT present |
54 | 54 | * @return EE_Payment updated |
55 | 55 | */ |
56 | - public abstract function do_direct_payment($payment,$billing_info = null); |
|
56 | + public abstract function do_direct_payment($payment, $billing_info = null); |
|
57 | 57 | } |
@@ -2,10 +2,10 @@ |
||
2 | 2 | if (!defined('EVENT_ESPRESSO_VERSION')) |
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | - * payment_details_content |
|
6 | - * @var EE_Payment $payment |
|
7 | - * @var EE_Payment_Method $payment_method |
|
8 | - */ |
|
5 | + * payment_details_content |
|
6 | + * @var EE_Payment $payment |
|
7 | + * @var EE_Payment_Method $payment_method |
|
8 | + */ |
|
9 | 9 | $gateway_response = $payment->gateway_response(); |
10 | 10 | if ( ! empty( $gateway_response )) { |
11 | 11 | echo '<span class="error payment-problem">' . $gateway_response . '</span>'; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | 5 | * payment_details_content |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @var EE_Payment_Method $payment_method |
8 | 8 | */ |
9 | 9 | $gateway_response = $payment->gateway_response(); |
10 | -if ( ! empty( $gateway_response )) { |
|
11 | - echo '<span class="error payment-problem">' . $gateway_response . '</span>'; |
|
10 | +if ( ! empty($gateway_response)) { |
|
11 | + echo '<span class="error payment-problem">'.$gateway_response.'</span>'; |
|
12 | 12 | } |
13 | 13 | // End of file payment_details_content.template.php |
14 | 14 | \ No newline at end of file |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | +} |
|
4 | 5 | /** |
5 | 6 | * payment_details_content |
6 | 7 | * @var EE_Payment $payment |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param array $setup_args an array of key value pairs of info for registering the component |
35 | 35 | * @return void |
36 | 36 | */ |
37 | - public static function register( $ID = NULL, $setup_args = array() ); |
|
37 | + public static function register($ID = NULL, $setup_args = array()); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
@@ -45,5 +45,5 @@ discard block |
||
45 | 45 | * @param string $ID a unique name or ID for the component being registered |
46 | 46 | * @return void |
47 | 47 | */ |
48 | - public static function deregister( $ID = NULL ); |
|
48 | + public static function deregister($ID = NULL); |
|
49 | 49 | } |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage helpers |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * This interface is used to define the common methods shared by all "plugin api" classes. |
@@ -18,30 +18,30 @@ discard block |
||
18 | 18 | class EE_Register_Admin_Page implements EEI_Plugin_API { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Holds registered EE_Admin_Pages |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected static $_ee_admin_page_registry = array(); |
|
21 | + /** |
|
22 | + * Holds registered EE_Admin_Pages |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected static $_ee_admin_page_registry = array(); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system). |
|
32 | - * |
|
33 | - * @since 4.3.0 |
|
34 | - * |
|
30 | + /** |
|
31 | + * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system). |
|
32 | + * |
|
33 | + * @since 4.3.0 |
|
34 | + * |
|
35 | 35 | * @param string $page_basename This string represents the basename of the Admin Page init. |
36 | 36 | * The init file must use this basename in its name and class (i.e. {page_basename}_Admin_Page_Init.core.php). |
37 | - * @param array $config { An array of configuration options that will be used in different circumstances |
|
37 | + * @param array $config { An array of configuration options that will be used in different circumstances |
|
38 | 38 | * |
39 | 39 | * @type string $page_path This is the path where the registered admin pages reside ( used to setup autoloaders). |
40 | 40 | * |
41 | 41 | * } |
42 | - * @return void |
|
43 | - */ |
|
44 | - public static function register( $page_basename = NULL, $config = array() ) { |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public static function register( $page_basename = NULL, $config = array() ) { |
|
45 | 45 | |
46 | 46 | // check that an admin_page has not already been registered with that name |
47 | 47 | if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) { |
62 | - EE_Error::doing_it_wrong( |
|
62 | + EE_Error::doing_it_wrong( |
|
63 | 63 | __METHOD__, |
64 | 64 | sprintf( |
65 | 65 | __('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'), |
@@ -67,36 +67,36 @@ discard block |
||
67 | 67 | ), |
68 | 68 | '4.3' |
69 | 69 | ); |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | - //add incoming stuff to our registry property |
|
73 | - self::$_ee_admin_page_registry[ $page_basename ] = array( |
|
74 | - 'page_path' => $config['page_path'], |
|
75 | - 'config' => $config |
|
76 | - ); |
|
72 | + //add incoming stuff to our registry property |
|
73 | + self::$_ee_admin_page_registry[ $page_basename ] = array( |
|
74 | + 'page_path' => $config['page_path'], |
|
75 | + 'config' => $config |
|
76 | + ); |
|
77 | 77 | |
78 | - //add filters |
|
78 | + //add filters |
|
79 | 79 | |
80 | - add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 ); |
|
81 | - add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 ); |
|
80 | + add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 ); |
|
81 | + add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 ); |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * This deregisters a EE_Admin page that is already registered. Note, this MUST be loaded after the |
|
89 | - * page being deregistered is loaded. |
|
90 | - * |
|
91 | - * @since 4.3.0 |
|
92 | - * |
|
93 | - * @param string $page_basename Use whatever string was used to register the admin page. |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public static function deregister( $page_basename = NULL ) { |
|
97 | - if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | - unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
99 | - } |
|
87 | + /** |
|
88 | + * This deregisters a EE_Admin page that is already registered. Note, this MUST be loaded after the |
|
89 | + * page being deregistered is loaded. |
|
90 | + * |
|
91 | + * @since 4.3.0 |
|
92 | + * |
|
93 | + * @param string $page_basename Use whatever string was used to register the admin page. |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public static function deregister( $page_basename = NULL ) { |
|
97 | + if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | + unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | 102 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | $installed_refs[ $basename ] = $args['page_path']; |
113 | 113 | } |
114 | 114 | } |
115 | - return $installed_refs; |
|
116 | - } |
|
115 | + return $installed_refs; |
|
116 | + } |
|
117 | 117 | |
118 | 118 | |
119 | 119 | |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | * @return mixed |
125 | 125 | */ |
126 | 126 | public static function set_page_path( $paths ) { |
127 | - foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
128 | - $paths[ $basename ] = $args['page_path']; |
|
129 | - } |
|
130 | - return $paths; |
|
131 | - } |
|
127 | + foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
128 | + $paths[ $basename ] = $args['page_path']; |
|
129 | + } |
|
130 | + return $paths; |
|
131 | + } |
|
132 | 132 | } |
@@ -41,28 +41,28 @@ discard block |
||
41 | 41 | * } |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public static function register( $page_basename = NULL, $config = array() ) { |
|
44 | + public static function register($page_basename = NULL, $config = array()) { |
|
45 | 45 | |
46 | 46 | // check that an admin_page has not already been registered with that name |
47 | - if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) { |
|
48 | - throw new EE_Error( sprintf( __( 'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso' ), $page_basename )); |
|
47 | + if (isset(self::$_ee_admin_page_registry[$page_basename])) { |
|
48 | + throw new EE_Error(sprintf(__('An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso'), $page_basename)); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // required fields MUST be present, so let's make sure they are. |
52 | - if ( empty( $page_basename ) || ! is_array( $config ) || empty( $config['page_path'] )) { |
|
53 | - throw new EE_Error( __( 'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso' )); |
|
52 | + if (empty($page_basename) || ! is_array($config) || empty($config['page_path'])) { |
|
53 | + throw new EE_Error(__('In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | //make sure we don't register twice |
57 | - if( isset( self::$_ee_admin_page_registry[ $page_basename ] ) ){ |
|
57 | + if (isset(self::$_ee_admin_page_registry[$page_basename])) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) { |
|
61 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
62 | 62 | EE_Error::doing_it_wrong( |
63 | 63 | __METHOD__, |
64 | 64 | sprintf( |
65 | - __('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'), |
|
65 | + __('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.', 'event_espresso'), |
|
66 | 66 | $page_basename |
67 | 67 | ), |
68 | 68 | '4.3' |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | //add incoming stuff to our registry property |
73 | - self::$_ee_admin_page_registry[ $page_basename ] = array( |
|
73 | + self::$_ee_admin_page_registry[$page_basename] = array( |
|
74 | 74 | 'page_path' => $config['page_path'], |
75 | 75 | 'config' => $config |
76 | 76 | ); |
77 | 77 | |
78 | 78 | //add filters |
79 | 79 | |
80 | - add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 ); |
|
81 | - add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 ); |
|
80 | + add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array('EE_Register_Admin_Page', 'set_page_basename'), 10); |
|
81 | + add_filter('FHEE__EEH_Autoloader__load_admin_core', array('EE_Register_Admin_Page', 'set_page_path'), 10); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * @param string $page_basename Use whatever string was used to register the admin page. |
94 | 94 | * @return void |
95 | 95 | */ |
96 | - public static function deregister( $page_basename = NULL ) { |
|
97 | - if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | - unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
96 | + public static function deregister($page_basename = NULL) { |
|
97 | + if ( ! empty(self::$_ee_admin_page_registry[$page_basename])) |
|
98 | + unset(self::$_ee_admin_page_registry[$page_basename]); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * @param $installed_refs |
107 | 107 | * @return mixed |
108 | 108 | */ |
109 | - public static function set_page_basename( $installed_refs ) { |
|
110 | - if ( ! empty( self::$_ee_admin_page_registry )) { |
|
111 | - foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
112 | - $installed_refs[ $basename ] = $args['page_path']; |
|
109 | + public static function set_page_basename($installed_refs) { |
|
110 | + if ( ! empty(self::$_ee_admin_page_registry)) { |
|
111 | + foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
112 | + $installed_refs[$basename] = $args['page_path']; |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | return $installed_refs; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * @param $paths |
124 | 124 | * @return mixed |
125 | 125 | */ |
126 | - public static function set_page_path( $paths ) { |
|
127 | - foreach ( self::$_ee_admin_page_registry as $basename => $args ) { |
|
128 | - $paths[ $basename ] = $args['page_path']; |
|
126 | + public static function set_page_path($paths) { |
|
127 | + foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
128 | + $paths[$basename] = $args['page_path']; |
|
129 | 129 | } |
130 | 130 | return $paths; |
131 | 131 | } |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | * @subpackage helpers |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister an EE Admin Page. |
@@ -94,8 +96,9 @@ discard block |
||
94 | 96 | * @return void |
95 | 97 | */ |
96 | 98 | public static function deregister( $page_basename = NULL ) { |
97 | - if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) |
|
98 | - unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
99 | + if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) { |
|
100 | + unset( self::$_ee_admin_page_registry[$page_basename] ); |
|
101 | + } |
|
99 | 102 | } |
100 | 103 | |
101 | 104 |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | * @subpackage helpers |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new config with the EE_Registry::instance->CFG property. |
@@ -111,7 +113,8 @@ discard block |
||
111 | 113 | * @param mixed $config_class_name |
112 | 114 | */ |
113 | 115 | public static function deregister( $config_class_name = NULL ) { |
114 | - if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
|
115 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
116 | + if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) { |
|
117 | + unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
118 | + } |
|
116 | 119 | } |
117 | 120 | } |
@@ -42,24 +42,24 @@ discard block |
||
42 | 42 | * } |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - public static function register( $config_class = NULL, $setup_args = array() ) { |
|
45 | + public static function register($config_class = NULL, $setup_args = array()) { |
|
46 | 46 | |
47 | - $setup_args['config_name'] = isset( $setup_args['config_name'] ) && ! empty( $setup_args['config_name'] ) ? $setup_args['config_name'] : $config_class; |
|
48 | - $setup_args['config_section'] = isset( $setup_args['config_section'] ) && ! empty( $setup_args['config_section'] ) ? $setup_args['config_section'] : 'addons'; |
|
47 | + $setup_args['config_name'] = isset($setup_args['config_name']) && ! empty($setup_args['config_name']) ? $setup_args['config_name'] : $config_class; |
|
48 | + $setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section']) ? $setup_args['config_section'] : 'addons'; |
|
49 | 49 | |
50 | 50 | //required fields MUST be present, so let's make sure they are. |
51 | - if ( empty( $config_class ) || ! is_array( $setup_args ) || empty( $setup_args['config_name'] )) { |
|
52 | - throw new EE_Error( __( 'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso' )); |
|
51 | + if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) { |
|
52 | + throw new EE_Error(__('In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso')); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //make sure we don't register twice |
56 | - if( isset( self::$_ee_config_registry[ $config_class ] ) ){ |
|
56 | + if (isset(self::$_ee_config_registry[$config_class])) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | //first find out if this happened too late. |
62 | - if ( did_action( 'AHEE__EE_System__load_core_configuration__begin' ) ) { |
|
62 | + if (did_action('AHEE__EE_System__load_core_configuration__begin')) { |
|
63 | 63 | EE_Error::doing_it_wrong( |
64 | 64 | __METHOD__, |
65 | 65 | sprintf( |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | ); |
71 | 71 | } |
72 | 72 | //add incoming stuff to our registry property |
73 | - self::$_ee_config_registry[ $config_class ] = array( |
|
73 | + self::$_ee_config_registry[$config_class] = array( |
|
74 | 74 | 'section' => $setup_args['config_section'], |
75 | 75 | 'name' => $setup_args['config_name'] |
76 | 76 | ); |
77 | 77 | |
78 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 ); |
|
79 | - add_action( 'AHEE__EE_Config__update_espresso_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 ); |
|
78 | + add_action('AHEE__EE_Config___load_core_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
79 | + add_action('AHEE__EE_Config__update_espresso_config__end', array('EE_Register_Config', 'set_config'), 15, 1); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | * @param \EE_Config $EE_Config |
91 | 91 | * @return \StdClass |
92 | 92 | */ |
93 | - public static function set_config( EE_Config $EE_Config ) { |
|
94 | - foreach ( self::$_ee_config_registry as $config_class => $settings ) { |
|
93 | + public static function set_config(EE_Config $EE_Config) { |
|
94 | + foreach (self::$_ee_config_registry as $config_class => $settings) { |
|
95 | 95 | //first some validation of our incoming class_name. We'll throw an error early if its' not registered correctly |
96 | - if ( ! class_exists( $config_class )) { |
|
96 | + if ( ! class_exists($config_class)) { |
|
97 | 97 | throw new EE_Error( |
98 | 98 | sprintf( |
99 | - __( 'The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', 'event_espresso' ), |
|
99 | + __('The "%s" config class can not be registered with EE_Config because it does not exist. Verify that an autoloader has been set for this class', 'event_espresso'), |
|
100 | 100 | $config_class |
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | } |
104 | - $EE_Config->get_config( $settings['section'], $settings['name'], $config_class ); |
|
104 | + $EE_Config->get_config($settings['section'], $settings['name'], $config_class); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * @param mixed $config_class_name |
113 | 113 | */ |
114 | - public static function deregister( $config_class_name = NULL ) { |
|
115 | - if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
|
116 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
114 | + public static function deregister($config_class_name = NULL) { |
|
115 | + if ( ! empty(self::$_ee_config_registry[$config_class_name])) |
|
116 | + unset(self::$_ee_config_registry[$config_class_name]); |
|
117 | 117 | } |
118 | 118 | } |
@@ -113,6 +113,6 @@ |
||
113 | 113 | */ |
114 | 114 | public static function deregister( $config_class_name = NULL ) { |
115 | 115 | if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) |
116 | - unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
116 | + unset( self::$_ee_config_registry[ $config_class_name ] ); |
|
117 | 117 | } |
118 | 118 | } |
@@ -62,44 +62,44 @@ discard block |
||
62 | 62 | * } |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - public static function register( $name = NULL, $setup_args = array() ) { |
|
65 | + public static function register($name = NULL, $setup_args = array()) { |
|
66 | 66 | |
67 | 67 | //required fields MUST be present, so let's make sure they are. |
68 | - if ( empty( $name ) || ! is_array( $setup_args ) || empty( $setup_args['autoloadpaths'] ) ) { |
|
69 | - throw new EE_Error( __( 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso' ) ); |
|
68 | + if (empty($name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) { |
|
69 | + throw new EE_Error(__('In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | //make sure we don't register twice |
73 | - if( isset( self::$_ee_messages_shortcode_registry[ $name ] ) ){ |
|
73 | + if (isset(self::$_ee_messages_shortcode_registry[$name])) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | 77 | //make sure this was called in the right place! |
78 | - if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) { |
|
79 | - EE_Error::doing_it_wrong(__METHOD__, sprintf( __('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).','event_espresso'), $name ), '4.3.0' ); |
|
78 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) { |
|
79 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', 'event_espresso'), $name), '4.3.0'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $name = (string) $name; |
83 | 83 | self::$_ee_messages_shortcode_registry[$name] = array( |
84 | 84 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
85 | - 'list_type_shortcodes' => !empty( $setup_args['list_type_shortcodes'] ) ? (array) $setup_args['list_type_shortcodes'] : array() |
|
85 | + 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) ? (array) $setup_args['list_type_shortcodes'] : array() |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | //add filters |
89 | - add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 ); |
|
89 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array('EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10); |
|
90 | 90 | |
91 | 91 | //add below filters if the required callback is provided. |
92 | - if ( !empty( $setup_args['msgr_validator_callback'] ) ) |
|
93 | - add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
92 | + if ( ! empty($setup_args['msgr_validator_callback'])) |
|
93 | + add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
|
94 | 94 | |
95 | - if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) |
|
96 | - add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
95 | + if ( ! empty($setup_args['msgr_template_fields_callback'])) |
|
96 | + add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
|
97 | 97 | |
98 | - if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) |
|
99 | - add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
98 | + if ( ! empty($setup_args['valid_shortcodes_callback'])) |
|
99 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
|
100 | 100 | |
101 | - if ( !empty( $setup_args['list_type_shortcodes'] ) ) |
|
102 | - add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
101 | + if ( ! empty($setup_args['list_type_shortcodes'])) |
|
102 | + add_filter('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * @param string $name name used to register the shortcode library. |
113 | 113 | * @return void |
114 | 114 | */ |
115 | - public static function deregister( $name = NULL ) { |
|
116 | - if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) |
|
117 | - unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
115 | + public static function deregister($name = NULL) { |
|
116 | + if ( ! empty(self::$_ee_messages_shortcode_registry[$name])) |
|
117 | + unset(self::$_ee_messages_shortcode_registry[$name]); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | * @param array $paths array of paths to be checked by EE_messages autoloader. |
128 | 128 | * @return array |
129 | 129 | */ |
130 | - public static function register_msgs_autoload_paths( $paths ) { |
|
130 | + public static function register_msgs_autoload_paths($paths) { |
|
131 | 131 | |
132 | - if ( !empty( self::$_ee_messages_shortcode_registry ) ) { |
|
133 | - foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) { |
|
134 | - if ( empty( $st_reg['autoloadpaths'] ) ) |
|
132 | + if ( ! empty(self::$_ee_messages_shortcode_registry)) { |
|
133 | + foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
|
134 | + if (empty($st_reg['autoloadpaths'])) |
|
135 | 135 | continue; |
136 | - $paths = array_merge( $paths, $st_reg['autoloadpaths'] ); |
|
136 | + $paths = array_merge($paths, $st_reg['autoloadpaths']); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * @param array $original_shortcodes |
152 | 152 | * @return array Modifications to original shortcodes. |
153 | 153 | */ |
154 | - public static function register_list_type_shortcodes( $original_shortcodes ) { |
|
155 | - if ( empty( self::$_ee_messages_shortcode_registry ) ) |
|
154 | + public static function register_list_type_shortcodes($original_shortcodes) { |
|
155 | + if (empty(self::$_ee_messages_shortcode_registry)) |
|
156 | 156 | return $original_shortcodes; |
157 | 157 | |
158 | - foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) { |
|
159 | - if ( !empty( $sc_reg['list_type_shortcodes'] ) ) |
|
160 | - $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
158 | + foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
|
159 | + if ( ! empty($sc_reg['list_type_shortcodes'])) |
|
160 | + $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | return $original_shortcodes; |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new shortcode library for the EE messages system. |
@@ -89,17 +91,21 @@ discard block |
||
89 | 91 | add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 ); |
90 | 92 | |
91 | 93 | //add below filters if the required callback is provided. |
92 | - if ( !empty( $setup_args['msgr_validator_callback'] ) ) |
|
93 | - add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
94 | + if ( !empty( $setup_args['msgr_validator_callback'] ) ) { |
|
95 | + add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
96 | + } |
|
94 | 97 | |
95 | - if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) |
|
96 | - add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
98 | + if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) { |
|
99 | + add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
100 | + } |
|
97 | 101 | |
98 | - if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) |
|
99 | - add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
102 | + if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) { |
|
103 | + add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
104 | + } |
|
100 | 105 | |
101 | - if ( !empty( $setup_args['list_type_shortcodes'] ) ) |
|
102 | - add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
106 | + if ( !empty( $setup_args['list_type_shortcodes'] ) ) { |
|
107 | + add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
108 | + } |
|
103 | 109 | } |
104 | 110 | |
105 | 111 | |
@@ -113,8 +119,9 @@ discard block |
||
113 | 119 | * @return void |
114 | 120 | */ |
115 | 121 | public static function deregister( $name = NULL ) { |
116 | - if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) |
|
117 | - unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
122 | + if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) { |
|
123 | + unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
124 | + } |
|
118 | 125 | } |
119 | 126 | |
120 | 127 | |
@@ -131,8 +138,9 @@ discard block |
||
131 | 138 | |
132 | 139 | if ( !empty( self::$_ee_messages_shortcode_registry ) ) { |
133 | 140 | foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) { |
134 | - if ( empty( $st_reg['autoloadpaths'] ) ) |
|
135 | - continue; |
|
141 | + if ( empty( $st_reg['autoloadpaths'] ) ) { |
|
142 | + continue; |
|
143 | + } |
|
136 | 144 | $paths = array_merge( $paths, $st_reg['autoloadpaths'] ); |
137 | 145 | } |
138 | 146 | } |
@@ -152,12 +160,14 @@ discard block |
||
152 | 160 | * @return array Modifications to original shortcodes. |
153 | 161 | */ |
154 | 162 | public static function register_list_type_shortcodes( $original_shortcodes ) { |
155 | - if ( empty( self::$_ee_messages_shortcode_registry ) ) |
|
156 | - return $original_shortcodes; |
|
163 | + if ( empty( self::$_ee_messages_shortcode_registry ) ) { |
|
164 | + return $original_shortcodes; |
|
165 | + } |
|
157 | 166 | |
158 | 167 | foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) { |
159 | - if ( !empty( $sc_reg['list_type_shortcodes'] ) ) |
|
160 | - $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
168 | + if ( !empty( $sc_reg['list_type_shortcodes'] ) ) { |
|
169 | + $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
170 | + } |
|
161 | 171 | } |
162 | 172 | |
163 | 173 | return $original_shortcodes; |
@@ -18,56 +18,56 @@ discard block |
||
18 | 18 | class EE_Register_Messages_Shortcode_Library implements EEI_Plugin_API { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * holds values for registered messages shortcode libraries |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected static $_ee_messages_shortcode_registry = array(); |
|
26 | - |
|
27 | - |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * Helper method for registring a new shortcodes library class for the messages system. |
|
32 | - * |
|
33 | - * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
34 | - * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
35 | - * |
|
36 | - * @since 4.3.0 |
|
37 | - * |
|
38 | - * @param array $setup_args { |
|
39 | - * An array of arguments provided for registering the new messages shortcode library. |
|
40 | - * |
|
41 | - * @type string $name What is the name of this shortcode library |
|
42 | - * (e.g. 'question_list'); |
|
43 | - * @type array $autoloadpaths An array of paths to add to the messages |
|
44 | - * autoloader for the new shortcode library |
|
45 | - * class file. |
|
46 | - * @type string $msgr_validator_callback Callback for a method that will register the |
|
47 | - * library with the messenger |
|
48 | - * _validator_config. Optional. |
|
49 | - * @type string $msgr_template_fields_callback Callback for changing adding the |
|
50 | - * _template_fields property for messenger. |
|
51 | - * For example, the shortcode library may add |
|
52 | - * a new field to the message templates. |
|
53 | - * Optional. |
|
54 | - * @type string $valid_shortcodes_callback Callback for message types |
|
55 | - * _valid_shortcodes array setup. Optional. |
|
56 | - * @type array $list_type_shortcodes If there are any specific shortcodes with this |
|
57 | - * message shortcode library that should be |
|
58 | - * considered "list type" then include them in an |
|
59 | - * array. List Type shortcodes are shortcodes that |
|
60 | - * have a corresponding field that indicates how |
|
61 | - * they are parsed. Optional. |
|
62 | - * } |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public static function register( $name = NULL, $setup_args = array() ) { |
|
66 | - |
|
67 | - //required fields MUST be present, so let's make sure they are. |
|
68 | - if ( empty( $name ) || ! is_array( $setup_args ) || empty( $setup_args['autoloadpaths'] ) ) { |
|
69 | - throw new EE_Error( __( 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso' ) ); |
|
70 | - } |
|
21 | + /** |
|
22 | + * holds values for registered messages shortcode libraries |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected static $_ee_messages_shortcode_registry = array(); |
|
26 | + |
|
27 | + |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * Helper method for registring a new shortcodes library class for the messages system. |
|
32 | + * |
|
33 | + * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
34 | + * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
35 | + * |
|
36 | + * @since 4.3.0 |
|
37 | + * |
|
38 | + * @param array $setup_args { |
|
39 | + * An array of arguments provided for registering the new messages shortcode library. |
|
40 | + * |
|
41 | + * @type string $name What is the name of this shortcode library |
|
42 | + * (e.g. 'question_list'); |
|
43 | + * @type array $autoloadpaths An array of paths to add to the messages |
|
44 | + * autoloader for the new shortcode library |
|
45 | + * class file. |
|
46 | + * @type string $msgr_validator_callback Callback for a method that will register the |
|
47 | + * library with the messenger |
|
48 | + * _validator_config. Optional. |
|
49 | + * @type string $msgr_template_fields_callback Callback for changing adding the |
|
50 | + * _template_fields property for messenger. |
|
51 | + * For example, the shortcode library may add |
|
52 | + * a new field to the message templates. |
|
53 | + * Optional. |
|
54 | + * @type string $valid_shortcodes_callback Callback for message types |
|
55 | + * _valid_shortcodes array setup. Optional. |
|
56 | + * @type array $list_type_shortcodes If there are any specific shortcodes with this |
|
57 | + * message shortcode library that should be |
|
58 | + * considered "list type" then include them in an |
|
59 | + * array. List Type shortcodes are shortcodes that |
|
60 | + * have a corresponding field that indicates how |
|
61 | + * they are parsed. Optional. |
|
62 | + * } |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public static function register( $name = NULL, $setup_args = array() ) { |
|
66 | + |
|
67 | + //required fields MUST be present, so let's make sure they are. |
|
68 | + if ( empty( $name ) || ! is_array( $setup_args ) || empty( $setup_args['autoloadpaths'] ) ) { |
|
69 | + throw new EE_Error( __( 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso' ) ); |
|
70 | + } |
|
71 | 71 | |
72 | 72 | //make sure we don't register twice |
73 | 73 | if( isset( self::$_ee_messages_shortcode_registry[ $name ] ) ){ |
@@ -79,88 +79,88 @@ discard block |
||
79 | 79 | EE_Error::doing_it_wrong(__METHOD__, sprintf( __('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).','event_espresso'), $name ), '4.3.0' ); |
80 | 80 | } |
81 | 81 | |
82 | - $name = (string) $name; |
|
83 | - self::$_ee_messages_shortcode_registry[$name] = array( |
|
84 | - 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
85 | - 'list_type_shortcodes' => !empty( $setup_args['list_type_shortcodes'] ) ? (array) $setup_args['list_type_shortcodes'] : array() |
|
86 | - ); |
|
87 | - |
|
88 | - //add filters |
|
89 | - add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 ); |
|
90 | - |
|
91 | - //add below filters if the required callback is provided. |
|
92 | - if ( !empty( $setup_args['msgr_validator_callback'] ) ) |
|
93 | - add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
94 | - |
|
95 | - if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) |
|
96 | - add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
97 | - |
|
98 | - if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) |
|
99 | - add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
100 | - |
|
101 | - if ( !empty( $setup_args['list_type_shortcodes'] ) ) |
|
102 | - add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * This deregisters any messages shortcode library previously registered with the given name. |
|
110 | - * |
|
111 | - * @since 4.3.0 |
|
112 | - * @param string $name name used to register the shortcode library. |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - public static function deregister( $name = NULL ) { |
|
116 | - if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) |
|
117 | - unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
124 | - * |
|
125 | - * @since 4.3.0 |
|
126 | - * |
|
127 | - * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
128 | - * @return array |
|
129 | - */ |
|
130 | - public static function register_msgs_autoload_paths( $paths ) { |
|
131 | - |
|
132 | - if ( !empty( self::$_ee_messages_shortcode_registry ) ) { |
|
133 | - foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) { |
|
134 | - if ( empty( $st_reg['autoloadpaths'] ) ) |
|
135 | - continue; |
|
136 | - $paths = array_merge( $paths, $st_reg['autoloadpaths'] ); |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - return $paths; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
147 | - * filter which is used to add additional list type shortcodes. |
|
148 | - * |
|
149 | - * @since 4.3.0 |
|
150 | - * |
|
151 | - * @param array $original_shortcodes |
|
152 | - * @return array Modifications to original shortcodes. |
|
153 | - */ |
|
154 | - public static function register_list_type_shortcodes( $original_shortcodes ) { |
|
155 | - if ( empty( self::$_ee_messages_shortcode_registry ) ) |
|
156 | - return $original_shortcodes; |
|
157 | - |
|
158 | - foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) { |
|
159 | - if ( !empty( $sc_reg['list_type_shortcodes'] ) ) |
|
160 | - $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
161 | - } |
|
162 | - |
|
163 | - return $original_shortcodes; |
|
164 | - } |
|
82 | + $name = (string) $name; |
|
83 | + self::$_ee_messages_shortcode_registry[$name] = array( |
|
84 | + 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
85 | + 'list_type_shortcodes' => !empty( $setup_args['list_type_shortcodes'] ) ? (array) $setup_args['list_type_shortcodes'] : array() |
|
86 | + ); |
|
87 | + |
|
88 | + //add filters |
|
89 | + add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 ); |
|
90 | + |
|
91 | + //add below filters if the required callback is provided. |
|
92 | + if ( !empty( $setup_args['msgr_validator_callback'] ) ) |
|
93 | + add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 ); |
|
94 | + |
|
95 | + if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) |
|
96 | + add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 ); |
|
97 | + |
|
98 | + if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) |
|
99 | + add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 ); |
|
100 | + |
|
101 | + if ( !empty( $setup_args['list_type_shortcodes'] ) ) |
|
102 | + add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 ); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * This deregisters any messages shortcode library previously registered with the given name. |
|
110 | + * |
|
111 | + * @since 4.3.0 |
|
112 | + * @param string $name name used to register the shortcode library. |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + public static function deregister( $name = NULL ) { |
|
116 | + if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) |
|
117 | + unset( self::$_ee_messages_shortcode_registry[$name] ); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
124 | + * |
|
125 | + * @since 4.3.0 |
|
126 | + * |
|
127 | + * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
128 | + * @return array |
|
129 | + */ |
|
130 | + public static function register_msgs_autoload_paths( $paths ) { |
|
131 | + |
|
132 | + if ( !empty( self::$_ee_messages_shortcode_registry ) ) { |
|
133 | + foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) { |
|
134 | + if ( empty( $st_reg['autoloadpaths'] ) ) |
|
135 | + continue; |
|
136 | + $paths = array_merge( $paths, $st_reg['autoloadpaths'] ); |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + return $paths; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
147 | + * filter which is used to add additional list type shortcodes. |
|
148 | + * |
|
149 | + * @since 4.3.0 |
|
150 | + * |
|
151 | + * @param array $original_shortcodes |
|
152 | + * @return array Modifications to original shortcodes. |
|
153 | + */ |
|
154 | + public static function register_list_type_shortcodes( $original_shortcodes ) { |
|
155 | + if ( empty( self::$_ee_messages_shortcode_registry ) ) |
|
156 | + return $original_shortcodes; |
|
157 | + |
|
158 | + foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) { |
|
159 | + if ( !empty( $sc_reg['list_type_shortcodes'] ) ) |
|
160 | + $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] ); |
|
161 | + } |
|
162 | + |
|
163 | + return $original_shortcodes; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | } |
@@ -185,7 +185,7 @@ |
||
185 | 185 | */ |
186 | 186 | public static function deregister( $variation_ref = NULL ) { |
187 | 187 | if ( !empty( self::$_registry[$variation_ref] ) ) { |
188 | - unset( self::$_registry[$variation_ref] ); |
|
189 | - } |
|
188 | + unset( self::$_registry[$variation_ref] ); |
|
189 | + } |
|
190 | 190 | } |
191 | 191 | } |
@@ -54,39 +54,39 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return void |
56 | 56 | */ |
57 | - public static function register( $ref = NULL, $setup_args = array() ) { |
|
57 | + public static function register($ref = NULL, $setup_args = array()) { |
|
58 | 58 | |
59 | 59 | //check for required params |
60 | - if ( empty( $ref ) || empty( $setup_args['path'] ) || empty( $setup_args['classname'] ) ) { |
|
60 | + if (empty($ref) || empty($setup_args['path']) || empty($setup_args['classname'])) { |
|
61 | 61 | throw new EE_Error( |
62 | 62 | __('In order to register a new template pack for the EE Messages system, you must include a value to reference the template pack being registered and the setup_args must have the path for the new template pack class as well as the classname for the new Template Pack Class. ', 'event_espresso') |
63 | 63 | ); |
64 | 64 | } |
65 | 65 | |
66 | 66 | //make sure we don't register twice |
67 | - if( isset( self::$_registry[ $ref ] ) ){ |
|
67 | + if (isset(self::$_registry[$ref])) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | 71 | //check that incoming $ref doesn't already exist. If it does then we'll create a unique reference for this template pack. |
72 | - if ( isset( self::$_registry[$ref] ) ) { |
|
73 | - $ref = uniqid() . '_' . $ref; |
|
72 | + if (isset(self::$_registry[$ref])) { |
|
73 | + $ref = uniqid().'_'.$ref; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
77 | 77 | //make sure this was called in the right place! |
78 | - if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) { |
|
78 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) { |
|
79 | 79 | EE_Error::doing_it_wrong( |
80 | 80 | __METHOD__, |
81 | 81 | sprintf( |
82 | - __('A EE Messages Template Pack given the reference "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.','event_espresso'), |
|
82 | + __('A EE Messages Template Pack given the reference "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.', 'event_espresso'), |
|
83 | 83 | $ref |
84 | 84 | ), |
85 | 85 | '4.5.0' |
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
89 | - if ( self::_verify_class_not_exist( $setup_args['classname'] ) ) { |
|
89 | + if (self::_verify_class_not_exist($setup_args['classname'])) { |
|
90 | 90 | self::$_registry[$ref] = array( |
91 | 91 | 'path' => (string) $setup_args['path'], |
92 | 92 | 'classname' => (string) $setup_args['classname'] |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | //hook into the system |
97 | - add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Template_Pack', 'set_template_pack_path'), 10 ); |
|
98 | - add_filter( 'FHEE__EED_Messages__get_template_packs__template_packs', array( 'EE_Register_Messages_Template_Pack', 'set_template_pack' ), 10 ); |
|
97 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array('EE_Register_Messages_Template_Pack', 'set_template_pack_path'), 10); |
|
98 | + add_filter('FHEE__EED_Messages__get_template_packs__template_packs', array('EE_Register_Messages_Template_Pack', 'set_template_pack'), 10); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public static function set_template_pack_path( $paths ) { |
|
116 | - foreach( self::$_registry as $ref => $args ) { |
|
115 | + public static function set_template_pack_path($paths) { |
|
116 | + foreach (self::$_registry as $ref => $args) { |
|
117 | 117 | $paths[] = $args['path']; |
118 | 118 | } |
119 | 119 | return $paths; |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | * @param EE_Messages_Template_Pack[] $template_packs |
131 | 131 | * @return EE_Messages_Template_Pack[] |
132 | 132 | */ |
133 | - public static function set_template_pack( $template_packs ) { |
|
134 | - foreach( self::$_registry as $ref => $args ) { |
|
133 | + public static function set_template_pack($template_packs) { |
|
134 | + foreach (self::$_registry as $ref => $args) { |
|
135 | 135 | //verify class_exists |
136 | - if ( ! class_exists( $args['classname'] ) ) { |
|
137 | - require_once( $args['path'] . '/' . $args['classname'] . '.class.php' ); |
|
136 | + if ( ! class_exists($args['classname'])) { |
|
137 | + require_once($args['path'].'/'.$args['classname'].'.class.php'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | //check again! |
141 | - if ( class_exists( $args['classname'] ) ) { |
|
141 | + if (class_exists($args['classname'])) { |
|
142 | 142 | $template_pack = new $args['classname']; |
143 | 143 | $template_packs[$template_pack->dbref] = $template_pack; |
144 | 144 | } |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @return bool |
161 | 161 | */ |
162 | - private static function _verify_class_not_exist( $classname ) { |
|
162 | + private static function _verify_class_not_exist($classname) { |
|
163 | 163 | |
164 | 164 | //loop through the existing registry and see if the classname is already present. |
165 | - foreach ( self::$_registry as $ref => $args ) { |
|
166 | - if ( $args['classname'] == $classname ) { |
|
167 | - EE_Error::add_error( sprintf( __('The %s template pack that you just activated cannot be registered with the messages system because there is already a template pack active using the same classname. Contact the author of this template pack to let them know of the conflict. To stop seeing this message you will need to deactivate this template pack.', 'event_espresso' ), (string) $setup_args['classname'] ), __FILE__, __LINE__, __FUNCTION__ ); |
|
165 | + foreach (self::$_registry as $ref => $args) { |
|
166 | + if ($args['classname'] == $classname) { |
|
167 | + EE_Error::add_error(sprintf(__('The %s template pack that you just activated cannot be registered with the messages system because there is already a template pack active using the same classname. Contact the author of this template pack to let them know of the conflict. To stop seeing this message you will need to deactivate this template pack.', 'event_espresso'), (string) $setup_args['classname']), __FILE__, __LINE__, __FUNCTION__); |
|
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | } |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return void |
185 | 185 | */ |
186 | - public static function deregister( $variation_ref = NULL ) { |
|
187 | - if ( !empty( self::$_registry[$variation_ref] ) ) { |
|
188 | - unset( self::$_registry[$variation_ref] ); |
|
186 | + public static function deregister($variation_ref = NULL) { |
|
187 | + if ( ! empty(self::$_registry[$variation_ref])) { |
|
188 | + unset(self::$_registry[$variation_ref]); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.5.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new message template pack for the EE messages system. |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | * @throws EE_Error |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - public static function register( $variation_ref = NULL, $setup_args = array() ) { |
|
71 | + public static function register($variation_ref = NULL, $setup_args = array()) { |
|
72 | 72 | |
73 | 73 | //check for required params |
74 | - if ( empty( $variation_ref ) ) { |
|
74 | + if (empty($variation_ref)) { |
|
75 | 75 | throw new EE_Error( |
76 | 76 | __('In order to register variations for a EE_Message_Template_Pack, you must include a value to reference the variations being registered', 'event_espresso') |
77 | 77 | ); |
78 | 78 | } |
79 | 79 | |
80 | - if ( ! is_array( $setup_args ) || empty( $setup_args['variations'] ) || empty( $setup_args['base_path'] ) || empty( $setup_args['base_url'] ) ) { |
|
80 | + if ( ! is_array($setup_args) || empty($setup_args['variations']) || empty($setup_args['base_path']) || empty($setup_args['base_url'])) { |
|
81 | 81 | throw new EE_Error( |
82 | 82 | __('In order to register variations for a EE_Message_Template_Pack, you must include an array containing the following keys: "variations", "base_path", "base_url", "extension"', 'event_espresso') |
83 | 83 | ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | //make sure we don't register twice |
87 | - if( isset( self::$_registry[ $variation_ref ] ) ){ |
|
87 | + if (isset(self::$_registry[$variation_ref])) { |
|
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | //make sure variation ref is unique. |
92 | - if ( isset( self::$_registry[$variation_ref] ) ) { |
|
93 | - $variation_ref = uniqid() . '_' . $variation_ref; |
|
92 | + if (isset(self::$_registry[$variation_ref])) { |
|
93 | + $variation_ref = uniqid().'_'.$variation_ref; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | 97 | //make sure this was called in the right place! |
98 | - if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) { |
|
98 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) { |
|
99 | 99 | EE_Error::doing_it_wrong( |
100 | 100 | __METHOD__, |
101 | 101 | sprintf( |
102 | - __('Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System. It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.','event_espresso'), |
|
102 | + __('Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System. It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.', 'event_espresso'), |
|
103 | 103 | $variation_ref |
104 | 104 | ), |
105 | 105 | '4.5.0' |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | |
116 | 116 | |
117 | 117 | //check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack. The former will throw an error. The latter will remove the conflicting variation name but still register the others and will add EE_Error notice. |
118 | - $validated = self::_verify_variations( $variation_ref, $validated ); |
|
118 | + $validated = self::_verify_variations($variation_ref, $validated); |
|
119 | 119 | self::$_registry[$variation_ref] = $validated; |
120 | 120 | |
121 | - add_filter( 'FHEE__EE_Messages_Template_Pack__get_variations', array( 'EE_Register_Messages_Template_Variations', 'get_variations' ), 10, 4 ); |
|
122 | - add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( 'EE_Register_Messages_Template_Variations', 'get_variation' ), 10, 8 ); |
|
121 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variations', array('EE_Register_Messages_Template_Variations', 'get_variations'), 10, 4); |
|
122 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array('EE_Register_Messages_Template_Variations', 'get_variation'), 10, 8); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | * @throws EE_Error |
137 | 137 | * @return bool |
138 | 138 | */ |
139 | - private static function _verify_variations( $variation_ref, $validated_variations ) { |
|
140 | - foreach ( self::$_registry as $variation_ref => $settings ) { |
|
141 | - foreach ( $settings['variations'] as $template_pack => $messenger ) { |
|
142 | - foreach ( $messenger as $all_variations ) { |
|
143 | - if ( isset( $all_variations['default'] ) ) { |
|
139 | + private static function _verify_variations($variation_ref, $validated_variations) { |
|
140 | + foreach (self::$_registry as $variation_ref => $settings) { |
|
141 | + foreach ($settings['variations'] as $template_pack => $messenger) { |
|
142 | + foreach ($messenger as $all_variations) { |
|
143 | + if (isset($all_variations['default'])) { |
|
144 | 144 | throw new EE_Error( |
145 | - sprintf( __('Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template. Please check the code registering variations with this reference, "%s" and modify.', 'event_espresso' ), $variation_ref ) |
|
145 | + sprintf(__('Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template. Please check the code registering variations with this reference, "%s" and modify.', 'event_espresso'), $variation_ref) |
|
146 | 146 | ); |
147 | 147 | } |
148 | 148 | } |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | //is there already a variation registered with a given variation slug? |
153 | - foreach ( $validated_variations['variations'] as $template_pack => $messenger ) { |
|
154 | - foreach ( $messenger as $message_type => $variations ) { |
|
155 | - foreach( $variations as $slug => $label ) { |
|
156 | - foreach ( self::$_registry as $registered_var => $reg_settings ) { |
|
157 | - if ( isset( $reg_settings['variations'][$template_pack][$messenger][$message_type][$slug] ) ) { |
|
158 | - unset( $validated_variations['variations'][$template_pack][$messenger][$message_type][$slug] ); |
|
159 | - EE_Error::add_error( sprintf( __('Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.', 'event_espresso' ), $label, $template_pack, $messenger, $message_type, $registered_var ) ); |
|
153 | + foreach ($validated_variations['variations'] as $template_pack => $messenger) { |
|
154 | + foreach ($messenger as $message_type => $variations) { |
|
155 | + foreach ($variations as $slug => $label) { |
|
156 | + foreach (self::$_registry as $registered_var => $reg_settings) { |
|
157 | + if (isset($reg_settings['variations'][$template_pack][$messenger][$message_type][$slug])) { |
|
158 | + unset($validated_variations['variations'][$template_pack][$messenger][$message_type][$slug]); |
|
159 | + EE_Error::add_error(sprintf(__('Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.', 'event_espresso'), $label, $template_pack, $messenger, $message_type, $registered_var)); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return string The path to the requested variation. |
187 | 187 | */ |
188 | - public static function get_variation( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack ) { |
|
188 | + public static function get_variation($variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack) { |
|
189 | 189 | |
190 | 190 | //so let's loop through our registered variations and then pull any details matching the request. |
191 | - foreach ( self::$_registry as $registry_slug => $registry_settings ) { |
|
191 | + foreach (self::$_registry as $registry_slug => $registry_settings) { |
|
192 | 192 | $base = $url ? $registry_settings['base_url'] : $registry_settings['base_path']; |
193 | - $file_string = $messenger . '_' . $type. '_' . $variation . $file_extension; |
|
193 | + $file_string = $messenger.'_'.$type.'_'.$variation.$file_extension; |
|
194 | 194 | //see if this file exists |
195 | - if ( is_readable( $registry_settings['base_path'] . $file_string ) ) { |
|
196 | - return $base . $file_string; |
|
195 | + if (is_readable($registry_settings['base_path'].$file_string)) { |
|
196 | + return $base.$file_string; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
@@ -217,21 +217,21 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return array new variations array (or existing one if nothing registered) |
219 | 219 | */ |
220 | - public static function get_variations( $variations, $messenger, $message_type, EE_Messages_Template_Pack $template_pack ) { |
|
220 | + public static function get_variations($variations, $messenger, $message_type, EE_Messages_Template_Pack $template_pack) { |
|
221 | 221 | //first let's check if we even have registered variations and get out early. |
222 | - if ( empty( self::$_registry ) ) { |
|
222 | + if (empty(self::$_registry)) { |
|
223 | 223 | return $variations; |
224 | 224 | } |
225 | 225 | |
226 | 226 | //do we have any new variations for the given messenger, $message_type, and template packs |
227 | - foreach ( self::$_registry as $registry_slug => $registry_settings ) { |
|
227 | + foreach (self::$_registry as $registry_slug => $registry_settings) { |
|
228 | 228 | //allow for different conditions. |
229 | - if ( empty( $messenger) ) { |
|
230 | - $variations = array_merge( $registry_settings['variations'], $variations ); |
|
231 | - } else if ( ! empty( $messenger ) && empty( $message_type ) && ! empty( $registry_settings['variations'][$template_pack->dbref][$messenger] ) ) { |
|
232 | - $variations = array_merge( $registry_settings['variations'][$template_pack->dbref][$messenger], $variations ); |
|
233 | - } else if ( ! empty( $messenger ) && ! empty( $message_type ) && ! empty( $registry_settings['variations'][$template_pack->dbref][$messenger][$message_type] ) ) { |
|
234 | - $variations = array_merge( $registry_settings['variations'][$template_pack->dbref][$messenger][$message_type], $variations ); |
|
229 | + if (empty($messenger)) { |
|
230 | + $variations = array_merge($registry_settings['variations'], $variations); |
|
231 | + } else if ( ! empty($messenger) && empty($message_type) && ! empty($registry_settings['variations'][$template_pack->dbref][$messenger])) { |
|
232 | + $variations = array_merge($registry_settings['variations'][$template_pack->dbref][$messenger], $variations); |
|
233 | + } else if ( ! empty($messenger) && ! empty($message_type) && ! empty($registry_settings['variations'][$template_pack->dbref][$messenger][$message_type])) { |
|
234 | + $variations = array_merge($registry_settings['variations'][$template_pack->dbref][$messenger][$message_type], $variations); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | return $variations; |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return void |
252 | 252 | */ |
253 | - public static function deregister( $variation_ref = NULL ) { |
|
254 | - if ( !empty( self::$_registry[$variation_ref] ) ) { |
|
255 | - unset( self::$_registry[$variation_ref] ); |
|
253 | + public static function deregister($variation_ref = NULL) { |
|
254 | + if ( ! empty(self::$_registry[$variation_ref])) { |
|
255 | + unset(self::$_registry[$variation_ref]); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.5.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new message template pack variation for the EE messages system. |
@@ -185,7 +185,7 @@ |
||
185 | 185 | */ |
186 | 186 | public static function deregister( $variation_ref = NULL ) { |
187 | 187 | if ( !empty( self::$_registry[$variation_ref] ) ) { |
188 | - unset( self::$_registry[$variation_ref] ); |
|
189 | - } |
|
188 | + unset( self::$_registry[$variation_ref] ); |
|
189 | + } |
|
190 | 190 | } |
191 | 191 | } |