Completed
Push — master ( 6435ab...d652f3 )
by Warwick
03:23
created
classes/class-tours.php 3 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -82,20 +82,20 @@  discard block
 block discarded – undo
82 82
 	public function __construct() {
83 83
 		$this->set_variables();
84 84
 
85
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
86
-		add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));	
87
-		add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));		
85
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
86
+		add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));	
87
+		add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));		
88 88
 
89
-		add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));	
90
-		add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
89
+		add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));	
90
+		add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
91 91
 
92
-		$temp_options = get_option('_lsx-to_settings',false);
93
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
92
+		$temp_options = get_option('_lsx-to_settings', false);
93
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
94 94
 			$this->options = $temp_options[$this->plugin_slug];
95 95
 		}
96 96
 
97
-		$tour_options = get_option('wetu_importer_tour_settings',false);
98
-		if(false !== $tour_options){
97
+		$tour_options = get_option('wetu_importer_tour_settings', false);
98
+		if (false !== $tour_options) {
99 99
 			$this->tour_options = $tour_options;
100 100
         }
101 101
 	}
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	{
108 108
 		parent::set_variables();
109 109
 
110
-		if ( false !== $this->api_username && false !== $this->api_password ) {
110
+		if (false !== $this->api_username && false !== $this->api_password) {
111 111
 			$this->url    = 'https://wetu.com/API/Itinerary/';
112
-			$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
113
-		} elseif ( false !== $this->api_key ) {
114
-			$this->url    = 'https://wetu.com/API/Itinerary/' . $this->api_key;
112
+			$this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password;
113
+		} elseif (false !== $this->api_key) {
114
+			$this->url    = 'https://wetu.com/API/Itinerary/'.$this->api_key;
115 115
 			$this->url_qs = '';
116 116
 		}
117 117
 	}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 			<form method="get" action="" id="posts-filter">
132 132
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
133 133
 				
134
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
135
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
134
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
135
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
136 136
 				</p>				
137 137
 
138 138
 				<table class="wp-list-table widefat fixed posts">
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 					<tbody id="the-list">
142 142
 						<tr class="post-0 type-tour status-none" id="post-0">
143 143
 							<th class="check-column" scope="row">
144
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
144
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
145 145
 							</th>
146 146
 							<td class="post-title page-title column-title">
147 147
 								<strong>
148
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
148
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
149 149
 								</strong>
150 150
 							</td>
151 151
 							<td class="date column-date">							
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 
160 160
 				</table>
161 161
 
162
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
163
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
162
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
163
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
164 164
 				</p>
165 165
 			</form> 
166 166
 
@@ -172,36 +172,36 @@  discard block
 block discarded – undo
172 172
 						<div style="width:30%;display:block;float:left;">
173 173
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
174 174
 							<ul>
175
-								<li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
176
-								<li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
175
+								<li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
176
+								<li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
177 177
 
178
-                                <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li>
179
-                                <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li>
178
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li>
179
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li>
180 180
 
181
-								<li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
181
+								<li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
182 182
 
183
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li>
183
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li>
184 184
 
185
-								<?php if(class_exists('LSX_TO_Maps')){ ?>
186
-                                    <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>
185
+								<?php if (class_exists('LSX_TO_Maps')) { ?>
186
+                                    <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>
187 187
 								<?php } ?>
188 188
 							</ul>
189 189
 						</div>
190 190
                         <div style="width:30%;display:block;float:left;">
191 191
                             <h3><?php _e('Itinerary Info'); ?></h3>
192 192
                             <ul>
193
-                                <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>
194
-                                <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>
195
-                                <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>
193
+                                <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>
194
+                                <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>
195
+                                <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 196
                             </ul>
197 197
 
198 198
                             <h4><?php _e('Additional Content'); ?></h4>
199 199
                             <ul>
200
-                                <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li>
201
-                                <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li>
200
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li>
201
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li>
202 202
                             </ul>
203 203
                         </div>
204
-                        <?php if(class_exists('LSX_TO_Team')){ ?>
204
+                        <?php if (class_exists('LSX_TO_Team')) { ?>
205 205
                             <div style="width:30%;display:block;float:left;">
206 206
                                 <h3><?php _e('Assign a Team Member'); ?></h3>
207 207
                                 <?php $this->team_member_checkboxes($this->tour_options); ?>
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
 
215 215
 					<h3><?php _e('Your List'); ?></h3>
216
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
216
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
217 217
 					<table class="wp-list-table widefat fixed posts">
218 218
 						<?php $this->table_header(); ?>
219 219
 
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 
226 226
 					</table>
227 227
 
228
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
228
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
229 229
 				</form>
230 230
 			</div>
231 231
 
232 232
 			<div style="display:none;" class="completed-list-wrapper">
233
-				<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>
233
+				<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>
234 234
 				<ul>
235 235
 				</ul>
236 236
 			</div>
@@ -243,20 +243,20 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public function update_options_form() {
245 245
 		$tours = get_transient('lsx_ti_tours');
246
-		echo '<div class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - ';
247
-		if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){
246
+		echo '<div class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - ';
247
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
248 248
 			$result = $this->update_options();
249 249
 
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>';
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 254
                 }
255
-            }else{
255
+            }else {
256 256
 			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
257 257
             }
258
-		}else{
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>';
258
+		}else {
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
 	}
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 	 * Save the list of Tours into an option
266 266
 	 */
267 267
 	public function update_options() {
268
-		$data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs . '&own=true&type=All' );
268
+		$data = file_get_contents($this->url.'/V7/List?'.$this->url_qs.'&own=true&type=All');
269 269
 		$tours = json_decode($data, true);
270 270
 
271
-		if(isset($tours['error'])){
271
+		if (isset($tours['error'])) {
272 272
 		    return $tours['error'];
273 273
         }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
274
-			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
274
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
275 275
 			return true;
276 276
 		}
277 277
 	}
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 
296 296
 					LIMIT 0,500
297 297
 		");
298
-		if(null !== $current_tours && !empty($current_tours)){
299
-			foreach($current_tours as $tour){
298
+		if (null !== $current_tours && !empty($current_tours)) {
299
+			foreach ($current_tours as $tour) {
300 300
 				$return[$tour->meta_value] = $tour;
301 301
 			}
302 302
 		}
@@ -309,36 +309,36 @@  discard block
 block discarded – undo
309 309
 	public function process_ajax_search() {
310 310
 		$return = false;
311 311
 
312
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){
312
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
313 313
 			$tours = get_transient('lsx_ti_tours');
314
-			if ( false !== $tours) {
314
+			if (false !== $tours) {
315 315
 
316 316
 				$searched_items = false;
317 317
 
318
-				if(isset($_POST['keyword'] )) {
318
+				if (isset($_POST['keyword'])) {
319 319
 					$keyphrases = $_POST['keyword'];
320
-				}else{
320
+				}else {
321 321
 					$keyphrases = array(0);
322 322
                 }
323 323
 
324
-				if(!is_array($keyphrases)){
324
+				if (!is_array($keyphrases)) {
325 325
 					$keyphrases = array($keyphrases);
326 326
 				}
327
-				foreach($keyphrases as &$keyword){
327
+				foreach ($keyphrases as &$keyword) {
328 328
 					$keyword = ltrim(rtrim($keyword));
329 329
 				}
330 330
 
331 331
 				$post_status = false;
332
-				if(in_array('publish',$keyphrases)){
332
+				if (in_array('publish', $keyphrases)) {
333 333
 					$post_status = 'publish';
334 334
 				}
335
-				if(in_array('pending',$keyphrases)){
335
+				if (in_array('pending', $keyphrases)) {
336 336
 					$post_status = 'pending';
337 337
 				}
338
-				if(in_array('draft',$keyphrases)){
338
+				if (in_array('draft', $keyphrases)) {
339 339
 					$post_status = 'draft';
340 340
 				}
341
-				if(in_array('import',$keyphrases)){
341
+				if (in_array('import', $keyphrases)) {
342 342
 					$post_status = 'import';
343 343
 				}
344 344
 
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 				if (!empty($tours)) {
347 347
 					$current_tours = $this->find_current_tours();
348 348
 
349
-					foreach($tours as $row_key => $row){
349
+					foreach ($tours as $row_key => $row) {
350 350
 
351
-					    if(isset($row['is_disabled']) && true === $row['is_disabled']){
351
+					    if (isset($row['is_disabled']) && true === $row['is_disabled']) {
352 352
                             continue;
353 353
                         }
354 354
 
@@ -358,29 +358,29 @@  discard block
 block discarded – undo
358 358
 
359 359
                         //If this is a current tour, add its ID to the row.
360 360
 						$row['post_id'] = 0;
361
-						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
361
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
362 362
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
363 363
 						}
364 364
 
365 365
 						//If we are searching for
366
-						if(false !== $post_status){
366
+						if (false !== $post_status) {
367 367
 
368
-                            if('import' === $post_status){
368
+                            if ('import' === $post_status) {
369 369
 
370
-								if(0 !== $row['post_id']){
370
+								if (0 !== $row['post_id']) {
371 371
 								    continue;
372
-								}else{
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
-								if(0 === $row['post_id']){
379
+								if (0 === $row['post_id']) {
380 380
 									continue;
381
-								}else{
381
+								}else {
382 382
 									$current_status = get_post_status($row['post_id']);
383
-									if($current_status !== $post_status){
383
+									if ($current_status !== $post_status) {
384 384
 									    continue;
385 385
                                     }
386 386
 
@@ -389,17 +389,17 @@  discard block
 block discarded – undo
389 389
 
390 390
                             }
391 391
 
392
-                        }else{
392
+                        }else {
393 393
 							//Search through each keyword.
394
-							foreach($keyphrases as $keyphrase){
394
+							foreach ($keyphrases as $keyphrase) {
395 395
 
396 396
 								//Make sure the keyphrase is turned into an array
397
-								$keywords = explode(" ",$keyphrase);
398
-								if(!is_array($keywords)){
397
+								$keywords = explode(" ", $keyphrase);
398
+								if (!is_array($keywords)) {
399 399
 									$keywords = array($keywords);
400 400
 								}
401 401
 
402
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
402
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
403 403
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
404 404
 								}
405 405
 							}
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 					}		
408 408
 				}
409 409
 
410
-				if(false !== $searched_items){
410
+				if (false !== $searched_items) {
411 411
 					ksort($searched_items);
412 412
 					$return = implode($searched_items);
413 413
 				}
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 	/**
421 421
 	 * Formats the row for output on the screen.
422 422
 	 */	
423
-	public function format_row($row = false){
424
-		if(false !== $row){
423
+	public function format_row($row = false) {
424
+		if (false !== $row) {
425 425
 
426 426
 			$status = 'import';
427
-			if(0 !== $row['post_id']){
427
+			if (0 !== $row['post_id']) {
428 428
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
429 429
 			}
430 430
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 					<strong>'.$row['name'].'</strong> - '.$status.'
439 439
 				</td>
440 440
 				<td class="date column-date">
441
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
441
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
442 442
 				</td>
443 443
 				<td class="ssid column-ssid">
444 444
 					'.$row['identifier'].'
@@ -453,31 +453,31 @@  discard block
 block discarded – undo
453 453
 	 */
454 454
 	public function process_ajax_import($force = false) {
455 455
 		$return = false;
456
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){
456
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
457 457
 			
458 458
 			$wetu_id = $_POST['wetu_id'];
459
-			if(isset($_POST['post_id'])){
459
+			if (isset($_POST['post_id'])) {
460 460
 				$post_id = $_POST['post_id'];	
461
-			}else{
461
+			}else {
462 462
 				$post_id = 0;
463 463
 			}
464 464
 
465
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
465
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
466 466
 				$content = $_POST['content'];
467
-				add_option('wetu_importer_tour_settings',$content);
468
-			}else{
467
+				add_option('wetu_importer_tour_settings', $content);
468
+			}else {
469 469
 				delete_option('wetu_importer_tour_settings');
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)
475
+            if ($jdata)
476 476
             {
477
-				$jdata=json_decode($jdata,true);
478
-                if(!empty($jdata))
477
+				$jdata = json_decode($jdata, true);
478
+                if (!empty($jdata))
479 479
                 {
480
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
480
+                	$return = $this->import_row($jdata, $wetu_id, $post_id, $content);
481 481
                 	$this->format_completed_row($return);
482 482
                 }
483 483
             }
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
      * @param $data array
493 493
      * @param $wetu_id string
494 494
 	 */
495
-	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
495
+	public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) {
496 496
         $post_name = $data_post_content = $data_post_excerpt = '';
497 497
         $post = array(
498 498
           'post_type'		=> 'tour',
@@ -500,29 +500,29 @@  discard block
 block discarded – undo
500 500
 
501 501
         //Set the post_content
502 502
 		$content_used_general_description = false;
503
-        if(false !== $importable_content && in_array('description',$importable_content)){
503
+        if (false !== $importable_content && in_array('description', $importable_content)) {
504 504
             $data_post_content = '';
505 505
 
506
-            if(isset($data['description'])){
506
+            if (isset($data['description'])) {
507 507
                 $data_post_content = $data['description'];
508
-            }elseif(isset($data['summary'])){
508
+            }elseif (isset($data['summary'])) {
509 509
                 $data_post_content = $data['summary'];
510 510
             }
511 511
             $post['post_content'] = $data_post_content;
512 512
         }
513 513
 
514 514
         //Create or update the post
515
-        if(false !== $id && '0' !== $id){
515
+        if (false !== $id && '0' !== $id) {
516 516
             $post['ID'] = $id;
517 517
 	        $post['post_status'] = 'publish';
518 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{
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 522
 
523 523
             //Set the name
524
-            if(isset($data['name'])){
525
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
524
+            if (isset($data['name'])) {
525
+                $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
526 526
             }
527 527
             $post['post_name'] = $post_name;
528 528
             $post['post_title'] = $data['name'];
@@ -530,51 +530,51 @@  discard block
 block discarded – undo
530 530
             $id = wp_insert_post($post);
531 531
 
532 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']));
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 536
             }
537 537
         }
538 538
 
539 539
 
540 540
 		//Set the price
541
-		if(false !== $importable_content && in_array('price',$importable_content)){
542
-			$this->set_price($data,$id);
541
+		if (false !== $importable_content && in_array('price', $importable_content)) {
542
+			$this->set_price($data, $id);
543 543
 		}
544 544
 
545 545
 		//Set the Duration
546
-		if(false !== $importable_content && in_array('duration',$importable_content)){
547
-			$this->set_duration($data,$id);
546
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
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);
550
+        if (in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
551
+            $this->process_itineraries($data, $id, $importable_content);
552 552
         }
553 553
 
554
-		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
555
-			$this->process_map_points($data,$id);
554
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
555
+			$this->process_map_points($data, $id);
556 556
 		}
557 557
 
558 558
 		//TODO Test These
559 559
 		//Setup some default for use in the import
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))){
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 563
         //Set the featured image
564 564
         //TODO Test These
565
-        if(false !== $importable_content && in_array('featured_image',$importable_content)){
566
-            $this->set_featured_image($data,$id);
565
+        if (false !== $importable_content && in_array('featured_image', $importable_content)) {
566
+            $this->set_featured_image($data, $id);
567 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);
570
+        if (false !== $importable_content && in_array('banner_image', $importable_content)) {
571
+            $this->set_banner_image($data, $id);
572 572
         }
573 573
 
574 574
 		//TODO Test These
575 575
         //Import the main gallery
576
-        if(false !== $importable_content && in_array('gallery',$importable_content)){
577
-            $this->create_main_gallery($data,$id);
576
+        if (false !== $importable_content && in_array('gallery', $importable_content)) {
577
+            $this->create_main_gallery($data, $id);
578 578
         }
579 579
 
580 580
         return $id;
@@ -583,151 +583,151 @@  discard block
 block discarded – undo
583 583
 	/**
584 584
 	 * A loop which runs through each leg on the tour.
585 585
 	 */
586
-	public function process_itineraries($data,$id,$importable_content) {
586
+	public function process_itineraries($data, $id, $importable_content) {
587 587
 		$day_counter = 1;
588 588
 		$leg_counter = 0;
589 589
 
590
-		delete_post_meta($id,'itinerary');
590
+		delete_post_meta($id, 'itinerary');
591 591
 
592
-		if(false !== $importable_content && in_array('accommodation',$importable_content)){
593
-			delete_post_meta($id,'accommodation_to_tour');
592
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
593
+			delete_post_meta($id, 'accommodation_to_tour');
594 594
 		}
595
-		if(false !== $importable_content && in_array('destination',$importable_content)){
596
-			delete_post_meta($id,'destination_to_tour');
597
-			delete_post_meta($id,'departs_from');
598
-			delete_post_meta($id,'ends_in');
595
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
596
+			delete_post_meta($id, 'destination_to_tour');
597
+			delete_post_meta($id, 'departs_from');
598
+			delete_post_meta($id, 'ends_in');
599 599
 		}
600 600
 
601 601
 		$departs_from = false;
602 602
 		$ends_in = false;
603 603
 
604
-		foreach($data['legs'] as $leg){
604
+		foreach ($data['legs'] as $leg) {
605 605
 
606
-			if(isset($leg['days']) && !empty($leg['days'])){
606
+			if (isset($leg['days']) && !empty($leg['days'])) {
607 607
 
608 608
 				//Itinerary Accommodation
609 609
 				$current_accommodation = false;
610
-				if(false !== $importable_content && in_array('accommodation',$importable_content)){
611
-					$current_accommodation = $this->set_accommodation($leg,$id);
610
+				if (false !== $importable_content && in_array('accommodation', $importable_content)) {
611
+					$current_accommodation = $this->set_accommodation($leg, $id);
612 612
 				}
613 613
 
614 614
 				//Itinerary Destination
615 615
 				$current_destination = false;
616
-				if(false !== $importable_content && in_array('destination',$importable_content)){
617
-					$current_destination = $this->set_destination($leg,$id);
616
+				if (false !== $importable_content && in_array('destination', $importable_content)) {
617
+					$current_destination = $this->set_destination($leg, $id);
618 618
 				}
619 619
 
620 620
 				//If the Nights are the same mount of days in the array,  then it isnt "By Destination"
621
-				if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){
621
+				if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) {
622 622
 
623
-					foreach($leg['days'] as $day){
623
+					foreach ($leg['days'] as $day) {
624 624
 
625 625
 						$current_day = array();
626 626
 
627
-						$current_day['title'] =  esc_attr('Day ','wetu-importer').$day_counter;
627
+						$current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter;
628 628
 
629 629
 						//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
630 630
 
631 631
 						//Description
632
-						if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){
632
+						if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
633 633
 							$current_day['description'] = $day['notes'];
634
-						}else{
634
+						}else {
635 635
 							$current_day['description'] = '';
636 636
 						}
637 637
 
638 638
 						//Itinerary Gallery
639
-						if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){
639
+						if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
640 640
 							$current_day['featured_image'] = '';
641
-						}else{
641
+						}else {
642 642
 							$current_day['featured_image'] = '';
643 643
 						}
644 644
 
645 645
 						//Accommodation
646
-						if(false !== $current_accommodation){
646
+						if (false !== $current_accommodation) {
647 647
 							$current_day['accommodation_to_tour'] = array($current_accommodation);
648
-						}else{
648
+						}else {
649 649
 							$current_day['accommodation_to_tour'] = array();
650 650
 						}
651 651
 
652 652
 						//Destination
653
-						if(false !== $current_destination){
653
+						if (false !== $current_destination) {
654 654
 							$current_day['destination_to_tour'] = array($current_destination);
655
-						}else{
655
+						}else {
656 656
 							$current_day['destination_to_tour'] = array();
657 657
 						}
658 658
 
659 659
 						//Included
660
-						if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){
660
+						if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
661 661
 							$current_day['included'] = $day['included'];
662
-						}else{
662
+						}else {
663 663
 							$current_day['included'] = '';
664 664
 						}
665 665
 
666 666
 						//Excluded
667
-						if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){
667
+						if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
668 668
 							$current_day['excluded'] = $day['excluded'];
669
-						}else{
669
+						}else {
670 670
 							$current_day['excluded'] = '';
671 671
 						}
672 672
 
673
-						$this->set_itinerary_day($current_day,$id);
673
+						$this->set_itinerary_day($current_day, $id);
674 674
 						$day_counter++;
675 675
 					}
676 676
 
677
-				}else{
678
-					$day_counter = $day_counter + (int)$leg['nights'];
677
+				}else {
678
+					$day_counter = $day_counter + (int) $leg['nights'];
679 679
 				}
680 680
 
681 681
 			}
682 682
 
683 683
 			//If we are in the first leg,  and the destination was attached then save it as the departure field.
684
-			if( 0 === $leg_counter && false !== $current_destination){
684
+			if (0 === $leg_counter && false !== $current_destination) {
685 685
 				$departs_from = $current_destination;
686 686
 			}
687 687
 
688 688
 			//If its the last leg then save it as the ends in.
689
-			if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){
689
+			if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) {
690 690
 				$ends_in = $current_destination;
691 691
 			}
692 692
 			$leg_counter++;
693 693
 		}
694 694
 
695
-		if(false !== $departs_from){
696
-			add_post_meta($id,'departs_from',$departs_from,true);
695
+		if (false !== $departs_from) {
696
+			add_post_meta($id, 'departs_from', $departs_from, true);
697 697
 		}
698
-		if(false !== $ends_in){
699
-			add_post_meta($id,'ends_in',$ends_in,true);
698
+		if (false !== $ends_in) {
699
+			add_post_meta($id, 'ends_in', $ends_in, true);
700 700
 		}
701 701
 	}
702 702
 
703 703
 	/**
704 704
 	 * Run through your routes and save the points as a KML file.
705 705
 	 */
706
-	public function process_map_points($data,$id) {
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 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']);
719
+	                $temp_points = explode(';', $route['points']);
720 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 728
             }
729
-            if(!empty($points)){
730
-				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
729
+            if (!empty($points)) {
730
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
731 731
             }
732 732
         }
733 733
 
@@ -736,28 +736,28 @@  discard block
 block discarded – undo
736 736
 	/**
737 737
 	 * Set the Itinerary Day
738 738
 	 */
739
-	public function set_itinerary_day($day,$id) {
740
-        $this->save_custom_field($day,'itinerary',$id,false,false);
739
+	public function set_itinerary_day($day, $id) {
740
+        $this->save_custom_field($day, 'itinerary', $id, false, false);
741 741
 	}
742 742
 
743 743
 	/**
744 744
 	 * Set the price
745 745
 	 */
746
-	public function set_price($data,$id) {
746
+	public function set_price($data, $id) {
747 747
 	    //Price
748
-		if(isset($data['price']) && ''!== $data['price']){
748
+		if (isset($data['price']) && '' !== $data['price']) {
749 749
             $price = preg_replace("/[^0-9,.]/", "", $data['price']);
750
-            $this->save_custom_field($price,'price',$id);
750
+            $this->save_custom_field($price, 'price', $id);
751 751
 		}
752 752
 
753 753
 		//Price includes
754
-		if(isset($data['price_includes']) && ''!== $data['price_includes']){
755
-			$this->save_custom_field($data['price_includes'],'included',$id);
754
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
755
+			$this->save_custom_field($data['price_includes'], 'included', $id);
756 756
 		}
757 757
 
758 758
         //Price Excludes
759
-		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
760
-			$this->save_custom_field($data['price_excludes'],'not_included',$id);
759
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
760
+			$this->save_custom_field($data['price_excludes'], 'not_included', $id);
761 761
 		}
762 762
 
763 763
 	}
@@ -765,11 +765,11 @@  discard block
 block discarded – undo
765 765
 	/**
766 766
 	 * Set the duration
767 767
 	 */
768
-	public function set_duration($data,$id) {
769
-		if(isset($data['days']) && !empty($data['days'])){
768
+	public function set_duration($data, $id) {
769
+		if (isset($data['days']) && !empty($data['days'])) {
770 770
 			$price = $data['days'];
771 771
 			$price = preg_replace("/[^0-9,.]/", "", $price);
772
-			$this->save_custom_field($price,'duration',$id);
772
+			$this->save_custom_field($price, 'duration', $id);
773 773
 		}
774 774
 	}
775 775
 
@@ -777,27 +777,27 @@  discard block
 block discarded – undo
777 777
 	/**
778 778
 	 * Connects the Accommodation if its available
779 779
 	 */
780
-	public function set_accommodation($day,$id) {
780
+	public function set_accommodation($day, $id) {
781 781
 
782 782
 	    $ac_id = false;
783 783
 		$this->current_accommodation = $this->find_current_accommodation();
784 784
 		
785
-		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
785
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
786 786
 
787
-			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
787
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
788 788
                 $ac_id = $this->current_accommodation[$day['content_entity_id']];
789
-			}else{
789
+			}else {
790 790
 				$ac_id = wp_insert_post(array(
791 791
                     'post_type' => 'accommodation',
792 792
                     'post_status' => 'draft',
793 793
                     'post_title' => $day['content_entity_id']
794 794
                 ));
795
-				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
795
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
796 796
 			}
797 797
 
798
-			if('' !== $ac_id && false !== $ac_id){
799
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
800
-				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
798
+			if ('' !== $ac_id && false !== $ac_id) {
799
+			    $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
800
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
801 801
             }
802 802
 		}
803 803
 		return $ac_id;
@@ -809,13 +809,13 @@  discard block
 block discarded – undo
809 809
      * @param $post_type string
810 810
      * @return boolean / array
811 811
 	 */
812
-	public function find_current_accommodation($post_type='accommodation') {
812
+	public function find_current_accommodation($post_type = 'accommodation') {
813 813
 		global $wpdb;
814 814
 		$accommodation = parent::find_current_accommodation($post_type);
815 815
 
816 816
 		$return = false;
817
-		if(!empty($accommodation)){
818
-		    foreach($accommodation as $key => $acc){
817
+		if (!empty($accommodation)) {
818
+		    foreach ($accommodation as $key => $acc) {
819 819
 				$return[$acc->meta_value] = $acc->post_id;
820 820
             }
821 821
         }
@@ -837,25 +837,25 @@  discard block
 block discarded – undo
837 837
 	 * @param $id string
838 838
 	 * @return boolean / string
839 839
 	 */
840
-	public function set_destination($day,$id) {
840
+	public function set_destination($day, $id) {
841 841
 		$dest_id = false;
842 842
 		$country_id = false;
843 843
 		$this->current_destinations = $this->find_current_destinations();
844 844
 
845
-		if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){
845
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
846 846
 
847
-			if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){
847
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
848 848
 				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
849 849
 
850 850
 				$potential_id = wp_get_post_parent_id($dest_id);
851
-				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
852
-				if(false !== $country_wetu_id){
851
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
852
+				if (false !== $country_wetu_id) {
853 853
 					$this->set_country($country_wetu_id, $id);
854 854
                 }
855 855
 
856 856
 			}else {
857 857
 
858
-				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']);
858
+				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']);
859 859
 
860 860
 				if ($destination_json) {
861 861
 					$destination_data = json_decode($destination_json, true);
@@ -864,12 +864,12 @@  discard block
 block discarded – undo
864 864
 
865 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
                         }
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
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);
@@ -913,9 +913,9 @@  discard block
 block discarded – undo
913 913
 
914 914
         if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
915 915
             $country_id = $this->current_destinations[$country_wetu_id];
916
-        } else {
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 920
             if ($country_json) {
921 921
                 $country_data = json_decode($country_json, true);
Please login to merge, or discard this patch.
Braces   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 			    if(!isset($_GET['refresh_tours'])){
253 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 254
                 }
255
-            }else{
255
+            } else{
256 256
 			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
257 257
             }
258
-		}else{
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>';
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 
271 271
 		if(isset($tours['error'])){
272 272
 		    return $tours['error'];
273
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
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
 		}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 				if(isset($_POST['keyword'] )) {
319 319
 					$keyphrases = $_POST['keyword'];
320
-				}else{
320
+				} else{
321 321
 					$keyphrases = array(0);
322 322
                 }
323 323
 
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 
370 370
 								if(0 !== $row['post_id']){
371 371
 								    continue;
372
-								}else{
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
-								}else{
381
+								} else{
382 382
 									$current_status = get_post_status($row['post_id']);
383 383
 									if($current_status !== $post_status){
384 384
 									    continue;
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
                             }
391 391
 
392
-                        }else{
392
+                        } else{
393 393
 							//Search through each keyword.
394 394
 							foreach($keyphrases as $keyphrase){
395 395
 
@@ -458,14 +458,14 @@  discard block
 block discarded – undo
458 458
 			$wetu_id = $_POST['wetu_id'];
459 459
 			if(isset($_POST['post_id'])){
460 460
 				$post_id = $_POST['post_id'];	
461
-			}else{
461
+			} else{
462 462
 				$post_id = 0;
463 463
 			}
464 464
 
465 465
 			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
466 466
 				$content = $_POST['content'];
467 467
 				add_option('wetu_importer_tour_settings',$content);
468
-			}else{
468
+			} else{
469 469
 				delete_option('wetu_importer_tour_settings');
470 470
 				$content = false;
471 471
 			}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 
506 506
             if(isset($data['description'])){
507 507
                 $data_post_content = $data['description'];
508
-            }elseif(isset($data['summary'])){
508
+            } elseif(isset($data['summary'])){
509 509
                 $data_post_content = $data['summary'];
510 510
             }
511 511
             $post['post_content'] = $data_post_content;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
             $id = wp_update_post($post);
519 519
             $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
520 520
             update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
521
-        }else{
521
+        } else{
522 522
 
523 523
             //Set the name
524 524
             if(isset($data['name'])){
@@ -631,42 +631,42 @@  discard block
 block discarded – undo
631 631
 						//Description
632 632
 						if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){
633 633
 							$current_day['description'] = $day['notes'];
634
-						}else{
634
+						} else{
635 635
 							$current_day['description'] = '';
636 636
 						}
637 637
 
638 638
 						//Itinerary Gallery
639 639
 						if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){
640 640
 							$current_day['featured_image'] = '';
641
-						}else{
641
+						} else{
642 642
 							$current_day['featured_image'] = '';
643 643
 						}
644 644
 
645 645
 						//Accommodation
646 646
 						if(false !== $current_accommodation){
647 647
 							$current_day['accommodation_to_tour'] = array($current_accommodation);
648
-						}else{
648
+						} else{
649 649
 							$current_day['accommodation_to_tour'] = array();
650 650
 						}
651 651
 
652 652
 						//Destination
653 653
 						if(false !== $current_destination){
654 654
 							$current_day['destination_to_tour'] = array($current_destination);
655
-						}else{
655
+						} else{
656 656
 							$current_day['destination_to_tour'] = array();
657 657
 						}
658 658
 
659 659
 						//Included
660 660
 						if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){
661 661
 							$current_day['included'] = $day['included'];
662
-						}else{
662
+						} else{
663 663
 							$current_day['included'] = '';
664 664
 						}
665 665
 
666 666
 						//Excluded
667 667
 						if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){
668 668
 							$current_day['excluded'] = $day['excluded'];
669
-						}else{
669
+						} else{
670 670
 							$current_day['excluded'] = '';
671 671
 						}
672 672
 
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 						$day_counter++;
675 675
 					}
676 676
 
677
-				}else{
677
+				} else{
678 678
 					$day_counter = $day_counter + (int)$leg['nights'];
679 679
 				}
680 680
 
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 
787 787
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
788 788
                 $ac_id = $this->current_accommodation[$day['content_entity_id']];
789
-			}else{
789
+			} else{
790 790
 				$ac_id = wp_insert_post(array(
791 791
                     'post_type' => 'accommodation',
792 792
                     'post_status' => 'draft',
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 					$this->set_country($country_wetu_id, $id);
854 854
                 }
855 855
 
856
-			}else {
856
+			} else {
857 857
 
858 858
 				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']);
859 859
 
Please login to merge, or discard this patch.