@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function set_variables() |
| 99 | 99 | { |
| 100 | - parent::set_variables(); |
|
| 100 | + parent::set_variables(); |
|
| 101 | 101 | |
| 102 | 102 | if ( false !== $this->api_username && false !== $this->api_password ) { |
| 103 | 103 | $this->url = 'https://wetu.com/API/Itinerary/'; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * Display the importer administration screen |
| 123 | 123 | */ |
| 124 | 124 | public function display_page() { |
| 125 | - ?> |
|
| 125 | + ?> |
|
| 126 | 126 | <div class="wrap"> |
| 127 | 127 | <?php $this->navigation('tour'); ?> |
| 128 | 128 | |
@@ -254,20 +254,20 @@ discard block |
||
| 254 | 254 | $result = $this->update_options(); |
| 255 | 255 | |
| 256 | 256 | if(true === $result){ |
| 257 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
| 258 | - echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
| 259 | - }else{ |
|
| 260 | - echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
| 261 | - } |
|
| 257 | + echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
| 258 | + echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
| 259 | + }else{ |
|
| 260 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
| 261 | + } |
|
| 262 | 262 | }else{ |
| 263 | 263 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
| 264 | - } |
|
| 264 | + } |
|
| 265 | 265 | echo '</h3>'; |
| 266 | 266 | |
| 267 | 267 | $form_options = get_option('lsx_ti_tours_api_options'); |
| 268 | 268 | if(false === $form_options){ |
| 269 | 269 | $form_options = array(0); |
| 270 | - } |
|
| 270 | + } |
|
| 271 | 271 | ?> |
| 272 | 272 | <form method="get" class="tour-refresh-form" action="<?php echo admin_url('admin.php'); ?>"> |
| 273 | 273 | |
@@ -295,15 +295,15 @@ discard block |
||
| 295 | 295 | */ |
| 296 | 296 | public function update_options() { |
| 297 | 297 | |
| 298 | - $own = ''; |
|
| 299 | - $options = array(); |
|
| 298 | + $own = ''; |
|
| 299 | + $options = array(); |
|
| 300 | 300 | |
| 301 | - delete_option('lsx_ti_tours_api_options'); |
|
| 301 | + delete_option('lsx_ti_tours_api_options'); |
|
| 302 | 302 | |
| 303 | - if(isset($_GET['own'])){ |
|
| 303 | + if(isset($_GET['own'])){ |
|
| 304 | 304 | $this->url_qs .= '&own=true'; |
| 305 | 305 | $options[] = 'own'; |
| 306 | - } |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | 308 | if(isset($_GET['type'])){ |
| 309 | 309 | $this->url_qs .= '&type='.implode('',$_GET['type']); |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | $tours = json_decode($data, true); |
| 320 | 320 | |
| 321 | 321 | if(isset($tours['error'])){ |
| 322 | - return $tours['error']; |
|
| 323 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
| 322 | + return $tours['error']; |
|
| 323 | + }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
| 324 | 324 | set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
| 325 | 325 | return true; |
| 326 | 326 | } |
@@ -523,71 +523,71 @@ discard block |
||
| 523 | 523 | $content = false; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
| 526 | + $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
| 527 | 527 | |
| 528 | - if($jdata) |
|
| 529 | - { |
|
| 528 | + if($jdata) |
|
| 529 | + { |
|
| 530 | 530 | $jdata=json_decode($jdata,true); |
| 531 | - if(!empty($jdata)) |
|
| 532 | - { |
|
| 533 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
| 534 | - $this->format_completed_row($return); |
|
| 535 | - $this->cleanup_posts(); |
|
| 536 | - $this->attach_destination_images($content); |
|
| 537 | - } |
|
| 538 | - } |
|
| 531 | + if(!empty($jdata)) |
|
| 532 | + { |
|
| 533 | + $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
| 534 | + $this->format_completed_row($return); |
|
| 535 | + $this->cleanup_posts(); |
|
| 536 | + $this->attach_destination_images($content); |
|
| 537 | + } |
|
| 538 | + } |
|
| 539 | 539 | } |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
| 543 | 543 | * Connect to wetu |
| 544 | - * |
|
| 545 | - * @param $data array |
|
| 546 | - * @param $wetu_id string |
|
| 544 | + * |
|
| 545 | + * @param $data array |
|
| 546 | + * @param $wetu_id string |
|
| 547 | 547 | */ |
| 548 | 548 | public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
| 549 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
| 550 | - $post = array( |
|
| 551 | - 'post_type' => 'tour', |
|
| 552 | - ); |
|
| 549 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
| 550 | + $post = array( |
|
| 551 | + 'post_type' => 'tour', |
|
| 552 | + ); |
|
| 553 | 553 | |
| 554 | - //Set the post_content |
|
| 554 | + //Set the post_content |
|
| 555 | 555 | $content_used_general_description = false; |
| 556 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
| 557 | - $data_post_content = ''; |
|
| 558 | - |
|
| 559 | - if(isset($data['description'])){ |
|
| 560 | - $data_post_content = $data['description']; |
|
| 561 | - }elseif(isset($data['summary'])){ |
|
| 562 | - $data_post_content = $data['summary']; |
|
| 563 | - } |
|
| 564 | - $post['post_content'] = $data_post_content; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - //Create or update the post |
|
| 568 | - if(false !== $id && '0' !== $id){ |
|
| 569 | - $post['ID'] = $id; |
|
| 570 | - $post['post_status'] = 'publish'; |
|
| 571 | - $id = wp_update_post($post); |
|
| 572 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
| 573 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
| 574 | - }else{ |
|
| 575 | - |
|
| 576 | - //Set the name |
|
| 577 | - if(isset($data['name'])){ |
|
| 578 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
| 579 | - } |
|
| 580 | - $post['post_name'] = $post_name; |
|
| 581 | - $post['post_title'] = $data['name']; |
|
| 582 | - $post['post_status'] = 'publish'; |
|
| 583 | - $id = wp_insert_post($post); |
|
| 584 | - |
|
| 585 | - //Save the WETU ID and the Last date it was modified. |
|
| 586 | - if(false !== $id){ |
|
| 587 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
| 588 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
| 589 | - } |
|
| 590 | - } |
|
| 556 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
| 557 | + $data_post_content = ''; |
|
| 558 | + |
|
| 559 | + if(isset($data['description'])){ |
|
| 560 | + $data_post_content = $data['description']; |
|
| 561 | + }elseif(isset($data['summary'])){ |
|
| 562 | + $data_post_content = $data['summary']; |
|
| 563 | + } |
|
| 564 | + $post['post_content'] = $data_post_content; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + //Create or update the post |
|
| 568 | + if(false !== $id && '0' !== $id){ |
|
| 569 | + $post['ID'] = $id; |
|
| 570 | + $post['post_status'] = 'publish'; |
|
| 571 | + $id = wp_update_post($post); |
|
| 572 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
| 573 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
| 574 | + }else{ |
|
| 575 | + |
|
| 576 | + //Set the name |
|
| 577 | + if(isset($data['name'])){ |
|
| 578 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
| 579 | + } |
|
| 580 | + $post['post_name'] = $post_name; |
|
| 581 | + $post['post_title'] = $data['name']; |
|
| 582 | + $post['post_status'] = 'publish'; |
|
| 583 | + $id = wp_insert_post($post); |
|
| 584 | + |
|
| 585 | + //Save the WETU ID and the Last date it was modified. |
|
| 586 | + if(false !== $id){ |
|
| 587 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
| 588 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
| 589 | + } |
|
| 590 | + } |
|
| 591 | 591 | |
| 592 | 592 | |
| 593 | 593 | //Set the price |
@@ -600,15 +600,15 @@ discard block |
||
| 600 | 600 | $this->set_duration($data,$id); |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
| 604 | - $this->process_itineraries($data,$id,$importable_content); |
|
| 605 | - } |
|
| 603 | + if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
| 604 | + $this->process_itineraries($data,$id,$importable_content); |
|
| 605 | + } |
|
| 606 | 606 | |
| 607 | 607 | if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
| 608 | 608 | $this->set_map_data($data,$id); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - return $id; |
|
| 611 | + return $id; |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /** |
@@ -770,17 +770,17 @@ discard block |
||
| 770 | 770 | * Set the Itinerary Day |
| 771 | 771 | */ |
| 772 | 772 | public function set_itinerary_day($day,$id) { |
| 773 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
| 773 | + $this->save_custom_field($day,'itinerary',$id,false,false); |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | /** |
| 777 | 777 | * Set the price |
| 778 | 778 | */ |
| 779 | 779 | public function set_price($data,$id) { |
| 780 | - //Price |
|
| 780 | + //Price |
|
| 781 | 781 | if(isset($data['price']) && ''!== $data['price']){ |
| 782 | - $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
| 783 | - $this->save_custom_field($price,'price',$id); |
|
| 782 | + $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
| 783 | + $this->save_custom_field($price,'price',$id); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | //Price includes |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | $this->save_custom_field($data['price_includes'],'included',$id); |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | - //Price Excludes |
|
| 791 | + //Price Excludes |
|
| 792 | 792 | if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
| 793 | 793 | $this->save_custom_field($data['price_excludes'],'not_included',$id); |
| 794 | 794 | } |
@@ -811,35 +811,35 @@ discard block |
||
| 811 | 811 | */ |
| 812 | 812 | public function set_accommodation($day,$id) { |
| 813 | 813 | |
| 814 | - $ac_id = false; |
|
| 814 | + $ac_id = false; |
|
| 815 | 815 | $this->current_accommodation = $this->find_current_accommodation(); |
| 816 | 816 | |
| 817 | 817 | if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
| 818 | 818 | |
| 819 | 819 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
| 820 | - $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
| 820 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
| 821 | 821 | }else{ |
| 822 | 822 | $ac_id = wp_insert_post(array( |
| 823 | - 'post_type' => 'accommodation', |
|
| 824 | - 'post_status' => 'draft', |
|
| 825 | - 'post_title' => $day['content_entity_id'] |
|
| 826 | - )); |
|
| 823 | + 'post_type' => 'accommodation', |
|
| 824 | + 'post_status' => 'draft', |
|
| 825 | + 'post_title' => $day['content_entity_id'] |
|
| 826 | + )); |
|
| 827 | 827 | $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | if('' !== $ac_id && false !== $ac_id){ |
| 831 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
| 831 | + $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
| 832 | 832 | $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
| 833 | - } |
|
| 833 | + } |
|
| 834 | 834 | } |
| 835 | 835 | return $ac_id; |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | /** |
| 839 | 839 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
| 840 | - * |
|
| 841 | - * @param $post_type string |
|
| 842 | - * @return boolean / array |
|
| 840 | + * |
|
| 841 | + * @param $post_type string |
|
| 842 | + * @return boolean / array |
|
| 843 | 843 | */ |
| 844 | 844 | public function find_current_accommodation($post_type='accommodation') { |
| 845 | 845 | global $wpdb; |
@@ -847,16 +847,16 @@ discard block |
||
| 847 | 847 | |
| 848 | 848 | $return = false; |
| 849 | 849 | if(!empty($accommodation)){ |
| 850 | - foreach($accommodation as $key => $acc){ |
|
| 850 | + foreach($accommodation as $key => $acc){ |
|
| 851 | 851 | $return[$acc->meta_value] = $acc->post_id; |
| 852 | - } |
|
| 853 | - } |
|
| 852 | + } |
|
| 853 | + } |
|
| 854 | 854 | return $return; |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
| 858 | 858 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
| 859 | - * @return boolean / array |
|
| 859 | + * @return boolean / array |
|
| 860 | 860 | */ |
| 861 | 861 | public function find_current_destinations() { |
| 862 | 862 | return $this->find_current_accommodation('destination'); |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
| 885 | 885 | if(false !== $country_wetu_id){ |
| 886 | 886 | $country_id = $this->set_country($country_wetu_id, $id); |
| 887 | - } |
|
| 887 | + } |
|
| 888 | 888 | |
| 889 | 889 | }else { |
| 890 | 890 | |
@@ -895,27 +895,27 @@ discard block |
||
| 895 | 895 | |
| 896 | 896 | if (!empty($destination_data) && !isset($destination_data['error'])) { |
| 897 | 897 | |
| 898 | - $destination_title = $day['destination_content_entity_id']; |
|
| 898 | + $destination_title = $day['destination_content_entity_id']; |
|
| 899 | 899 | |
| 900 | - if(isset($destination_data[0]['name'])){ |
|
| 900 | + if(isset($destination_data[0]['name'])){ |
|
| 901 | 901 | $destination_title = $destination_data[0]['name']; |
| 902 | - } |
|
| 902 | + } |
|
| 903 | 903 | |
| 904 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
| 905 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
| 904 | + if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
| 905 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
| 906 | 906 | |
| 907 | 907 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
| 908 | - } |
|
| 908 | + } |
|
| 909 | 909 | |
| 910 | - $dest_post = array( |
|
| 910 | + $dest_post = array( |
|
| 911 | 911 | 'post_type' => 'destination', |
| 912 | 912 | 'post_status' => 'draft', |
| 913 | 913 | 'post_title' => $destination_title |
| 914 | 914 | ); |
| 915 | 915 | |
| 916 | - if(false !== $country_id){ |
|
| 916 | + if(false !== $country_id){ |
|
| 917 | 917 | $dest_post['post_parent'] = $country_id; |
| 918 | - } |
|
| 918 | + } |
|
| 919 | 919 | $dest_id = wp_insert_post($dest_post); |
| 920 | 920 | |
| 921 | 921 | //Make sure we register the |
@@ -933,16 +933,16 @@ discard block |
||
| 933 | 933 | |
| 934 | 934 | // Save the first destination so we can grab the tour featured image and banner |
| 935 | 935 | if(0 === $leg_counter){ |
| 936 | - $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']); |
|
| 937 | - } |
|
| 936 | + $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']); |
|
| 937 | + } |
|
| 938 | 938 | |
| 939 | 939 | //Add this relation info so we can make sure certain items are set as countries. |
| 940 | 940 | if(0 !== $country_id && false !== $country_id){ |
| 941 | - $this->relation_meta[$dest_id] = $country_id; |
|
| 941 | + $this->relation_meta[$dest_id] = $country_id; |
|
| 942 | 942 | $this->relation_meta[$country_id] = 0; |
| 943 | - }else{ |
|
| 943 | + }else{ |
|
| 944 | 944 | $this->relation_meta[$dest_id] = 0; |
| 945 | - } |
|
| 945 | + } |
|
| 946 | 946 | } |
| 947 | 947 | } |
| 948 | 948 | return $dest_id; |
@@ -952,53 +952,53 @@ discard block |
||
| 952 | 952 | * Connects the destinations post type |
| 953 | 953 | * |
| 954 | 954 | * @param $dest_id string |
| 955 | - * @param $country_id array |
|
| 955 | + * @param $country_id array |
|
| 956 | 956 | * @param $id string |
| 957 | - * |
|
| 958 | - * @return string |
|
| 957 | + * |
|
| 958 | + * @return string |
|
| 959 | 959 | */ |
| 960 | 960 | public function set_country($country_wetu_id, $id) { |
| 961 | - $country_id = false; |
|
| 961 | + $country_id = false; |
|
| 962 | 962 | $this->current_destinations = $this->find_current_destinations(); |
| 963 | 963 | |
| 964 | - if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
| 965 | - $country_id = $this->current_destinations[$country_wetu_id]; |
|
| 966 | - } else { |
|
| 964 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
| 965 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
| 966 | + } else { |
|
| 967 | 967 | |
| 968 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
| 968 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
| 969 | 969 | |
| 970 | - if ($country_json) { |
|
| 971 | - $country_data = json_decode($country_json, true); |
|
| 970 | + if ($country_json) { |
|
| 971 | + $country_data = json_decode($country_json, true); |
|
| 972 | 972 | |
| 973 | - if (!empty($country_data) && !isset($country_data['error'])) { |
|
| 973 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
| 974 | 974 | |
| 975 | 975 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
| 976 | - $country_title = $country_wetu_id; |
|
| 977 | - if (isset($country_data[0]['name'])) { |
|
| 976 | + $country_title = $country_wetu_id; |
|
| 977 | + if (isset($country_data[0]['name'])) { |
|
| 978 | 978 | $country_title = $country_data[0]['name']; |
| 979 | - } |
|
| 979 | + } |
|
| 980 | 980 | |
| 981 | 981 | $country_id = wp_insert_post(array( |
| 982 | - 'post_type' => 'destination', |
|
| 983 | - 'post_status' => 'draft', |
|
| 984 | - 'post_title' => $country_title |
|
| 985 | - )); |
|
| 982 | + 'post_type' => 'destination', |
|
| 983 | + 'post_status' => 'draft', |
|
| 984 | + 'post_title' => $country_title |
|
| 985 | + )); |
|
| 986 | 986 | //add the country to the current destination stack |
| 987 | 987 | $this->current_destinations[$country_wetu_id] = $country_id; |
| 988 | 988 | |
| 989 | 989 | //Save the wetu field |
| 990 | - $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
| 991 | - } |
|
| 992 | - } |
|
| 993 | - } |
|
| 994 | - |
|
| 995 | - if ('' !== $country_id && false !== $country_id) { |
|
| 996 | - $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
| 997 | - $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
| 990 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
| 991 | + } |
|
| 992 | + } |
|
| 993 | + } |
|
| 994 | + |
|
| 995 | + if ('' !== $country_id && false !== $country_id) { |
|
| 996 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
| 997 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
| 998 | 998 | $this->cleanup_posts[$country_id] = 'tour_to_destination'; |
| 999 | 999 | |
| 1000 | - return $country_id; |
|
| 1001 | - } |
|
| 1000 | + return $country_id; |
|
| 1001 | + } |
|
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | /** |
@@ -1011,9 +1011,9 @@ discard block |
||
| 1011 | 1011 | * @return string |
| 1012 | 1012 | */ |
| 1013 | 1013 | public function attach_destination_images($importable_content=array()) { |
| 1014 | - if(false !== $this->destination_images){ |
|
| 1014 | + if(false !== $this->destination_images){ |
|
| 1015 | 1015 | |
| 1016 | - foreach($this->destination_images as $tour => $destination){ |
|
| 1016 | + foreach($this->destination_images as $tour => $destination){ |
|
| 1017 | 1017 | |
| 1018 | 1018 | $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
| 1019 | 1019 | $url_qs = ''; |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | } |
| 1035 | 1035 | } |
| 1036 | 1036 | } |
| 1037 | - } |
|
| 1038 | - } |
|
| 1037 | + } |
|
| 1038 | + } |
|
| 1039 | 1039 | } |
| 1040 | 1040 | } |
| 1041 | 1041 | \ No newline at end of file |
@@ -99,21 +99,21 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | parent::set_variables(); |
| 101 | 101 | |
| 102 | - if ( false !== $this->api_username && false !== $this->api_password ) { |
|
| 102 | + if (false !== $this->api_username && false !== $this->api_password) { |
|
| 103 | 103 | $this->url = 'https://wetu.com/API/Itinerary/'; |
| 104 | - $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
|
| 105 | - } elseif ( false !== $this->api_key ) { |
|
| 106 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
| 104 | + $this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password; |
|
| 105 | + } elseif (false !== $this->api_key) { |
|
| 106 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
| 107 | 107 | $this->url_qs = ''; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $temp_options = get_option('_lsx-to_settings',false); |
|
| 111 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
| 110 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 111 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
| 112 | 112 | $this->options = $temp_options[$this->plugin_slug]; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $tour_options = get_option('wetu_importer_tour_settings',false); |
|
| 116 | - if(false !== $tour_options){ |
|
| 115 | + $tour_options = get_option('wetu_importer_tour_settings', false); |
|
| 116 | + if (false !== $tour_options) { |
|
| 117 | 117 | $this->tour_options = $tour_options; |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | <form method="get" action="" id="posts-filter"> |
| 134 | 134 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
| 135 | 135 | |
| 136 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
| 137 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
| 136 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
| 137 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
| 138 | 138 | </p> |
| 139 | 139 | |
| 140 | 140 | <table class="wp-list-table widefat fixed posts"> |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | <tbody id="the-list"> |
| 144 | 144 | <tr class="post-0 type-tour status-none" id="post-0"> |
| 145 | 145 | <th class="check-column" scope="row"> |
| 146 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
| 146 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
| 147 | 147 | </th> |
| 148 | 148 | <td class="post-title page-title column-title"> |
| 149 | 149 | <strong> |
| 150 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
| 150 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
| 151 | 151 | </strong> |
| 152 | 152 | </td> |
| 153 | 153 | <td class="date column-date"> |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | </table> |
| 163 | 163 | |
| 164 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
| 165 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
| 164 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
| 165 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
| 166 | 166 | </p> |
| 167 | 167 | </form> |
| 168 | 168 | |
@@ -174,16 +174,16 @@ discard block |
||
| 174 | 174 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 175 | 175 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
| 176 | 176 | <ul> |
| 177 | - <li><input class="content select-all" <?php $this->checked($this->tour_options,'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All','wetu-importer'); ?></li> |
|
| 178 | - <li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
| 179 | - <li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
| 177 | + <li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li> |
|
| 178 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
| 179 | + <li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
| 180 | 180 | |
| 181 | - <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li> |
|
| 182 | - <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li> |
|
| 181 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li> |
|
| 182 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li> |
|
| 183 | 183 | |
| 184 | - <li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
| 184 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
| 185 | 185 | |
| 186 | - <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li> |
|
| 186 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li> |
|
| 187 | 187 | |
| 188 | 188 | <?php /*if(class_exists('LSX_TO_Maps')){ ?> |
| 189 | 189 | <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li> |
@@ -193,20 +193,20 @@ discard block |
||
| 193 | 193 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 194 | 194 | <h3><?php _e('Itinerary Info'); ?></h3> |
| 195 | 195 | <ul> |
| 196 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
| 197 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included','wetu-importer'); ?></li> |
|
| 198 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded','wetu-importer'); ?></li> |
|
| 196 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
| 197 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included', 'wetu-importer'); ?></li> |
|
| 198 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded', 'wetu-importer'); ?></li> |
|
| 199 | 199 | </ul> |
| 200 | 200 | |
| 201 | 201 | <h4><?php _e('Additional Content'); ?></h4> |
| 202 | 202 | <ul> |
| 203 | - <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li> |
|
| 204 | - <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li> |
|
| 205 | - <li><input class="content" <?php $this->checked($this->tour_options,'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image','wetu-importer'); ?></li> |
|
| 206 | - <li><input class="content" <?php $this->checked($this->tour_options,'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image','wetu-importer'); ?></li> |
|
| 203 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li> |
|
| 204 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li> |
|
| 205 | + <li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image', 'wetu-importer'); ?></li> |
|
| 206 | + <li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image', 'wetu-importer'); ?></li> |
|
| 207 | 207 | </ul> |
| 208 | 208 | </div> |
| 209 | - <?php if(class_exists('LSX_TO_Team')){ ?> |
|
| 209 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
| 210 | 210 | <div style="width:30%;display:block;float:left;"> |
| 211 | 211 | <h3><?php _e('Assign a Team Member'); ?></h3> |
| 212 | 212 | <?php $this->team_member_checkboxes($this->tour_options); ?> |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | <h3><?php _e('Your List'); ?></h3> |
| 221 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
| 221 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 222 | 222 | <table class="wp-list-table widefat fixed posts"> |
| 223 | 223 | <?php $this->table_header(); ?> |
| 224 | 224 | |
@@ -230,12 +230,12 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | </table> |
| 232 | 232 | |
| 233 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
| 233 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 234 | 234 | </form> |
| 235 | 235 | </div> |
| 236 | 236 | |
| 237 | 237 | <div style="display:none;" class="completed-list-wrapper"> |
| 238 | - <h3><?php _e('Completed','wetu-importer'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3> |
|
| 238 | + <h3><?php _e('Completed', 'wetu-importer'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3> |
|
| 239 | 239 | <ul> |
| 240 | 240 | </ul> |
| 241 | 241 | </div> |
@@ -249,23 +249,23 @@ discard block |
||
| 249 | 249 | public function update_options_form() { |
| 250 | 250 | $tours = get_transient('lsx_ti_tours'); |
| 251 | 251 | |
| 252 | - echo '<div class="wetu-status tour-wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - '; |
|
| 253 | - if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){ |
|
| 252 | + echo '<div class="wetu-status tour-wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - '; |
|
| 253 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
| 254 | 254 | $result = $this->update_options(); |
| 255 | 255 | |
| 256 | - if(true === $result){ |
|
| 257 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
| 258 | - echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
| 259 | - }else{ |
|
| 256 | + if (true === $result) { |
|
| 257 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
| 258 | + echo ' - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
| 259 | + }else { |
|
| 260 | 260 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
| 261 | 261 | } |
| 262 | - }else{ |
|
| 263 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
| 262 | + }else { |
|
| 263 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
| 264 | 264 | } |
| 265 | 265 | echo '</h3>'; |
| 266 | 266 | |
| 267 | 267 | $form_options = get_option('lsx_ti_tours_api_options'); |
| 268 | - if(false === $form_options){ |
|
| 268 | + if (false === $form_options) { |
|
| 269 | 269 | $form_options = array(0); |
| 270 | 270 | } |
| 271 | 271 | ?> |
@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | <input type="hidden" name="refresh_tours" value="true" /> |
| 277 | 277 | |
| 278 | 278 | <p class="tour-search-options"> |
| 279 | - <label for="own"><input class="content" <?php if(in_array('own',$form_options)){ echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours','wetu-importer'); ?> </label> |
|
| 279 | + <label for="own"><input class="content" <?php if (in_array('own', $form_options)) { echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours', 'wetu-importer'); ?> </label> |
|
| 280 | 280 | </p> |
| 281 | 281 | |
| 282 | 282 | <p class="tour-search-options"> |
| 283 | - <label for="type"><input class="content" <?php if(in_array('allitineraries',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php _e('All','wetu-importer'); ?></label> |
|
| 284 | - <label for="type"><input class="content" <?php if(in_array('sample',$form_options)){ echo 'checked'; } ?>type="radio" name="type[]" value="sample" /> <?php _e('Sample','wetu-importer'); ?></label> |
|
| 285 | - <label for="type"><input class="content" <?php if(in_array('personal',$form_options)){ echo 'checked'; } ?>type="radio" name="type[]" value="personal" /> <?php _e('Personal','wetu-importer'); ?></label> |
|
| 283 | + <label for="type"><input class="content" <?php if (in_array('allitineraries', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php _e('All', 'wetu-importer'); ?></label> |
|
| 284 | + <label for="type"><input class="content" <?php if (in_array('sample', $form_options)) { echo 'checked'; } ?>type="radio" name="type[]" value="sample" /> <?php _e('Sample', 'wetu-importer'); ?></label> |
|
| 285 | + <label for="type"><input class="content" <?php if (in_array('personal', $form_options)) { echo 'checked'; } ?>type="radio" name="type[]" value="personal" /> <?php _e('Personal', 'wetu-importer'); ?></label> |
|
| 286 | 286 | </p> |
| 287 | 287 | </form> |
| 288 | 288 | |
@@ -300,28 +300,28 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | delete_option('lsx_ti_tours_api_options'); |
| 302 | 302 | |
| 303 | - if(isset($_GET['own'])){ |
|
| 303 | + if (isset($_GET['own'])) { |
|
| 304 | 304 | $this->url_qs .= '&own=true'; |
| 305 | 305 | $options[] = 'own'; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if(isset($_GET['type'])){ |
|
| 309 | - $this->url_qs .= '&type='.implode('',$_GET['type']); |
|
| 310 | - $options[] = implode('',$_GET['type']); |
|
| 308 | + if (isset($_GET['type'])) { |
|
| 309 | + $this->url_qs .= '&type='.implode('', $_GET['type']); |
|
| 310 | + $options[] = implode('', $_GET['type']); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | $this->url_qs .= '&results=2000'; |
| 314 | 314 | |
| 315 | - add_option('lsx_ti_tours_api_options',$options); |
|
| 315 | + add_option('lsx_ti_tours_api_options', $options); |
|
| 316 | 316 | |
| 317 | - $data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs ); |
|
| 317 | + $data = file_get_contents($this->url.'/V7/List?'.$this->url_qs); |
|
| 318 | 318 | |
| 319 | 319 | $tours = json_decode($data, true); |
| 320 | 320 | |
| 321 | - if(isset($tours['error'])){ |
|
| 321 | + if (isset($tours['error'])) { |
|
| 322 | 322 | return $tours['error']; |
| 323 | 323 | }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
| 324 | - set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
|
| 324 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
| 325 | 325 | return true; |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -345,8 +345,8 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | LIMIT 0,500 |
| 347 | 347 | "); |
| 348 | - if(null !== $current_tours && !empty($current_tours)){ |
|
| 349 | - foreach($current_tours as $tour){ |
|
| 348 | + if (null !== $current_tours && !empty($current_tours)) { |
|
| 349 | + foreach ($current_tours as $tour) { |
|
| 350 | 350 | $return[$tour->meta_value] = $tour; |
| 351 | 351 | } |
| 352 | 352 | } |
@@ -359,38 +359,38 @@ discard block |
||
| 359 | 359 | public function process_ajax_search() { |
| 360 | 360 | $return = false; |
| 361 | 361 | |
| 362 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){ |
|
| 362 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
| 363 | 363 | |
| 364 | 364 | |
| 365 | 365 | $tours = get_transient('lsx_ti_tours'); |
| 366 | - if ( false !== $tours) { |
|
| 366 | + if (false !== $tours) { |
|
| 367 | 367 | |
| 368 | 368 | $searched_items = false; |
| 369 | 369 | |
| 370 | - if(isset($_POST['keyword'] )) { |
|
| 370 | + if (isset($_POST['keyword'])) { |
|
| 371 | 371 | $keyphrases = $_POST['keyword']; |
| 372 | - }else{ |
|
| 372 | + }else { |
|
| 373 | 373 | $keyphrases = array(0); |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if(!is_array($keyphrases)){ |
|
| 376 | + if (!is_array($keyphrases)) { |
|
| 377 | 377 | $keyphrases = array($keyphrases); |
| 378 | 378 | } |
| 379 | - foreach($keyphrases as &$keyword){ |
|
| 379 | + foreach ($keyphrases as &$keyword) { |
|
| 380 | 380 | $keyword = ltrim(rtrim($keyword)); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | $post_status = false; |
| 384 | - if(in_array('publish',$keyphrases)){ |
|
| 384 | + if (in_array('publish', $keyphrases)) { |
|
| 385 | 385 | $post_status = 'publish'; |
| 386 | 386 | } |
| 387 | - if(in_array('pending',$keyphrases)){ |
|
| 387 | + if (in_array('pending', $keyphrases)) { |
|
| 388 | 388 | $post_status = 'pending'; |
| 389 | 389 | } |
| 390 | - if(in_array('draft',$keyphrases)){ |
|
| 390 | + if (in_array('draft', $keyphrases)) { |
|
| 391 | 391 | $post_status = 'draft'; |
| 392 | 392 | } |
| 393 | - if(in_array('import',$keyphrases)){ |
|
| 393 | + if (in_array('import', $keyphrases)) { |
|
| 394 | 394 | $post_status = 'import'; |
| 395 | 395 | } |
| 396 | 396 | |
@@ -398,9 +398,9 @@ discard block |
||
| 398 | 398 | if (!empty($tours)) { |
| 399 | 399 | $current_tours = $this->find_current_tours(); |
| 400 | 400 | |
| 401 | - foreach($tours as $row_key => $row){ |
|
| 401 | + foreach ($tours as $row_key => $row) { |
|
| 402 | 402 | |
| 403 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
| 403 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
| 404 | 404 | continue; |
| 405 | 405 | } |
| 406 | 406 | |
@@ -410,29 +410,29 @@ discard block |
||
| 410 | 410 | |
| 411 | 411 | //If this is a current tour, add its ID to the row. |
| 412 | 412 | $row['post_id'] = 0; |
| 413 | - if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
|
| 413 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
| 414 | 414 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | //If we are searching for |
| 418 | - if(false !== $post_status){ |
|
| 418 | + if (false !== $post_status) { |
|
| 419 | 419 | |
| 420 | - if('import' === $post_status){ |
|
| 420 | + if ('import' === $post_status) { |
|
| 421 | 421 | |
| 422 | - if(0 !== $row['post_id']){ |
|
| 422 | + if (0 !== $row['post_id']) { |
|
| 423 | 423 | continue; |
| 424 | - }else{ |
|
| 424 | + }else { |
|
| 425 | 425 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | |
| 429 | - }else{ |
|
| 429 | + }else { |
|
| 430 | 430 | |
| 431 | - if(0 === $row['post_id']){ |
|
| 431 | + if (0 === $row['post_id']) { |
|
| 432 | 432 | continue; |
| 433 | - }else{ |
|
| 433 | + }else { |
|
| 434 | 434 | $current_status = get_post_status($row['post_id']); |
| 435 | - if($current_status !== $post_status){ |
|
| 435 | + if ($current_status !== $post_status) { |
|
| 436 | 436 | continue; |
| 437 | 437 | } |
| 438 | 438 | |
@@ -441,17 +441,17 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - }else{ |
|
| 444 | + }else { |
|
| 445 | 445 | //Search through each keyword. |
| 446 | - foreach($keyphrases as $keyphrase){ |
|
| 446 | + foreach ($keyphrases as $keyphrase) { |
|
| 447 | 447 | |
| 448 | 448 | //Make sure the keyphrase is turned into an array |
| 449 | - $keywords = explode(" ",$keyphrase); |
|
| 450 | - if(!is_array($keywords)){ |
|
| 449 | + $keywords = explode(" ", $keyphrase); |
|
| 450 | + if (!is_array($keywords)) { |
|
| 451 | 451 | $keywords = array($keywords); |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
| 454 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
| 455 | 455 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
| 456 | 456 | } |
| 457 | 457 | } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | } |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - if(false !== $searched_items){ |
|
| 462 | + if (false !== $searched_items) { |
|
| 463 | 463 | ksort($searched_items); |
| 464 | 464 | $return = implode($searched_items); |
| 465 | 465 | } |
@@ -472,11 +472,11 @@ discard block |
||
| 472 | 472 | /** |
| 473 | 473 | * Formats the row for output on the screen. |
| 474 | 474 | */ |
| 475 | - public function format_row($row = false){ |
|
| 476 | - if(false !== $row){ |
|
| 475 | + public function format_row($row = false) { |
|
| 476 | + if (false !== $row) { |
|
| 477 | 477 | |
| 478 | 478 | $status = 'import'; |
| 479 | - if(0 !== $row['post_id']){ |
|
| 479 | + if (0 !== $row['post_id']) { |
|
| 480 | 480 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
| 481 | 481 | } |
| 482 | 482 | |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | <strong>'.$row['name'].'</strong> - '.$status.' |
| 491 | 491 | </td> |
| 492 | 492 | <td class="date column-date"> |
| 493 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 493 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 494 | 494 | </td> |
| 495 | 495 | <td class="ssid column-ssid"> |
| 496 | 496 | '.$row['identifier'].' |
@@ -506,31 +506,31 @@ discard block |
||
| 506 | 506 | public function process_ajax_import($force = false) { |
| 507 | 507 | $return = false; |
| 508 | 508 | |
| 509 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){ |
|
| 509 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
| 510 | 510 | |
| 511 | 511 | $wetu_id = $_POST['wetu_id']; |
| 512 | - if(isset($_POST['post_id'])){ |
|
| 512 | + if (isset($_POST['post_id'])) { |
|
| 513 | 513 | $post_id = $_POST['post_id']; |
| 514 | - }else{ |
|
| 514 | + }else { |
|
| 515 | 515 | $post_id = 0; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | delete_option('wetu_importer_tour_settings'); |
| 519 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
| 519 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 520 | 520 | $content = $_POST['content']; |
| 521 | - add_option('wetu_importer_tour_settings',$content); |
|
| 522 | - }else{ |
|
| 521 | + add_option('wetu_importer_tour_settings', $content); |
|
| 522 | + }else { |
|
| 523 | 523 | $content = false; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
| 526 | + $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
| 527 | 527 | |
| 528 | - if($jdata) |
|
| 528 | + if ($jdata) |
|
| 529 | 529 | { |
| 530 | - $jdata=json_decode($jdata,true); |
|
| 531 | - if(!empty($jdata)) |
|
| 530 | + $jdata = json_decode($jdata, true); |
|
| 531 | + if (!empty($jdata)) |
|
| 532 | 532 | { |
| 533 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
| 533 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
| 534 | 534 | $this->format_completed_row($return); |
| 535 | 535 | $this->cleanup_posts(); |
| 536 | 536 | $this->attach_destination_images($content); |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | * @param $data array |
| 546 | 546 | * @param $wetu_id string |
| 547 | 547 | */ |
| 548 | - public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
|
| 548 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) { |
|
| 549 | 549 | $post_name = $data_post_content = $data_post_excerpt = ''; |
| 550 | 550 | $post = array( |
| 551 | 551 | 'post_type' => 'tour', |
@@ -553,29 +553,29 @@ discard block |
||
| 553 | 553 | |
| 554 | 554 | //Set the post_content |
| 555 | 555 | $content_used_general_description = false; |
| 556 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
| 556 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
| 557 | 557 | $data_post_content = ''; |
| 558 | 558 | |
| 559 | - if(isset($data['description'])){ |
|
| 559 | + if (isset($data['description'])) { |
|
| 560 | 560 | $data_post_content = $data['description']; |
| 561 | - }elseif(isset($data['summary'])){ |
|
| 561 | + }elseif (isset($data['summary'])) { |
|
| 562 | 562 | $data_post_content = $data['summary']; |
| 563 | 563 | } |
| 564 | 564 | $post['post_content'] = $data_post_content; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | //Create or update the post |
| 568 | - if(false !== $id && '0' !== $id){ |
|
| 568 | + if (false !== $id && '0' !== $id) { |
|
| 569 | 569 | $post['ID'] = $id; |
| 570 | 570 | $post['post_status'] = 'publish'; |
| 571 | 571 | $id = wp_update_post($post); |
| 572 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
| 573 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
| 574 | - }else{ |
|
| 572 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 573 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date); |
|
| 574 | + }else { |
|
| 575 | 575 | |
| 576 | 576 | //Set the name |
| 577 | - if(isset($data['name'])){ |
|
| 578 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
| 577 | + if (isset($data['name'])) { |
|
| 578 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
| 579 | 579 | } |
| 580 | 580 | $post['post_name'] = $post_name; |
| 581 | 581 | $post['post_title'] = $data['name']; |
@@ -583,29 +583,29 @@ discard block |
||
| 583 | 583 | $id = wp_insert_post($post); |
| 584 | 584 | |
| 585 | 585 | //Save the WETU ID and the Last date it was modified. |
| 586 | - if(false !== $id){ |
|
| 587 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
| 588 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
| 586 | + if (false !== $id) { |
|
| 587 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 588 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified'])); |
|
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | |
| 593 | 593 | //Set the price |
| 594 | - if(false !== $importable_content && in_array('price',$importable_content)){ |
|
| 595 | - $this->set_price($data,$id); |
|
| 594 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
| 595 | + $this->set_price($data, $id); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | //Set the Duration |
| 599 | - if(false !== $importable_content && in_array('duration',$importable_content)){ |
|
| 600 | - $this->set_duration($data,$id); |
|
| 599 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
| 600 | + $this->set_duration($data, $id); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
| 604 | - $this->process_itineraries($data,$id,$importable_content); |
|
| 603 | + if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
| 604 | + $this->process_itineraries($data, $id, $importable_content); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
|
| 608 | - $this->set_map_data($data,$id); |
|
| 607 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
| 608 | + $this->set_map_data($data, $id); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | return $id; |
@@ -614,151 +614,151 @@ discard block |
||
| 614 | 614 | /** |
| 615 | 615 | * A loop which runs through each leg on the tour. |
| 616 | 616 | */ |
| 617 | - public function process_itineraries($data,$id,$importable_content) { |
|
| 617 | + public function process_itineraries($data, $id, $importable_content) { |
|
| 618 | 618 | $day_counter = 1; |
| 619 | 619 | $leg_counter = 0; |
| 620 | 620 | |
| 621 | - delete_post_meta($id,'itinerary'); |
|
| 621 | + delete_post_meta($id, 'itinerary'); |
|
| 622 | 622 | |
| 623 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
| 624 | - delete_post_meta($id,'accommodation_to_tour'); |
|
| 623 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 624 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
| 625 | 625 | } |
| 626 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
| 627 | - delete_post_meta($id,'destination_to_tour'); |
|
| 628 | - delete_post_meta($id,'departs_from'); |
|
| 629 | - delete_post_meta($id,'ends_in'); |
|
| 626 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 627 | + delete_post_meta($id, 'destination_to_tour'); |
|
| 628 | + delete_post_meta($id, 'departs_from'); |
|
| 629 | + delete_post_meta($id, 'ends_in'); |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | $departs_from = false; |
| 633 | 633 | $ends_in = false; |
| 634 | 634 | |
| 635 | - foreach($data['legs'] as $leg){ |
|
| 635 | + foreach ($data['legs'] as $leg) { |
|
| 636 | 636 | |
| 637 | - if(isset($leg['days']) && !empty($leg['days'])){ |
|
| 637 | + if (isset($leg['days']) && !empty($leg['days'])) { |
|
| 638 | 638 | |
| 639 | 639 | //Itinerary Accommodation |
| 640 | 640 | $current_accommodation = false; |
| 641 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
| 642 | - $current_accommodation = $this->set_accommodation($leg,$id); |
|
| 641 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 642 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | //Itinerary Destination |
| 646 | 646 | $current_destination = false; |
| 647 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
| 648 | - $current_destination = $this->set_destination($leg,$id,$leg_counter); |
|
| 647 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 648 | + $current_destination = $this->set_destination($leg, $id, $leg_counter); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
| 652 | - if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){ |
|
| 652 | + if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) { |
|
| 653 | 653 | |
| 654 | - foreach($leg['days'] as $day){ |
|
| 654 | + foreach ($leg['days'] as $day) { |
|
| 655 | 655 | |
| 656 | 656 | $current_day = array(); |
| 657 | 657 | |
| 658 | - $current_day['title'] = esc_attr('Day ','wetu-importer').$day_counter; |
|
| 658 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
| 659 | 659 | |
| 660 | 660 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
| 661 | 661 | |
| 662 | 662 | //Description |
| 663 | - if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){ |
|
| 663 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
| 664 | 664 | $current_day['description'] = $day['notes']; |
| 665 | - }else{ |
|
| 665 | + }else { |
|
| 666 | 666 | $current_day['description'] = ''; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | //Itinerary Gallery |
| 670 | - if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
|
| 670 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
| 671 | 671 | $current_day['featured_image'] = ''; |
| 672 | - }else{ |
|
| 672 | + }else { |
|
| 673 | 673 | $current_day['featured_image'] = ''; |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | //Accommodation |
| 677 | - if(false !== $current_accommodation){ |
|
| 677 | + if (false !== $current_accommodation) { |
|
| 678 | 678 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
| 679 | - }else{ |
|
| 679 | + }else { |
|
| 680 | 680 | $current_day['accommodation_to_tour'] = array(); |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | //Destination |
| 684 | - if(false !== $current_destination){ |
|
| 684 | + if (false !== $current_destination) { |
|
| 685 | 685 | $current_day['destination_to_tour'] = array($current_destination); |
| 686 | - }else{ |
|
| 686 | + }else { |
|
| 687 | 687 | $current_day['destination_to_tour'] = array(); |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | //Included |
| 691 | - if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){ |
|
| 691 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
| 692 | 692 | $current_day['included'] = $day['included']; |
| 693 | - }else{ |
|
| 693 | + }else { |
|
| 694 | 694 | $current_day['included'] = ''; |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | //Excluded |
| 698 | - if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){ |
|
| 698 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
| 699 | 699 | $current_day['excluded'] = $day['excluded']; |
| 700 | - }else{ |
|
| 700 | + }else { |
|
| 701 | 701 | $current_day['excluded'] = ''; |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - $this->set_itinerary_day($current_day,$id); |
|
| 704 | + $this->set_itinerary_day($current_day, $id); |
|
| 705 | 705 | $day_counter++; |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - }else{ |
|
| 709 | - $day_counter = $day_counter + (int)$leg['nights']; |
|
| 708 | + }else { |
|
| 709 | + $day_counter = $day_counter + (int) $leg['nights']; |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
| 715 | - if( 0 === $leg_counter && false !== $current_destination){ |
|
| 715 | + if (0 === $leg_counter && false !== $current_destination) { |
|
| 716 | 716 | $departs_from = $current_destination; |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | //If its the last leg then save it as the ends in. |
| 720 | - if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){ |
|
| 720 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
| 721 | 721 | $ends_in = $current_destination; |
| 722 | 722 | } |
| 723 | 723 | $leg_counter++; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - if(false !== $departs_from){ |
|
| 727 | - add_post_meta($id,'departs_from',$departs_from,true); |
|
| 726 | + if (false !== $departs_from) { |
|
| 727 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
| 728 | 728 | } |
| 729 | - if(false !== $ends_in){ |
|
| 730 | - add_post_meta($id,'ends_in',$ends_in,true); |
|
| 729 | + if (false !== $ends_in) { |
|
| 730 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
| 731 | 731 | } |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | /** |
| 735 | 735 | * Run through your routes and save the points as a KML file. |
| 736 | 736 | */ |
| 737 | - public function set_map_data($data,$id,$zoom=9) { |
|
| 737 | + public function set_map_data($data, $id, $zoom = 9) { |
|
| 738 | 738 | |
| 739 | - if(!empty($data['routes'])){ |
|
| 739 | + if (!empty($data['routes'])) { |
|
| 740 | 740 | |
| 741 | - delete_post_meta($id,'wetu_map_points'); |
|
| 741 | + delete_post_meta($id, 'wetu_map_points'); |
|
| 742 | 742 | |
| 743 | 743 | $points = array(); |
| 744 | 744 | |
| 745 | - foreach($data['routes'] as $route){ |
|
| 745 | + foreach ($data['routes'] as $route) { |
|
| 746 | 746 | |
| 747 | 747 | |
| 748 | - if(isset($route['points']) && '' !== $route['points']){ |
|
| 748 | + if (isset($route['points']) && '' !== $route['points']) { |
|
| 749 | 749 | |
| 750 | - $temp_points = explode(';',$route['points']); |
|
| 750 | + $temp_points = explode(';', $route['points']); |
|
| 751 | 751 | $point_counter = count($temp_points); |
| 752 | 752 | |
| 753 | 753 | for ($x = 0; $x <= $point_counter; $x++) { |
| 754 | - $y = $x+1; |
|
| 754 | + $y = $x + 1; |
|
| 755 | 755 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
| 756 | 756 | $x++; |
| 757 | 757 | } |
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | - if(!empty($points)){ |
|
| 761 | - $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
|
| 760 | + if (!empty($points)) { |
|
| 761 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
| 762 | 762 | } |
| 763 | 763 | } |
| 764 | 764 | |
@@ -769,28 +769,28 @@ discard block |
||
| 769 | 769 | /** |
| 770 | 770 | * Set the Itinerary Day |
| 771 | 771 | */ |
| 772 | - public function set_itinerary_day($day,$id) { |
|
| 773 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
| 772 | + public function set_itinerary_day($day, $id) { |
|
| 773 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | /** |
| 777 | 777 | * Set the price |
| 778 | 778 | */ |
| 779 | - public function set_price($data,$id) { |
|
| 779 | + public function set_price($data, $id) { |
|
| 780 | 780 | //Price |
| 781 | - if(isset($data['price']) && ''!== $data['price']){ |
|
| 781 | + if (isset($data['price']) && '' !== $data['price']) { |
|
| 782 | 782 | $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
| 783 | - $this->save_custom_field($price,'price',$id); |
|
| 783 | + $this->save_custom_field($price, 'price', $id); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | //Price includes |
| 787 | - if(isset($data['price_includes']) && ''!== $data['price_includes']){ |
|
| 788 | - $this->save_custom_field($data['price_includes'],'included',$id); |
|
| 787 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
| 788 | + $this->save_custom_field($data['price_includes'], 'included', $id); |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | //Price Excludes |
| 792 | - if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
|
| 793 | - $this->save_custom_field($data['price_excludes'],'not_included',$id); |
|
| 792 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
| 793 | + $this->save_custom_field($data['price_excludes'], 'not_included', $id); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | } |
@@ -798,38 +798,38 @@ discard block |
||
| 798 | 798 | /** |
| 799 | 799 | * Set the duration |
| 800 | 800 | */ |
| 801 | - public function set_duration($data,$id) { |
|
| 802 | - if(isset($data['days']) && !empty($data['days'])){ |
|
| 801 | + public function set_duration($data, $id) { |
|
| 802 | + if (isset($data['days']) && !empty($data['days'])) { |
|
| 803 | 803 | $price = $data['days']; |
| 804 | 804 | $price = preg_replace("/[^0-9,.]/", "", $price); |
| 805 | - $this->save_custom_field($price,'duration',$id); |
|
| 805 | + $this->save_custom_field($price, 'duration', $id); |
|
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | /** |
| 810 | 810 | * Connects the Accommodation if its available |
| 811 | 811 | */ |
| 812 | - public function set_accommodation($day,$id) { |
|
| 812 | + public function set_accommodation($day, $id) { |
|
| 813 | 813 | |
| 814 | 814 | $ac_id = false; |
| 815 | 815 | $this->current_accommodation = $this->find_current_accommodation(); |
| 816 | 816 | |
| 817 | - if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
|
| 817 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
| 818 | 818 | |
| 819 | - if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
|
| 819 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
| 820 | 820 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
| 821 | - }else{ |
|
| 821 | + }else { |
|
| 822 | 822 | $ac_id = wp_insert_post(array( |
| 823 | 823 | 'post_type' => 'accommodation', |
| 824 | 824 | 'post_status' => 'draft', |
| 825 | 825 | 'post_title' => $day['content_entity_id'] |
| 826 | 826 | )); |
| 827 | - $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
|
| 827 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - if('' !== $ac_id && false !== $ac_id){ |
|
| 831 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
| 832 | - $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
|
| 830 | + if ('' !== $ac_id && false !== $ac_id) { |
|
| 831 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
| 832 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | 835 | return $ac_id; |
@@ -841,13 +841,13 @@ discard block |
||
| 841 | 841 | * @param $post_type string |
| 842 | 842 | * @return boolean / array |
| 843 | 843 | */ |
| 844 | - public function find_current_accommodation($post_type='accommodation') { |
|
| 844 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
| 845 | 845 | global $wpdb; |
| 846 | 846 | $accommodation = parent::find_current_accommodation($post_type); |
| 847 | 847 | |
| 848 | 848 | $return = false; |
| 849 | - if(!empty($accommodation)){ |
|
| 850 | - foreach($accommodation as $key => $acc){ |
|
| 849 | + if (!empty($accommodation)) { |
|
| 850 | + foreach ($accommodation as $key => $acc) { |
|
| 851 | 851 | $return[$acc->meta_value] = $acc->post_id; |
| 852 | 852 | } |
| 853 | 853 | } |
@@ -869,26 +869,26 @@ discard block |
||
| 869 | 869 | * @param $id string |
| 870 | 870 | * @return boolean / string |
| 871 | 871 | */ |
| 872 | - public function set_destination($day,$id,$leg_counter) { |
|
| 872 | + public function set_destination($day, $id, $leg_counter) { |
|
| 873 | 873 | $dest_id = false; |
| 874 | 874 | $country_id = false; |
| 875 | 875 | $this->current_destinations = $this->find_current_destinations(); |
| 876 | 876 | |
| 877 | - if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){ |
|
| 877 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
| 878 | 878 | |
| 879 | - if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){ |
|
| 879 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
| 880 | 880 | $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
| 881 | 881 | |
| 882 | 882 | //Check if there is a country asigned. |
| 883 | 883 | $potential_id = wp_get_post_parent_id($dest_id); |
| 884 | - $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
|
| 885 | - if(false !== $country_wetu_id){ |
|
| 884 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
| 885 | + if (false !== $country_wetu_id) { |
|
| 886 | 886 | $country_id = $this->set_country($country_wetu_id, $id); |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | }else { |
| 890 | 890 | |
| 891 | - $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
|
| 891 | + $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']); |
|
| 892 | 892 | |
| 893 | 893 | if ($destination_json) { |
| 894 | 894 | $destination_data = json_decode($destination_json, true); |
@@ -897,12 +897,12 @@ discard block |
||
| 897 | 897 | |
| 898 | 898 | $destination_title = $day['destination_content_entity_id']; |
| 899 | 899 | |
| 900 | - if(isset($destination_data[0]['name'])){ |
|
| 900 | + if (isset($destination_data[0]['name'])) { |
|
| 901 | 901 | $destination_title = $destination_data[0]['name']; |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
| 905 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
| 904 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
| 905 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
| 906 | 906 | |
| 907 | 907 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
| 908 | 908 | } |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | 'post_title' => $destination_title |
| 914 | 914 | ); |
| 915 | 915 | |
| 916 | - if(false !== $country_id){ |
|
| 916 | + if (false !== $country_id) { |
|
| 917 | 917 | $dest_post['post_parent'] = $country_id; |
| 918 | 918 | } |
| 919 | 919 | $dest_id = wp_insert_post($dest_post); |
@@ -932,15 +932,15 @@ discard block |
||
| 932 | 932 | $this->cleanup_posts[$dest_id] = 'tour_to_destination'; |
| 933 | 933 | |
| 934 | 934 | // Save the first destination so we can grab the tour featured image and banner |
| 935 | - if(0 === $leg_counter){ |
|
| 936 | - $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']); |
|
| 935 | + if (0 === $leg_counter) { |
|
| 936 | + $this->destination_images[$id] = array($dest_id, $day['destination_content_entity_id']); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | //Add this relation info so we can make sure certain items are set as countries. |
| 940 | - if(0 !== $country_id && false !== $country_id){ |
|
| 940 | + if (0 !== $country_id && false !== $country_id) { |
|
| 941 | 941 | $this->relation_meta[$dest_id] = $country_id; |
| 942 | 942 | $this->relation_meta[$country_id] = 0; |
| 943 | - }else{ |
|
| 943 | + }else { |
|
| 944 | 944 | $this->relation_meta[$dest_id] = 0; |
| 945 | 945 | } |
| 946 | 946 | } |
@@ -963,9 +963,9 @@ discard block |
||
| 963 | 963 | |
| 964 | 964 | if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
| 965 | 965 | $country_id = $this->current_destinations[$country_wetu_id]; |
| 966 | - } else { |
|
| 966 | + }else { |
|
| 967 | 967 | |
| 968 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
| 968 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id); |
|
| 969 | 969 | |
| 970 | 970 | if ($country_json) { |
| 971 | 971 | $country_data = json_decode($country_json, true); |
@@ -1010,15 +1010,15 @@ discard block |
||
| 1010 | 1010 | * |
| 1011 | 1011 | * @return string |
| 1012 | 1012 | */ |
| 1013 | - public function attach_destination_images($importable_content=array()) { |
|
| 1014 | - if(false !== $this->destination_images){ |
|
| 1013 | + public function attach_destination_images($importable_content = array()) { |
|
| 1014 | + if (false !== $this->destination_images) { |
|
| 1015 | 1015 | |
| 1016 | - foreach($this->destination_images as $tour => $destination){ |
|
| 1016 | + foreach ($this->destination_images as $tour => $destination) { |
|
| 1017 | 1017 | |
| 1018 | - $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
| 1018 | + $url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
| 1019 | 1019 | $url_qs = ''; |
| 1020 | 1020 | |
| 1021 | - $jdata = file_get_contents($url . '/Get?' . $url_qs . '&ids=' . $destination[1]); |
|
| 1021 | + $jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]); |
|
| 1022 | 1022 | if ($jdata) { |
| 1023 | 1023 | $adata = json_decode($jdata, true); |
| 1024 | 1024 | |
@@ -256,10 +256,10 @@ discard block |
||
| 256 | 256 | if(true === $result){ |
| 257 | 257 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
| 258 | 258 | echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
| 259 | - }else{ |
|
| 259 | + } else{ |
|
| 260 | 260 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
| 261 | 261 | } |
| 262 | - }else{ |
|
| 262 | + } else{ |
|
| 263 | 263 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
| 264 | 264 | } |
| 265 | 265 | echo '</h3>'; |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | if(isset($tours['error'])){ |
| 322 | 322 | return $tours['error']; |
| 323 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
| 323 | + } elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
| 324 | 324 | set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
| 325 | 325 | return true; |
| 326 | 326 | } |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | if(isset($_POST['keyword'] )) { |
| 371 | 371 | $keyphrases = $_POST['keyword']; |
| 372 | - }else{ |
|
| 372 | + } else{ |
|
| 373 | 373 | $keyphrases = array(0); |
| 374 | 374 | } |
| 375 | 375 | |
@@ -421,16 +421,16 @@ discard block |
||
| 421 | 421 | |
| 422 | 422 | if(0 !== $row['post_id']){ |
| 423 | 423 | continue; |
| 424 | - }else{ |
|
| 424 | + } else{ |
|
| 425 | 425 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | |
| 429 | - }else{ |
|
| 429 | + } else{ |
|
| 430 | 430 | |
| 431 | 431 | if(0 === $row['post_id']){ |
| 432 | 432 | continue; |
| 433 | - }else{ |
|
| 433 | + } else{ |
|
| 434 | 434 | $current_status = get_post_status($row['post_id']); |
| 435 | 435 | if($current_status !== $post_status){ |
| 436 | 436 | continue; |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - }else{ |
|
| 444 | + } else{ |
|
| 445 | 445 | //Search through each keyword. |
| 446 | 446 | foreach($keyphrases as $keyphrase){ |
| 447 | 447 | |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | $wetu_id = $_POST['wetu_id']; |
| 512 | 512 | if(isset($_POST['post_id'])){ |
| 513 | 513 | $post_id = $_POST['post_id']; |
| 514 | - }else{ |
|
| 514 | + } else{ |
|
| 515 | 515 | $post_id = 0; |
| 516 | 516 | } |
| 517 | 517 | |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
| 520 | 520 | $content = $_POST['content']; |
| 521 | 521 | add_option('wetu_importer_tour_settings',$content); |
| 522 | - }else{ |
|
| 522 | + } else{ |
|
| 523 | 523 | $content = false; |
| 524 | 524 | } |
| 525 | 525 | |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | if(isset($data['description'])){ |
| 560 | 560 | $data_post_content = $data['description']; |
| 561 | - }elseif(isset($data['summary'])){ |
|
| 561 | + } elseif(isset($data['summary'])){ |
|
| 562 | 562 | $data_post_content = $data['summary']; |
| 563 | 563 | } |
| 564 | 564 | $post['post_content'] = $data_post_content; |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | $id = wp_update_post($post); |
| 572 | 572 | $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
| 573 | 573 | update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
| 574 | - }else{ |
|
| 574 | + } else{ |
|
| 575 | 575 | |
| 576 | 576 | //Set the name |
| 577 | 577 | if(isset($data['name'])){ |
@@ -662,42 +662,42 @@ discard block |
||
| 662 | 662 | //Description |
| 663 | 663 | if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){ |
| 664 | 664 | $current_day['description'] = $day['notes']; |
| 665 | - }else{ |
|
| 665 | + } else{ |
|
| 666 | 666 | $current_day['description'] = ''; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | //Itinerary Gallery |
| 670 | 670 | if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
| 671 | 671 | $current_day['featured_image'] = ''; |
| 672 | - }else{ |
|
| 672 | + } else{ |
|
| 673 | 673 | $current_day['featured_image'] = ''; |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | //Accommodation |
| 677 | 677 | if(false !== $current_accommodation){ |
| 678 | 678 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
| 679 | - }else{ |
|
| 679 | + } else{ |
|
| 680 | 680 | $current_day['accommodation_to_tour'] = array(); |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | //Destination |
| 684 | 684 | if(false !== $current_destination){ |
| 685 | 685 | $current_day['destination_to_tour'] = array($current_destination); |
| 686 | - }else{ |
|
| 686 | + } else{ |
|
| 687 | 687 | $current_day['destination_to_tour'] = array(); |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | //Included |
| 691 | 691 | if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){ |
| 692 | 692 | $current_day['included'] = $day['included']; |
| 693 | - }else{ |
|
| 693 | + } else{ |
|
| 694 | 694 | $current_day['included'] = ''; |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | //Excluded |
| 698 | 698 | if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){ |
| 699 | 699 | $current_day['excluded'] = $day['excluded']; |
| 700 | - }else{ |
|
| 700 | + } else{ |
|
| 701 | 701 | $current_day['excluded'] = ''; |
| 702 | 702 | } |
| 703 | 703 | |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | $day_counter++; |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - }else{ |
|
| 708 | + } else{ |
|
| 709 | 709 | $day_counter = $day_counter + (int)$leg['nights']; |
| 710 | 710 | } |
| 711 | 711 | |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
| 820 | 820 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
| 821 | - }else{ |
|
| 821 | + } else{ |
|
| 822 | 822 | $ac_id = wp_insert_post(array( |
| 823 | 823 | 'post_type' => 'accommodation', |
| 824 | 824 | 'post_status' => 'draft', |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | $country_id = $this->set_country($country_wetu_id, $id); |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | - }else { |
|
| 889 | + } else { |
|
| 890 | 890 | |
| 891 | 891 | $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
| 892 | 892 | |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | if(0 !== $country_id && false !== $country_id){ |
| 941 | 941 | $this->relation_meta[$dest_id] = $country_id; |
| 942 | 942 | $this->relation_meta[$country_id] = 0; |
| 943 | - }else{ |
|
| 943 | + } else{ |
|
| 944 | 944 | $this->relation_meta[$dest_id] = 0; |
| 945 | 945 | } |
| 946 | 946 | } |