@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | /** |
421 | 421 | * @param $old_event |
422 | - * @param $new_cpt_id |
|
422 | + * @param integer $new_cpt_id |
|
423 | 423 | * @return int |
424 | 424 | */ |
425 | 425 | private function _insert_event_meta( $old_event, $new_cpt_id){ |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | |
677 | 677 | |
678 | 678 | /** |
679 | - * @param $new_event_id |
|
680 | - * @param $new_venue_id |
|
679 | + * @param integer $new_event_id |
|
680 | + * @param integer $new_venue_id |
|
681 | 681 | * @return int |
682 | 682 | */ |
683 | 683 | private function _insert_new_venue_to_event( $new_event_id, $new_venue_id){ |
@@ -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; |
@@ -205,43 +205,43 @@ discard block |
||
205 | 205 | * @param int $num_items_to_migrate |
206 | 206 | * @return int number of items ACTUALLY migrated |
207 | 207 | */ |
208 | - protected function _migration_step( $num_items_to_migrate = 50) { |
|
208 | + protected function _migration_step($num_items_to_migrate = 50) { |
|
209 | 209 | global $wpdb; |
210 | 210 | //because the migration of each event can be a LOT more work, make each step smaller |
211 | - $num_items_to_migrate = max(1,$num_items_to_migrate/5); |
|
212 | - $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d",$this->count_records_migrated(),$num_items_to_migrate),ARRAY_A); |
|
211 | + $num_items_to_migrate = max(1, $num_items_to_migrate / 5); |
|
212 | + $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $this->count_records_migrated(), $num_items_to_migrate), ARRAY_A); |
|
213 | 213 | $items_migrated_this_step = 0; |
214 | 214 | |
215 | - foreach($events as $event_row){ |
|
215 | + foreach ($events as $event_row) { |
|
216 | 216 | $guid = null; |
217 | 217 | //insert new 4.1 Attendee object using $wpdb |
218 | 218 | $post_id = $this->_insert_cpt($event_row); |
219 | - if($post_id){ |
|
219 | + if ($post_id) { |
|
220 | 220 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_table, $post_id); |
221 | 221 | $meta_id = $this->_insert_event_meta($event_row, $post_id); |
222 | - if($meta_id){ |
|
222 | + if ($meta_id) { |
|
223 | 223 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_meta_table, $meta_id); |
224 | 224 | } |
225 | - $this->_convert_start_end_times($event_row,$post_id); |
|
225 | + $this->_convert_start_end_times($event_row, $post_id); |
|
226 | 226 | $event_meta = maybe_unserialize($event_row['event_meta']); |
227 | 227 | $guid = isset($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : null; |
228 | - $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid,$post_id,$this); |
|
228 | + $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $post_id, $this); |
|
229 | 229 | |
230 | 230 | //maybe create a venue from info on the event? |
231 | 231 | $new_venue_id = $this->_maybe_create_venue($event_row); |
232 | - if($new_venue_id){ |
|
233 | - $this->_insert_new_venue_to_event($post_id,$new_venue_id); |
|
232 | + if ($new_venue_id) { |
|
233 | + $this->_insert_new_venue_to_event($post_id, $new_venue_id); |
|
234 | 234 | } |
235 | 235 | $this->_add_post_metas($event_row, $post_id); |
236 | 236 | } |
237 | 237 | $items_migrated_this_step++; |
238 | - if($guid){ |
|
238 | + if ($guid) { |
|
239 | 239 | //if we had to check for an image attachment |
240 | 240 | //then let's call it a day (avoid timing out, because this took a long time) |
241 | 241 | break; |
242 | 242 | } |
243 | 243 | } |
244 | - if($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()){ |
|
244 | + if ($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()) { |
|
245 | 245 | $this->set_status(EE_Data_Migration_Manager::status_completed); |
246 | 246 | } |
247 | 247 | return $items_migrated_this_step; |
@@ -253,28 +253,28 @@ discard block |
||
253 | 253 | * @param int $post_id |
254 | 254 | * @return void |
255 | 255 | */ |
256 | - private function _add_post_metas($old_event,$post_id){ |
|
256 | + private function _add_post_metas($old_event, $post_id) { |
|
257 | 257 | $event_meta = maybe_unserialize($old_event['event_meta']); |
258 | - if( ! $event_meta || ! is_array( $event_meta ) ){ |
|
258 | + if ( ! $event_meta || ! is_array($event_meta)) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | - unset($event_meta['date_submitted']);//factored into CPT |
|
262 | - unset($event_meta['additional_attendee_reg_info']);//factored into event meta table |
|
263 | - unset($event_meta['default_payment_status']);//dido |
|
264 | - unset($event_meta['event_thumbnail_url']);//used to find post featured image |
|
265 | - foreach($event_meta as $meta_key => $meta_value){ |
|
266 | - if ($meta_key){//if the meta key is just an empty string, ignore it |
|
267 | - $success = add_post_meta($post_id,$meta_key,$meta_value,true); |
|
268 | - if( ! $success ){ |
|
269 | - $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))); |
|
261 | + unset($event_meta['date_submitted']); //factored into CPT |
|
262 | + unset($event_meta['additional_attendee_reg_info']); //factored into event meta table |
|
263 | + unset($event_meta['default_payment_status']); //dido |
|
264 | + unset($event_meta['event_thumbnail_url']); //used to find post featured image |
|
265 | + foreach ($event_meta as $meta_key => $meta_value) { |
|
266 | + if ($meta_key) {//if the meta key is just an empty string, ignore it |
|
267 | + $success = add_post_meta($post_id, $meta_key, $meta_value, true); |
|
268 | + if ( ! $success) { |
|
269 | + $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))); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | } |
273 | - if($old_event['alt_email']){ |
|
274 | - add_post_meta($post_id,'alt_email',$old_event['alt_email']); |
|
273 | + if ($old_event['alt_email']) { |
|
274 | + add_post_meta($post_id, 'alt_email', $old_event['alt_email']); |
|
275 | 275 | } |
276 | - if($old_event['recurrence_id']){ |
|
277 | - add_post_meta($post_id,'recurrence_id',$old_event['recurrence_id']); |
|
276 | + if ($old_event['recurrence_id']) { |
|
277 | + add_post_meta($post_id, 'recurrence_id', $old_event['recurrence_id']); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * @param string $new_post_status a post status |
290 | 290 | * @return string |
291 | 291 | */ |
292 | - private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish'){ |
|
292 | + private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish') { |
|
293 | 293 | $count = 0; |
294 | 294 | $original_name = $event_name ? sanitize_title($event_name) : $old_identifier; |
295 | - return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0 ); |
|
295 | + return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | * @param string $slug |
302 | 302 | * @return boolean |
303 | 303 | */ |
304 | - private function _other_post_exists_with_that_slug($slug){ |
|
304 | + private function _other_post_exists_with_that_slug($slug) { |
|
305 | 305 | global $wpdb; |
306 | - $query = $wpdb->prepare("SELECT COUNT(ID) FROM {$this->_new_table} WHERE post_name = %s",$slug); |
|
306 | + $query = $wpdb->prepare("SELECT COUNT(ID) FROM {$this->_new_table} WHERE post_name = %s", $slug); |
|
307 | 307 | $count = $wpdb->get_var($query); |
308 | - return (boolean)intval($count); |
|
308 | + return (boolean) intval($count); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @param $old_event |
315 | 315 | * @return int |
316 | 316 | */ |
317 | - private function _insert_cpt( $old_event ){ |
|
317 | + private function _insert_cpt($old_event) { |
|
318 | 318 | global $wpdb; |
319 | 319 | //convert 3.1 event status to 4.1 CPT status |
320 | 320 | //for reference, 3.1 event stati available for setting are: |
@@ -333,66 +333,66 @@ discard block |
||
333 | 333 | // and 3 custom ones: cancelled,postponed,sold_out |
334 | 334 | $status_conversions = array( |
335 | 335 | 'R'=>'draft', |
336 | - 'X'=>'draft',//4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
336 | + 'X'=>'draft', //4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
337 | 337 | 'P'=>'pending', |
338 | - 'IA'=>'draft',//draft and in the past |
|
338 | + 'IA'=>'draft', //draft and in the past |
|
339 | 339 | //IA=inactive in 3.1: events were switched to this when they expired. in 4.1 that's just calculated |
340 | - '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' |
|
340 | + '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' |
|
341 | 341 | 'A'=>'publish', |
342 | - 'S'=>'draft',//@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
342 | + 'S'=>'draft', //@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
343 | 343 | 'D'=>'trash', |
344 | 344 | ); |
345 | 345 | $post_status = $status_conversions[$old_event['event_status']]; |
346 | 346 | //check if we've sold out |
347 | - if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])){ |
|
347 | + if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])) { |
|
348 | 348 | $post_status = 'sold_out'; |
349 | 349 | } |
350 | 350 | // FYI postponed and cancelled don't exist in 3.1 |
351 | 351 | $cols_n_values = array( |
352 | - 'post_title'=>stripslashes($old_event['event_name']),//EVT_name |
|
353 | - 'post_content'=>stripslashes($old_event['event_desc']),//EVT_desc |
|
354 | - 'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status ),//EVT_slug |
|
355 | - 'post_date'=>$old_event['submitted'],//EVT_created NOT |
|
352 | + 'post_title'=>stripslashes($old_event['event_name']), //EVT_name |
|
353 | + 'post_content'=>stripslashes($old_event['event_desc']), //EVT_desc |
|
354 | + 'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status), //EVT_slug |
|
355 | + 'post_date'=>$old_event['submitted'], //EVT_created NOT |
|
356 | 356 | 'post_date_gmt'=>get_gmt_from_date($old_event['submitted']), |
357 | - 'post_excerpt'=>'',//EVT_short_desc |
|
358 | - 'post_modified'=>$old_event['submitted'],//EVT_modified |
|
357 | + 'post_excerpt'=>'', //EVT_short_desc |
|
358 | + 'post_modified'=>$old_event['submitted'], //EVT_modified |
|
359 | 359 | 'post_modified_gmt'=>get_gmt_from_date($old_event['submitted']), |
360 | - 'post_author'=>$old_event['wp_user'],//EVT_wp_user |
|
361 | - 'post_parent'=>0,//parent maybe get this from some REM field? |
|
362 | - 'menu_order'=>0,//EVT_order |
|
363 | - 'post_type'=>'espresso_events',//post_type |
|
364 | - 'post_status'=>$post_status,//status |
|
360 | + 'post_author'=>$old_event['wp_user'], //EVT_wp_user |
|
361 | + 'post_parent'=>0, //parent maybe get this from some REM field? |
|
362 | + 'menu_order'=>0, //EVT_order |
|
363 | + 'post_type'=>'espresso_events', //post_type |
|
364 | + 'post_status'=>$post_status, //status |
|
365 | 365 | ); |
366 | 366 | $cols_n_values_with_no_invalid_text = array(); |
367 | - foreach( $cols_n_values as $col => $value ) { |
|
368 | - $value_sans_invalid_chars = $wpdb->strip_invalid_text_for_column( $this->_new_table, $col, $value ); |
|
369 | - if( ! is_wp_error( $value_sans_invalid_chars ) ) { |
|
370 | - $cols_n_values_with_no_invalid_text[ $col ] = $value_sans_invalid_chars; |
|
367 | + foreach ($cols_n_values as $col => $value) { |
|
368 | + $value_sans_invalid_chars = $wpdb->strip_invalid_text_for_column($this->_new_table, $col, $value); |
|
369 | + if ( ! is_wp_error($value_sans_invalid_chars)) { |
|
370 | + $cols_n_values_with_no_invalid_text[$col] = $value_sans_invalid_chars; |
|
371 | 371 | } else { |
372 | 372 | //otherwise leave it as-is. It will blow everything up and stop the migration |
373 | - $cols_n_values_with_no_invalid_text[ $col ] = $value; |
|
373 | + $cols_n_values_with_no_invalid_text[$col] = $value; |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | $cols_n_values = $cols_n_values_with_no_invalid_text; |
377 | 377 | $datatypes = array( |
378 | - '%s',//EVT_name |
|
379 | - '%s',//EVT_desc |
|
380 | - '%s',//EVT_slug |
|
381 | - '%s',//EVT_created |
|
378 | + '%s', //EVT_name |
|
379 | + '%s', //EVT_desc |
|
380 | + '%s', //EVT_slug |
|
381 | + '%s', //EVT_created |
|
382 | 382 | '%s', |
383 | - '%s',//EVT_short_desc |
|
384 | - '%s',//EVT_modified |
|
383 | + '%s', //EVT_short_desc |
|
384 | + '%s', //EVT_modified |
|
385 | 385 | '%s', |
386 | - '%s',//EVT_wp_user |
|
387 | - '%d',//post_parent |
|
388 | - '%d',//EVT_order |
|
389 | - '%s',//post_type |
|
390 | - '%s',//status |
|
386 | + '%s', //EVT_wp_user |
|
387 | + '%d', //post_parent |
|
388 | + '%d', //EVT_order |
|
389 | + '%s', //post_type |
|
390 | + '%s', //status |
|
391 | 391 | ); |
392 | 392 | $success = $wpdb->insert($this->_new_table, |
393 | 393 | $cols_n_values, |
394 | 394 | $datatypes); |
395 | - if( ! $success ){ |
|
395 | + if ( ! $success) { |
|
396 | 396 | $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)); |
397 | 397 | return 0; |
398 | 398 | } |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | * @param int $event_id |
406 | 406 | * @return int |
407 | 407 | */ |
408 | - public static function count_registrations($event_id){ |
|
408 | + public static function count_registrations($event_id) { |
|
409 | 409 | global $wpdb; |
410 | - $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d",$event_id)); |
|
410 | + $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d", $event_id)); |
|
411 | 411 | return intval($count); |
412 | 412 | } |
413 | 413 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @param $new_cpt_id |
419 | 419 | * @return int |
420 | 420 | */ |
421 | - private function _insert_event_meta( $old_event, $new_cpt_id){ |
|
421 | + private function _insert_event_meta($old_event, $new_cpt_id) { |
|
422 | 422 | global $wpdb; |
423 | 423 | $event_meta = maybe_unserialize($old_event['event_meta']); |
424 | 424 | // for reference, 3.1 'default_payment_status' are: $default_payment_status = array( |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | //); |
430 | 430 | $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'])); |
431 | 431 | $cols_n_values = array( |
432 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID_fk |
|
432 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID_fk |
|
433 | 433 | 'EVT_display_desc'=> 'Y' == $old_event['display_desc'], |
434 | - 'EVT_display_ticket_selector'=> 'Y'== $old_event['display_reg_form'], |
|
435 | - '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 wasn't ever used |
|
434 | + 'EVT_display_ticket_selector'=> 'Y' == $old_event['display_reg_form'], |
|
435 | + '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 wasn't ever used |
|
436 | 436 | 'EVT_additional_limit'=> $old_event['allow_multiple'] == 'N' ? 1 : $old_event['additional_limit'], |
437 | 437 | 'EVT_default_registration_status' => $default_reg_status, |
438 | 438 | 'EVT_member_only'=>$old_event['member_only'], |
@@ -444,23 +444,23 @@ discard block |
||
444 | 444 | |
445 | 445 | ); |
446 | 446 | $datatypes = array( |
447 | - '%s',//EVT_ID |
|
448 | - '%d',//EVT_display_desc |
|
449 | - '%d',//EVT_display_ticket_selector |
|
450 | - '%s',//EVT_visible_on |
|
451 | - '%d',//EVT_additional_limit |
|
452 | - '%s',//EVT_default_registration_status |
|
453 | - '%d',//EVT_member_only |
|
454 | - '%s',//EVT_phone |
|
455 | - '%d',//EVT_allow_overflow |
|
456 | - '%s',//EVT_timezone_string |
|
457 | - '%s',//EVT_external_URL |
|
458 | - '%d',//EVT_donations |
|
447 | + '%s', //EVT_ID |
|
448 | + '%d', //EVT_display_desc |
|
449 | + '%d', //EVT_display_ticket_selector |
|
450 | + '%s', //EVT_visible_on |
|
451 | + '%d', //EVT_additional_limit |
|
452 | + '%s', //EVT_default_registration_status |
|
453 | + '%d', //EVT_member_only |
|
454 | + '%s', //EVT_phone |
|
455 | + '%d', //EVT_allow_overflow |
|
456 | + '%s', //EVT_timezone_string |
|
457 | + '%s', //EVT_external_URL |
|
458 | + '%d', //EVT_donations |
|
459 | 459 | ); |
460 | 460 | $success = $wpdb->insert($this->_new_meta_table, |
461 | 461 | $cols_n_values, |
462 | 462 | $datatypes); |
463 | - if( ! $success ){ |
|
463 | + if ( ! $success) { |
|
464 | 464 | $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)); |
465 | 465 | return 0; |
466 | 466 | } |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | * @param $old_event |
474 | 474 | * @return int |
475 | 475 | */ |
476 | - private function _maybe_create_venue( $old_event){ |
|
477 | - if( $old_event['address'] || |
|
476 | + private function _maybe_create_venue($old_event) { |
|
477 | + if ($old_event['address'] || |
|
478 | 478 | $old_event['address2'] || |
479 | 479 | $old_event['city'] || |
480 | 480 | $old_event['state'] || |
@@ -485,21 +485,21 @@ discard block |
||
485 | 485 | $old_event['venue_phone'] || |
486 | 486 | $old_event['virtual_url'] || |
487 | 487 | $old_event['virtual_phone'] |
488 | - ){ |
|
489 | - $old_id = $this->_duplicate_venue_exists( $old_event ); |
|
490 | - if( $old_id ){ |
|
488 | + ) { |
|
489 | + $old_id = $this->_duplicate_venue_exists($old_event); |
|
490 | + if ($old_id) { |
|
491 | 491 | return $old_id; |
492 | 492 | } |
493 | 493 | $new_id = $this->_insert_venue_into_posts($old_event); |
494 | - if( $new_id ){ |
|
494 | + if ($new_id) { |
|
495 | 495 | $this->_insert_venue_into_meta_table($new_id, $old_event); |
496 | - $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
497 | - $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id,$this); |
|
496 | + $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
497 | + $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this); |
|
498 | 498 | } |
499 | 499 | //we don't bother recording the conversion from old events to venues as that |
500 | 500 | //will complicate finding the conversion from old venues to new events |
501 | 501 | return $new_id; |
502 | - }else{ |
|
502 | + } else { |
|
503 | 503 | return 0; |
504 | 504 | } |
505 | 505 | } |
@@ -510,29 +510,29 @@ discard block |
||
510 | 510 | * @param array $old_event |
511 | 511 | * @return int duplicate venue id |
512 | 512 | */ |
513 | - private function _duplicate_venue_exists($old_event){ |
|
513 | + private function _duplicate_venue_exists($old_event) { |
|
514 | 514 | global $wpdb; |
515 | 515 | $conditions = array( |
516 | - 'VNU_address' => $old_event [ 'address' ], |
|
517 | - 'VNU_address2' => $old_event[ 'address2' ], |
|
518 | - 'VNU_city' => $old_event[ 'city' ], |
|
519 | - 'VNU_zip' => $old_event[ 'zip' ], |
|
520 | - 'post_title'=> $this->_get_venue_title_for_event( $old_event ), |
|
521 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
522 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
523 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
524 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
516 | + 'VNU_address' => $old_event ['address'], |
|
517 | + 'VNU_address2' => $old_event['address2'], |
|
518 | + 'VNU_city' => $old_event['city'], |
|
519 | + 'VNU_zip' => $old_event['zip'], |
|
520 | + 'post_title'=> $this->_get_venue_title_for_event($old_event), |
|
521 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
522 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
523 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
524 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
525 | 525 | ); |
526 | 526 | $sql_conditions = array(); |
527 | - foreach($conditions as $column => $value){ |
|
528 | - $sql_conditions [] = $wpdb->prepare("$column = %s", $value ); |
|
527 | + foreach ($conditions as $column => $value) { |
|
528 | + $sql_conditions [] = $wpdb->prepare("$column = %s", $value); |
|
529 | 529 | } |
530 | 530 | $query = "SELECT VNU_ID |
531 | 531 | FROM |
532 | 532 | {$wpdb->posts} as p INNER JOIN |
533 | 533 | {$wpdb->prefix}esp_venue_meta as v ON p.ID = v.VNU_ID |
534 | - WHERE " . implode( " AND ",$sql_conditions ) . " LIMIT 1"; |
|
535 | - $id = $wpdb->get_var( $query ); |
|
534 | + WHERE ".implode(" AND ", $sql_conditions)." LIMIT 1"; |
|
535 | + $id = $wpdb->get_var($query); |
|
536 | 536 | return $id; |
537 | 537 | } |
538 | 538 | |
@@ -541,8 +541,8 @@ discard block |
||
541 | 541 | * @param array $event_data_array keys are events_details columns and values are their values |
542 | 542 | * @return string |
543 | 543 | */ |
544 | - protected function _get_venue_title_for_event( $event_data_array ) { |
|
545 | - return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes( sprintf( __( 'Venue of %s', 'event_espresso' ), $event_data_array['event_name'])); |
|
544 | + protected function _get_venue_title_for_event($event_data_array) { |
|
545 | + return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes(sprintf(__('Venue of %s', 'event_espresso'), $event_data_array['event_name'])); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -551,40 +551,40 @@ discard block |
||
551 | 551 | * @param array $old_event keys are cols, values are col values |
552 | 552 | * @return int |
553 | 553 | */ |
554 | - private function _insert_venue_into_posts($old_event){ |
|
554 | + private function _insert_venue_into_posts($old_event) { |
|
555 | 555 | global $wpdb; |
556 | 556 | $insertion_array = array( |
557 | - 'post_title'=> $this->_get_venue_title_for_event( $old_event ),//VNU_name |
|
558 | - 'post_content'=>'',//VNU_desc |
|
559 | - 'post_name'=> $this->_find_unique_slug( $old_event['venue_title'], sanitize_title( 'venue-of-' . $old_event['event_name'] ) ),//VNU_identifier |
|
560 | - 'post_date'=>current_time('mysql'),//VNU_created |
|
557 | + 'post_title'=> $this->_get_venue_title_for_event($old_event), //VNU_name |
|
558 | + 'post_content'=>'', //VNU_desc |
|
559 | + 'post_name'=> $this->_find_unique_slug($old_event['venue_title'], sanitize_title('venue-of-'.$old_event['event_name'])), //VNU_identifier |
|
560 | + 'post_date'=>current_time('mysql'), //VNU_created |
|
561 | 561 | 'post_date_gmt'=>get_gmt_from_date(current_time('mysql')), |
562 | - 'post_excerpt'=>'',//VNU_short_desc arbitrary only 50 characters |
|
563 | - 'post_modified'=>current_time('mysql'),//VNU_modified |
|
562 | + 'post_excerpt'=>'', //VNU_short_desc arbitrary only 50 characters |
|
563 | + 'post_modified'=>current_time('mysql'), //VNU_modified |
|
564 | 564 | 'post_modified_gmt'=>get_gmt_from_date(current_time('mysql')), |
565 | - 'post_author'=>$old_event['wp_user'],//VNU_wp_user |
|
566 | - 'post_parent'=>0,//parent |
|
567 | - 'menu_order'=>0,//VNU_order |
|
565 | + 'post_author'=>$old_event['wp_user'], //VNU_wp_user |
|
566 | + 'post_parent'=>0, //parent |
|
567 | + 'menu_order'=>0, //VNU_order |
|
568 | 568 | 'post_type'=>'espresso_venues'//post_type |
569 | 569 | ); |
570 | 570 | $datatypes_array = array( |
571 | - '%s',//VNU_name |
|
572 | - '%s',//VNU_desc |
|
573 | - '%s',//VNU_identifier |
|
574 | - '%s',//VNU_created |
|
571 | + '%s', //VNU_name |
|
572 | + '%s', //VNU_desc |
|
573 | + '%s', //VNU_identifier |
|
574 | + '%s', //VNU_created |
|
575 | 575 | '%s', |
576 | - '%s',//VNU_short_desc |
|
577 | - '%s',//VNU_modified |
|
576 | + '%s', //VNU_short_desc |
|
577 | + '%s', //VNU_modified |
|
578 | 578 | '%s', |
579 | - '%d',//VNU_wp_user |
|
580 | - '%d',//parent |
|
581 | - '%d',//VNU_order |
|
582 | - '%s',//post_type |
|
579 | + '%d', //VNU_wp_user |
|
580 | + '%d', //parent |
|
581 | + '%d', //VNU_order |
|
582 | + '%s', //post_type |
|
583 | 583 | ); |
584 | 584 | $success = $wpdb->insert($wpdb->posts, |
585 | 585 | $insertion_array, |
586 | 586 | $datatypes_array); |
587 | - if( ! $success ){ |
|
587 | + if ( ! $success) { |
|
588 | 588 | $this->add_error( |
589 | 589 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
590 | 590 | $this->_old_table, |
@@ -605,64 +605,64 @@ discard block |
||
605 | 605 | * @param array $old_event |
606 | 606 | * @return int |
607 | 607 | */ |
608 | - private function _insert_venue_into_meta_table($cpt_id,$old_event){ |
|
608 | + private function _insert_venue_into_meta_table($cpt_id, $old_event) { |
|
609 | 609 | global $wpdb; |
610 | 610 | |
611 | 611 | //assume the country is the same as the organization's old settings |
612 | 612 | $country_iso = $this->get_migration_script()->get_default_country_iso(); |
613 | 613 | //find the state from the venue, or the organization, or just guess california |
614 | - if( ! $old_event['state']){ |
|
614 | + if ( ! $old_event['state']) { |
|
615 | 615 | $old_org_options = get_option('events_organization_settings'); |
616 | 616 | $state_name = stripslashes($old_org_options['organization_state']); |
617 | - }else{ |
|
617 | + } else { |
|
618 | 618 | $state_name = $old_event['state']; |
619 | 619 | } |
620 | - if ( ! $state_name ){ |
|
620 | + if ( ! $state_name) { |
|
621 | 621 | $state_name = 'CA'; |
622 | 622 | } |
623 | 623 | //get a state ID with the same name, if possible |
624 | - try{ |
|
625 | - $state = $this->get_migration_script()->get_or_create_state($state_name,$country_iso); |
|
624 | + try { |
|
625 | + $state = $this->get_migration_script()->get_or_create_state($state_name, $country_iso); |
|
626 | 626 | $state_id = $state['STA_ID']; |
627 | - }catch(EE_Error $e){ |
|
627 | + } catch (EE_Error $e) { |
|
628 | 628 | $this->add_error($e->getMessage()); |
629 | 629 | $state_id = 0; |
630 | 630 | } |
631 | 631 | //now insert into meta table |
632 | 632 | $insertion_array = array( |
633 | - 'VNU_ID'=>$cpt_id,//VNU_ID_fk |
|
634 | - 'VNU_address'=>stripslashes($old_event['address']),//VNU_address |
|
635 | - 'VNU_address2'=>stripslashes($old_event['address2']),//VNU_address2 |
|
636 | - 'VNU_city'=>stripslashes($old_event['city']),//VNU_city |
|
637 | - 'STA_ID'=>$state_id,//STA_ID |
|
638 | - 'CNT_ISO'=>$country_iso,//CNT_ISO |
|
639 | - 'VNU_zip'=>$old_event['zip'],//VNU_zip |
|
640 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
641 | - 'VNU_capacity'=>-1,//VNU_capacity |
|
642 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
643 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
644 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
645 | - 'VNU_google_map_link'=>'',//VNU_google_map_link |
|
633 | + 'VNU_ID'=>$cpt_id, //VNU_ID_fk |
|
634 | + 'VNU_address'=>stripslashes($old_event['address']), //VNU_address |
|
635 | + 'VNU_address2'=>stripslashes($old_event['address2']), //VNU_address2 |
|
636 | + 'VNU_city'=>stripslashes($old_event['city']), //VNU_city |
|
637 | + 'STA_ID'=>$state_id, //STA_ID |
|
638 | + 'CNT_ISO'=>$country_iso, //CNT_ISO |
|
639 | + 'VNU_zip'=>$old_event['zip'], //VNU_zip |
|
640 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
641 | + 'VNU_capacity'=>-1, //VNU_capacity |
|
642 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
643 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
644 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
645 | + 'VNU_google_map_link'=>'', //VNU_google_map_link |
|
646 | 646 | 'VNU_enable_for_gmap'=>true //VNU_enable_for_gmap |
647 | 647 | ); |
648 | 648 | $datatypes = array( |
649 | - '%d',//VNU_ID_fk |
|
650 | - '%s',//VNU_address |
|
651 | - '%s',//VNU_address2 |
|
652 | - '%s',//VNU_city |
|
653 | - '%d',//STA_ID |
|
654 | - '%s',//CNT_ISO |
|
655 | - '%s',//VNU_zip |
|
656 | - '%s',//VNU_phone |
|
657 | - '%d',//VNU_capacity |
|
658 | - '%s',//VNU_url |
|
659 | - '%s',//VNU_virtual_phone |
|
660 | - '%s',//VNU_virtual_url |
|
661 | - '%s',//VNU_google_map_link |
|
662 | - '%d',//VNU_enable_for_gmap |
|
649 | + '%d', //VNU_ID_fk |
|
650 | + '%s', //VNU_address |
|
651 | + '%s', //VNU_address2 |
|
652 | + '%s', //VNU_city |
|
653 | + '%d', //STA_ID |
|
654 | + '%s', //CNT_ISO |
|
655 | + '%s', //VNU_zip |
|
656 | + '%s', //VNU_phone |
|
657 | + '%d', //VNU_capacity |
|
658 | + '%s', //VNU_url |
|
659 | + '%s', //VNU_virtual_phone |
|
660 | + '%s', //VNU_virtual_url |
|
661 | + '%s', //VNU_google_map_link |
|
662 | + '%d', //VNU_enable_for_gmap |
|
663 | 663 | ); |
664 | - $success = $wpdb->insert($wpdb->prefix."esp_venue_meta",$insertion_array,$datatypes); |
|
665 | - if( ! $success ){ |
|
664 | + $success = $wpdb->insert($wpdb->prefix."esp_venue_meta", $insertion_array, $datatypes); |
|
665 | + if ( ! $success) { |
|
666 | 666 | $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)); |
667 | 667 | return 0; |
668 | 668 | } |
@@ -676,14 +676,14 @@ discard block |
||
676 | 676 | * @param $new_venue_id |
677 | 677 | * @return int |
678 | 678 | */ |
679 | - private function _insert_new_venue_to_event( $new_event_id, $new_venue_id){ |
|
679 | + private function _insert_new_venue_to_event($new_event_id, $new_venue_id) { |
|
680 | 680 | global $wpdb; |
681 | - if( ! $new_event_id){ |
|
682 | - $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"),$new_event_id)); |
|
681 | + if ( ! $new_event_id) { |
|
682 | + $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $new_event_id)); |
|
683 | 683 | return 0; |
684 | 684 | } |
685 | - if( ! $new_venue_id){ |
|
686 | - $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"),$new_venue_id)); |
|
685 | + if ( ! $new_venue_id) { |
|
686 | + $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $new_venue_id)); |
|
687 | 687 | return 0; |
688 | 688 | } |
689 | 689 | $cols_n_values = array( |
@@ -692,12 +692,12 @@ discard block |
||
692 | 692 | 'EVV_primary'=>true |
693 | 693 | ); |
694 | 694 | $datatypes = array( |
695 | - '%d',//EVT_ID |
|
696 | - '%d',//VNU_ID |
|
697 | - '%d',//EVT_primary |
|
695 | + '%d', //EVT_ID |
|
696 | + '%d', //VNU_ID |
|
697 | + '%d', //EVT_primary |
|
698 | 698 | ); |
699 | - $success = $wpdb->insert($wpdb->prefix."esp_event_venue",$cols_n_values,$datatypes); |
|
700 | - if ( ! $success){ |
|
699 | + $success = $wpdb->insert($wpdb->prefix."esp_event_venue", $cols_n_values, $datatypes); |
|
700 | + if ( ! $success) { |
|
701 | 701 | $this->add_error( |
702 | 702 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
703 | 703 | $this->_old_table, |
@@ -719,11 +719,11 @@ discard block |
||
719 | 719 | * @param int $new_cpt_id new post ID |
720 | 720 | * @return void (if there are errors though, adds them to the stage's error list |
721 | 721 | */ |
722 | - private function _convert_start_end_times($old_event,$new_cpt_id){ |
|
722 | + private function _convert_start_end_times($old_event, $new_cpt_id) { |
|
723 | 723 | $start_end_times = $this->_get_old_start_end_times($old_event['id']); |
724 | - foreach($start_end_times as $start_end_time){ |
|
725 | - $datetime_id = $this->_insert_new_datetime($start_end_time,$old_event,$new_cpt_id); |
|
726 | - if($datetime_id){ |
|
724 | + foreach ($start_end_times as $start_end_time) { |
|
725 | + $datetime_id = $this->_insert_new_datetime($start_end_time, $old_event, $new_cpt_id); |
|
726 | + if ($datetime_id) { |
|
727 | 727 | $this->get_migration_script()->set_mapping($this->_old_start_end_table, $start_end_time['id'], $this->_new_datetime_table, $datetime_id); |
728 | 728 | } |
729 | 729 | } |
@@ -734,9 +734,9 @@ discard block |
||
734 | 734 | * @param int $old_event_id |
735 | 735 | * @return array |
736 | 736 | */ |
737 | - private function _get_old_start_end_times($old_event_id){ |
|
737 | + private function _get_old_start_end_times($old_event_id) { |
|
738 | 738 | global $wpdb; |
739 | - return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d",$old_event_id),ARRAY_A); |
|
739 | + return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d", $old_event_id), ARRAY_A); |
|
740 | 740 | } |
741 | 741 | /** |
742 | 742 | * Inserts a 4.1 datetime given the 3.1 start_end db row and event_details row |
@@ -745,40 +745,40 @@ discard block |
||
745 | 745 | * @param int $new_cpt_id |
746 | 746 | * @return int ID of new datetime |
747 | 747 | */ |
748 | - private function _insert_new_datetime($start_end_time_row,$old_event_row,$new_cpt_id){ |
|
748 | + private function _insert_new_datetime($start_end_time_row, $old_event_row, $new_cpt_id) { |
|
749 | 749 | global $wpdb; |
750 | 750 | $start_date = $old_event_row['start_date']; |
751 | 751 | $start_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['start_time']); |
752 | 752 | $end_date = $old_event_row['end_date']; |
753 | 753 | $end_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['end_time']); |
754 | 754 | $existing_datetimes = $this->_count_other_datetimes_exist_for_new_event($new_cpt_id); |
755 | - $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']); |
|
756 | - $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']); |
|
755 | + $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']); |
|
756 | + $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']); |
|
757 | 757 | $cols_n_values = array( |
758 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID |
|
759 | - 'DTT_EVT_start'=>$start_datetime_utc,//DTT_EVT_start |
|
760 | - 'DTT_EVT_end'=> $end_datetime_utc,//DTT_EVT_end |
|
761 | - 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'],//DTT_reg_limit |
|
762 | - 'DTT_sold'=>0,//note: we will increment this as registrations are added during the migration |
|
758 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID |
|
759 | + 'DTT_EVT_start'=>$start_datetime_utc, //DTT_EVT_start |
|
760 | + 'DTT_EVT_end'=> $end_datetime_utc, //DTT_EVT_end |
|
761 | + 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'], //DTT_reg_limit |
|
762 | + 'DTT_sold'=>0, //note: we will increment this as registrations are added during the migration |
|
763 | 763 | // 'DTT_is_primary'=> 0 == $existing_datetimes ,//DTT_is_primary... if count==0, then we'll call it the 'primary' |
764 | - 'DTT_order'=> $existing_datetimes,//DTT_order, just give it the same order as the count of how many datetimes already exist |
|
764 | + 'DTT_order'=> $existing_datetimes, //DTT_order, just give it the same order as the count of how many datetimes already exist |
|
765 | 765 | 'DTT_parent'=>0, |
766 | 766 | 'DTT_deleted'=>false |
767 | 767 | ); |
768 | 768 | $datatypes = array( |
769 | - '%d',//EVT_Id |
|
770 | - '%s',//DTT_EVT_start |
|
771 | - '%s',//DTT_EVT_end |
|
772 | - '%d',//DTT_reg_limit |
|
773 | - '%d',//DTT_sold |
|
769 | + '%d', //EVT_Id |
|
770 | + '%s', //DTT_EVT_start |
|
771 | + '%s', //DTT_EVT_end |
|
772 | + '%d', //DTT_reg_limit |
|
773 | + '%d', //DTT_sold |
|
774 | 774 | // '%d',//DTT_is_primary |
775 | - '%d',//DTT_order |
|
776 | - '%d',//DTT_parent |
|
777 | - '%d',//DTT_deleted |
|
775 | + '%d', //DTT_order |
|
776 | + '%d', //DTT_parent |
|
777 | + '%d', //DTT_deleted |
|
778 | 778 | ); |
779 | - $success = $wpdb->insert($this->_new_datetime_table,$cols_n_values,$datatypes); |
|
780 | - if ( ! $success){ |
|
781 | - $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)); |
|
779 | + $success = $wpdb->insert($this->_new_datetime_table, $cols_n_values, $datatypes); |
|
780 | + if ( ! $success) { |
|
781 | + $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)); |
|
782 | 782 | return 0; |
783 | 783 | } |
784 | 784 | return $wpdb->insert_id; |
@@ -791,9 +791,9 @@ discard block |
||
791 | 791 | * @param int $cpt_event_id |
792 | 792 | * @return int |
793 | 793 | */ |
794 | - private function _count_other_datetimes_exist_for_new_event($cpt_event_id){ |
|
794 | + private function _count_other_datetimes_exist_for_new_event($cpt_event_id) { |
|
795 | 795 | global $wpdb; |
796 | - $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d",$cpt_event_id)); |
|
796 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d", $cpt_event_id)); |
|
797 | 797 | return intval($count); |
798 | 798 | } |
799 | 799 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @since 4.3.2 |
16 | 16 | * @author Darren Ethier |
17 | 17 | */ |
18 | -class EE_Caf_Messages { |
|
18 | +class EE_Caf_Messages { |
|
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
@@ -34,36 +34,36 @@ discard block |
||
34 | 34 | * @return void |
35 | 35 | */ |
36 | 36 | private function _caf_hooks() { |
37 | - add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( $this, 'messages_autoload_paths'), 5 ); |
|
38 | - add_filter('FHEE__EE_Email_messenger__get_validator_config', array( $this, 'email_messenger_validator_config'), 5, 2 ); |
|
39 | - add_filter('FHEE__EE_Email_messenger__get_template_fields', array( $this, 'email_messenger_template_fields'), 5, 2 ); |
|
40 | - add_filter( 'FHEE__EE_Html_messenger__get_template_fields', array( $this, 'html_messenger_template_fields' ), 5, 2 ); |
|
41 | - add_filter( 'FHEE__EE_Html_messenger__get_validator_config', array( $this, 'html_messenger_validator_config' ), 5, 2 ); |
|
42 | - add_filter( 'FHEE__EE_Pdf_messenger__get_template_fields', array( $this, 'pdf_messenger_template_fields' ), 5, 2 ); |
|
43 | - add_filter( 'FHEE__EE_Pdf_messenger__get_validator_config', array( $this, 'pdf_messenger_validator_config' ), 5, 2 ); |
|
44 | - add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', array( $this, 'new_default_templates'), 5, 7 ); |
|
45 | - add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array( $this, 'message_types_valid_shortcodes'), 5, 2 ); |
|
37 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
38 | + add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), 5, 2); |
|
39 | + add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, 2); |
|
40 | + add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, 2); |
|
41 | + add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, 2); |
|
42 | + add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
43 | + add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, 2); |
|
44 | + add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', array($this, 'new_default_templates'), 5, 7); |
|
45 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, 2); |
|
46 | 46 | |
47 | 47 | //shortcode parsers |
48 | - add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array( $this, 'additional_attendee_shortcodes'), 5, 2 ); |
|
49 | - add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array( $this, 'additional_attendee_parser'), 5, 5 ); |
|
50 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', array( $this, 'additional_recipient_details_shortcodes'), 5, 2 ); |
|
51 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', array( $this, 'additional_recipient_details_parser'), 5, 5 ); |
|
52 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', array( $this, 'additional_primary_registration_details_shortcodes'), 5, 2 ); |
|
53 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', array( $this, 'additional_primary_registration_details_parser'), 5, 5 ); |
|
48 | + add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
49 | + add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
50 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
51 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', array($this, 'additional_recipient_details_parser'), 5, 5); |
|
52 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
53 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @since 4.2.0 |
57 | 57 | */ |
58 | - add_filter( 'FHEE__EE_Datetime_Shortcodes__shortcodes', array( $this, 'additional_datetime_shortcodes'), 10, 2 ); |
|
59 | - add_filter( 'FHEE__EE_Datetime_Shortcodes__parser_after', array( $this, 'additional_datetime_parser'), 10, 5 ); |
|
58 | + add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
59 | + add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @since 4.3.0 |
63 | 63 | */ |
64 | 64 | //eat our own dog food! |
65 | - add_action('EE_Brewing_Regular___messages_caf', array( $this, 'register_caf_message_types' ) ); |
|
66 | - add_action('EE_Brewing_Regular___messages_caf', array( $this, 'register_caf_shortcodes' ) ); |
|
65 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
66 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
67 | 67 | do_action('EE_Brewing_Regular___messages_caf'); |
68 | 68 | } |
69 | 69 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * @param array $dir_ref original array of paths |
75 | 75 | * @return array appended paths |
76 | 76 | */ |
77 | - public function messages_autoload_paths( $dir_ref ) { |
|
78 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
77 | + public function messages_autoload_paths($dir_ref) { |
|
78 | + $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/'; |
|
79 | 79 | return $dir_ref; |
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | 83 | |
84 | - public function email_messenger_validator_config( $validator_config, EE_Email_messenger $messenger ) { |
|
84 | + public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) { |
|
85 | 85 | $validator_config['attendee_list'] = array( |
86 | 86 | 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
87 | 87 | 'required' => array('[ATTENDEE_LIST]') |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | - public function html_messenger_validator_config( $validator_config, EE_Html_messenger $messenger ) { |
|
98 | + public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) { |
|
99 | 99 | $validator_config['attendee_list'] = array( |
100 | 100 | 'shortcodes' => array('attendee', 'question_list'), |
101 | 101 | 'required' => array('[ATTENDEE_LIST]') |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | |
111 | 111 | |
112 | - public function pdf_messenger_validator_config( $validator_config, EE_Pdf_messenger $messenger ) { |
|
112 | + public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) { |
|
113 | 113 | $validator_config['attendee_list'] = array( |
114 | 114 | 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
115 | 115 | 'required' => array('[ATTENDEE_LIST]') |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | |
126 | 126 | |
127 | - public function email_messenger_template_fields( $template_fields, EE_Email_messenger $messenger ) { |
|
127 | + public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) { |
|
128 | 128 | $template_fields['extra']['content']['question_list'] = array( |
129 | 129 | 'input' => 'textarea', |
130 | 130 | 'label' => '[QUESTION_LIST]', |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | - public function html_messenger_template_fields( $template_fields, EE_Html_messenger $messenger ) { |
|
143 | + public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) { |
|
144 | 144 | $template_fields['extra']['content']['question_list'] = array( |
145 | 145 | 'input' => 'textarea', |
146 | 146 | 'label' => '[QUESTION_LIST]', |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | |
159 | 159 | |
160 | - public function pdf_messenger_template_fields( $template_fields, EE_Pdf_messenger $messenger ) { |
|
160 | + public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) { |
|
161 | 161 | $template_fields['extra']['content']['question_list'] = array( |
162 | 162 | 'input' => 'textarea', |
163 | 163 | 'label' => '[QUESTION_LIST]', |
@@ -174,39 +174,39 @@ discard block |
||
174 | 174 | |
175 | 175 | |
176 | 176 | |
177 | - public function new_default_templates( $contents, $actual_path, EE_messenger $messenger, EE_message_type $message_type, $field, $context, EE_Messages_Template_Pack $template_pack ) { |
|
177 | + public function new_default_templates($contents, $actual_path, EE_messenger $messenger, EE_message_type $message_type, $field, $context, EE_Messages_Template_Pack $template_pack) { |
|
178 | 178 | |
179 | 179 | //we're only modifying templates for the default template pack |
180 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default ) { |
|
180 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
181 | 181 | return $contents; |
182 | 182 | } |
183 | 183 | |
184 | 184 | //the template file name we're replacing contents for. |
185 | - $template_file_prefix = $field . '_' . $context; |
|
186 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_' ; |
|
185 | + $template_file_prefix = $field.'_'.$context; |
|
186 | + $msg_prefix = $messenger->name.'_'.$message_type->name.'_'; |
|
187 | 187 | |
188 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
188 | + $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/'; |
|
189 | 189 | |
190 | - if ( $messenger->name == 'email' && $message_type->name == 'registration' ) { |
|
190 | + if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
191 | 191 | |
192 | - switch ( $template_file_prefix ) { |
|
192 | + switch ($template_file_prefix) { |
|
193 | 193 | |
194 | 194 | case 'question_list_admin' : |
195 | 195 | case 'question_list_attendee' : |
196 | 196 | case 'question_list_primary_attendee' : |
197 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
198 | - $contents = EEH_Template::display_template( $path, array(), true ); |
|
197 | + $path = $base_path.$msg_prefix.'question_list.template.php'; |
|
198 | + $contents = EEH_Template::display_template($path, array(), true); |
|
199 | 199 | break; |
200 | 200 | |
201 | 201 | case 'attendee_list_primary_attendee' : |
202 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
203 | - $contents = EEH_Template::display_template( $path, array(), true ); |
|
202 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
203 | + $contents = EEH_Template::display_template($path, array(), true); |
|
204 | 204 | break; |
205 | 205 | |
206 | 206 | case 'attendee_list_admin' : |
207 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
208 | - $contents = EEH_Template::display_template( $path, |
|
209 | - array(), true ); |
|
207 | + $path = $base_path.$msg_prefix.'attendee_list_admin.template.php'; |
|
208 | + $contents = EEH_Template::display_template($path, |
|
209 | + array(), true); |
|
210 | 210 | break; |
211 | 211 | |
212 | 212 | case 'attendee_list_attendee' : |
@@ -214,33 +214,33 @@ discard block |
||
214 | 214 | break; |
215 | 215 | |
216 | 216 | case 'event_list_attendee' : |
217 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
218 | - $contents = EEH_Template::display_template( $path, array(), true ); |
|
217 | + $path = $base_path.$msg_prefix.'event_list_attendee.template.php'; |
|
218 | + $contents = EEH_Template::display_template($path, array(), true); |
|
219 | 219 | break; |
220 | 220 | } |
221 | - } elseif ( $messenger->name == 'email' && $message_type->name == 'newsletter' ) { |
|
222 | - switch( $template_file_prefix ) { |
|
221 | + } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
222 | + switch ($template_file_prefix) { |
|
223 | 223 | |
224 | 224 | case 'content_attendee' : |
225 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
226 | - $contents = EEH_Template::display_template( $path, array(), true ); |
|
225 | + $path = $base_path.$msg_prefix.'content.template.php'; |
|
226 | + $contents = EEH_Template::display_template($path, array(), true); |
|
227 | 227 | break; |
228 | 228 | |
229 | 229 | case 'newsletter_content_attendee' : |
230 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
231 | - $contents = EEH_Template::display_template( $path, array(), true ); |
|
230 | + $path = $base_path.$msg_prefix.'newsletter_content.template.php'; |
|
231 | + $contents = EEH_Template::display_template($path, array(), true); |
|
232 | 232 | break; |
233 | 233 | |
234 | 234 | case 'newsletter_subject_attendee' : |
235 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
236 | - $contents = EEH_Template::display_template( $path, array(), true ); |
|
235 | + $path = $base_path.$msg_prefix.'subject.template.php'; |
|
236 | + $contents = EEH_Template::display_template($path, array(), true); |
|
237 | 237 | break; |
238 | 238 | } |
239 | - } elseif ( $messenger->name == 'html' && $message_type->name == 'receipt' ) { |
|
240 | - switch ( $template_file_prefix ) { |
|
239 | + } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
240 | + switch ($template_file_prefix) { |
|
241 | 241 | case 'attendee_list_purchaser' : |
242 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
243 | - $contents = EEH_Template::display_template( $path, array(), true ); |
|
242 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
243 | + $contents = EEH_Template::display_template($path, array(), true); |
|
244 | 244 | break; |
245 | 245 | } |
246 | 246 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | |
253 | 253 | |
254 | - public function message_types_valid_shortcodes( $valid_shortcodes, EE_Messages_Base $msg ) { |
|
254 | + public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) { |
|
255 | 255 | //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
256 | 256 | $include_with = array( |
257 | 257 | 'registration', |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | 'invoice', |
269 | 269 | 'receipt' |
270 | 270 | ); |
271 | - if ( $msg instanceof EE_message_type && in_array( $msg->name, $include_with )) { |
|
271 | + if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
272 | 272 | $contexts = array_keys($msg->get_contexts()); |
273 | - foreach ( $contexts as $context ) { |
|
273 | + foreach ($contexts as $context) { |
|
274 | 274 | $valid_shortcodes[$context][] = 'question_list'; |
275 | 275 | $valid_shortcodes[$context][] = 'question'; |
276 | 276 | } |
@@ -282,40 +282,40 @@ discard block |
||
282 | 282 | |
283 | 283 | |
284 | 284 | |
285 | - public function additional_attendee_shortcodes( $shortcodes, $shortcode_parser ) { |
|
285 | + public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) { |
|
286 | 286 | $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', 'event_espresso'); |
287 | 287 | return $shortcodes; |
288 | 288 | } |
289 | 289 | |
290 | 290 | |
291 | 291 | |
292 | - public function additional_attendee_parser( $parsed, $shortcode, $data, $extra_data, $shortcode_parser ) { |
|
292 | + public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) { |
|
293 | 293 | |
294 | - if ( strpos( $shortcode, '[ANSWER_*' ) === FALSE || !isset( $extra_data['data']->questions) || !isset( $extra_data['data']->registrations) ) |
|
294 | + if (strpos($shortcode, '[ANSWER_*') === FALSE || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations)) |
|
295 | 295 | return $parsed; |
296 | 296 | |
297 | 297 | //let's get the question from the code. |
298 | 298 | $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
299 | - $shortcode = trim( str_replace(']', '', $shortcode) ); |
|
299 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
300 | 300 | |
301 | 301 | $registration = $data instanceof EE_Registration ? $data : null; |
302 | - $registration = ! $registration instanceof EE_Registration && is_array( $extra_data ) && isset( $extra_data['data'] ) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
302 | + $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
303 | 303 | |
304 | 304 | $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
305 | - $aee = ! $aee instanceof EE_Messages_Addressee && is_array( $extra_data ) && isset( $extra_data['data'] ) ? $extra_data['data'] : $aee; |
|
305 | + $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
306 | 306 | |
307 | - if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee ) { |
|
307 | + if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
308 | 308 | return $parsed; |
309 | 309 | } |
310 | 310 | |
311 | 311 | //now let's figure out which question has this text. |
312 | - foreach ( $aee->questions as $ansid => $question ) { |
|
312 | + foreach ($aee->questions as $ansid => $question) { |
|
313 | 313 | if ( |
314 | 314 | $question instanceof EE_Question |
315 | - && trim( $question->display_text() ) == trim( $shortcode ) |
|
316 | - && isset( $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ] ) |
|
315 | + && trim($question->display_text()) == trim($shortcode) |
|
316 | + && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
317 | 317 | ) { |
318 | - return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty('ANS_value', 'no_wpautop'); |
|
318 | + return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', 'no_wpautop'); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @return array array of shortcodes and |
337 | 337 | * descriptions |
338 | 338 | */ |
339 | - public function additional_datetime_shortcodes( $shortcodes, $shortcode_parser ) { |
|
339 | + public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) { |
|
340 | 340 | $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', 'event_espresso'); |
341 | 341 | $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', 'event_espresso'); |
342 | 342 | $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', 'event_espresso'); |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | * @param EE_Datetime_Shortcodes $shortcode_parser |
359 | 359 | * @return string The new parsed string. |
360 | 360 | */ |
361 | - public function additional_datetime_parser( $parsed, $shortcode, $data, $extra_data, $shortcode_parser ) { |
|
361 | + public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) { |
|
362 | 362 | |
363 | - if ( ! $data instanceof EE_Datetime ) { |
|
363 | + if ( ! $data instanceof EE_Datetime) { |
|
364 | 364 | return ''; //get out because we can only parse with the datetime object. |
365 | 365 | } |
366 | 366 | |
367 | - switch ( $shortcode ) { |
|
367 | + switch ($shortcode) { |
|
368 | 368 | case '[DTT_NAME]' : |
369 | 369 | return $data->name(); |
370 | 370 | break; |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | return $data->description(); |
373 | 373 | break; |
374 | 374 | case '[DTT_NAME_OR_DATES]' : |
375 | - return $data->get_dtt_display_name( TRUE ); |
|
375 | + return $data->get_dtt_display_name(TRUE); |
|
376 | 376 | break; |
377 | 377 | default : |
378 | 378 | return $parsed; |
@@ -384,40 +384,40 @@ discard block |
||
384 | 384 | |
385 | 385 | |
386 | 386 | |
387 | - public function additional_recipient_details_shortcodes( $shortcodes, $shortcode_parser ) { |
|
387 | + public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) { |
|
388 | 388 | $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', 'event_espresso'); |
389 | 389 | return $shortcodes; |
390 | 390 | } |
391 | 391 | |
392 | 392 | |
393 | - public function additional_recipient_details_parser( $parsed, $shortcode, $data, $extra_data, $shortcode_parser ) { |
|
393 | + public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) { |
|
394 | 394 | |
395 | - if ( array($data) && ! isset( $data['data'] ) ) |
|
395 | + if (array($data) && ! isset($data['data'])) |
|
396 | 396 | return $parsed; |
397 | 397 | |
398 | 398 | $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : NULL; |
399 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset( $extra_data['data'] ) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
399 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
400 | 400 | |
401 | - if ( ! $recipient instanceof EE_Messages_Addressee ) |
|
401 | + if ( ! $recipient instanceof EE_Messages_Addressee) |
|
402 | 402 | return $parsed; |
403 | 403 | |
404 | - switch ( $shortcode ) { |
|
404 | + switch ($shortcode) { |
|
405 | 405 | case '[RECIPIENT_QUESTION_LIST]' : |
406 | 406 | $att = $recipient->att_obj; |
407 | 407 | $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
408 | - $registrations_on_attendee = empty( $registrations_on_attendee ) && $recipient->reg_obj instanceof EE_Registration ? array( $recipient->reg_obj ) : $registrations_on_attendee; |
|
408 | + $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
409 | 409 | $answers = array(); |
410 | 410 | |
411 | - $template = is_array($data['template'] ) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
411 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
412 | 412 | $valid_shortcodes = array('question'); |
413 | 413 | |
414 | 414 | //if the context is main_content then get all answers for all registrations on this attendee |
415 | - if ( $data['data'] instanceof EE_Messages_Addressee ) { |
|
416 | - foreach ( $registrations_on_attendee as $reg ) { |
|
417 | - if ( $reg instanceof EE_Registration ) { |
|
418 | - $anss = !empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
419 | - foreach( $anss as $ans ) { |
|
420 | - if ( $ans instanceof EE_Answer ) { |
|
415 | + if ($data['data'] instanceof EE_Messages_Addressee) { |
|
416 | + foreach ($registrations_on_attendee as $reg) { |
|
417 | + if ($reg instanceof EE_Registration) { |
|
418 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
419 | + foreach ($anss as $ans) { |
|
420 | + if ($ans instanceof EE_Answer) { |
|
421 | 421 | $answers[$ans->ID()] = $ans; |
422 | 422 | } |
423 | 423 | } |
@@ -426,13 +426,13 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
429 | - if ( $data['data'] instanceof EE_Event ) { |
|
429 | + if ($data['data'] instanceof EE_Event) { |
|
430 | 430 | $event = $data['data']; |
431 | - foreach( $registrations_on_attendee as $reg ) { |
|
432 | - if ( $reg instanceof EE_Registration && $reg->event_ID() == $event->ID() ) { |
|
433 | - $anss = !empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
434 | - foreach( $anss as $ans ) { |
|
435 | - if ( $ans instanceof EE_Answer ) { |
|
431 | + foreach ($registrations_on_attendee as $reg) { |
|
432 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
433 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
434 | + foreach ($anss as $ans) { |
|
435 | + if ($ans instanceof EE_Answer) { |
|
436 | 436 | $answers[$ans->ID()] = $ans; |
437 | 437 | } |
438 | 438 | } |
@@ -442,13 +442,13 @@ discard block |
||
442 | 442 | |
443 | 443 | $question_list = ''; |
444 | 444 | $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
445 | - foreach ( $answers as $answer ) { |
|
446 | - if ( $answer instanceof EE_Answer ) { |
|
445 | + foreach ($answers as $answer) { |
|
446 | + if ($answer instanceof EE_Answer) { |
|
447 | 447 | $question = $answer->question(); |
448 | - if ( ! $question instanceof EE_Question || ( $question instanceof EE_Question && $question->admin_only() ) ) { |
|
448 | + if ( ! $question instanceof EE_Question || ($question instanceof EE_Question && $question->admin_only())) { |
|
449 | 449 | continue; |
450 | 450 | } |
451 | - $question_list .= $shortcode_helper->parse_question_list_template( $template, $answer, $valid_shortcodes, $extra_data); |
|
451 | + $question_list .= $shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes, $extra_data); |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | return $question_list; |
@@ -461,41 +461,41 @@ discard block |
||
461 | 461 | } |
462 | 462 | |
463 | 463 | |
464 | - public function additional_primary_registration_details_shortcodes( $shortcodes, $shortcode_parser ) { |
|
464 | + public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) { |
|
465 | 465 | $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', 'event_espresso'); |
466 | 466 | return $shortcodes; |
467 | 467 | } |
468 | 468 | |
469 | 469 | |
470 | - public function additional_primary_registration_details_parser( $parsed, $shortcode, $data, $extra_data, $shortcode_parser ) { |
|
471 | - if ( array($data) && ! isset( $data['data'] ) ) |
|
470 | + public function additional_primary_registration_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) { |
|
471 | + if (array($data) && ! isset($data['data'])) |
|
472 | 472 | return $parsed; |
473 | 473 | |
474 | 474 | $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : NULL; |
475 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset( $extra_data['data'] ) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
475 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
476 | 476 | |
477 | - if ( ! $recipient instanceof EE_Messages_Addressee ) |
|
477 | + if ( ! $recipient instanceof EE_Messages_Addressee) |
|
478 | 478 | return $parsed; |
479 | 479 | |
480 | 480 | $send_data = ! $data['data'] instanceof EE_Messages_Addressee ? $extra_data : $data; |
481 | 481 | |
482 | - switch ( $shortcode ) { |
|
482 | + switch ($shortcode) { |
|
483 | 483 | case '[RECIPIENT_QUESTION_LIST]' : |
484 | - if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration ) |
|
484 | + if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) |
|
485 | 485 | return ''; |
486 | 486 | $registration = $recipient->primary_reg_obj; |
487 | - $template = is_array($data['template'] ) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
487 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
488 | 488 | $valid_shortcodes = array('question'); |
489 | 489 | $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
490 | 490 | $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
491 | 491 | $question_list = ''; |
492 | - foreach ( $answers as $answer ) { |
|
493 | - if ( $answer instanceof EE_Answer ) { |
|
492 | + foreach ($answers as $answer) { |
|
493 | + if ($answer instanceof EE_Answer) { |
|
494 | 494 | $question = $answer->question(); |
495 | - if ( $question instanceof EE_Question and $question->admin_only() ) { |
|
495 | + if ($question instanceof EE_Question and $question->admin_only()) { |
|
496 | 496 | continue; |
497 | 497 | } |
498 | - $question_list .= $shortcode_helper->parse_question_list_template( $template, $answer, $valid_shortcodes, $send_data); |
|
498 | + $question_list .= $shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes, $send_data); |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | return $question_list; |
@@ -521,67 +521,67 @@ discard block |
||
521 | 521 | $setup_args = array( |
522 | 522 | 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
523 | 523 | 'autoloadpaths' => array( |
524 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
524 | + EE_CAF_LIBRARIES.'messages/message_type/newsletter/' |
|
525 | 525 | ), |
526 | - 'messengers_to_activate_with' => array( 'email' ), |
|
527 | - 'messengers_to_validate_with' => array( 'email' ) |
|
526 | + 'messengers_to_activate_with' => array('email'), |
|
527 | + 'messengers_to_validate_with' => array('email') |
|
528 | 528 | ); |
529 | - EE_Register_Message_Type::register( 'newsletter', $setup_args ); |
|
529 | + EE_Register_Message_Type::register('newsletter', $setup_args); |
|
530 | 530 | |
531 | 531 | //register payment reminder message type |
532 | 532 | $setup_args = array( |
533 | 533 | 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
534 | - 'autoloadpaths' => array( EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/' ), |
|
535 | - 'messengers_to_activate_with' => array( 'email' ), |
|
536 | - 'messengers_to_validate_with' => array( 'email' ) |
|
534 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'), |
|
535 | + 'messengers_to_activate_with' => array('email'), |
|
536 | + 'messengers_to_validate_with' => array('email') |
|
537 | 537 | ); |
538 | - EE_Register_Message_Type::register( 'payment_reminder', $setup_args ); |
|
538 | + EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
539 | 539 | |
540 | 540 | //register payment declined message type |
541 | 541 | $setup_args = array( |
542 | 542 | 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
543 | - 'autoloadpaths' => array( EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/' ), |
|
544 | - 'messengers_to_activate_with' => array( 'email' ), |
|
545 | - 'messengers_to_validate_with' => array( 'email' ) |
|
543 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'), |
|
544 | + 'messengers_to_activate_with' => array('email'), |
|
545 | + 'messengers_to_validate_with' => array('email') |
|
546 | 546 | ); |
547 | - EE_Register_Message_Type::register( 'payment_declined', $setup_args ); |
|
547 | + EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
548 | 548 | |
549 | 549 | //register registration declined message type |
550 | 550 | $setup_args = array( |
551 | 551 | 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
552 | - 'autoloadpaths' => array( EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/' ), |
|
553 | - 'messengers_to_activate_with' => array( 'email' ), |
|
554 | - 'messengers_to_validate_with' => array( 'email' ) |
|
552 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'), |
|
553 | + 'messengers_to_activate_with' => array('email'), |
|
554 | + 'messengers_to_validate_with' => array('email') |
|
555 | 555 | ); |
556 | - EE_Register_Message_Type::register( 'declined_registration', $setup_args ); |
|
556 | + EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
557 | 557 | |
558 | 558 | //register registration cancelled message type |
559 | 559 | $setup_args = array( |
560 | 560 | 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
561 | - 'autoloadpaths' => array( EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/' ), |
|
562 | - 'messengers_to_activate_with' => array( 'email' ), |
|
563 | - 'messengers_to_validate_with' => array( 'email' ) |
|
561 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'), |
|
562 | + 'messengers_to_activate_with' => array('email'), |
|
563 | + 'messengers_to_validate_with' => array('email') |
|
564 | 564 | ); |
565 | - EE_Register_Message_Type::register( 'cancelled_registration', $setup_args ); |
|
565 | + EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
566 | 566 | |
567 | 567 | |
568 | 568 | //register payment failed message type |
569 | 569 | $setup_args = array( |
570 | 570 | 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
571 | - 'autoloadpaths' => array( EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/' ), |
|
572 | - 'messengers_to_activate_with' => array( 'email' ), |
|
573 | - 'messengers_to_validate_with' => array( 'email' ) |
|
571 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'), |
|
572 | + 'messengers_to_activate_with' => array('email'), |
|
573 | + 'messengers_to_validate_with' => array('email') |
|
574 | 574 | ); |
575 | - EE_Register_Message_Type::register( 'payment_failed', $setup_args ); |
|
575 | + EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
576 | 576 | |
577 | 577 | //register payment declined message type |
578 | 578 | $setup_args = array( |
579 | 579 | 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
580 | - 'autoloadpaths' => array( EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/' ), |
|
581 | - 'messengers_to_activate_with' => array( 'email' ), |
|
582 | - 'messengers_to_validate_with' => array( 'email' ) |
|
580 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'), |
|
581 | + 'messengers_to_activate_with' => array('email'), |
|
582 | + 'messengers_to_validate_with' => array('email') |
|
583 | 583 | ); |
584 | - EE_Register_Message_Type::register( 'payment_cancelled', $setup_args ); |
|
584 | + EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -597,12 +597,12 @@ discard block |
||
597 | 597 | public function register_caf_shortcodes() { |
598 | 598 | $setup_args = array( |
599 | 599 | 'autoloadpaths' => array( |
600 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
600 | + EE_CAF_LIBRARIES.'shortcodes/' |
|
601 | 601 | ), |
602 | - 'msgr_validator_callback' => array( 'EE_Newsletter_Shortcodes', 'messenger_validator_config' ), |
|
603 | - 'msgr_template_fields_callback' => array( 'EE_Newsletter_Shortcodes', 'messenger_template_fields' ), |
|
604 | - 'list_type_shortcodes' => array( '[NEWSLETTER_CONTENT]' ) |
|
602 | + 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
603 | + 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
604 | + 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
605 | 605 | ); |
606 | - EE_Register_Messages_Shortcode_Library::register( 'newsletter', $setup_args ); |
|
606 | + EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
607 | 607 | } |
608 | 608 | } |
@@ -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 | /** |
@@ -45,32 +45,32 @@ discard block |
||
45 | 45 | '[PRIMARY_REGISTRANT_ADDRESS2]' => __('Whatever was in the address 2 field for the primary registrant for the transaction.', 'event_espresso'), |
46 | 46 | '[PRIMARY_REGISTRANT_CITY]' => __('The city for the primary registrant for the transaction.', 'event_espresso'), |
47 | 47 | '[PRIMARY_REGISTRANT_ZIP_PC]' => __('The ZIP (or Postal) Code for the primary registrant for the transaction.', 'event_espresso'), |
48 | - '[PRIMARY_REGISTRANT_ADDRESS_STATE]' => __('The state/province for the primary registrant for the transaction.', 'event_espresso' ), |
|
48 | + '[PRIMARY_REGISTRANT_ADDRESS_STATE]' => __('The state/province for the primary registrant for the transaction.', 'event_espresso'), |
|
49 | 49 | '[PRIMARY_REGISTRANT_COUNTRY]' => __('The country for the primary registrant for the transaction.', 'event_espresso'), |
50 | 50 | '[PRIMARY_REGISTRANT_REGISTRATION_DATE]' => __('The date the registration occured for the primary registration.', 'event_espresso'), |
51 | 51 | '[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]' => __('Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso'), |
52 | - '[PRIMARY_REGISTRANT_ANSWER_*]' => __('This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this primary registrant, then it will be output in place of this shortcode.', 'event_espresso' ) |
|
52 | + '[PRIMARY_REGISTRANT_ANSWER_*]' => __('This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this primary registrant, then it will be output in place of this shortcode.', 'event_espresso') |
|
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | - protected function _parser( $shortcode ) { |
|
58 | + protected function _parser($shortcode) { |
|
59 | 59 | //make sure we end up with a copy of the EE_Messages_Addressee object |
60 | 60 | $primary_registration = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL; |
61 | - $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && is_array($this->_data) && isset( $this->_data['data'] ) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] : $primary_registration; |
|
62 | - $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && !empty( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : $primary_registration; |
|
61 | + $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && is_array($this->_data) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] : $primary_registration; |
|
62 | + $primary_registration = ! $primary_registration instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : $primary_registration; |
|
63 | 63 | |
64 | - if ( ! $primary_registration instanceof EE_Messages_Addressee ) |
|
64 | + if ( ! $primary_registration instanceof EE_Messages_Addressee) |
|
65 | 65 | return ''; |
66 | 66 | |
67 | 67 | $attendee = $primary_registration->primary_att_obj; |
68 | 68 | $primary_reg = $primary_registration->primary_reg_obj; |
69 | 69 | |
70 | - if ( ! $attendee instanceof EE_Attendee || ! $primary_reg instanceof EE_Registration ) |
|
70 | + if ( ! $attendee instanceof EE_Attendee || ! $primary_reg instanceof EE_Registration) |
|
71 | 71 | return ''; |
72 | 72 | |
73 | - switch ( $shortcode ) { |
|
73 | + switch ($shortcode) { |
|
74 | 74 | case '[PRIMARY_REGISTRANT_FNAME]' : |
75 | 75 | return $attendee->fname(); |
76 | 76 | break; |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | break; |
119 | 119 | |
120 | 120 | case '[PRIMARY_REGISTRANT_REGISTRATION_DATE]' : |
121 | - if ( ! $primary_registration->primary_reg_obj instanceof EE_Registration ) |
|
121 | + if ( ! $primary_registration->primary_reg_obj instanceof EE_Registration) |
|
122 | 122 | return ''; |
123 | - return $primary_registration->primary_reg_obj->get_i18n_datetime( 'REG_date', get_option( 'date_format' ) ); |
|
123 | + return $primary_registration->primary_reg_obj->get_i18n_datetime('REG_date', get_option('date_format')); |
|
124 | 124 | break; |
125 | 125 | |
126 | 126 | case '[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]' : |
@@ -128,22 +128,22 @@ discard block |
||
128 | 128 | break; |
129 | 129 | } |
130 | 130 | |
131 | - if ( strpos( $shortcode, '[PRIMARY_REGISTRANT_ANSWER_*' ) !== false ) { |
|
132 | - $shortcode = str_replace( '[PRIMARY_REGISTRANT_ANSWER_*', '', $shortcode ); |
|
133 | - $shortcode = trim( str_replace( ']', '', $shortcode ) ); |
|
131 | + if (strpos($shortcode, '[PRIMARY_REGISTRANT_ANSWER_*') !== false) { |
|
132 | + $shortcode = str_replace('[PRIMARY_REGISTRANT_ANSWER_*', '', $shortcode); |
|
133 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
134 | 134 | |
135 | 135 | |
136 | 136 | //now let's figure out what question has this text |
137 | - if ( empty( $primary_registration->questions ) ) { |
|
137 | + if (empty($primary_registration->questions)) { |
|
138 | 138 | return ''; |
139 | 139 | } |
140 | 140 | |
141 | - foreach ( $primary_registration->questions as $ansid => $question ) { |
|
141 | + foreach ($primary_registration->questions as $ansid => $question) { |
|
142 | 142 | if ( |
143 | - trim( $question->get( 'QST_display_text' ) ) == trim( $shortcode ) |
|
144 | - && isset( $primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ] ) |
|
143 | + trim($question->get('QST_display_text')) == trim($shortcode) |
|
144 | + && isset($primary_registration->registrations[$primary_reg->ID()]['ans_objs'][$ansid]) |
|
145 | 145 | ) { |
146 | - return $primary_registration->registrations[ $primary_reg->ID() ]['ans_objs'][ $ansid ]->get_pretty( 'ANS_value', 'no_wpautop' ); |
|
146 | + return $primary_registration->registrations[$primary_reg->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', 'no_wpautop'); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -404,10 +404,6 @@ |
||
404 | 404 | /** |
405 | 405 | * Log a "Cleared" request. |
406 | 406 | * |
407 | - * @param array $response |
|
408 | - * @param EEI_Payment $payment |
|
409 | - * @param string $info |
|
410 | - * @return void |
|
411 | 407 | */ |
412 | 408 | private function _log_clean_request( $request_prms, $payment, $info ) { |
413 | 409 | $cleaned_request_data = $request_prms; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @param type $settings_array |
84 | 84 | */ |
85 | - public function set_settings( $settings_array ) { |
|
85 | + public function set_settings($settings_array) { |
|
86 | 86 | parent::set_settings($settings_array); |
87 | 87 | // Redirect URL. |
88 | - if ( $this->_debug_mode ) { |
|
88 | + if ($this->_debug_mode) { |
|
89 | 89 | $this->_base_gateway_url = 'https://api-3t.sandbox.paypal.com/nvp'; |
90 | 90 | } else { |
91 | 91 | $this->_base_gateway_url = 'https://api-3t.paypal.com/nvp'; |
@@ -100,19 +100,19 @@ discard block |
||
100 | 100 | * @param type $return_url |
101 | 101 | * @param type $cancel_url |
102 | 102 | */ |
103 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
104 | - if ( ! $payment instanceof EEI_Payment ) { |
|
105 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
106 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
103 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
104 | + if ( ! $payment instanceof EEI_Payment) { |
|
105 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
106 | + $payment->set_status($this->_pay_model->failed_status()); |
|
107 | 107 | return $payment; |
108 | 108 | } |
109 | 109 | $transaction = $payment->transaction(); |
110 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
111 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
112 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
110 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
111 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
112 | + $payment->set_status($this->_pay_model->failed_status()); |
|
113 | 113 | return $payment; |
114 | 114 | } |
115 | - $order_description = substr( $this->_format_order_description($payment), 0, 127 ); |
|
115 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
116 | 116 | $primary_registration = $transaction->primary_registration(); |
117 | 117 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
118 | 118 | $locale = explode('-', get_bloginfo('language')); |
@@ -126,28 +126,28 @@ discard block |
||
126 | 126 | 'RETURNURL' => $return_url, |
127 | 127 | 'CANCELURL' => $cancel_url, |
128 | 128 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
129 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
130 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
129 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
130 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
131 | 131 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
132 | 132 | ); |
133 | 133 | |
134 | 134 | // Show itemized list. |
135 | - if ( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
135 | + if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
136 | 136 | $item_num = 0; |
137 | 137 | $itemized_sum = 0; |
138 | 138 | $total_line_items = $transaction->total_line_item(); |
139 | 139 | // Go through each item in the list. |
140 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
141 | - if ( $line_item instanceof EE_Line_Item ) { |
|
140 | + foreach ($total_line_items->get_items() as $line_item) { |
|
141 | + if ($line_item instanceof EE_Line_Item) { |
|
142 | 142 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
143 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
143 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
147 | 147 | $unit_price = $line_item->unit_price(); |
148 | 148 | $line_item_quantity = $line_item->quantity(); |
149 | 149 | // This is a discount. |
150 | - if ( $line_item->is_percent() ) { |
|
150 | + if ($line_item->is_percent()) { |
|
151 | 151 | $unit_price = $line_item->total(); |
152 | 152 | $line_item_quantity = 1; |
153 | 153 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | // Item description. |
157 | 157 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($line_item->desc(), 0, 127); |
158 | 158 | // Cost of individual item. |
159 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
159 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
160 | 160 | // Item Number. |
161 | 161 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
162 | 162 | // Item quantity. |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
174 | 174 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
175 | 175 | |
176 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
176 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
177 | 177 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
178 | 178 | // add the difference as an extra line item. |
179 | - if ( $itemized_sum_diff_from_txn_total != 0 ) { |
|
179 | + if ($itemized_sum_diff_from_txn_total != 0) { |
|
180 | 180 | // Item Name. |
181 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
181 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
182 | 182 | // Item description. |
183 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr( $line_item->desc(), 0, 127 ); |
|
183 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($line_item->desc(), 0, 127); |
|
184 | 184 | // Cost of individual item. |
185 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
185 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
186 | 186 | // Item Number. |
187 | 187 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
188 | 188 | // Item quantity. |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | } else { |
193 | 193 | // Just one Item. |
194 | 194 | // Item Name. |
195 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( sprintf( __('Payment for %1$s', 'event_espresso'), $primary_registration->reg_code() ), 0, 127 ); |
|
195 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr(sprintf(__('Payment for %1$s', 'event_espresso'), $primary_registration->reg_code()), 0, 127); |
|
196 | 196 | // Item description. |
197 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( sprintf( __('Payment of %1$s for %2$s', 'event_espresso'), $payment->amount(), $primary_registration->reg_code() ), 0, 127 ); |
|
197 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr(sprintf(__('Payment of %1$s for %2$s', 'event_espresso'), $payment->amount(), $primary_registration->reg_code()), 0, 127); |
|
198 | 198 | // Cost of individual item. |
199 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
199 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
200 | 200 | // Item Number. |
201 | 201 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
202 | 202 | // Item quantity. |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | // Digital item is sold. |
205 | 205 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
206 | 206 | // Item's sales S/H and tax amount. |
207 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
207 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
208 | 208 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
209 | 209 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
210 | 210 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
211 | 211 | } |
212 | 212 | // Automatically filling out shipping and contact information. |
213 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
214 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
213 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
214 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
215 | 215 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
216 | 216 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
217 | 217 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -220,34 +220,34 @@ discard block |
||
220 | 220 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
221 | 221 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
222 | 222 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
223 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
223 | + } elseif ( ! $this->_request_shipping_addr) { |
|
224 | 224 | // Do not request shipping details on the PP Checkout page. |
225 | 225 | $token_request_dtls['NOSHIPPING'] = '1'; |
226 | 226 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
227 | 227 | |
228 | 228 | } |
229 | 229 | // Used a business/personal logo on the PayPal page. |
230 | - if ( ! empty($this->_image_url) ) { |
|
230 | + if ( ! empty($this->_image_url)) { |
|
231 | 231 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
232 | 232 | } |
233 | 233 | // Request PayPal token. |
234 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
235 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
236 | - $response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
237 | - if ( $token_rstatus['status'] ) { |
|
234 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
235 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
236 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
237 | + if ($token_rstatus['status']) { |
|
238 | 238 | // We got the Token so we may continue with the payment and redirect the client. |
239 | - $payment->set_details( $response_args ); |
|
239 | + $payment->set_details($response_args); |
|
240 | 240 | |
241 | - $gateway_url = ( $this->_debug_mode ) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
242 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
241 | + $gateway_url = ($this->_debug_mode) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
242 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
243 | 243 | } else { |
244 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
245 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
244 | + if (isset($response_args['L_ERRORCODE'])) { |
|
245 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
246 | 246 | } else { |
247 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
247 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
248 | 248 | } |
249 | - $payment->set_details( $response_args ); |
|
250 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
249 | + $payment->set_details($response_args); |
|
250 | + $payment->set_status($this->_pay_model->failed_status()); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | return $payment; |
@@ -263,24 +263,24 @@ discard block |
||
263 | 263 | * @param type $transaction |
264 | 264 | * @return EEI_Payment |
265 | 265 | */ |
266 | - public function handle_payment_update( $update_info, $transaction ) { |
|
267 | - $payment = ( $transaction instanceof EEI_Transaction ) ? $transaction->last_payment() : null; |
|
266 | + public function handle_payment_update($update_info, $transaction) { |
|
267 | + $payment = ($transaction instanceof EEI_Transaction) ? $transaction->last_payment() : null; |
|
268 | 268 | |
269 | - if ( $payment instanceof EEI_Payment ) { |
|
270 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
269 | + if ($payment instanceof EEI_Payment) { |
|
270 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
271 | 271 | |
272 | 272 | $payment_details = $payment->details(); |
273 | 273 | $transaction = $payment->transaction(); |
274 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
275 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
276 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
274 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
275 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
276 | + $payment->set_status($this->_pay_model->failed_status()); |
|
277 | 277 | return $payment; |
278 | 278 | } |
279 | 279 | $primary_registrant = $transaction->primary_registration(); |
280 | 280 | |
281 | 281 | // Check if we still have the token. |
282 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
283 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
282 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
283 | + $payment->set_status($this->_pay_model->failed_status()); |
|
284 | 284 | return $payment; |
285 | 285 | } |
286 | 286 | |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | 'TOKEN' => $payment_details['TOKEN'] |
290 | 290 | ); |
291 | 291 | // Request Customer Details. |
292 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
293 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
294 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
295 | - if ( $cdetails_rstatus['status'] ) { |
|
292 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
293 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
294 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
295 | + if ($cdetails_rstatus['status']) { |
|
296 | 296 | // We got the PayerID so now we can Complete the transaction. |
297 | 297 | $docheckout_request_dtls = array( |
298 | 298 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -303,39 +303,39 @@ discard block |
||
303 | 303 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
304 | 304 | ); |
305 | 305 | // Payment Checkout/Capture. |
306 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
307 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
308 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
309 | - if ( $docheckout_rstatus['status'] ) { |
|
306 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
307 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
308 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
309 | + if ($docheckout_rstatus['status']) { |
|
310 | 310 | // All is well, payment approved. |
311 | 311 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
312 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
313 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? floatval( $docheckout_response_args['PAYMENTINFO_0_AMT'] ) : 0 ); |
|
314 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
315 | - $payment->set_details( $cdata_response_args ); |
|
316 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
317 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
312 | + $payment->set_extra_accntng($primary_registration_code); |
|
313 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? floatval($docheckout_response_args['PAYMENTINFO_0_AMT']) : 0); |
|
314 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
315 | + $payment->set_details($cdata_response_args); |
|
316 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
317 | + $payment->set_status($this->_pay_model->approved_status()); |
|
318 | 318 | } else { |
319 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
320 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
319 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
320 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
321 | 321 | } else { |
322 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
322 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
323 | 323 | } |
324 | - $payment->set_details( $docheckout_response_args ); |
|
325 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
324 | + $payment->set_details($docheckout_response_args); |
|
325 | + $payment->set_status($this->_pay_model->declined_status()); |
|
326 | 326 | } |
327 | 327 | } else { |
328 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
329 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
328 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
329 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
330 | 330 | } else { |
331 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
331 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
332 | 332 | } |
333 | - $payment->set_details( $cdata_response_args ); |
|
334 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
333 | + $payment->set_details($cdata_response_args); |
|
334 | + $payment->set_status($this->_pay_model->failed_status()); |
|
335 | 335 | } |
336 | 336 | } else { |
337 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
338 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
337 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
338 | + $payment->set_status($this->_pay_model->failed_status()); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $payment; |
@@ -350,16 +350,16 @@ discard block |
||
350 | 350 | * @param EEI_Payment $payment |
351 | 351 | * @return mixed |
352 | 352 | */ |
353 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
353 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
354 | 354 | $request_dtls = array( |
355 | 355 | 'VERSION' => '204.0', |
356 | - 'USER' => urlencode( $this->_api_username ), |
|
357 | - 'PWD' => urlencode( $this->_api_password ), |
|
358 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
356 | + 'USER' => urlencode($this->_api_username), |
|
357 | + 'PWD' => urlencode($this->_api_password), |
|
358 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
359 | 359 | ); |
360 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
360 | + $dtls = array_merge($request_dtls, $request_params); |
|
361 | 361 | |
362 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
362 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
363 | 363 | // Request Customer Details. |
364 | 364 | $request_response = wp_remote_post( |
365 | 365 | $this->_base_gateway_url, |
@@ -369,11 +369,11 @@ discard block |
||
369 | 369 | 'httpversion' => '1.1', |
370 | 370 | 'cookies' => array(), |
371 | 371 | 'headers' => array(), |
372 | - 'body' => http_build_query( $dtls ) |
|
372 | + 'body' => http_build_query($dtls) |
|
373 | 373 | ) |
374 | 374 | ); |
375 | 375 | // Log the response. |
376 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
376 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
377 | 377 | |
378 | 378 | return $request_response; |
379 | 379 | } |
@@ -385,31 +385,31 @@ discard block |
||
385 | 385 | * @param mixed $request_response |
386 | 386 | * @return array |
387 | 387 | */ |
388 | - public function _ppExpress_check_response( $request_response ) { |
|
389 | - if ( ! is_wp_error( $request_response ) && $request_response['body'] && ! empty($request_response['body'] ) ) { |
|
388 | + public function _ppExpress_check_response($request_response) { |
|
389 | + if ( ! is_wp_error($request_response) && $request_response['body'] && ! empty($request_response['body'])) { |
|
390 | 390 | $response_args = array(); |
391 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
392 | - if ( isset($response_args['ACK']) |
|
391 | + parse_str(urldecode($request_response['body']), $response_args); |
|
392 | + if (isset($response_args['ACK']) |
|
393 | 393 | && $response_args['ACK'] === 'Success' |
394 | - && ( isset($response_args['PAYERID']) |
|
394 | + && (isset($response_args['PAYERID']) |
|
395 | 395 | || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
396 | - || ( isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed' ) |
|
396 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
397 | 397 | || isset($response_args['TOKEN']) |
398 | 398 | ) |
399 | 399 | ) { |
400 | 400 | // Response status OK, return response parameters for further processing. |
401 | 401 | return array('status' => true, 'args' => $response_args); |
402 | 402 | } else { |
403 | - if ( isset($response_args['ACK']) ) { |
|
403 | + if (isset($response_args['ACK'])) { |
|
404 | 404 | $errors = $this->_get_errors($response_args); |
405 | - return array( 'status' => false, 'args' => $errors ); |
|
405 | + return array('status' => false, 'args' => $errors); |
|
406 | 406 | } else { |
407 | - return array( 'status' => false, 'args' => $request_response ); |
|
407 | + return array('status' => false, 'args' => $request_response); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } else { |
411 | 411 | // If we got here then there was an error in this request. |
412 | - return array( 'status' => false, 'args' => $request_response ); |
|
412 | + return array('status' => false, 'args' => $request_response); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -422,12 +422,12 @@ discard block |
||
422 | 422 | * @param string $info |
423 | 423 | * @return void |
424 | 424 | */ |
425 | - private function _log_clean_request( $request_prms, $payment, $info ) { |
|
425 | + private function _log_clean_request($request_prms, $payment, $info) { |
|
426 | 426 | $cleaned_request_data = $request_prms; |
427 | 427 | unset($cleaned_request_data['PWD']); |
428 | 428 | unset($cleaned_request_data['USER']); |
429 | 429 | unset($cleaned_request_data['SIGNATURE']); |
430 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
430 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -437,16 +437,16 @@ discard block |
||
437 | 437 | * @param array $data_array |
438 | 438 | * @return array |
439 | 439 | */ |
440 | - private function _get_errors( $data_array ) { |
|
440 | + private function _get_errors($data_array) { |
|
441 | 441 | $errors = array(); |
442 | 442 | $n = 0; |
443 | - while ( isset($data_array['L_ERRORCODE' . $n . '']) ) { |
|
444 | - $l_error_code = isset($data_array['L_ERRORCODE' . $n . '']) ? $data_array['L_ERRORCODE' . $n . ''] : ''; |
|
445 | - $l_severity_code = isset($data_array['L_SEVERITYCODE' . $n . '']) ? $data_array['L_SEVERITYCODE' . $n . ''] : ''; |
|
446 | - $l_short_message = isset($data_array['L_SHORTMESSAGE' . $n . '']) ? $data_array['L_SHORTMESSAGE' . $n . ''] : ''; |
|
447 | - $l_long_message = isset($data_array['L_LONGMESSAGE' . $n . '']) ? $data_array['L_LONGMESSAGE' . $n . ''] : ''; |
|
443 | + while (isset($data_array['L_ERRORCODE'.$n.''])) { |
|
444 | + $l_error_code = isset($data_array['L_ERRORCODE'.$n.'']) ? $data_array['L_ERRORCODE'.$n.''] : ''; |
|
445 | + $l_severity_code = isset($data_array['L_SEVERITYCODE'.$n.'']) ? $data_array['L_SEVERITYCODE'.$n.''] : ''; |
|
446 | + $l_short_message = isset($data_array['L_SHORTMESSAGE'.$n.'']) ? $data_array['L_SHORTMESSAGE'.$n.''] : ''; |
|
447 | + $l_long_message = isset($data_array['L_LONGMESSAGE'.$n.'']) ? $data_array['L_LONGMESSAGE'.$n.''] : ''; |
|
448 | 448 | |
449 | - if ( $n == 0 ) { |
|
449 | + if ($n == 0) { |
|
450 | 450 | $errors = array( |
451 | 451 | 'L_ERRORCODE' => $l_error_code, |
452 | 452 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | 'L_SEVERITYCODE' => $l_severity_code |
455 | 455 | ); |
456 | 456 | } else { |
457 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
458 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
459 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
460 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
457 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
458 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
459 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
460 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | $n++; |
@@ -1,1 +1,1 @@ |
||
1 | -<?php printf( __('PayPal Express (Express Checkout) is an off-site payment method for accepting payments via PayPal and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalexpress/" target="_blank">','</a>' ); ?> |
|
2 | 1 | \ No newline at end of file |
2 | +<?php printf(__('PayPal Express (Express Checkout) is an off-site payment method for accepting payments via PayPal and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalexpress/" target="_blank">', '</a>'); ?> |
|
3 | 3 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { exit('No direct script access allowed'); } ?> |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } ?> |
|
2 | 2 | |
3 | 3 | <div id="ppexpress-sandbox-panel" class="sandbox-panel"> |
4 | 4 | |
@@ -6,13 +6,13 @@ discard block |
||
6 | 6 | |
7 | 7 | <h4><?php _e('How do I test specific error codes?', 'event_espresso'); ?></h4> |
8 | 8 | <p> |
9 | - <?php _e( 'To trigger an error condition on an amount-related field, |
|
9 | + <?php _e('To trigger an error condition on an amount-related field, |
|
10 | 10 | specify a error code value as a number with two digits to the right of the decimal point. |
11 | 11 | For example, specify a value of 107.55 to trigger the 10755 error.', |
12 | - 'event_espresso');?> |
|
12 | + 'event_espresso'); ?> |
|
13 | 13 | </p> |
14 | 14 | <p> |
15 | - <?php printf( __( 'More details can be found here: %1$s Testing Error Conditions %2$s.', 'event_espresso'), '<a href="https://developer.paypal.com/docs/classic/lifecycle/sb_error-conditions">', '</a>');?> |
|
15 | + <?php printf(__('More details can be found here: %1$s Testing Error Conditions %2$s.', 'event_espresso'), '<a href="https://developer.paypal.com/docs/classic/lifecycle/sb_error-conditions">', '</a>'); ?> |
|
16 | 16 | </p> |
17 | 17 | |
18 | 18 | </div> |
19 | 19 | \ No newline at end of file |
@@ -15,8 +15,8 @@ |
||
15 | 15 | class EE_PMT_Paypal_Express extends EE_PMT_Base { |
16 | 16 | |
17 | 17 | /** |
18 | - * Class constructor. |
|
19 | - */ |
|
18 | + * Class constructor. |
|
19 | + */ |
|
20 | 20 | public function __construct( $pm_instance = NULL ) { |
21 | 21 | require_once( $this->file_folder() . 'EEG_Paypal_Express.gateway.php' ); |
22 | 22 | $this->_gateway = new EEG_Paypal_Express(); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Class constructor. |
19 | 19 | */ |
20 | - public function __construct( $pm_instance = NULL ) { |
|
21 | - require_once( $this->file_folder() . 'EEG_Paypal_Express.gateway.php' ); |
|
20 | + public function __construct($pm_instance = NULL) { |
|
21 | + require_once($this->file_folder().'EEG_Paypal_Express.gateway.php'); |
|
22 | 22 | $this->_gateway = new EEG_Paypal_Express(); |
23 | 23 | |
24 | - $this->_pretty_name = __( 'PayPal Express', 'event_espresso' ); |
|
25 | - $this->_template_path = $this->file_folder() . 'templates' . DS; |
|
26 | - $this->_default_description = __( 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', 'event_espresso' ); |
|
27 | - $this->_default_button_url = $this->file_url() . 'lib' . DS . 'paypal-express-checkout-logo.png'; |
|
24 | + $this->_pretty_name = __('PayPal Express', 'event_espresso'); |
|
25 | + $this->_template_path = $this->file_folder().'templates'.DS; |
|
26 | + $this->_default_description = __('After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', 'event_espresso'); |
|
27 | + $this->_default_button_url = $this->file_url().'lib'.DS.'paypal-express-checkout-logo.png'; |
|
28 | 28 | |
29 | - parent::__construct( $pm_instance ); |
|
29 | + parent::__construct($pm_instance); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -58,34 +58,34 @@ discard block |
||
58 | 58 | 'extra_meta_inputs' => array( |
59 | 59 | 'api_username' => new EE_Text_Input( |
60 | 60 | array( |
61 | - 'html_label_text'=> sprintf( __( 'API Username %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
61 | + 'html_label_text'=> sprintf(__('API Username %s', 'event_espresso'), $this->get_help_tab_link()), |
|
62 | 62 | 'required' => true, |
63 | 63 | ) |
64 | 64 | ), |
65 | 65 | 'api_password' => new EE_Text_Input( |
66 | 66 | array( |
67 | - 'html_label_text' => sprintf( __( 'API Password %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
67 | + 'html_label_text' => sprintf(__('API Password %s', 'event_espresso'), $this->get_help_tab_link()), |
|
68 | 68 | 'required' => true |
69 | 69 | ) |
70 | 70 | ), |
71 | 71 | 'api_signature' => new EE_Text_Input( |
72 | 72 | array( |
73 | - 'html_label_text' => sprintf( __( 'API Signature %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
73 | + 'html_label_text' => sprintf(__('API Signature %s', 'event_espresso'), $this->get_help_tab_link()), |
|
74 | 74 | 'required' => true |
75 | 75 | ) |
76 | 76 | ), |
77 | 77 | 'request_shipping_addr' => new EE_Yes_No_Input( |
78 | 78 | array( |
79 | - 'html_label_text' => sprintf( __( 'Request Shipping Address %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
80 | - 'html_help_text' => __( 'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', 'event_espresso' ), |
|
79 | + 'html_label_text' => sprintf(__('Request Shipping Address %s', 'event_espresso'), $this->get_help_tab_link()), |
|
80 | + 'html_help_text' => __('If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', 'event_espresso'), |
|
81 | 81 | 'required' => true, |
82 | 82 | 'default' => true, |
83 | 83 | ) |
84 | 84 | ), |
85 | 85 | 'image_url' => new EE_Admin_File_Uploader_Input( |
86 | 86 | array( |
87 | - 'html_label_text' => sprintf( __( 'Image URL %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
88 | - 'html_help_text' => __( 'Used for your business/personal logo on the PayPal page', 'event_espresso' ), |
|
87 | + 'html_label_text' => sprintf(__('Image URL %s', 'event_espresso'), $this->get_help_tab_link()), |
|
88 | + 'html_help_text' => __('Used for your business/personal logo on the PayPal page', 'event_espresso'), |
|
89 | 89 | 'required' => false |
90 | 90 | ) |
91 | 91 | ), |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @param \EE_Transaction $transaction |
103 | 103 | * @return \EE_Billing_Info_Form |
104 | 104 | */ |
105 | - public function generate_new_billing_form( EE_Transaction $transaction = null ) { |
|
106 | - if ( $this->_pm_instance->debug_mode() ) { |
|
105 | + public function generate_new_billing_form(EE_Transaction $transaction = null) { |
|
106 | + if ($this->_pm_instance->debug_mode()) { |
|
107 | 107 | $form = new EE_Billing_Info_Form( |
108 | 108 | $this->_pm_instance, |
109 | 109 | array( |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'layout_strategy' => new EE_Template_Layout( |
115 | 115 | array( |
116 | - 'layout_template_file' => $this->_template_path . 'paypal_express_debug_info.template.php', |
|
117 | - 'template_args' => array( 'debug_mode' => $this->_pm_instance->debug_mode() ) |
|
116 | + 'layout_template_file' => $this->_template_path.'paypal_express_debug_info.template.php', |
|
117 | + 'template_args' => array('debug_mode' => $this->_pm_instance->debug_mode()) |
|
118 | 118 | ) |
119 | 119 | ) |
120 | 120 | ) |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <p><strong><?php _e('PayPal Standard', 'event_espresso'); ?></strong></p> |
2 | -<p><span class="required"><?php _e('Please Note! This gateway has been deprecated and replaced with the PayPal Express payment method. ', 'event_espresso'); ?> <?php printf( __('If you still want to use this gateway, please follow the directions to %1$sactivate it here%2$s.', 'event_espresso'), "<a href='https://eventespresso.com/wiki/paypal-standard-payment-gateway/#deprecated' target='_blank'>", '</a>'); ?></span></p> |
|
2 | +<p><span class="required"><?php _e('Please Note! This gateway has been deprecated and replaced with the PayPal Express payment method. ', 'event_espresso'); ?> <?php printf(__('If you still want to use this gateway, please follow the directions to %1$sactivate it here%2$s.', 'event_espresso'), "<a href='https://eventespresso.com/wiki/paypal-standard-payment-gateway/#deprecated' target='_blank'>", '</a>'); ?></span></p> |
|
3 | 3 | <p> |
4 | 4 | <?php _e('Adjust the settings for the PayPal Standard payment gateway.', 'event_espresso'); ?> |
5 | 5 | </p> |
6 | 6 | <p> |
7 | -<?php printf( __( 'See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso' ), "<a href='https://www.paypal.com/multicurrency' target='_blank'>","</a>" ); ?> |
|
7 | +<?php printf(__('See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso'), "<a href='https://www.paypal.com/multicurrency' target='_blank'>", "</a>"); ?> |
|
8 | 8 | </p> |
9 | 9 | <p><strong><?php _e('PayPal Standard Settings', 'event_espresso'); ?></strong></p> |
10 | 10 | <ul> |
@@ -22,18 +22,18 @@ discard block |
||
22 | 22 | </li> |
23 | 23 | <li> |
24 | 24 | <strong><?php _e('PayPal Calculates Taxes', 'event_espresso'); ?></strong><br /> |
25 | -<?php printf( __('If set to "Yes", we will indicate to PayPal that it should calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>' ); ?><br/> |
|
26 | -<?php _e( 'Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso' );?> |
|
25 | +<?php printf(__('If set to "Yes", we will indicate to PayPal that it should calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>'); ?><br/> |
|
26 | +<?php _e('Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso'); ?> |
|
27 | 27 | </li> |
28 | 28 | <li> |
29 | 29 | <strong><?php _e('PayPal Calculates Shipping', 'event_espresso'); ?></strong><br /> |
30 | 30 | <?php _e('Similar to the "PayPal Calculates Taxes" setting, if this is set to "Yes", we will indicate to PayPal that it should calculate the shipping on each payment (if there are multiple payments for a single transaction, PayPal is permitted to add shipping charges to each payment.)', 'event_espresso'); ?><br/> |
31 | -<?php _e( 'Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso' );?> |
|
31 | +<?php _e('Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso'); ?> |
|
32 | 32 | <li> |
33 | -<strong><?php _e( 'Notes Regarding Paypal Taxes and Shipping', 'event_espresso' );?></strong><br/> |
|
34 | -<?php _e( 'If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso' );?><br/> |
|
35 | -<?php _e( 'However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso' );?><br/> |
|
36 | -<?php _e( 'Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso' );?> |
|
33 | +<strong><?php _e('Notes Regarding Paypal Taxes and Shipping', 'event_espresso'); ?></strong><br/> |
|
34 | +<?php _e('If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso'); ?><br/> |
|
35 | +<?php _e('However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso'); ?><br/> |
|
36 | +<?php _e('Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso'); ?> |
|
37 | 37 | </li> |
38 | 38 | <li> |
39 | 39 | <strong><?php _e('Shipping Address Options', 'event_espresso'); ?></strong><br /> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ){ |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | } |
6 | 6 | /** |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | //define some page related constants |
30 | - define( 'EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings' ); |
|
31 | - define( 'EE_PAYMENTS_ADMIN_URL', admin_url( 'admin.php?page=' . EE_PAYMENTS_PG_SLUG )); |
|
32 | - define( 'EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES . 'payments' . DS ); |
|
33 | - define( 'EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN . 'templates' . DS ); |
|
34 | - define( 'EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'payments/assets/' ); |
|
35 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
30 | + define('EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings'); |
|
31 | + define('EE_PAYMENTS_ADMIN_URL', admin_url('admin.php?page='.EE_PAYMENTS_PG_SLUG)); |
|
32 | + define('EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES.'payments'.DS); |
|
33 | + define('EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN.'templates'.DS); |
|
34 | + define('EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL.'payments/assets/'); |
|
35 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
36 | 36 | //check that there are active gateways on all admin page loads. but dont do it just yet |
37 | 37 | // echo "constructing payments admin page";die; |
38 | - add_action('admin_notices',array($this,'check_payment_gateway_setup')); |
|
38 | + add_action('admin_notices', array($this, 'check_payment_gateway_setup')); |
|
39 | 39 | |
40 | 40 | // Show/hide PP Standard along side PP Express. |
41 | - add_filter( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', array( $this, 'unset_pp_standard' ) ); |
|
41 | + add_filter('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', array($this, 'unset_pp_standard')); |
|
42 | 42 | |
43 | 43 | parent::__construct(); |
44 | 44 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
63 | 63 | 'parent_slug' => 'espresso_events', |
64 | 64 | 'menu_slug' => EE_PAYMENTS_PG_SLUG, |
65 | - 'menu_label' => __( 'Payment Methods', 'event_espresso' ), |
|
65 | + 'menu_label' => __('Payment Methods', 'event_espresso'), |
|
66 | 66 | 'capability' => 'ee_manage_gateways', |
67 | 67 | 'admin_init_page' => $this, |
68 | 68 | ) |
@@ -76,25 +76,25 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | - public function check_payment_gateway_setup(){ |
|
79 | + public function check_payment_gateway_setup() { |
|
80 | 80 | //ONLY do this check if models can query |
81 | 81 | //and avoid a bug where when we nuke EE4's data that this causes a fatal error |
82 | 82 | //because the tables are deleted just before this request runs. see https://events.codebasehq.com/projects/event-espresso/tickets/7539 |
83 | 83 | if ( |
84 | 84 | ! EE_Maintenance_Mode::instance()->models_can_query() |
85 | - || ! $this->_get_table_analysis()->tableExists( EEM_Payment_Method::instance()->table() ) |
|
85 | + || ! $this->_get_table_analysis()->tableExists(EEM_Payment_Method::instance()->table()) |
|
86 | 86 | ) { |
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | // ensure Payment_Method model is loaded |
92 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
93 | - $actives = EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ); |
|
94 | - if( $actives < 1 ){ |
|
92 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
93 | + $actives = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart); |
|
94 | + if ($actives < 1) { |
|
95 | 95 | $url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_PAYMENTS_ADMIN_URL); |
96 | 96 | echo '<div class="error"> |
97 | - <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"),"<a href='$url'>","</a>").'</p> |
|
97 | + <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"), "<a href='$url'>", "</a>").'</p> |
|
98 | 98 | </div>'; |
99 | 99 | } |
100 | 100 | } |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | * @throws \EE_Error |
106 | 106 | */ |
107 | 107 | protected function _get_table_analysis() { |
108 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
108 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
109 | 109 | return $this->_table_analysis; |
110 | 110 | } else { |
111 | 111 | throw new \EE_Error( |
112 | 112 | sprintf( |
113 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
114 | - get_class( $this ) |
|
113 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
114 | + get_class($this) |
|
115 | 115 | ) |
116 | 116 | ); |
117 | 117 | } |
@@ -122,20 +122,20 @@ discard block |
||
122 | 122 | /** |
123 | 123 | * Hide PayPal Standard for "new" users. |
124 | 124 | */ |
125 | - public static function unset_pp_standard( $payment_method_types ) { |
|
126 | - $pps = EEM_Payment_Method::instance()->get_one_of_type( 'Paypal_Standard' ); |
|
127 | - $ppstandard_active = ( ! empty($pps) ) ? $pps->active() : false; |
|
125 | + public static function unset_pp_standard($payment_method_types) { |
|
126 | + $pps = EEM_Payment_Method::instance()->get_one_of_type('Paypal_Standard'); |
|
127 | + $ppstandard_active = ( ! empty($pps)) ? $pps->active() : false; |
|
128 | 128 | $ppstandard_active_before = false; |
129 | - if ( $pps ) { |
|
129 | + if ($pps) { |
|
130 | 130 | // PP Standard used before ? |
131 | - $paypal_id = $pps->get_extra_meta( 'paypal_id', TRUE ); |
|
132 | - if ( $paypal_id && ! empty($paypal_id) ) { |
|
131 | + $paypal_id = $pps->get_extra_meta('paypal_id', TRUE); |
|
132 | + if ($paypal_id && ! empty($paypal_id)) { |
|
133 | 133 | $ppstandard_active_before = true; |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Not using PP Standard? Then display only PayPal Express, do not show PayPal Standard. |
138 | - if ( apply_filters( 'FHEE__EE_PMT_Paypal_Express__register_payment_methods__hide_paypal_standard', ! $ppstandard_active && ! $ppstandard_active_before ) ) { |
|
138 | + if (apply_filters('FHEE__EE_PMT_Paypal_Express__register_payment_methods__hide_paypal_standard', ! $ppstandard_active && ! $ppstandard_active_before)) { |
|
139 | 139 | unset($payment_method_types['paypal_standard']); |
140 | 140 | } |
141 | 141 | return $payment_method_types; |