@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $tour_options = get_option('wetu_importer_tour_settings',false); |
98 | 98 | if(false !== $tour_options){ |
99 | 99 | $this->tour_options = $tour_options; |
100 | - } |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * Display the importer administration screen |
121 | 121 | */ |
122 | 122 | public function display_page() { |
123 | - ?> |
|
123 | + ?> |
|
124 | 124 | <div class="wrap"> |
125 | 125 | <?php screen_icon(); ?> |
126 | 126 | |
@@ -248,16 +248,16 @@ discard block |
||
248 | 248 | $result = $this->update_options(); |
249 | 249 | |
250 | 250 | if(true === $result){ |
251 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
252 | - if(!isset($_GET['refresh_tours'])){ |
|
253 | - echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
254 | - } |
|
255 | - }else{ |
|
256 | - echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
257 | - } |
|
251 | + echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
252 | + if(!isset($_GET['refresh_tours'])){ |
|
253 | + echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
254 | + } |
|
255 | + }else{ |
|
256 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
257 | + } |
|
258 | 258 | }else{ |
259 | 259 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
260 | - } |
|
260 | + } |
|
261 | 261 | echo '</h3></div>'; |
262 | 262 | } |
263 | 263 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | $tours = json_decode($data, true); |
270 | 270 | |
271 | 271 | if(isset($tours['error'])){ |
272 | - return $tours['error']; |
|
273 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
272 | + return $tours['error']; |
|
273 | + }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
274 | 274 | set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
275 | 275 | return true; |
276 | 276 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $keyphrases = $_POST['keyword']; |
320 | 320 | }else{ |
321 | 321 | $keyphrases = array(0); |
322 | - } |
|
322 | + } |
|
323 | 323 | |
324 | 324 | if(!is_array($keyphrases)){ |
325 | 325 | $keyphrases = array($keyphrases); |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | |
349 | 349 | foreach($tours as $row_key => $row){ |
350 | 350 | |
351 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
352 | - continue; |
|
353 | - } |
|
351 | + if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
352 | + continue; |
|
353 | + } |
|
354 | 354 | |
355 | - /*if('Sample' === $row['type']){ |
|
355 | + /*if('Sample' === $row['type']){ |
|
356 | 356 | continue; |
357 | 357 | }*/ |
358 | 358 | |
359 | - //If this is a current tour, add its ID to the row. |
|
359 | + //If this is a current tour, add its ID to the row. |
|
360 | 360 | $row['post_id'] = 0; |
361 | 361 | if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
362 | 362 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
@@ -365,31 +365,31 @@ discard block |
||
365 | 365 | //If we are searching for |
366 | 366 | if(false !== $post_status){ |
367 | 367 | |
368 | - if('import' === $post_status){ |
|
368 | + if('import' === $post_status){ |
|
369 | 369 | |
370 | 370 | if(0 !== $row['post_id']){ |
371 | - continue; |
|
371 | + continue; |
|
372 | 372 | }else{ |
373 | 373 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
374 | - } |
|
374 | + } |
|
375 | 375 | |
376 | 376 | |
377 | - }else{ |
|
377 | + }else{ |
|
378 | 378 | |
379 | 379 | if(0 === $row['post_id']){ |
380 | 380 | continue; |
381 | 381 | }else{ |
382 | 382 | $current_status = get_post_status($row['post_id']); |
383 | 383 | if($current_status !== $post_status){ |
384 | - continue; |
|
385 | - } |
|
384 | + continue; |
|
385 | + } |
|
386 | 386 | |
387 | 387 | } |
388 | 388 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
389 | 389 | |
390 | - } |
|
390 | + } |
|
391 | 391 | |
392 | - }else{ |
|
392 | + }else{ |
|
393 | 393 | //Search through each keyword. |
394 | 394 | foreach($keyphrases as $keyphrase){ |
395 | 395 | |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
404 | 404 | } |
405 | 405 | } |
406 | - } |
|
406 | + } |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 | |
@@ -470,17 +470,17 @@ discard block |
||
470 | 470 | $content = false; |
471 | 471 | } |
472 | 472 | |
473 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
473 | + $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
474 | 474 | |
475 | - if($jdata) |
|
476 | - { |
|
475 | + if($jdata) |
|
476 | + { |
|
477 | 477 | $jdata=json_decode($jdata,true); |
478 | - if(!empty($jdata)) |
|
479 | - { |
|
480 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
481 | - $this->format_completed_row($return); |
|
482 | - } |
|
483 | - } |
|
478 | + if(!empty($jdata)) |
|
479 | + { |
|
480 | + $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
481 | + $this->format_completed_row($return); |
|
482 | + } |
|
483 | + } |
|
484 | 484 | die(); |
485 | 485 | } |
486 | 486 | |
@@ -488,53 +488,53 @@ discard block |
||
488 | 488 | |
489 | 489 | /** |
490 | 490 | * Connect to wetu |
491 | - * |
|
492 | - * @param $data array |
|
493 | - * @param $wetu_id string |
|
491 | + * |
|
492 | + * @param $data array |
|
493 | + * @param $wetu_id string |
|
494 | 494 | */ |
495 | 495 | public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
496 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
497 | - $post = array( |
|
498 | - 'post_type' => 'tour', |
|
499 | - ); |
|
496 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
497 | + $post = array( |
|
498 | + 'post_type' => 'tour', |
|
499 | + ); |
|
500 | 500 | |
501 | - //Set the post_content |
|
501 | + //Set the post_content |
|
502 | 502 | $content_used_general_description = false; |
503 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
504 | - $data_post_content = ''; |
|
505 | - |
|
506 | - if(isset($data['description'])){ |
|
507 | - $data_post_content = $data['description']; |
|
508 | - }elseif(isset($data['summary'])){ |
|
509 | - $data_post_content = $data['summary']; |
|
510 | - } |
|
511 | - $post['post_content'] = $data_post_content; |
|
512 | - } |
|
513 | - |
|
514 | - //Create or update the post |
|
515 | - if(false !== $id && '0' !== $id){ |
|
516 | - $post['ID'] = $id; |
|
517 | - $post['post_status'] = 'publish'; |
|
518 | - $id = wp_update_post($post); |
|
519 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
520 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
521 | - }else{ |
|
522 | - |
|
523 | - //Set the name |
|
524 | - if(isset($data['name'])){ |
|
525 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
526 | - } |
|
527 | - $post['post_name'] = $post_name; |
|
528 | - $post['post_title'] = $data['name']; |
|
529 | - $post['post_status'] = 'publish'; |
|
530 | - $id = wp_insert_post($post); |
|
531 | - |
|
532 | - //Save the WETU ID and the Last date it was modified. |
|
533 | - if(false !== $id){ |
|
534 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
535 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
536 | - } |
|
537 | - } |
|
503 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
504 | + $data_post_content = ''; |
|
505 | + |
|
506 | + if(isset($data['description'])){ |
|
507 | + $data_post_content = $data['description']; |
|
508 | + }elseif(isset($data['summary'])){ |
|
509 | + $data_post_content = $data['summary']; |
|
510 | + } |
|
511 | + $post['post_content'] = $data_post_content; |
|
512 | + } |
|
513 | + |
|
514 | + //Create or update the post |
|
515 | + if(false !== $id && '0' !== $id){ |
|
516 | + $post['ID'] = $id; |
|
517 | + $post['post_status'] = 'publish'; |
|
518 | + $id = wp_update_post($post); |
|
519 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
520 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
521 | + }else{ |
|
522 | + |
|
523 | + //Set the name |
|
524 | + if(isset($data['name'])){ |
|
525 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
526 | + } |
|
527 | + $post['post_name'] = $post_name; |
|
528 | + $post['post_title'] = $data['name']; |
|
529 | + $post['post_status'] = 'publish'; |
|
530 | + $id = wp_insert_post($post); |
|
531 | + |
|
532 | + //Save the WETU ID and the Last date it was modified. |
|
533 | + if(false !== $id){ |
|
534 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
535 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
536 | + } |
|
537 | + } |
|
538 | 538 | |
539 | 539 | |
540 | 540 | //Set the price |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | $this->set_duration($data,$id); |
548 | 548 | } |
549 | 549 | |
550 | - if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
551 | - $this->process_itineraries($data,$id,$importable_content); |
|
552 | - } |
|
550 | + if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
551 | + $this->process_itineraries($data,$id,$importable_content); |
|
552 | + } |
|
553 | 553 | |
554 | 554 | if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
555 | 555 | $this->process_map_points($data,$id); |
@@ -560,24 +560,24 @@ discard block |
||
560 | 560 | if(false !== $importable_content && (in_array('itinerary_gallery',$importable_content) || in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
561 | 561 | $this->find_attachments($id); |
562 | 562 | } |
563 | - //Set the featured image |
|
564 | - //TODO Test These |
|
565 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
566 | - $this->set_featured_image($data,$id); |
|
567 | - } |
|
563 | + //Set the featured image |
|
564 | + //TODO Test These |
|
565 | + if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
566 | + $this->set_featured_image($data,$id); |
|
567 | + } |
|
568 | 568 | |
569 | 569 | //TODO Test These |
570 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
571 | - $this->set_banner_image($data,$id); |
|
572 | - } |
|
570 | + if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
571 | + $this->set_banner_image($data,$id); |
|
572 | + } |
|
573 | 573 | |
574 | 574 | //TODO Test These |
575 | - //Import the main gallery |
|
576 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
577 | - $this->create_main_gallery($data,$id); |
|
578 | - } |
|
575 | + //Import the main gallery |
|
576 | + if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
577 | + $this->create_main_gallery($data,$id); |
|
578 | + } |
|
579 | 579 | |
580 | - return $id; |
|
580 | + return $id; |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -705,31 +705,31 @@ discard block |
||
705 | 705 | */ |
706 | 706 | public function process_map_points($data,$id) { |
707 | 707 | |
708 | - if(!empty($data['routes'])){ |
|
708 | + if(!empty($data['routes'])){ |
|
709 | 709 | |
710 | - delete_post_meta($id,'wetu_map_points'); |
|
710 | + delete_post_meta($id,'wetu_map_points'); |
|
711 | 711 | |
712 | - $points = array(); |
|
712 | + $points = array(); |
|
713 | 713 | |
714 | - foreach($data['routes'] as $route){ |
|
714 | + foreach($data['routes'] as $route){ |
|
715 | 715 | |
716 | 716 | |
717 | - if(isset($route['points']) && '' !== $route['points']){ |
|
717 | + if(isset($route['points']) && '' !== $route['points']){ |
|
718 | 718 | |
719 | - $temp_points = explode(';',$route['points']); |
|
720 | - $point_counter = count($temp_points); |
|
719 | + $temp_points = explode(';',$route['points']); |
|
720 | + $point_counter = count($temp_points); |
|
721 | 721 | |
722 | 722 | for ($x = 0; $x <= $point_counter; $x++) { |
723 | - $y = $x+1; |
|
723 | + $y = $x+1; |
|
724 | 724 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
725 | 725 | $x++; |
726 | 726 | } |
727 | 727 | } |
728 | - } |
|
729 | - if(!empty($points)){ |
|
728 | + } |
|
729 | + if(!empty($points)){ |
|
730 | 730 | $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
731 | - } |
|
732 | - } |
|
731 | + } |
|
732 | + } |
|
733 | 733 | |
734 | 734 | } |
735 | 735 | |
@@ -737,17 +737,17 @@ discard block |
||
737 | 737 | * Set the Itinerary Day |
738 | 738 | */ |
739 | 739 | public function set_itinerary_day($day,$id) { |
740 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
740 | + $this->save_custom_field($day,'itinerary',$id,false,false); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
744 | 744 | * Set the price |
745 | 745 | */ |
746 | 746 | public function set_price($data,$id) { |
747 | - //Price |
|
747 | + //Price |
|
748 | 748 | if(isset($data['price']) && ''!== $data['price']){ |
749 | - $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
750 | - $this->save_custom_field($price,'price',$id); |
|
749 | + $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
750 | + $this->save_custom_field($price,'price',$id); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | //Price includes |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | $this->save_custom_field($data['price_includes'],'included',$id); |
756 | 756 | } |
757 | 757 | |
758 | - //Price Excludes |
|
758 | + //Price Excludes |
|
759 | 759 | if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
760 | 760 | $this->save_custom_field($data['price_excludes'],'not_included',$id); |
761 | 761 | } |
@@ -779,35 +779,35 @@ discard block |
||
779 | 779 | */ |
780 | 780 | public function set_accommodation($day,$id) { |
781 | 781 | |
782 | - $ac_id = false; |
|
782 | + $ac_id = false; |
|
783 | 783 | $this->current_accommodation = $this->find_current_accommodation(); |
784 | 784 | |
785 | 785 | if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
786 | 786 | |
787 | 787 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
788 | - $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
788 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
789 | 789 | }else{ |
790 | 790 | $ac_id = wp_insert_post(array( |
791 | - 'post_type' => 'accommodation', |
|
792 | - 'post_status' => 'draft', |
|
793 | - 'post_title' => $day['content_entity_id'] |
|
794 | - )); |
|
791 | + 'post_type' => 'accommodation', |
|
792 | + 'post_status' => 'draft', |
|
793 | + 'post_title' => $day['content_entity_id'] |
|
794 | + )); |
|
795 | 795 | $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
796 | 796 | } |
797 | 797 | |
798 | 798 | if('' !== $ac_id && false !== $ac_id){ |
799 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
799 | + $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
800 | 800 | $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
801 | - } |
|
801 | + } |
|
802 | 802 | } |
803 | 803 | return $ac_id; |
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
807 | 807 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
808 | - * |
|
809 | - * @param $post_type string |
|
810 | - * @return boolean / array |
|
808 | + * |
|
809 | + * @param $post_type string |
|
810 | + * @return boolean / array |
|
811 | 811 | */ |
812 | 812 | public function find_current_accommodation($post_type='accommodation') { |
813 | 813 | global $wpdb; |
@@ -815,16 +815,16 @@ discard block |
||
815 | 815 | |
816 | 816 | $return = false; |
817 | 817 | if(!empty($accommodation)){ |
818 | - foreach($accommodation as $key => $acc){ |
|
818 | + foreach($accommodation as $key => $acc){ |
|
819 | 819 | $return[$acc->meta_value] = $acc->post_id; |
820 | - } |
|
821 | - } |
|
820 | + } |
|
821 | + } |
|
822 | 822 | return $return; |
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
826 | 826 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
827 | - * @return boolean / array |
|
827 | + * @return boolean / array |
|
828 | 828 | */ |
829 | 829 | public function find_current_destinations() { |
830 | 830 | return $this->find_current_accommodation('destination'); |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
852 | 852 | if(false !== $country_wetu_id){ |
853 | 853 | $this->set_country($country_wetu_id, $id); |
854 | - } |
|
854 | + } |
|
855 | 855 | |
856 | 856 | }else { |
857 | 857 | |
@@ -862,27 +862,27 @@ discard block |
||
862 | 862 | |
863 | 863 | if (!empty($destination_data) && !isset($destination_data['error'])) { |
864 | 864 | |
865 | - $destination_title = $day['destination_content_entity_id']; |
|
865 | + $destination_title = $day['destination_content_entity_id']; |
|
866 | 866 | |
867 | - if(isset($destination_data[0]['name'])){ |
|
867 | + if(isset($destination_data[0]['name'])){ |
|
868 | 868 | $destination_title = $destination_data[0]['name']; |
869 | - } |
|
869 | + } |
|
870 | 870 | |
871 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
872 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
871 | + if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
872 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
873 | 873 | |
874 | 874 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
875 | - } |
|
875 | + } |
|
876 | 876 | |
877 | - $dest_post = array( |
|
877 | + $dest_post = array( |
|
878 | 878 | 'post_type' => 'destination', |
879 | 879 | 'post_status' => 'draft', |
880 | 880 | 'post_title' => $destination_title |
881 | 881 | ); |
882 | 882 | |
883 | - if(false !== $country_id){ |
|
883 | + if(false !== $country_id){ |
|
884 | 884 | $dest_post['post_parent'] = $country_id; |
885 | - } |
|
885 | + } |
|
886 | 886 | $dest_id = wp_insert_post($dest_post); |
887 | 887 | |
888 | 888 | //Make sure we register the |
@@ -904,50 +904,50 @@ discard block |
||
904 | 904 | * Connects the destinations post type |
905 | 905 | * |
906 | 906 | * @param $dest_id string |
907 | - * @param $country_id array |
|
907 | + * @param $country_id array |
|
908 | 908 | * @param $id string |
909 | 909 | */ |
910 | 910 | public function set_country($country_wetu_id, $id) { |
911 | - $country_id = false; |
|
911 | + $country_id = false; |
|
912 | 912 | $this->current_destinations = $this->find_current_destinations(); |
913 | 913 | |
914 | - if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
915 | - $country_id = $this->current_destinations[$country_wetu_id]; |
|
916 | - } else { |
|
914 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
915 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
916 | + } else { |
|
917 | 917 | |
918 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
918 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
919 | 919 | |
920 | - if ($country_json) { |
|
921 | - $country_data = json_decode($country_json, true); |
|
920 | + if ($country_json) { |
|
921 | + $country_data = json_decode($country_json, true); |
|
922 | 922 | |
923 | - if (!empty($country_data) && !isset($country_data['error'])) { |
|
923 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
924 | 924 | |
925 | 925 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
926 | - $country_title = $country_wetu_id; |
|
927 | - if (isset($country_data[0]['name'])) { |
|
926 | + $country_title = $country_wetu_id; |
|
927 | + if (isset($country_data[0]['name'])) { |
|
928 | 928 | $country_title = $country_data[0]['name']; |
929 | - } |
|
929 | + } |
|
930 | 930 | |
931 | 931 | $country_id = wp_insert_post(array( |
932 | - 'post_type' => 'destination', |
|
933 | - 'post_status' => 'draft', |
|
934 | - 'post_title' => $country_title |
|
935 | - )); |
|
932 | + 'post_type' => 'destination', |
|
933 | + 'post_status' => 'draft', |
|
934 | + 'post_title' => $country_title |
|
935 | + )); |
|
936 | 936 | //add the country to the current destination stack |
937 | 937 | $this->current_destinations[$country_wetu_id] = $country_id; |
938 | 938 | |
939 | 939 | //Save the wetu field |
940 | - $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
941 | - } |
|
942 | - } |
|
943 | - } |
|
940 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
941 | + } |
|
942 | + } |
|
943 | + } |
|
944 | 944 | |
945 | - if ('' !== $country_id && false !== $country_id) { |
|
946 | - $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
947 | - $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
945 | + if ('' !== $country_id && false !== $country_id) { |
|
946 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
947 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
948 | 948 | |
949 | - return $country_id; |
|
950 | - } |
|
949 | + return $country_id; |
|
950 | + } |
|
951 | 951 | } |
952 | 952 | } |
953 | 953 | $wetu_importer_tours = new WETU_Importer_Tours(); |
954 | 954 | \ No newline at end of file |