@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\services\container; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -18,70 +18,70 @@ discard block |
||
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * returns an instance of the requested entity type using the supplied arguments. |
|
23 | - * If a shared service is requested and an instance is already in the carafe, then it will be returned. |
|
24 | - * If it is not already in the carafe, then the service will be constructed, added to the carafe, and returned |
|
25 | - * If the request is for a new entity and a closure exists in the reservoir for creating it, |
|
26 | - * then a new entity will be instantiated from the closure and returned. |
|
27 | - * If a closure does not exist, then one will be built and added to the reservoir |
|
28 | - * before instantiating the requested entity. |
|
29 | - * |
|
30 | - * @param string $identifier Identifier for the entity class to be constructed. |
|
31 | - * Typically a Fully Qualified Class Name |
|
32 | - * @param array $arguments an array of arguments to be passed to the entity constructor |
|
33 | - * @param string $type |
|
34 | - * @return mixed |
|
35 | - */ |
|
36 | - public function brew($identifier, $arguments = array(), $type = ''); |
|
21 | + /** |
|
22 | + * returns an instance of the requested entity type using the supplied arguments. |
|
23 | + * If a shared service is requested and an instance is already in the carafe, then it will be returned. |
|
24 | + * If it is not already in the carafe, then the service will be constructed, added to the carafe, and returned |
|
25 | + * If the request is for a new entity and a closure exists in the reservoir for creating it, |
|
26 | + * then a new entity will be instantiated from the closure and returned. |
|
27 | + * If a closure does not exist, then one will be built and added to the reservoir |
|
28 | + * before instantiating the requested entity. |
|
29 | + * |
|
30 | + * @param string $identifier Identifier for the entity class to be constructed. |
|
31 | + * Typically a Fully Qualified Class Name |
|
32 | + * @param array $arguments an array of arguments to be passed to the entity constructor |
|
33 | + * @param string $type |
|
34 | + * @return mixed |
|
35 | + */ |
|
36 | + public function brew($identifier, $arguments = array(), $type = ''); |
|
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @param string $identifier |
|
42 | - * @param callable $closure |
|
43 | - */ |
|
44 | - public function addClosure($identifier, $closure); |
|
40 | + /** |
|
41 | + * @param string $identifier |
|
42 | + * @param callable $closure |
|
43 | + */ |
|
44 | + public function addClosure($identifier, $closure); |
|
45 | 45 | |
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param string $identifier |
|
50 | - * @param mixed $service |
|
51 | - * @return boolean |
|
52 | - */ |
|
53 | - public function addService($identifier, $service); |
|
48 | + /** |
|
49 | + * @param string $identifier |
|
50 | + * @param mixed $service |
|
51 | + * @return boolean |
|
52 | + */ |
|
53 | + public function addService($identifier, $service); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Adds instructions on how to brew objects |
|
59 | - * |
|
60 | - * @param RecipeInterface $recipe |
|
61 | - * @return mixed |
|
62 | - */ |
|
63 | - public function addRecipe(RecipeInterface $recipe); |
|
57 | + /** |
|
58 | + * Adds instructions on how to brew objects |
|
59 | + * |
|
60 | + * @param RecipeInterface $recipe |
|
61 | + * @return mixed |
|
62 | + */ |
|
63 | + public function addRecipe(RecipeInterface $recipe); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * Get instructions on how to brew objects |
|
69 | - * |
|
70 | - * @param string $identifier |
|
71 | - * @return Recipe |
|
72 | - */ |
|
73 | - public function getRecipe($identifier); |
|
67 | + /** |
|
68 | + * Get instructions on how to brew objects |
|
69 | + * |
|
70 | + * @param string $identifier |
|
71 | + * @return Recipe |
|
72 | + */ |
|
73 | + public function getRecipe($identifier); |
|
74 | 74 | |
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * adds class name aliases to list of filters |
|
79 | - * |
|
80 | - * @param string $identifier |
|
81 | - * @param array $aliases |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function addAliases($identifier, $aliases); |
|
77 | + /** |
|
78 | + * adds class name aliases to list of filters |
|
79 | + * |
|
80 | + * @param string $identifier |
|
81 | + * @param array $aliases |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function addAliases($identifier, $aliases); |
|
85 | 85 | |
86 | 86 | |
87 | 87 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEG_Aim extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Aim extends EE_Onsite_Gateway { |
|
29 | 29 | |
30 | 30 | const LIVE_URL = 'https://secure2.authorize.net/gateway/transact.dll'; //Authnet URL |
31 | 31 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param EEG_Aim $gateway_object |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function possibly_use_deprecated_aim_server( $url, EEG_Aim $gateway_object ) { |
|
161 | - if( $gateway_object->_server === 'authorize.net' |
|
162 | - && ! $gateway_object->_debug_mode ) { |
|
160 | + public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object) { |
|
161 | + if ($gateway_object->_server === 'authorize.net' |
|
162 | + && ! $gateway_object->_debug_mode) { |
|
163 | 163 | return 'https://secure.authorize.net/gateway/transact.dll'; |
164 | 164 | } else { |
165 | 165 | return $url; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | |
184 | 184 | public function do_direct_payment($payment, $billing_info = null) { |
185 | - add_filter( 'FHEE__EEG_Aim___get_server_url', array( $this, 'possibly_use_deprecated_aim_server' ), 10, 2 ); |
|
185 | + add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2); |
|
186 | 186 | // Enable test mode if needed |
187 | 187 | //4007000000027 <-- test successful visa |
188 | 188 | //4222222222222 <-- test failure card number |
@@ -193,21 +193,21 @@ discard block |
||
193 | 193 | $primary_registrant = $transaction->primary_registration(); |
194 | 194 | //if we're are charging for the full amount, show the normal line items |
195 | 195 | //and the itemized total adds up properly |
196 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
196 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
197 | 197 | $total_line_item = $transaction->total_line_item(); |
198 | 198 | foreach ($total_line_item->get_items() as $line_item) { |
199 | 199 | //ignore line items with a quantity of 0 |
200 | - if( $line_item->quantity() == 0 ){ |
|
200 | + if ($line_item->quantity() == 0) { |
|
201 | 201 | continue; |
202 | 202 | } |
203 | 203 | $this->addLineItem($item_num++, $line_item->name(), $line_item->desc(), $line_item->quantity(), $line_item->unit_price(), 'N'); |
204 | 204 | $order_description .= $line_item->desc().', '; |
205 | 205 | } |
206 | - foreach($total_line_item->tax_descendants() as $tax_line_item){ |
|
206 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
207 | 207 | $this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N'); |
208 | 208 | } |
209 | - }else{//partial payment |
|
210 | - $order_description = sprintf(__("Payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code()); |
|
209 | + } else {//partial payment |
|
210 | + $order_description = sprintf(__("Payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code()); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | //start transaction |
217 | 217 | //if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id |
218 | 218 | $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363'; |
219 | - $this->setField( 'solution_id', $partner_id ); |
|
219 | + $this->setField('solution_id', $partner_id); |
|
220 | 220 | $this->setField('amount', $this->format_currency($payment->amount())); |
221 | - $this->setField('description',substr(rtrim($order_description, ', '), 0, 255)); |
|
222 | - $this->_set_sensitive_billing_data( $billing_info ); |
|
221 | + $this->setField('description', substr(rtrim($order_description, ', '), 0, 255)); |
|
222 | + $this->_set_sensitive_billing_data($billing_info); |
|
223 | 223 | $this->setField('first_name', $billing_info['first_name']); |
224 | 224 | $this->setField('last_name', $billing_info['last_name']); |
225 | 225 | $this->setField('email', $billing_info['email']); |
226 | 226 | $this->setField('company', $billing_info['company']); |
227 | 227 | $this->setField('address', $billing_info['address'].' '.$billing_info['address2']); |
228 | 228 | $this->setField('city', $billing_info['city']); |
229 | - $this->setField('state', $billing_info['state'] ); |
|
230 | - $this->setField('country', $billing_info['country'] ); |
|
229 | + $this->setField('state', $billing_info['state']); |
|
230 | + $this->setField('country', $billing_info['country']); |
|
231 | 231 | $this->setField('zip', $billing_info['zip']); |
232 | 232 | $this->setField('fax', $billing_info['fax']); |
233 | 233 | $this->setField('cust_id', $primary_registrant->ID()); |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | //invoice_num would be nice to have it be unique per SPCO page-load, that way if users |
236 | 236 | //press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page |
237 | 237 | //in which case, we need to generate teh invoice num per request right here... |
238 | - $this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
238 | + $this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
239 | 239 | //tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
240 | - $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS ); |
|
240 | + $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
|
241 | 241 | |
242 | 242 | |
243 | 243 | if ($this->_test_transactions) { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | //Capture response |
248 | 248 | $this->type = "AUTH_CAPTURE"; |
249 | 249 | $response = $this->_sendRequest($payment); |
250 | - if (!empty($response)){ |
|
250 | + if ( ! empty($response)) { |
|
251 | 251 | if ($this->_debug_mode) { |
252 | 252 | $txn_id = $response->invoice_number; |
253 | 253 | } else { |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status(); |
257 | 257 | $payment->set_status($payment_status); |
258 | 258 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
259 | - $payment->set_amount( (float) $response->amount ); |
|
260 | - $payment->set_gateway_response(sprintf("%s (code: %s)",$response->response_reason_text,$response->response_reason_code)); |
|
261 | - $payment->set_txn_id_chq_nmbr( $txn_id ); |
|
259 | + $payment->set_amount((float) $response->amount); |
|
260 | + $payment->set_gateway_response(sprintf("%s (code: %s)", $response->response_reason_text, $response->response_reason_code)); |
|
261 | + $payment->set_txn_id_chq_nmbr($txn_id); |
|
262 | 262 | $payment->set_extra_accntng($primary_registrant->reg_code()); |
263 | - $payment->set_details(print_r($response,true)); |
|
263 | + $payment->set_details(print_r($response, true)); |
|
264 | 264 | } else { |
265 | 265 | $payment->set_status($this->_pay_model->failed_status()); |
266 | 266 | $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso')); |
267 | - $payment->set_details(print_r($response,true)); |
|
267 | + $payment->set_details(print_r($response, true)); |
|
268 | 268 | } |
269 | 269 | return $payment; |
270 | 270 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * what billing data gets sent |
276 | 276 | * @param array $billing_info |
277 | 277 | */ |
278 | - protected function _set_sensitive_billing_data( $billing_info ) { |
|
278 | + protected function _set_sensitive_billing_data($billing_info) { |
|
279 | 279 | $this->setField('card_num', $billing_info['credit_card']); |
280 | 280 | $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']); |
281 | 281 | $this->setField('card_code', $billing_info['cvv']); |
@@ -334,22 +334,22 @@ discard block |
||
334 | 334 | $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
335 | 335 | $x_keys = array(); |
336 | 336 | foreach ($this->_x_post_fields as $key => $value) { |
337 | - $x_keys[] = "x_$key=" . urlencode($value); |
|
337 | + $x_keys[] = "x_$key=".urlencode($value); |
|
338 | 338 | } |
339 | 339 | // Add line items |
340 | 340 | foreach ($this->_additional_line_items as $key => $value) { |
341 | - $x_keys[] = "x_line_item=" . urlencode($value); |
|
341 | + $x_keys[] = "x_line_item=".urlencode($value); |
|
342 | 342 | } |
343 | 343 | $this->_log_clean_request($x_keys, $payment); |
344 | 344 | $post_url = $this->_get_server_url(); |
345 | 345 | $curl_request = curl_init($post_url); |
346 | - curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&",$x_keys)); |
|
346 | + curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&", $x_keys)); |
|
347 | 347 | curl_setopt($curl_request, CURLOPT_HEADER, 0); |
348 | 348 | curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
349 | 349 | curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
350 | 350 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
351 | 351 | if ($this->VERIFY_PEER) { |
352 | - curl_setopt($curl_request, CURLOPT_CAINFO, dirname( __DIR__ ) . '/ssl/cert.pem'); |
|
352 | + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem'); |
|
353 | 353 | } else { |
354 | 354 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
355 | 355 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | $response = curl_exec($curl_request); |
362 | 362 | |
363 | 363 | curl_close($curl_request); |
364 | - $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
364 | + $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
365 | 365 | |
366 | 366 | return $this->_log_and_clean_response($response_obj, $payment); |
367 | 367 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | * @param array $request_array |
371 | 371 | * @param EEI_Payment $payment |
372 | 372 | */ |
373 | - protected function _log_clean_request($request_array,$payment){ |
|
374 | - $keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' ); |
|
375 | - foreach($request_array as $index => $keyvaltogether ) { |
|
376 | - foreach( $keys_to_filter_out as $key ) { |
|
377 | - if( strpos( $keyvaltogether, $key ) === 0 ){ |
|
373 | + protected function _log_clean_request($request_array, $payment) { |
|
374 | + $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date'); |
|
375 | + foreach ($request_array as $index => $keyvaltogether) { |
|
376 | + foreach ($keys_to_filter_out as $key) { |
|
377 | + if (strpos($keyvaltogether, $key) === 0) { |
|
378 | 378 | //found it at the first character |
379 | 379 | //so its one of them |
380 | - unset( $request_array[ $index ] ); |
|
380 | + unset($request_array[$index]); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | } |
384 | - $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url() ),$payment); |
|
384 | + $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url()), $payment); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -393,9 +393,9 @@ discard block |
||
393 | 393 | * @param EE_Payment $payment |
394 | 394 | * @return \EE_AuthorizeNetAIM_Response |
395 | 395 | */ |
396 | - private function _log_and_clean_response($response_obj,$payment){ |
|
396 | + private function _log_and_clean_response($response_obj, $payment) { |
|
397 | 397 | $response_obj->account_number = ''; |
398 | - $this->log(array('AIM Response received:'=>$response_obj),$payment); |
|
398 | + $this->log(array('AIM Response received:'=>$response_obj), $payment); |
|
399 | 399 | return $response_obj; |
400 | 400 | } |
401 | 401 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | // Split Array |
495 | 495 | $this->response = $response; |
496 | 496 | if ($encap_char) { |
497 | - $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
497 | + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
498 | 498 | } else { |
499 | 499 | $this->_response_array = explode($delimiter, $response); |
500 | 500 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $this->held = ($this->response_code === self::HELD); |
565 | 565 | |
566 | 566 | if ($this->error || $this->declined || $this->held) { |
567 | - $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />' . $this->response_reason_text . '<br /><span class="response_code">Response Code: ' . $this->response_code . '<br /></span><span class="response_subcode">Response Subcode: ' . $this->response_subcode . '</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
567 | + $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />'.$this->response_reason_text.'<br /><span class="response_code">Response Code: '.$this->response_code.'<br /></span><span class="response_subcode">Response Subcode: '.$this->response_subcode.'</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
568 | 568 | |
569 | 569 | |
570 | 570 | /* $this->error_message = "AuthorizeNet Error: |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | -if ( ! class_exists( 'AuthorizeNetException' ) ) { |
|
586 | +if ( ! class_exists('AuthorizeNetException')) { |
|
587 | 587 | /** |
588 | 588 | * Class AuthorizeNetException |
589 | 589 | * |
@@ -599,8 +599,8 @@ discard block |
||
599 | 599 | * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0 |
600 | 600 | * @since 5.1.0 |
601 | 601 | */ |
602 | - public function __construct( $message = "", $code = 0, Exception $previous = null ) { |
|
603 | - parent::__construct( $message, $code, $previous ); |
|
602 | + public function __construct($message = "", $code = 0, Exception $previous = null) { |
|
603 | + parent::__construct($message, $code, $previous); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers\config; |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * @param \WP_REST_Request $request |
22 | 22 | * @return \EE_Config|\WP_Error |
23 | 23 | */ |
24 | - public static function handle_request( \WP_REST_Request $request) { |
|
24 | + public static function handle_request(\WP_REST_Request $request) { |
|
25 | 25 | $cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap(); |
26 | - if( \EE_Capabilities::instance()->current_user_can( $cap, 'read_over_api' ) ){ |
|
26 | + if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) { |
|
27 | 27 | return \EE_Config::instance(); |
28 | - }else{ |
|
28 | + } else { |
|
29 | 29 | return new \WP_Error( |
30 | 30 | 'cannot_read_config', |
31 | 31 | sprintf( |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | ), |
36 | 36 | $cap |
37 | 37 | ), |
38 | - array( 'status' => 403 ) |
|
38 | + array('status' => 403) |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | } |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | * @param \WP_REST_Request $request |
46 | 46 | * @return \EE_Config|\WP_Error |
47 | 47 | */ |
48 | - public static function handle_request_site_info( \WP_REST_Request $request) { |
|
48 | + public static function handle_request_site_info(\WP_REST_Request $request) { |
|
49 | 49 | return array( |
50 | 50 | 'default_timezone' => array( |
51 | 51 | 'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(), |
52 | - 'string' => get_option( 'timezone_string' ), |
|
52 | + 'string' => get_option('timezone_string'), |
|
53 | 53 | 'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
54 | 54 | ), |
55 | 55 | 'default_currency' => \EE_Config::instance()->currency |
@@ -18,43 +18,43 @@ |
||
18 | 18 | * @throws EE_Error |
19 | 19 | * @return string of html to display the field |
20 | 20 | */ |
21 | - public function display(){ |
|
21 | + public function display() { |
|
22 | 22 | $input = $this->get_input(); |
23 | 23 | //d( $input ); |
24 | - $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
24 | + $multi = count($input->options()) > 1 ? TRUE : FALSE; |
|
25 | 25 | $input->set_label_sizes(); |
26 | 26 | $label_size_class = $input->get_label_size_class(); |
27 | 27 | $html = ''; |
28 | - if ( ! is_array( $input->raw_value() ) && $input->raw_value() !== NULL ) { |
|
28 | + if ( ! is_array($input->raw_value()) && $input->raw_value() !== NULL) { |
|
29 | 29 | EE_Error::doing_it_wrong( |
30 | 30 | 'EE_Checkbox_Display_Strategy::display()', |
31 | 31 | sprintf( |
32 | - __( 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'), |
|
32 | + __('Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'), |
|
33 | 33 | $input->html_id(), |
34 | - var_export( $input->raw_value(), true), |
|
35 | - $input->html_name() . '[]' |
|
34 | + var_export($input->raw_value(), true), |
|
35 | + $input->html_name().'[]' |
|
36 | 36 | ), |
37 | 37 | '4.8.1' |
38 | 38 | ); |
39 | 39 | } |
40 | - $input_raw_value = (array)$input->raw_value(); |
|
41 | - foreach( $input->options() as $value => $display_text ){ |
|
42 | - $value = $input->get_normalization_strategy()->unnormalize_one( $value ); |
|
43 | - $html_id = $this->get_sub_input_id( $value ); |
|
44 | - $html .= EEH_HTML::nl( 0, 'checkbox' ); |
|
45 | - $html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">'; |
|
46 | - $html .= EEH_HTML::nl( 1, 'checkbox' ); |
|
40 | + $input_raw_value = (array) $input->raw_value(); |
|
41 | + foreach ($input->options() as $value => $display_text) { |
|
42 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
43 | + $html_id = $this->get_sub_input_id($value); |
|
44 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
45 | + $html .= '<label for="'.$html_id.'" id="'.$html_id.'-lbl" class="ee-checkbox-label-after'.$label_size_class.'">'; |
|
46 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
47 | 47 | $html .= '<input type="checkbox"'; |
48 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
49 | - $html .= ' id="' . $html_id . '"'; |
|
50 | - $html .= ' class="' . $input->html_class() . '"'; |
|
51 | - $html .= ' style="' . $input->html_style() . '"'; |
|
52 | - $html .= ' value="' . esc_attr( $value ) . '"'; |
|
53 | - $html .= ! empty( $input_raw_value ) && in_array( $value, $input_raw_value ) ? ' checked="checked"' : ''; |
|
54 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
48 | + $html .= ' name="'.$input->html_name().'[]"'; |
|
49 | + $html .= ' id="'.$html_id.'"'; |
|
50 | + $html .= ' class="'.$input->html_class().'"'; |
|
51 | + $html .= ' style="'.$input->html_style().'"'; |
|
52 | + $html .= ' value="'.esc_attr($value).'"'; |
|
53 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value) ? ' checked="checked"' : ''; |
|
54 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
55 | 55 | $html .= '> '; |
56 | 56 | $html .= $display_text; |
57 | - $html .= EEH_HTML::nl( -1, 'checkbox' ) . '</label>'; |
|
57 | + $html .= EEH_HTML::nl( -1, 'checkbox' ).'</label>'; |
|
58 | 58 | } |
59 | 59 | return $html; |
60 | 60 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Specialized form for payment methods, allowing for easy setting and retrieving of meta fields. |
5 | 5 | * Uses EEM_Payment_Method as the model |
6 | 6 | */ |
7 | -class EE_Payment_Method_Form extends EE_Model_Form_Section{ |
|
7 | +class EE_Payment_Method_Form extends EE_Model_Form_Section { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * All the subsection inputs that correspond ot extra meta rows |
@@ -39,37 +39,37 @@ discard block |
||
39 | 39 | * @see EE_Model_Form_Section::__construct() for more |
40 | 40 | * } |
41 | 41 | */ |
42 | - public function __construct($options_array = array()){ |
|
42 | + public function __construct($options_array = array()) { |
|
43 | 43 | $this->_model = EEM_Payment_Method::instance(); |
44 | 44 | $this->_options_array = $options_array; |
45 | - if(isset($options_array['payment_method_type'])){ |
|
45 | + if (isset($options_array['payment_method_type'])) { |
|
46 | 46 | $this->_payment_method_type = $options_array['payment_method_type']; |
47 | 47 | } |
48 | 48 | $options_array = $this->_options_array; |
49 | - if(isset($options_array['extra_meta_inputs'])){ |
|
50 | - $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs,$options_array['extra_meta_inputs']); |
|
49 | + if (isset($options_array['extra_meta_inputs'])) { |
|
50 | + $this->_extra_meta_inputs = array_merge($this->_extra_meta_inputs, $options_array['extra_meta_inputs']); |
|
51 | 51 | } |
52 | - if($this->_extra_meta_inputs){ |
|
53 | - $this->_subsections = array_merge($this->_subsections,$this->_extra_meta_inputs); |
|
52 | + if ($this->_extra_meta_inputs) { |
|
53 | + $this->_subsections = array_merge($this->_subsections, $this->_extra_meta_inputs); |
|
54 | 54 | } |
55 | 55 | $this->_subsections['PMD_button_url'] = new EE_Admin_File_Uploader_Input( |
56 | - array( 'html_label_text'=> __( 'Button URL', 'event_espresso' )) |
|
56 | + array('html_label_text'=> __('Button URL', 'event_espresso')) |
|
57 | 57 | ); |
58 | 58 | $this->_subsections['PMD_scope'] = new EE_Checkbox_Multi_Input( |
59 | 59 | EEM_Payment_Method::instance()->scopes(), |
60 | - array( 'html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename() . EEH_Template::get_help_tab_link( 'payment_methods_overview' )) |
|
60 | + array('html_label_text' => $this->_model->field_settings_for('PMD_scope')->get_nicename().EEH_Template::get_help_tab_link('payment_methods_overview')) |
|
61 | 61 | ); |
62 | 62 | //setup the currency options |
63 | 63 | $this->_subsections['Currency'] = new EE_Select_Multi_Model_Input( |
64 | - EEM_Currency::instance()->get_all_currencies_usable_by( $this->_payment_method_type ), |
|
64 | + EEM_Currency::instance()->get_all_currencies_usable_by($this->_payment_method_type), |
|
65 | 65 | array( |
66 | - 'html_label_text'=> __( 'Currencies Supported', 'event_espresso' ), |
|
66 | + 'html_label_text'=> __('Currencies Supported', 'event_espresso'), |
|
67 | 67 | 'required'=>TRUE |
68 | 68 | ) |
69 | 69 | ); |
70 | - $this->_subsections['PMD_order'] = new EE_Text_Input( array( |
|
71 | - 'html_label_text' => __( 'Order', 'event_espresso' ), |
|
72 | - 'html_help_text' => __( 'Lowest numbers will be shown first', 'event_espresso' ), |
|
70 | + $this->_subsections['PMD_order'] = new EE_Text_Input(array( |
|
71 | + 'html_label_text' => __('Order', 'event_espresso'), |
|
72 | + 'html_help_text' => __('Lowest numbers will be shown first', 'event_espresso'), |
|
73 | 73 | 'normalization_strategy' => new EE_Int_Normalization(), |
74 | 74 | 'validation_strategies' => array( |
75 | 75 | new EE_Int_Validation_Strategy() |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | )); |
79 | 79 | $this->_layout_strategy = new EE_Admin_Two_Column_Layout(); |
80 | 80 | parent::__construct($options_array); |
81 | - $debug_mode = isset( $this->_subsections[ 'PMD_debug_mode' ] ) ? $this->_subsections[ 'PMD_debug_mode' ] : null; |
|
82 | - if( $debug_mode instanceof EE_Form_Input_Base ) { |
|
83 | - $debug_mode->set_html_help_text( __( 'This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', 'event_espresso' ) ); |
|
81 | + $debug_mode = isset($this->_subsections['PMD_debug_mode']) ? $this->_subsections['PMD_debug_mode'] : null; |
|
82 | + if ($debug_mode instanceof EE_Form_Input_Base) { |
|
83 | + $debug_mode->set_html_help_text(__('This payment method has a Sandbox Server (also known as Testing Server, Development Server, Quality Assurance Server, etc). While in debug mode and using this sandbox server, real payments will not be processed.', 'event_espresso')); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | * @param string $name |
93 | 93 | * @throws EE_Error |
94 | 94 | */ |
95 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
96 | - if( ! $this->_payment_method_type instanceof EE_PMT_Base ){ |
|
97 | - throw new EE_Error( sprintf( __( 'Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso' ))); |
|
95 | + public function _construct_finalize($parent_form_section, $name) { |
|
96 | + if ( ! $this->_payment_method_type instanceof EE_PMT_Base) { |
|
97 | + throw new EE_Error(sprintf(__('Payment Method forms must have set their payment method type BEFORE calling _construct_finalize', 'event_espresso'))); |
|
98 | 98 | } |
99 | 99 | //set the name of this form based on the payment method type |
100 | - if( ! $this->_name && ! $name ){ |
|
101 | - $name = str_replace(" ","_",ucwords(str_replace("_"," ",($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
100 | + if ( ! $this->_name && ! $name) { |
|
101 | + $name = str_replace(" ", "_", ucwords(str_replace("_", " ", ($this->_payment_method_type->system_name()))))."_Settings_Form"; |
|
102 | 102 | } |
103 | - parent::_construct_finalize( $parent_form_section, $name ); |
|
103 | + parent::_construct_finalize($parent_form_section, $name); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @param $payment_method_type |
110 | 110 | * @throws EE_Error |
111 | 111 | */ |
112 | - public function set_payment_method_type( $payment_method_type ){ |
|
113 | - if( ! $payment_method_type instanceof EE_PMT_Base){ |
|
112 | + public function set_payment_method_type($payment_method_type) { |
|
113 | + if ( ! $payment_method_type instanceof EE_PMT_Base) { |
|
114 | 114 | throw new EE_Error(sprintf(__("Payment Method forms MUST set a payment method type by using _set_payment_method_type", "event_espresso"))); |
115 | 115 | } |
116 | 116 | $this->_payment_method_type = $payment_method_type; |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | * extends the model form section's save method to also save the extra meta field values |
123 | 123 | * @return int ID of the payment method inserted, or true on update |
124 | 124 | */ |
125 | - public function save(){ |
|
125 | + public function save() { |
|
126 | 126 | $parent_save_val = parent::save(); |
127 | - if( $this->_model_object && $this->_model_object->ID()){ |
|
128 | - foreach($this->_extra_meta_inputs as $input_name => $input){ |
|
127 | + if ($this->_model_object && $this->_model_object->ID()) { |
|
128 | + foreach ($this->_extra_meta_inputs as $input_name => $input) { |
|
129 | 129 | $this->_model_object->update_extra_meta($input_name, $input->normalized_value()); |
130 | 130 | } |
131 | 131 | } |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | $model_obj = $this->_model->ensure_is_obj($model_obj); |
143 | 143 | parent::populate_model_obj($model_obj); |
144 | 144 | $extra_meta = $model_obj->all_extra_meta_array(); |
145 | - foreach($this->_extra_meta_inputs as $input_name => $extra_meta_input){ |
|
146 | - if(isset($extra_meta[$input_name])){ |
|
145 | + foreach ($this->_extra_meta_inputs as $input_name => $extra_meta_input) { |
|
146 | + if (isset($extra_meta[$input_name])) { |
|
147 | 147 | $extra_meta_input->set_default($extra_meta[$input_name]); |
148 | 148 | } |
149 | 149 | } |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | * gets the default name of this form section if none is specified |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - protected function _set_default_name_if_empty(){ |
|
159 | - if( ! $this->_name ){ |
|
160 | - $default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form"; |
|
161 | - $this->_name = $default_name; |
|
158 | + protected function _set_default_name_if_empty() { |
|
159 | + if ( ! $this->_name) { |
|
160 | + $default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form"; |
|
161 | + $this->_name = $default_name; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * Gets all the extra meta inputs in this form |
169 | 169 | * @return EE_Form_Input_Base[] |
170 | 170 | */ |
171 | - public function extra_meta_inputs(){ |
|
171 | + public function extra_meta_inputs() { |
|
172 | 172 | return $this->_extra_meta_inputs; |
173 | 173 | } |
174 | 174 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
159 | 159 | )); |
160 | 160 | */ |
161 | -class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage{ |
|
161 | +class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage { |
|
162 | 162 | private $_old_table; |
163 | 163 | private $_old_start_end_table; |
164 | 164 | private $_new_table; |
@@ -184,41 +184,41 @@ discard block |
||
184 | 184 | protected function _migration_step($num_items_to_migrate = 50) { |
185 | 185 | global $wpdb; |
186 | 186 | //because the migration of each event can be a LOT more work, make each step smaller |
187 | - $num_items_to_migrate = max(1,$num_items_to_migrate/5); |
|
188 | - $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d",$this->count_records_migrated(),$num_items_to_migrate),ARRAY_A); |
|
187 | + $num_items_to_migrate = max(1, $num_items_to_migrate / 5); |
|
188 | + $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $this->count_records_migrated(), $num_items_to_migrate), ARRAY_A); |
|
189 | 189 | $items_migrated_this_step = 0; |
190 | 190 | |
191 | - foreach($events as $event_row){ |
|
191 | + foreach ($events as $event_row) { |
|
192 | 192 | $created_attachment_post = false; |
193 | 193 | //insert new 4.1 Attendee object using $wpdb |
194 | 194 | $post_id = $this->_insert_cpt($event_row); |
195 | - if($post_id){ |
|
195 | + if ($post_id) { |
|
196 | 196 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_table, $post_id); |
197 | 197 | $meta_id = $this->_insert_event_meta($event_row, $post_id); |
198 | - if($meta_id){ |
|
198 | + if ($meta_id) { |
|
199 | 199 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_meta_table, $meta_id); |
200 | 200 | } |
201 | - $this->_convert_start_end_times($event_row,$post_id); |
|
201 | + $this->_convert_start_end_times($event_row, $post_id); |
|
202 | 202 | $event_meta = maybe_unserialize($event_row['event_meta']); |
203 | 203 | $guid = isset($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : null; |
204 | - $created_attachment_post = $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid,$post_id,$this); |
|
204 | + $created_attachment_post = $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $post_id, $this); |
|
205 | 205 | |
206 | 206 | //maybe create a venue from info on the event? |
207 | 207 | $new_venue_id = $this->_maybe_create_venue($event_row); |
208 | - if($new_venue_id){ |
|
209 | - $this->_insert_new_venue_to_event($post_id,$new_venue_id); |
|
208 | + if ($new_venue_id) { |
|
209 | + $this->_insert_new_venue_to_event($post_id, $new_venue_id); |
|
210 | 210 | } |
211 | 211 | $this->_add_post_metas($event_row, $post_id); |
212 | 212 | |
213 | 213 | } |
214 | 214 | $items_migrated_this_step++; |
215 | - if($guid){ |
|
215 | + if ($guid) { |
|
216 | 216 | //if we had to check for an image attachment |
217 | 217 | //then let's call it a day (avoid timing out, because this took a long time) |
218 | 218 | break; |
219 | 219 | } |
220 | 220 | } |
221 | - if($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()){ |
|
221 | + if ($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()) { |
|
222 | 222 | $this->set_status(EE_Data_Migration_Manager::status_completed); |
223 | 223 | } |
224 | 224 | return $items_migrated_this_step; |
@@ -230,28 +230,28 @@ discard block |
||
230 | 230 | * @param type $post_id |
231 | 231 | * @return void |
232 | 232 | */ |
233 | - private function _add_post_metas($old_event,$post_id){ |
|
233 | + private function _add_post_metas($old_event, $post_id) { |
|
234 | 234 | $event_meta = maybe_unserialize($old_event['event_meta']); |
235 | - if( ! $event_meta || ! is_array( $event_meta ) ){ |
|
235 | + if ( ! $event_meta || ! is_array($event_meta)) { |
|
236 | 236 | return; |
237 | 237 | } |
238 | - unset($event_meta['date_submitted']);//factored into CPT |
|
239 | - unset($event_meta['additional_attendee_reg_info']);//facotred into event meta table |
|
240 | - unset($event_meta['default_payment_status']);//dido |
|
241 | - unset($event_meta['event_thumbnail_url']);//used to find post featured image |
|
242 | - foreach($event_meta as $meta_key => $meta_value){ |
|
243 | - if ($meta_key){//if th emeta key is just an empty string, ignore it |
|
244 | - $success = add_post_meta($post_id,$meta_key,$meta_value,true); |
|
245 | - if( ! $success ){ |
|
246 | - $this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"),$post_id,$meta_key,$meta_value,implode(",",$old_event))); |
|
238 | + unset($event_meta['date_submitted']); //factored into CPT |
|
239 | + unset($event_meta['additional_attendee_reg_info']); //facotred into event meta table |
|
240 | + unset($event_meta['default_payment_status']); //dido |
|
241 | + unset($event_meta['event_thumbnail_url']); //used to find post featured image |
|
242 | + foreach ($event_meta as $meta_key => $meta_value) { |
|
243 | + if ($meta_key) {//if th emeta key is just an empty string, ignore it |
|
244 | + $success = add_post_meta($post_id, $meta_key, $meta_value, true); |
|
245 | + if ( ! $success) { |
|
246 | + $this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"), $post_id, $meta_key, $meta_value, implode(",", $old_event))); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | - if($old_event['alt_email']){ |
|
251 | - add_post_meta($post_id,'alt_email',$old_event['alt_email']); |
|
250 | + if ($old_event['alt_email']) { |
|
251 | + add_post_meta($post_id, 'alt_email', $old_event['alt_email']); |
|
252 | 252 | } |
253 | - if($old_event['recurrence_id']){ |
|
254 | - add_post_meta($post_id,'recurrence_id',$old_event['recurrence_id']); |
|
253 | + if ($old_event['recurrence_id']) { |
|
254 | + add_post_meta($post_id, 'recurrence_id', $old_event['recurrence_id']); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | /** |
@@ -263,13 +263,13 @@ discard block |
||
263 | 263 | * @param string $new_post_status a post status |
264 | 264 | * @return string |
265 | 265 | */ |
266 | - private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish'){ |
|
266 | + private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish') { |
|
267 | 267 | $count = 0; |
268 | 268 | $original_name = $event_name ? sanitize_title($event_name) : $old_identifier; |
269 | - return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0 ); |
|
269 | + return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0); |
|
270 | 270 | } |
271 | 271 | |
272 | - private function _insert_cpt($old_event){ |
|
272 | + private function _insert_cpt($old_event) { |
|
273 | 273 | global $wpdb; |
274 | 274 | //convert 3.1 event status to 4.1 CPT status |
275 | 275 | //for refrence, 3.1 event stati available for setting are: |
@@ -288,55 +288,55 @@ discard block |
||
288 | 288 | // and 3 custom ones: cancelled,postponed,sold_out |
289 | 289 | $status_conversions = array( |
290 | 290 | 'R'=>'draft', |
291 | - 'X'=>'draft',//4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
291 | + 'X'=>'draft', //4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
292 | 292 | 'P'=>'pending', |
293 | - 'IA'=>'draft',//draft and in the past |
|
293 | + 'IA'=>'draft', //draft and in the past |
|
294 | 294 | //IA=inactive in 3.1: events were switched to this when they expired. in 4.1 that's just calculated |
295 | - 'O'=>'publish',//@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing' |
|
295 | + 'O'=>'publish', //@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing' |
|
296 | 296 | 'A'=>'publish', |
297 | - 'S'=>'draft',//@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
297 | + 'S'=>'draft', //@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
298 | 298 | 'D'=>'trash', |
299 | 299 | ); |
300 | 300 | $post_status = $status_conversions[$old_event['event_status']]; |
301 | 301 | //check if we've sold out |
302 | - if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])){ |
|
302 | + if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])) { |
|
303 | 303 | $post_status = 'sold_out'; |
304 | 304 | } |
305 | 305 | // FYI postponed and cancelled don't exist in 3.1 |
306 | 306 | $cols_n_values = array( |
307 | - 'post_title'=>stripslashes($old_event['event_name']),//EVT_name |
|
308 | - 'post_content'=>stripslashes($old_event['event_desc']),//EVT_desc |
|
309 | - 'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status ),//EVT_slug |
|
310 | - 'post_date'=>$old_event['submitted'],//EVT_created NOT |
|
307 | + 'post_title'=>stripslashes($old_event['event_name']), //EVT_name |
|
308 | + 'post_content'=>stripslashes($old_event['event_desc']), //EVT_desc |
|
309 | + 'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status), //EVT_slug |
|
310 | + 'post_date'=>$old_event['submitted'], //EVT_created NOT |
|
311 | 311 | 'post_date_gmt'=>get_gmt_from_date($old_event['submitted']), |
312 | - 'post_excerpt'=>'',//EVT_short_desc |
|
313 | - 'post_modified'=>$old_event['submitted'],//EVT_modified |
|
312 | + 'post_excerpt'=>'', //EVT_short_desc |
|
313 | + 'post_modified'=>$old_event['submitted'], //EVT_modified |
|
314 | 314 | 'post_modified_gmt'=>get_gmt_from_date($old_event['submitted']), |
315 | - 'post_author'=>$old_event['wp_user'],//EVT_wp_user |
|
316 | - 'post_parent'=>0,//parent maybe get this from some REM field? |
|
317 | - 'menu_order'=>0,//EVT_order |
|
318 | - 'post_type'=>'espresso_events',//post_type |
|
319 | - 'post_status'=>$post_status,//status |
|
315 | + 'post_author'=>$old_event['wp_user'], //EVT_wp_user |
|
316 | + 'post_parent'=>0, //parent maybe get this from some REM field? |
|
317 | + 'menu_order'=>0, //EVT_order |
|
318 | + 'post_type'=>'espresso_events', //post_type |
|
319 | + 'post_status'=>$post_status, //status |
|
320 | 320 | ); |
321 | 321 | $datatypes = array( |
322 | - '%s',//EVT_name |
|
323 | - '%s',//EVT_desc |
|
324 | - '%s',//EVT_slug |
|
325 | - '%s',//EVT_created |
|
322 | + '%s', //EVT_name |
|
323 | + '%s', //EVT_desc |
|
324 | + '%s', //EVT_slug |
|
325 | + '%s', //EVT_created |
|
326 | 326 | '%s', |
327 | - '%s',//EVT_short_desc |
|
328 | - '%s',//EVT_modified |
|
327 | + '%s', //EVT_short_desc |
|
328 | + '%s', //EVT_modified |
|
329 | 329 | '%s', |
330 | - '%s',//EVT_wp_user |
|
331 | - '%d',//post_parent |
|
332 | - '%d',//EVT_order |
|
333 | - '%s',//post_type |
|
334 | - '%s',//status |
|
330 | + '%s', //EVT_wp_user |
|
331 | + '%d', //post_parent |
|
332 | + '%d', //EVT_order |
|
333 | + '%s', //post_type |
|
334 | + '%s', //status |
|
335 | 335 | ); |
336 | 336 | $success = $wpdb->insert($this->_new_table, |
337 | 337 | $cols_n_values, |
338 | 338 | $datatypes); |
339 | - if( ! $success ){ |
|
339 | + if ( ! $success) { |
|
340 | 340 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_table, $cols_n_values, $datatypes)); |
341 | 341 | return 0; |
342 | 342 | } |
@@ -349,13 +349,13 @@ discard block |
||
349 | 349 | * @param type $event_id |
350 | 350 | * @return int |
351 | 351 | */ |
352 | - public static function count_registrations($event_id){ |
|
352 | + public static function count_registrations($event_id) { |
|
353 | 353 | global $wpdb; |
354 | - $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d",$event_id)); |
|
354 | + $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d", $event_id)); |
|
355 | 355 | return intval($count); |
356 | 356 | } |
357 | 357 | |
358 | - private function _insert_event_meta($old_event,$new_cpt_id){ |
|
358 | + private function _insert_event_meta($old_event, $new_cpt_id) { |
|
359 | 359 | global $wpdb; |
360 | 360 | $event_meta = maybe_unserialize($old_event['event_meta']); |
361 | 361 | // for reference, 3.1 'default_payment_status' are: $default_payment_status = array( |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | //); |
367 | 367 | $default_reg_status = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID(isset($event_meta['default_payment_status']) ? $event_meta['default_payment_status'] : '', intval($old_event['require_pre_approval'])); |
368 | 368 | $cols_n_values = array( |
369 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID_fk |
|
369 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID_fk |
|
370 | 370 | 'EVT_display_desc'=> 'Y' == $old_event['display_desc'], |
371 | - 'EVT_display_ticket_selector'=> 'Y'== $old_event['display_reg_form'], |
|
372 | - 'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this,$old_event,current_time('mysql'),$old_event['timezone_string']),//don't use the old 'visible_on', as it wasnt ever used |
|
371 | + 'EVT_display_ticket_selector'=> 'Y' == $old_event['display_reg_form'], |
|
372 | + 'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this, $old_event, current_time('mysql'), $old_event['timezone_string']), //don't use the old 'visible_on', as it wasnt ever used |
|
373 | 373 | 'EVT_additional_limit'=> $old_event['allow_multiple'] == 'N' ? 1 : $old_event['additional_limit'], |
374 | 374 | 'EVT_default_registration_status' => $default_reg_status, |
375 | 375 | 'EVT_member_only'=>$old_event['member_only'], |
@@ -381,31 +381,31 @@ discard block |
||
381 | 381 | |
382 | 382 | ); |
383 | 383 | $datatypes = array( |
384 | - '%s',//EVT_ID |
|
385 | - '%d',//EVT_display_desc |
|
386 | - '%d',//EVT_display_ticket_selector |
|
387 | - '%s',//EVT_visible_on |
|
388 | - '%d',//EVT_additional_limit |
|
389 | - '%s',//EVT_default_registration_status |
|
390 | - '%d',//EVT_member_only |
|
391 | - '%s',//EVT_phone |
|
392 | - '%d',//EVT_allow_overflow |
|
393 | - '%s',//EVT_timezone_string |
|
394 | - '%s',//EVT_external_URL |
|
395 | - '%d',//EVT_donations |
|
384 | + '%s', //EVT_ID |
|
385 | + '%d', //EVT_display_desc |
|
386 | + '%d', //EVT_display_ticket_selector |
|
387 | + '%s', //EVT_visible_on |
|
388 | + '%d', //EVT_additional_limit |
|
389 | + '%s', //EVT_default_registration_status |
|
390 | + '%d', //EVT_member_only |
|
391 | + '%s', //EVT_phone |
|
392 | + '%d', //EVT_allow_overflow |
|
393 | + '%s', //EVT_timezone_string |
|
394 | + '%s', //EVT_external_URL |
|
395 | + '%d', //EVT_donations |
|
396 | 396 | ); |
397 | 397 | $success = $wpdb->insert($this->_new_meta_table, |
398 | 398 | $cols_n_values, |
399 | 399 | $datatypes); |
400 | - if( ! $success ){ |
|
400 | + if ( ! $success) { |
|
401 | 401 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $cols_n_values, $datatypes)); |
402 | 402 | return 0; |
403 | 403 | } |
404 | 404 | return $wpdb->insert_id; |
405 | 405 | } |
406 | 406 | |
407 | - private function _maybe_create_venue($old_event){ |
|
408 | - if( $old_event['address'] || |
|
407 | + private function _maybe_create_venue($old_event) { |
|
408 | + if ($old_event['address'] || |
|
409 | 409 | $old_event['address2'] || |
410 | 410 | $old_event['city'] || |
411 | 411 | $old_event['state'] || |
@@ -416,21 +416,21 @@ discard block |
||
416 | 416 | $old_event['venue_phone'] || |
417 | 417 | $old_event['virtual_url'] || |
418 | 418 | $old_event['virtual_phone'] |
419 | - ){ |
|
420 | - $old_id = $this->_duplicate_venue_exists( $old_event ); |
|
421 | - if( $old_id ){ |
|
419 | + ) { |
|
420 | + $old_id = $this->_duplicate_venue_exists($old_event); |
|
421 | + if ($old_id) { |
|
422 | 422 | return $old_id; |
423 | 423 | } |
424 | 424 | $new_id = $this->_insert_venue_into_posts($old_event); |
425 | - if( $new_id ){ |
|
425 | + if ($new_id) { |
|
426 | 426 | $this->_insert_venue_into_meta_table($new_id, $old_event); |
427 | - $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
428 | - $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id,$this); |
|
427 | + $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
428 | + $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this); |
|
429 | 429 | } |
430 | 430 | //we don't bother recording the conversion from old events to venues as that |
431 | 431 | //will complicate finding the conversion from old venues to new events |
432 | 432 | return $new_id; |
433 | - }else{ |
|
433 | + } else { |
|
434 | 434 | return 0; |
435 | 435 | } |
436 | 436 | } |
@@ -441,29 +441,29 @@ discard block |
||
441 | 441 | * @param array $old_event |
442 | 442 | * @return int duplicate venue id |
443 | 443 | */ |
444 | - private function _duplicate_venue_exists($old_event){ |
|
444 | + private function _duplicate_venue_exists($old_event) { |
|
445 | 445 | global $wpdb; |
446 | 446 | $conditions = array( |
447 | - 'VNU_address' => $old_event [ 'address' ], |
|
448 | - 'VNU_address2' => $old_event[ 'address2' ], |
|
449 | - 'VNU_city' => $old_event[ 'city' ], |
|
450 | - 'VNU_zip' => $old_event[ 'zip' ], |
|
451 | - 'post_title'=> $this->_get_venue_title_for_event( $old_event ), |
|
452 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
453 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
454 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
455 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
447 | + 'VNU_address' => $old_event ['address'], |
|
448 | + 'VNU_address2' => $old_event['address2'], |
|
449 | + 'VNU_city' => $old_event['city'], |
|
450 | + 'VNU_zip' => $old_event['zip'], |
|
451 | + 'post_title'=> $this->_get_venue_title_for_event($old_event), |
|
452 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
453 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
454 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
455 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
456 | 456 | ); |
457 | 457 | $sql_conditions = array(); |
458 | - foreach($conditions as $column => $value){ |
|
458 | + foreach ($conditions as $column => $value) { |
|
459 | 459 | $sql_conditions [] = "$column = '$value'"; |
460 | 460 | } |
461 | 461 | $query = "SELECT VNU_ID |
462 | 462 | FROM |
463 | 463 | {$wpdb->posts} as p INNER JOIN |
464 | 464 | {$wpdb->prefix}esp_venue_meta as v ON p.ID = v.VNU_ID |
465 | - WHERE " . implode( " AND ",$sql_conditions ) . " LIMIT 1"; |
|
466 | - $id = $wpdb->get_var( $query ); |
|
465 | + WHERE ".implode(" AND ", $sql_conditions)." LIMIT 1"; |
|
466 | + $id = $wpdb->get_var($query); |
|
467 | 467 | return $id; |
468 | 468 | } |
469 | 469 | |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | * @param array $event_data_array keys are events_details columns and valuesa re their values |
473 | 473 | * @return string |
474 | 474 | */ |
475 | - protected function _get_venue_title_for_event( $event_data_array ) { |
|
476 | - return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes( sprintf( __( 'Venue of %s', 'event_espresso' ), $event_data_array['event_name'])); |
|
475 | + protected function _get_venue_title_for_event($event_data_array) { |
|
476 | + return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes(sprintf(__('Venue of %s', 'event_espresso'), $event_data_array['event_name'])); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -481,40 +481,40 @@ discard block |
||
481 | 481 | * @param array $old_venue keys are cols, values are col values |
482 | 482 | * @return int |
483 | 483 | */ |
484 | - private function _insert_venue_into_posts($old_event){ |
|
484 | + private function _insert_venue_into_posts($old_event) { |
|
485 | 485 | global $wpdb; |
486 | 486 | $insertion_array = array( |
487 | - 'post_title'=> $this->_get_venue_title_for_event( $old_event ),//VNU_name |
|
488 | - 'post_content'=>'',//VNU_desc |
|
489 | - 'post_name'=> $this->_find_unique_slug( $old_event['venue_title'], sanitize_title( 'venue-of-' . $old_event['event_name'] ) ),//VNU_identifier |
|
490 | - 'post_date'=>current_time('mysql'),//VNU_created |
|
487 | + 'post_title'=> $this->_get_venue_title_for_event($old_event), //VNU_name |
|
488 | + 'post_content'=>'', //VNU_desc |
|
489 | + 'post_name'=> $this->_find_unique_slug($old_event['venue_title'], sanitize_title('venue-of-'.$old_event['event_name'])), //VNU_identifier |
|
490 | + 'post_date'=>current_time('mysql'), //VNU_created |
|
491 | 491 | 'post_date_gmt'=>get_gmt_from_date(current_time('mysql')), |
492 | - 'post_excerpt'=>'',//VNU_short_desc arbitraty only 50 characters |
|
493 | - 'post_modified'=>current_time('mysql'),//VNU_modified |
|
492 | + 'post_excerpt'=>'', //VNU_short_desc arbitraty only 50 characters |
|
493 | + 'post_modified'=>current_time('mysql'), //VNU_modified |
|
494 | 494 | 'post_modified_gmt'=>get_gmt_from_date(current_time('mysql')), |
495 | - 'post_author'=>$old_event['wp_user'],//VNU_wp_user |
|
496 | - 'post_parent'=>0,//parent |
|
497 | - 'menu_order'=>0,//VNU_order |
|
495 | + 'post_author'=>$old_event['wp_user'], //VNU_wp_user |
|
496 | + 'post_parent'=>0, //parent |
|
497 | + 'menu_order'=>0, //VNU_order |
|
498 | 498 | 'post_type'=>'espresso_venues'//post_type |
499 | 499 | ); |
500 | 500 | $datatypes_array = array( |
501 | - '%s',//VNU_name |
|
502 | - '%s',//VNU_desc |
|
503 | - '%s',//VNU_identifier |
|
504 | - '%s',//VNU_created |
|
501 | + '%s', //VNU_name |
|
502 | + '%s', //VNU_desc |
|
503 | + '%s', //VNU_identifier |
|
504 | + '%s', //VNU_created |
|
505 | 505 | '%s', |
506 | - '%s',//VNU_short_desc |
|
507 | - '%s',//VNU_modified |
|
506 | + '%s', //VNU_short_desc |
|
507 | + '%s', //VNU_modified |
|
508 | 508 | '%s', |
509 | - '%d',//VNU_wp_user |
|
510 | - '%d',//parent |
|
511 | - '%d',//VNU_order |
|
512 | - '%s',//post_type |
|
509 | + '%d', //VNU_wp_user |
|
510 | + '%d', //parent |
|
511 | + '%d', //VNU_order |
|
512 | + '%s', //post_type |
|
513 | 513 | ); |
514 | 514 | $success = $wpdb->insert($wpdb->posts, |
515 | 515 | $insertion_array, |
516 | 516 | $datatypes_array); |
517 | - if( ! $success ){ |
|
517 | + if ( ! $success) { |
|
518 | 518 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array)); |
519 | 519 | return 0; |
520 | 520 | } |
@@ -527,78 +527,78 @@ discard block |
||
527 | 527 | * @param type $old_event |
528 | 528 | * @return int |
529 | 529 | */ |
530 | - private function _insert_venue_into_meta_table($cpt_id,$old_event){ |
|
530 | + private function _insert_venue_into_meta_table($cpt_id, $old_event) { |
|
531 | 531 | global $wpdb; |
532 | 532 | |
533 | 533 | //assume the country is the same as the organization's old settings |
534 | 534 | $country_iso = $this->get_migration_script()->get_default_country_iso(); |
535 | 535 | //find the state from the venue, or the organization, or just guess california |
536 | - if( ! $old_event['state']){ |
|
536 | + if ( ! $old_event['state']) { |
|
537 | 537 | $old_org_options = get_option('events_organization_settings'); |
538 | 538 | $state_name = stripslashes($old_org_options['organization_state']); |
539 | - }else{ |
|
539 | + } else { |
|
540 | 540 | $state_name = $old_event['state']; |
541 | 541 | } |
542 | - if ( ! $state_name ){ |
|
542 | + if ( ! $state_name) { |
|
543 | 543 | $state_name = 'CA'; |
544 | 544 | } |
545 | 545 | //get a state ID with the same name, if possible |
546 | - try{ |
|
547 | - $state = $this->get_migration_script()->get_or_create_state($state_name,$country_iso); |
|
546 | + try { |
|
547 | + $state = $this->get_migration_script()->get_or_create_state($state_name, $country_iso); |
|
548 | 548 | $state_id = $state['STA_ID']; |
549 | - }catch(EE_Error $e){ |
|
549 | + } catch (EE_Error $e) { |
|
550 | 550 | $this->add_error($e->getMessage()); |
551 | 551 | $state_id = 0; |
552 | 552 | } |
553 | 553 | //now insert into meta table |
554 | 554 | $insertion_array = array( |
555 | - 'VNU_ID'=>$cpt_id,//VNU_ID_fk |
|
556 | - 'VNU_address'=>stripslashes($old_event['address']),//VNU_address |
|
557 | - 'VNU_address2'=>stripslashes($old_event['address2']),//VNU_address2 |
|
558 | - 'VNU_city'=>stripslashes($old_event['city']),//VNU_city |
|
559 | - 'STA_ID'=>$state_id,//STA_ID |
|
560 | - 'CNT_ISO'=>$country_iso,//CNT_ISO |
|
561 | - 'VNU_zip'=>$old_event['zip'],//VNU_zip |
|
562 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
563 | - 'VNU_capacity'=>-1,//VNU_capacity |
|
564 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
565 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
566 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
567 | - 'VNU_google_map_link'=>'',//VNU_google_map_link |
|
555 | + 'VNU_ID'=>$cpt_id, //VNU_ID_fk |
|
556 | + 'VNU_address'=>stripslashes($old_event['address']), //VNU_address |
|
557 | + 'VNU_address2'=>stripslashes($old_event['address2']), //VNU_address2 |
|
558 | + 'VNU_city'=>stripslashes($old_event['city']), //VNU_city |
|
559 | + 'STA_ID'=>$state_id, //STA_ID |
|
560 | + 'CNT_ISO'=>$country_iso, //CNT_ISO |
|
561 | + 'VNU_zip'=>$old_event['zip'], //VNU_zip |
|
562 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
563 | + 'VNU_capacity'=>-1, //VNU_capacity |
|
564 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
565 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
566 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
567 | + 'VNU_google_map_link'=>'', //VNU_google_map_link |
|
568 | 568 | 'VNU_enable_for_gmap'=>true //VNU_enable_for_gmap |
569 | 569 | ); |
570 | 570 | $datatypes = array( |
571 | - '%d',//VNU_ID_fk |
|
572 | - '%s',//VNU_address |
|
573 | - '%s',//VNU_address2 |
|
574 | - '%s',//VNU_city |
|
575 | - '%d',//STA_ID |
|
576 | - '%s',//CNT_ISO |
|
577 | - '%s',//VNU_zip |
|
578 | - '%s',//VNU_phone |
|
579 | - '%d',//VNU_capacity |
|
580 | - '%s',//VNU_url |
|
581 | - '%s',//VNU_virtual_phone |
|
582 | - '%s',//VNU_virtual_url |
|
583 | - '%s',//VNU_google_map_link |
|
584 | - '%d',//VNU_enable_for_gmap |
|
571 | + '%d', //VNU_ID_fk |
|
572 | + '%s', //VNU_address |
|
573 | + '%s', //VNU_address2 |
|
574 | + '%s', //VNU_city |
|
575 | + '%d', //STA_ID |
|
576 | + '%s', //CNT_ISO |
|
577 | + '%s', //VNU_zip |
|
578 | + '%s', //VNU_phone |
|
579 | + '%d', //VNU_capacity |
|
580 | + '%s', //VNU_url |
|
581 | + '%s', //VNU_virtual_phone |
|
582 | + '%s', //VNU_virtual_url |
|
583 | + '%s', //VNU_google_map_link |
|
584 | + '%d', //VNU_enable_for_gmap |
|
585 | 585 | ); |
586 | - $success = $wpdb->insert($wpdb->prefix."esp_venue_meta",$insertion_array,$datatypes); |
|
587 | - if( ! $success ){ |
|
586 | + $success = $wpdb->insert($wpdb->prefix."esp_venue_meta", $insertion_array, $datatypes); |
|
587 | + if ( ! $success) { |
|
588 | 588 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $insertion_array, $datatypes)); |
589 | 589 | return 0; |
590 | 590 | } |
591 | 591 | return $wpdb->insert_id; |
592 | 592 | } |
593 | 593 | |
594 | - private function _insert_new_venue_to_event($new_event_id,$new_venue_id){ |
|
594 | + private function _insert_new_venue_to_event($new_event_id, $new_venue_id) { |
|
595 | 595 | global $wpdb; |
596 | - if( ! $new_event_id){ |
|
597 | - $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"),$new_event_id)); |
|
596 | + if ( ! $new_event_id) { |
|
597 | + $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $new_event_id)); |
|
598 | 598 | return 0; |
599 | 599 | } |
600 | - if( ! $new_venue_id){ |
|
601 | - $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"),$new_venue_id)); |
|
600 | + if ( ! $new_venue_id) { |
|
601 | + $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $new_venue_id)); |
|
602 | 602 | return 0; |
603 | 603 | } |
604 | 604 | $cols_n_values = array( |
@@ -607,12 +607,12 @@ discard block |
||
607 | 607 | 'EVV_primary'=>true |
608 | 608 | ); |
609 | 609 | $datatypes = array( |
610 | - '%d',//EVT_ID |
|
611 | - '%d',//VNU_ID |
|
612 | - '%d',//EVT_primary |
|
610 | + '%d', //EVT_ID |
|
611 | + '%d', //VNU_ID |
|
612 | + '%d', //EVT_primary |
|
613 | 613 | ); |
614 | - $success = $wpdb->insert($wpdb->prefix."esp_event_venue",$cols_n_values,$datatypes); |
|
615 | - if ( ! $success){ |
|
614 | + $success = $wpdb->insert($wpdb->prefix."esp_event_venue", $cols_n_values, $datatypes); |
|
615 | + if ( ! $success) { |
|
616 | 616 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_venue_rel, $this->_new_table, $cols_n_values, $datatypes)); |
617 | 617 | return 0; |
618 | 618 | } |
@@ -626,11 +626,11 @@ discard block |
||
626 | 626 | * @param int $new_cpt_id new post ID |
627 | 627 | * @return void (if there are errors though, adds them to the stage's error list |
628 | 628 | */ |
629 | - private function _convert_start_end_times($old_event,$new_cpt_id){ |
|
629 | + private function _convert_start_end_times($old_event, $new_cpt_id) { |
|
630 | 630 | $start_end_times = $this->_get_old_start_end_times($old_event['id']); |
631 | - foreach($start_end_times as $start_end_time){ |
|
632 | - $datetime_id = $this->_insert_new_datetime($start_end_time,$old_event,$new_cpt_id); |
|
633 | - if($datetime_id){ |
|
631 | + foreach ($start_end_times as $start_end_time) { |
|
632 | + $datetime_id = $this->_insert_new_datetime($start_end_time, $old_event, $new_cpt_id); |
|
633 | + if ($datetime_id) { |
|
634 | 634 | $this->get_migration_script()->set_mapping($this->_old_start_end_table, $start_end_time['id'], $this->_new_datetime_table, $datetime_id); |
635 | 635 | } |
636 | 636 | } |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | * @param type $old_event_id |
642 | 642 | * @return type |
643 | 643 | */ |
644 | - private function _get_old_start_end_times($old_event_id){ |
|
644 | + private function _get_old_start_end_times($old_event_id) { |
|
645 | 645 | global $wpdb; |
646 | - return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d",$old_event_id),ARRAY_A); |
|
646 | + return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d", $old_event_id), ARRAY_A); |
|
647 | 647 | } |
648 | 648 | /** |
649 | 649 | * Inserts a 4.1 datetime given the 3.1 start_end db row and event_details row |
@@ -652,40 +652,40 @@ discard block |
||
652 | 652 | * @param type $new_cpt_id |
653 | 653 | * @return int ID of new datetime |
654 | 654 | */ |
655 | - private function _insert_new_datetime($start_end_time_row,$old_event_row,$new_cpt_id){ |
|
655 | + private function _insert_new_datetime($start_end_time_row, $old_event_row, $new_cpt_id) { |
|
656 | 656 | global $wpdb; |
657 | 657 | $start_date = $old_event_row['start_date']; |
658 | 658 | $start_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['start_time']); |
659 | 659 | $end_date = $old_event_row['end_date']; |
660 | 660 | $end_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['end_time']); |
661 | 661 | $existing_datetimes = $this->_count_other_datetimes_exist_for_new_event($new_cpt_id); |
662 | - $start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$start_date $start_time:00",$old_event_row['timezone_string']); |
|
663 | - $end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$end_date $end_time:00",$old_event_row['timezone_string']); |
|
662 | + $start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$start_date $start_time:00", $old_event_row['timezone_string']); |
|
663 | + $end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$end_date $end_time:00", $old_event_row['timezone_string']); |
|
664 | 664 | $cols_n_values = array( |
665 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID |
|
666 | - 'DTT_EVT_start'=>$start_datetime_utc,//DTT_EVT_start |
|
667 | - 'DTT_EVT_end'=> $end_datetime_utc,//DTT_EVT_end |
|
668 | - 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'],//DTT_reg_limit |
|
669 | - 'DTT_sold'=>0,//note: we will increment this as registrations are added during the migration |
|
665 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID |
|
666 | + 'DTT_EVT_start'=>$start_datetime_utc, //DTT_EVT_start |
|
667 | + 'DTT_EVT_end'=> $end_datetime_utc, //DTT_EVT_end |
|
668 | + 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'], //DTT_reg_limit |
|
669 | + 'DTT_sold'=>0, //note: we will increment this as registrations are added during the migration |
|
670 | 670 | // 'DTT_is_primary'=> 0 == $existing_datetimes ,//DTT_is_primary... if count==0, then we'll call it the 'primary' |
671 | - 'DTT_order'=> $existing_datetimes,//DTT_order, just give it the same order as the count of how many datetimes already exist |
|
671 | + 'DTT_order'=> $existing_datetimes, //DTT_order, just give it the same order as the count of how many datetimes already exist |
|
672 | 672 | 'DTT_parent'=>0, |
673 | 673 | 'DTT_deleted'=>false |
674 | 674 | ); |
675 | 675 | $datatypes = array( |
676 | - '%d',//EVT_Id |
|
677 | - '%s',//DTT_EVT_start |
|
678 | - '%s',//DTT_EVT_end |
|
679 | - '%d',//DTT_reg_limit |
|
680 | - '%d',//DTT_sold |
|
676 | + '%d', //EVT_Id |
|
677 | + '%s', //DTT_EVT_start |
|
678 | + '%s', //DTT_EVT_end |
|
679 | + '%d', //DTT_reg_limit |
|
680 | + '%d', //DTT_sold |
|
681 | 681 | // '%d',//DTT_is_primary |
682 | - '%d',//DTT_order |
|
683 | - '%d',//DTT_parent |
|
684 | - '%d',//DTT_deleted |
|
682 | + '%d', //DTT_order |
|
683 | + '%d', //DTT_parent |
|
684 | + '%d', //DTT_deleted |
|
685 | 685 | ); |
686 | - $success = $wpdb->insert($this->_new_datetime_table,$cols_n_values,$datatypes); |
|
687 | - if ( ! $success){ |
|
688 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row,$start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes)); |
|
686 | + $success = $wpdb->insert($this->_new_datetime_table, $cols_n_values, $datatypes); |
|
687 | + if ( ! $success) { |
|
688 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row, $start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes)); |
|
689 | 689 | return 0; |
690 | 690 | } |
691 | 691 | return $wpdb->insert_id; |
@@ -698,9 +698,9 @@ discard block |
||
698 | 698 | * @param type $cpt_event_id |
699 | 699 | * @return int |
700 | 700 | */ |
701 | - private function _count_other_datetimes_exist_for_new_event($cpt_event_id){ |
|
701 | + private function _count_other_datetimes_exist_for_new_event($cpt_event_id) { |
|
702 | 702 | global $wpdb; |
703 | - $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d",$cpt_event_id)); |
|
703 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d", $cpt_event_id)); |
|
704 | 704 | return intval($count); |
705 | 705 | } |
706 | 706 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,32 +25,32 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEM_Currency extends EEM_Base{ |
|
28 | +class EEM_Currency extends EEM_Base { |
|
29 | 29 | // private instance of the Attendee object |
30 | 30 | protected static $_instance = NULL; |
31 | 31 | |
32 | - protected function __construct( $timezone = NULL ) { |
|
33 | - $this->singular_item = __('Currency','event_espresso'); |
|
34 | - $this->plural_item = __('Currencies','event_espresso'); |
|
32 | + protected function __construct($timezone = NULL) { |
|
33 | + $this->singular_item = __('Currency', 'event_espresso'); |
|
34 | + $this->plural_item = __('Currencies', 'event_espresso'); |
|
35 | 35 | $this->_tables = array( |
36 | 36 | 'Currency'=> new EE_Primary_Table('esp_currency', 'CUR_code') |
37 | 37 | ); |
38 | 38 | $this->_fields = array( |
39 | 39 | 'Currency'=>array( |
40 | - 'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code','event_espresso')), |
|
41 | - 'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular','event_espresso'), false), |
|
42 | - 'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural','event_espresso'), false), |
|
43 | - 'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign','event_espresso'), false), |
|
44 | - 'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places','event_espresso'), false, 2), |
|
45 | - 'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false,true), |
|
40 | + 'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')), |
|
41 | + 'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false), |
|
42 | + 'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false), |
|
43 | + 'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false), |
|
44 | + 'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2), |
|
45 | + 'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true), |
|
46 | 46 | )); |
47 | 47 | $this->_model_relations = array( |
48 | 48 | 'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'), |
49 | 49 | ); |
50 | 50 | //this model is generally available for reading |
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
51 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
52 | 52 | |
53 | - parent::__construct( $timezone ); |
|
53 | + parent::__construct($timezone); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * @param array $query_params see EEM_Base::get_all |
60 | 60 | * @return EE_Currency[] |
61 | 61 | */ |
62 | - public function get_all_active($query_params = array()){ |
|
62 | + public function get_all_active($query_params = array()) { |
|
63 | 63 | $query_params[0]['CUR_active'] = true; |
64 | - if( ! isset($query_params['order_by'])){ |
|
65 | - $query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC'); |
|
64 | + if ( ! isset($query_params['order_by'])) { |
|
65 | + $query_params['order_by'] = array('CUR_code'=>'ASC', 'CUR_single'=>'ASC'); |
|
66 | 66 | } |
67 | 67 | return $this->get_all($query_params); |
68 | 68 | } |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | * @param EE_PMT_Base $payment_method_type |
72 | 72 | * @return EE_Currency[] |
73 | 73 | */ |
74 | - public function get_all_currencies_usable_by($payment_method_type){ |
|
75 | - if($payment_method_type instanceof EE_PMT_Base && |
|
76 | - $payment_method_type->get_gateway()){ |
|
74 | + public function get_all_currencies_usable_by($payment_method_type) { |
|
75 | + if ($payment_method_type instanceof EE_PMT_Base && |
|
76 | + $payment_method_type->get_gateway()) { |
|
77 | 77 | $currencies_supported = $payment_method_type->get_gateway()->currencies_supported(); |
78 | - }else{ |
|
78 | + } else { |
|
79 | 79 | $currencies_supported = EE_Gateway::all_currencies_supported; |
80 | 80 | } |
81 | - if($currencies_supported == EE_Gateway::all_currencies_supported || empty( $currencies_supported ) ) { |
|
81 | + if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) { |
|
82 | 82 | $currencies = $this->get_all_active(); |
83 | - }else{ |
|
84 | - $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported)))); |
|
83 | + } else { |
|
84 | + $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN', $currencies_supported)))); |
|
85 | 85 | } |
86 | 86 | return $currencies; |
87 | 87 | } |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | * @param array $ee_gmaps_opts array of attributes required for the map link generation |
22 | 22 | * @return string (link to map!) |
23 | 23 | */ |
24 | - public static function google_map( $ee_gmaps_opts ){ |
|
25 | - |
|
26 | - $ee_map_width = isset( $ee_gmaps_opts['ee_map_width'] ) && ! empty( $ee_gmaps_opts['ee_map_width'] ) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
27 | - $ee_map_height = isset( $ee_gmaps_opts['ee_map_height'] ) && ! empty( $ee_gmaps_opts['ee_map_height'] ) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
28 | - $ee_map_zoom = isset( $ee_gmaps_opts['ee_map_zoom'] ) && ! empty( $ee_gmaps_opts['ee_map_zoom'] ) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
29 | - $ee_map_nav_display = isset( $ee_gmaps_opts['ee_map_nav_display'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_display'] ) ? 'true' : 'false'; |
|
30 | - $ee_map_nav_size = isset( $ee_gmaps_opts['ee_map_nav_size'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_size'] )? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
31 | - $ee_map_type_control = isset( $ee_gmaps_opts['ee_map_type_control'] ) && ! empty( $ee_gmaps_opts['ee_map_type_control'] )? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
32 | - $static_url = isset( $ee_gmaps_opts['ee_static_url'] ) && ! empty( $ee_gmaps_opts['ee_static_url'] )? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
33 | - |
|
34 | - if( isset( $ee_gmaps_opts['ee_map_align'] ) && ! empty( $ee_gmaps_opts['ee_map_align'] )){ |
|
35 | - switch( $ee_gmaps_opts['ee_map_align'] ){ |
|
24 | + public static function google_map($ee_gmaps_opts) { |
|
25 | + |
|
26 | + $ee_map_width = isset($ee_gmaps_opts['ee_map_width']) && ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
27 | + $ee_map_height = isset($ee_gmaps_opts['ee_map_height']) && ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
28 | + $ee_map_zoom = isset($ee_gmaps_opts['ee_map_zoom']) && ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
29 | + $ee_map_nav_display = isset($ee_gmaps_opts['ee_map_nav_display']) && ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
30 | + $ee_map_nav_size = isset($ee_gmaps_opts['ee_map_nav_size']) && ! empty($ee_gmaps_opts['ee_map_nav_size']) ? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
31 | + $ee_map_type_control = isset($ee_gmaps_opts['ee_map_type_control']) && ! empty($ee_gmaps_opts['ee_map_type_control']) ? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
32 | + $static_url = isset($ee_gmaps_opts['ee_static_url']) && ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
33 | + |
|
34 | + if (isset($ee_gmaps_opts['ee_map_align']) && ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
35 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
36 | 36 | case "left": |
37 | 37 | $map_align = 'ee-gmap-align-left left'; |
38 | 38 | break; |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | |
54 | 54 | // Determine whether user has set a hardoded url to use and |
55 | 55 | // if so display a Google static iframe map else run V3 api |
56 | - if( $static_url ) { |
|
56 | + if ($static_url) { |
|
57 | 57 | |
58 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
59 | - $html .= '<iframe src="' . $static_url . '&output=embed" style="width: ' . $ee_map_width .'px; height: ' . $ee_map_height . 'px;" frameborder="0" scrolling="no">'; |
|
58 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
59 | + $html .= '<iframe src="'.$static_url.'&output=embed" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;" frameborder="0" scrolling="no">'; |
|
60 | 60 | $html .= '</iframe>'; |
61 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
61 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
62 | 62 | $html .= '</div>'; |
63 | 63 | return $html; |
64 | 64 | |
65 | 65 | } else { |
66 | 66 | |
67 | - EEH_Maps::$gmap_vars[ $ee_gmaps_opts['map_ID'] ] = array( |
|
67 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
68 | 68 | 'map_ID' => $ee_gmaps_opts['map_ID'], |
69 | 69 | 'ee_map_zoom' => $ee_map_zoom, |
70 | 70 | 'ee_map_nav_display' => $ee_map_nav_display, |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | ); |
75 | 75 | |
76 | 76 | $html = '<div class="ee-gmap-wrapper '.$map_align.';">'; |
77 | - $html .= '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] .'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
77 | + $html .= '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
78 | 78 | $html .= '</div>'; |
79 | 79 | |
80 | - wp_enqueue_script( 'gmap_api' ); |
|
81 | - wp_enqueue_script( 'ee_gmap' ); |
|
82 | - add_action( 'wp_footer', array( 'EEH_Maps', 'footer_enqueue_script' )); |
|
80 | + wp_enqueue_script('gmap_api'); |
|
81 | + wp_enqueue_script('ee_gmap'); |
|
82 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
83 | 83 | |
84 | 84 | return $html; |
85 | 85 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return void |
95 | 95 | */ |
96 | 96 | public static function footer_enqueue_script() { |
97 | - wp_localize_script( 'ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars ); |
|
97 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | public static function espresso_google_map_js() { |
106 | 106 | $api_url = sprintf( |
107 | 107 | "https://maps.googleapis.com/maps/api/js?key=%s", |
108 | - apply_filters( 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', EE_Registry::instance()->CFG->map_settings->google_map_api_key ) |
|
108 | + apply_filters('FHEE__EEH_Maps__espresso_google_maps_js__api_key', EE_Registry::instance()->CFG->map_settings->google_map_api_key) |
|
109 | 109 | ); |
110 | - wp_register_script( 'gmap_api', $api_url, array('jquery'), NULL, TRUE ); |
|
111 | - wp_register_script( 'ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE ); |
|
110 | + wp_register_script('gmap_api', $api_url, array('jquery'), NULL, TRUE); |
|
111 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return string (link to map!) |
118 | 118 | */ |
119 | 119 | public static function google_map_link($atts) { |
120 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
120 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
121 | 121 | extract($atts); |
122 | 122 | /** @var string $address */ |
123 | 123 | /** @var string $city */ |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | $id = isset($id) ? $id : 'not_set'; |
137 | 137 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
138 | 138 | |
139 | - $address_string = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : ''); |
|
139 | + $address_string = ($address != '' ? $address : '').($city != '' ? ','.$city : '').($state != '' ? ','.$state : '').($zip != '' ? ','.$zip : '').($country != '' ? ','.$country : ''); |
|
140 | 140 | |
141 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode( $address_string )); |
|
141 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
142 | 142 | |
143 | 143 | switch ($type) { |
144 | 144 | case 'text': |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | case 'map': |
154 | 154 | $scheme = is_ssl() ? 'https://' : 'http://'; |
155 | 155 | |
156 | - $api_key = apply_filters( 'FHEE__EEH_Maps__espresso_google_maps_link__api_key', EE_Registry::instance()->CFG->map_settings->google_map_api_key ); |
|
156 | + $api_key = apply_filters('FHEE__EEH_Maps__espresso_google_maps_link__api_key', EE_Registry::instance()->CFG->map_settings->google_map_api_key); |
|
157 | 157 | |
158 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2( $scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode( $address_string ) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode( $address_string ) . '&sensor=false&key=' . $api_key ) . '" /></a>'; |
|
158 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false&key='.$api_key).'" /></a>'; |
|
159 | 159 | } |
160 | 160 | |
161 | - return '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
161 | + return '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 |
@@ -26,12 +26,12 @@ |
||
26 | 26 | <input type="text" id="ee-google-map-api-key" class="regular-text" name="google_map_api_key" value="<?php echo $map_settings->google_map_api_key; ?>" /> |
27 | 27 | <p class="description"> |
28 | 28 | <?php |
29 | - printf( |
|
30 | - __('An API key is now required to use the Google Maps API: %1$sclick here to get an API key%2$s', 'event_espresso'), |
|
31 | - '<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,static_maps_backend&keyType=CLIENT_SIDE&reusekey=true" target="_blank">', |
|
32 | - '</a>' |
|
33 | - ); |
|
34 | - ?> |
|
29 | + printf( |
|
30 | + __('An API key is now required to use the Google Maps API: %1$sclick here to get an API key%2$s', 'event_espresso'), |
|
31 | + '<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,static_maps_backend&keyType=CLIENT_SIDE&reusekey=true" target="_blank">', |
|
32 | + '</a>' |
|
33 | + ); |
|
34 | + ?> |
|
35 | 35 | </p> |
36 | 36 | </td> |
37 | 37 | </tr> |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | </td> |
16 | 16 | </tr> |
17 | 17 | <?php |
18 | - if( apply_filters( 'FHEE__google_map__show_api_key_input', true ) ) { ?> |
|
18 | + if (apply_filters('FHEE__google_map__show_api_key_input', true)) { ?> |
|
19 | 19 | <tr> |
20 | 20 | <th> |
21 | 21 | <label for="ee-google-map-api-key"> |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | <td> |
111 | 111 | <label for="event_details_control_type-default" class="ee-admin-radio-lbl"> |
112 | 112 | <?php $checked = $map_settings->event_details_control_type == 'default' ? 'checked="checked"' : ''; ?> |
113 | - <input id="event_details_control_type-default" type="radio" name="event_details_control_type" value="default"<?php echo $checked;?>/> |
|
113 | + <input id="event_details_control_type-default" type="radio" name="event_details_control_type" value="default"<?php echo $checked; ?>/> |
|
114 | 114 | <?php _e(' Default', 'event_espresso') ?> |
115 | 115 | </label> |
116 | 116 | |
117 | 117 | <label for="event_details_control_type-horizontal" class="ee-admin-radio-lbl"> |
118 | 118 | <?php $checked = $map_settings->event_details_control_type == 'horizontal' ? 'checked="checked"' : ''; ?> |
119 | - <input id="event_details_control_type-horizontal" type="radio" name="event_details_control_type" value="horizontal"<?php echo $checked;?>/> |
|
119 | + <input id="event_details_control_type-horizontal" type="radio" name="event_details_control_type" value="horizontal"<?php echo $checked; ?>/> |
|
120 | 120 | <?php _e(' Horizontal', 'event_espresso') ?> |
121 | 121 | </label> |
122 | 122 | |
123 | 123 | <label for="event_details_control_type-dropdown" class="ee-admin-radio-lbl"> |
124 | 124 | <?php $checked = $map_settings->event_details_control_type == 'dropdown' ? 'checked="checked"' : ''; ?> |
125 | - <input id="event_details_control_type-dropdown" type="radio" name="event_details_control_type" value="dropdown"<?php echo $checked;?>/> |
|
125 | + <input id="event_details_control_type-dropdown" type="radio" name="event_details_control_type" value="dropdown"<?php echo $checked; ?>/> |
|
126 | 126 | <?php _e(' Dropdown', 'event_espresso') ?> |
127 | 127 | </label> |
128 | 128 | </td> |
@@ -135,25 +135,25 @@ discard block |
||
135 | 135 | <td> |
136 | 136 | <label for="event_details_map_align-none" class="ee-admin-radio-lbl"> |
137 | 137 | <?php $checked = $map_settings->event_details_map_align == 'none' ? 'checked="checked"' : ''; ?> |
138 | - <input id="event_details_map_align-none" type="radio" name="event_details_map_align" value="none"<?php echo $checked;?>/> |
|
138 | + <input id="event_details_map_align-none" type="radio" name="event_details_map_align" value="none"<?php echo $checked; ?>/> |
|
139 | 139 | <?php _e(' None', 'event_espresso') ?> |
140 | 140 | </label> |
141 | 141 | |
142 | 142 | <label for="event_details_map_align-left" class="ee-admin-radio-lbl"> |
143 | 143 | <?php $checked = $map_settings->event_details_map_align == 'left' ? 'checked="checked"' : ''; ?> |
144 | - <input id="event_details_map_align-left" type="radio" name="event_details_map_align" value="left"<?php echo $checked;?>/> |
|
144 | + <input id="event_details_map_align-left" type="radio" name="event_details_map_align" value="left"<?php echo $checked; ?>/> |
|
145 | 145 | <?php _e(' Align Left', 'event_espresso') ?> |
146 | 146 | </label> |
147 | 147 | |
148 | 148 | <label for="event_details_map_align-center" class="ee-admin-radio-lbl"> |
149 | 149 | <?php $checked = $map_settings->event_details_map_align == 'center' ? 'checked="checked"' : ''; ?> |
150 | - <input id="event_details_map_align-center" type="radio" name="event_details_map_align" value="center"<?php echo $checked;?>/> |
|
150 | + <input id="event_details_map_align-center" type="radio" name="event_details_map_align" value="center"<?php echo $checked; ?>/> |
|
151 | 151 | <?php _e(' Align Center', 'event_espresso') ?> |
152 | 152 | </label> |
153 | 153 | |
154 | 154 | <label for="event_details_map_align-right" class="ee-admin-radio-lbl"> |
155 | 155 | <?php $checked = $map_settings->event_details_map_align == 'right' ? 'checked="checked"' : ''; ?> |
156 | - <input id="event_details_map_align-right" type="radio" name="event_details_map_align" value="right"<?php echo $checked;?>/> |
|
156 | + <input id="event_details_map_align-right" type="radio" name="event_details_map_align" value="right"<?php echo $checked; ?>/> |
|
157 | 157 | <?php _e(' Align Right', 'event_espresso') ?> |
158 | 158 | </label> |
159 | 159 | </td> |
@@ -228,19 +228,19 @@ discard block |
||
228 | 228 | <td> |
229 | 229 | <label for="event_list_control_type-default" class="ee-admin-radio-lbl"> |
230 | 230 | <?php $checked = $map_settings->event_list_control_type == 'default' ? 'checked="checked"' : ''; ?> |
231 | - <input id="event_list_control_type-default" type="radio" name="event_list_control_type" value="default"<?php echo $checked;?>/> |
|
231 | + <input id="event_list_control_type-default" type="radio" name="event_list_control_type" value="default"<?php echo $checked; ?>/> |
|
232 | 232 | <?php _e(' Default', 'event_espresso') ?> |
233 | 233 | </label> |
234 | 234 | |
235 | 235 | <label for="event_list_control_type-horizontal" class="ee-admin-radio-lbl"> |
236 | 236 | <?php $checked = $map_settings->event_list_control_type == 'horizontal' ? 'checked="checked"' : ''; ?> |
237 | - <input id="event_list_control_type-horizontal" type="radio" name="event_list_control_type" value="horizontal"<?php echo $checked;?>/> |
|
237 | + <input id="event_list_control_type-horizontal" type="radio" name="event_list_control_type" value="horizontal"<?php echo $checked; ?>/> |
|
238 | 238 | <?php _e(' Horizontal', 'event_espresso') ?> |
239 | 239 | </label> |
240 | 240 | |
241 | 241 | <label for="event_list_control_type-dropdown" class="ee-admin-radio-lbl"> |
242 | 242 | <?php $checked = $map_settings->event_list_control_type == 'dropdown' ? 'checked="checked"' : ''; ?> |
243 | - <input id="event_list_control_type-dropdown" type="radio" name="event_list_control_type" value="dropdown"<?php echo $checked;?>/> |
|
243 | + <input id="event_list_control_type-dropdown" type="radio" name="event_list_control_type" value="dropdown"<?php echo $checked; ?>/> |
|
244 | 244 | <?php _e(' Dropdown', 'event_espresso') ?> |
245 | 245 | </label> |
246 | 246 | |
@@ -254,25 +254,25 @@ discard block |
||
254 | 254 | <td> |
255 | 255 | <label for="event_list_map_align-none" class="ee-admin-radio-lbl"> |
256 | 256 | <?php $checked = $map_settings->event_list_map_align == 'none' ? 'checked="checked"' : ''; ?> |
257 | - <input id="event_list_map_align-none" type="radio" name="event_list_map_align" value="none"<?php echo $checked;?>/> |
|
257 | + <input id="event_list_map_align-none" type="radio" name="event_list_map_align" value="none"<?php echo $checked; ?>/> |
|
258 | 258 | <?php _e(' None', 'event_espresso') ?> |
259 | 259 | </label> |
260 | 260 | |
261 | 261 | <label for="event_list_map_align-left" class="ee-admin-radio-lbl"> |
262 | 262 | <?php $checked = $map_settings->event_list_map_align == 'left' ? 'checked="checked"' : ''; ?> |
263 | - <input id="event_list_map_align-left" type="radio" name="event_list_map_align" value="left"<?php echo $checked;?>/> |
|
263 | + <input id="event_list_map_align-left" type="radio" name="event_list_map_align" value="left"<?php echo $checked; ?>/> |
|
264 | 264 | <?php _e(' Align Left', 'event_espresso') ?> |
265 | 265 | </label> |
266 | 266 | |
267 | 267 | <label for="event_list_map_align-center" class="ee-admin-radio-lbl"> |
268 | 268 | <?php $checked = $map_settings->event_list_map_align == 'center' ? 'checked="checked"' : ''; ?> |
269 | - <input id="event_list_map_align-center" type="radio" name="event_list_map_align" value="center"<?php echo $checked;?>/> |
|
269 | + <input id="event_list_map_align-center" type="radio" name="event_list_map_align" value="center"<?php echo $checked; ?>/> |
|
270 | 270 | <?php _e(' Align Center', 'event_espresso') ?> |
271 | 271 | </label> |
272 | 272 | |
273 | 273 | <label for="event_list_map_align-right" class="ee-admin-radio-lbl"> |
274 | 274 | <?php $checked = $map_settings->event_list_map_align == 'right' ? 'checked="checked"' : ''; ?> |
275 | - <input id="event_list_map_align-right" type="radio" name="event_list_map_align" value="right"<?php echo $checked;?>/> |
|
275 | + <input id="event_list_map_align-right" type="radio" name="event_list_map_align" value="right"<?php echo $checked; ?>/> |
|
276 | 276 | <?php _e(' Align Right', 'event_espresso') ?> |
277 | 277 | </label> |
278 | 278 |