Completed
Push — master ( d652f3...3704f2 )
by Warwick
04:03
created
classes/class-accommodation.php 2 patches
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * Display the importer administration screen
137 137
 	 */
138 138
 	public function display_page() {
139
-        ?>
139
+		?>
140 140
         <div class="wrap">
141 141
             <?php $this->navigation('accommodation'); ?>
142 142
 
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
 		$accommodation = json_decode($data, true);
316 316
 
317 317
 		if(isset($accommodation['error'])){
318
-		    return $accommodation['error'];
319
-        }elseif (isset($accommodation) && !empty($accommodation)) {
318
+			return $accommodation['error'];
319
+		}elseif (isset($accommodation) && !empty($accommodation)) {
320 320
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
321 321
 			return true;
322 322
 		}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 					$keyphrases = $_POST['keyword'];
365 365
 				}else{
366 366
 					$keyphrases = array(0);
367
-                }
367
+				}
368 368
 
369 369
 				if(!is_array($keyphrases)){
370 370
 					$keyphrases = array($keyphrases);
@@ -461,13 +461,13 @@  discard block
 block discarded – undo
461 461
 	public function multineedle_stripos($haystack, $needles, $offset=0) {
462 462
 		$found = false;
463 463
 		$needle_count = count($needles);
464
-	    foreach($needles as $needle) {
465
-	    	if(false !== stripos($haystack, $needle, $offset)){
466
-	        	$found[] = true;
467
-	    	}
468
-	    }
469
-	    if(false !== $found && $needle_count === count($found)){ 
470
-	    	return true;
464
+		foreach($needles as $needle) {
465
+			if(false !== stripos($haystack, $needle, $offset)){
466
+				$found[] = true;
467
+			}
468
+		}
469
+		if(false !== $found && $needle_count === count($found)){ 
470
+			return true;
471 471
 		}else{
472 472
 			return false;
473 473
 		}
@@ -538,16 +538,16 @@  discard block
 block discarded – undo
538 538
 				$content = false;
539 539
 			}
540 540
 
541
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
542
-            if($jdata)
543
-            {
544
-                $adata=json_decode($jdata,true);
545
-                if(!empty($adata))
546
-                {
547
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
548
-                	$this->format_completed_row($return);
549
-                }
550
-            }
541
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
542
+			if($jdata)
543
+			{
544
+				$adata=json_decode($jdata,true);
545
+				if(!empty($adata))
546
+				{
547
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
548
+					$this->format_completed_row($return);
549
+				}
550
+			}
551 551
 
552 552
 			die();
553 553
 		}
@@ -564,148 +564,148 @@  discard block
 block discarded – undo
564 564
 	 */
565 565
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
566 566
 
567
-        if(trim($data[0]['type'])=='Accommodation')
568
-        {
569
-	        $post_name = $data_post_content = $data_post_excerpt = '';
570
-	        $post = array(
571
-	          'post_type'		=> 'accommodation',
572
-	        );
573
-
574
-	        $content_used_general_description = false;
575
-
576
-	        //Set the post_content
577
-	        if(false !== $importable_content && in_array('description',$importable_content)){
578
-		        if(isset($data[0]['content']['extended_description']))
579
-		        {
580
-		            $data_post_content = $data[0]['content']['extended_description'];
581
-		        }elseif(isset($data[0]['content']['general_description'])){
582
-		            $data_post_content = $data[0]['content']['general_description'];
583
-		            $content_used_general_description = true;
584
-		        }elseif(isset($data[0]['content']['teaser_description'])){
585
-		        	$data_post_content = $data[0]['content']['teaser_description'];
586
-		        }
587
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
588
-	        }
589
-
590
-	        //set the post_excerpt
591
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
592
-		        if(isset($data[0]['content']['teaser_description'])){
593
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
594
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
595
-		            $data_post_excerpt = $data[0]['content']['general_description'];
596
-		        }	   
597
-		        $post['post_excerpt'] = $data_post_excerpt;     	
598
-	        }
599
-
600
-	        if(false !== $id && '0' !== $id){
601
-	        	$post['ID'] = $id;
567
+		if(trim($data[0]['type'])=='Accommodation')
568
+		{
569
+			$post_name = $data_post_content = $data_post_excerpt = '';
570
+			$post = array(
571
+			  'post_type'		=> 'accommodation',
572
+			);
573
+
574
+			$content_used_general_description = false;
575
+
576
+			//Set the post_content
577
+			if(false !== $importable_content && in_array('description',$importable_content)){
578
+				if(isset($data[0]['content']['extended_description']))
579
+				{
580
+					$data_post_content = $data[0]['content']['extended_description'];
581
+				}elseif(isset($data[0]['content']['general_description'])){
582
+					$data_post_content = $data[0]['content']['general_description'];
583
+					$content_used_general_description = true;
584
+				}elseif(isset($data[0]['content']['teaser_description'])){
585
+					$data_post_content = $data[0]['content']['teaser_description'];
586
+				}
587
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
588
+			}
589
+
590
+			//set the post_excerpt
591
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
592
+				if(isset($data[0]['content']['teaser_description'])){
593
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
594
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
595
+					$data_post_excerpt = $data[0]['content']['general_description'];
596
+				}	   
597
+				$post['post_excerpt'] = $data_post_excerpt;     	
598
+			}
599
+
600
+			if(false !== $id && '0' !== $id){
601
+				$post['ID'] = $id;
602 602
 				if(isset($data[0]['name'])){
603 603
 					$post['post_title'] = $data[0]['name'];
604
-	        		$post['post_status'] = 'publish';
604
+					$post['post_status'] = 'publish';
605 605
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
606 606
 				}
607
-	        	$id = wp_update_post($post);
608
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
609
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
610
-	        }else{
611
-
612
-		        //Set the name
613
-		        if(isset($data[0]['name'])){
614
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
615
-		        }
616
-	        	$post['post_name'] = $post_name;
617
-	        	$post['post_title'] = $data[0]['name'];
618
-	        	$post['post_status'] = 'publish';
619
-	        	$id = wp_insert_post($post);
620
-
621
-	        	//Save the WETU ID and the Last date it was modified.
622
-	        	if(false !== $id){
623
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
624
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
625
-	        	}
626
-	        }
627
-	        //Setup some default for use in the import
628
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
607
+				$id = wp_update_post($post);
608
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
609
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
610
+			}else{
611
+
612
+				//Set the name
613
+				if(isset($data[0]['name'])){
614
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
615
+				}
616
+				$post['post_name'] = $post_name;
617
+				$post['post_title'] = $data[0]['name'];
618
+				$post['post_status'] = 'publish';
619
+				$id = wp_insert_post($post);
620
+
621
+				//Save the WETU ID and the Last date it was modified.
622
+				if(false !== $id){
623
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
624
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
625
+				}
626
+			}
627
+			//Setup some default for use in the import
628
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
629 629
 				$this->find_attachments($id);
630 630
 			}
631 631
 
632
-	        //Set the team member if it is there
633
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
634
-	        	$this->set_team_member($id,$team_members);
635
-	    	}
636
-
637
-	        //Set the safari brand
638
-	        if(false !== $safari_brands && '' !== $safari_brands){
639
-	        	$this->set_safari_brands($id,$safari_brands);
640
-
641
-	    	}	    	
642
-
643
-	        if(class_exists('LSX_TO_Maps')){
644
-	        	$this->set_map_data($data,$id,9);
645
-	        	$this->set_location_taxonomy($data,$id);
646
-	        }
647
-
648
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
649
-	        	$this->connect_destinations($data,$id);
650
-	        }
651
-
652
-	        if(false !== $importable_content && in_array('category',$importable_content)){
653
-	        	$this->set_taxonomy_style($data,$id);
654
-	        }
655
-
656
-	        //Set the Room Data
657
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
658
-	        	$this->set_room_data($data,$id);
659
-	    	}
660
-
661
-	    	//Set the rating
662
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
663
-	       		$this->set_rating($data,$id);
664
-	    	}
665
-
666
-	    	//Set the checkin checkout data
667
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
668
-	        	$this->set_checkin_checkout($data,$id);
669
-	        }
670
-
671
-	    	//Set the Spoken Languages
672
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
673
-	       		$this->set_spoken_languages($data,$id);
674
-	    	}
675
-
676
-	    	//Set the friendly options
677
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
678
-	       		$this->set_friendly($data,$id);
679
-	    	}
680
-
681
-	    	//Set the special_interests
682
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
683
-	       		$this->set_special_interests($data,$id);
684
-	    	}	    		    		        
685
-
686
-	        //Import the videos
687
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
688
-	        	$this->set_video_data($data,$id);
689
-	        }
690
-
691
-	        //Import the facilities
692
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
693
-	        	$this->set_facilities($data,$id);
694
-	        }	        
695
-
696
-	        //Set the featured image
697
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
698
-	        	$this->set_featured_image($data,$id);
699
-	        }
700
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
701
-	        	$this->set_banner_image($data,$id);
702
-	        }	        
703
-	        //Import the main gallery
704
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
705
-	    		$this->create_main_gallery($data,$id);
706
-	        }	        	        	        
707
-        }
708
-        return $id;
632
+			//Set the team member if it is there
633
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
634
+				$this->set_team_member($id,$team_members);
635
+			}
636
+
637
+			//Set the safari brand
638
+			if(false !== $safari_brands && '' !== $safari_brands){
639
+				$this->set_safari_brands($id,$safari_brands);
640
+
641
+			}	    	
642
+
643
+			if(class_exists('LSX_TO_Maps')){
644
+				$this->set_map_data($data,$id,9);
645
+				$this->set_location_taxonomy($data,$id);
646
+			}
647
+
648
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
649
+				$this->connect_destinations($data,$id);
650
+			}
651
+
652
+			if(false !== $importable_content && in_array('category',$importable_content)){
653
+				$this->set_taxonomy_style($data,$id);
654
+			}
655
+
656
+			//Set the Room Data
657
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
658
+				$this->set_room_data($data,$id);
659
+			}
660
+
661
+			//Set the rating
662
+			if(false !== $importable_content && in_array('rating',$importable_content)){
663
+		   		$this->set_rating($data,$id);
664
+			}
665
+
666
+			//Set the checkin checkout data
667
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
668
+				$this->set_checkin_checkout($data,$id);
669
+			}
670
+
671
+			//Set the Spoken Languages
672
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
673
+		   		$this->set_spoken_languages($data,$id);
674
+			}
675
+
676
+			//Set the friendly options
677
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
678
+		   		$this->set_friendly($data,$id);
679
+			}
680
+
681
+			//Set the special_interests
682
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
683
+		   		$this->set_special_interests($data,$id);
684
+			}	    		    		        
685
+
686
+			//Import the videos
687
+			if(false !== $importable_content && in_array('videos',$importable_content)){
688
+				$this->set_video_data($data,$id);
689
+			}
690
+
691
+			//Import the facilities
692
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
693
+				$this->set_facilities($data,$id);
694
+			}	        
695
+
696
+			//Set the featured image
697
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
698
+				$this->set_featured_image($data,$id);
699
+			}
700
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
701
+				$this->set_banner_image($data,$id);
702
+			}	        
703
+			//Import the main gallery
704
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
705
+				$this->create_main_gallery($data,$id);
706
+			}	        	        	        
707
+		}
708
+		return $id;
709 709
 	}
710 710
 
711 711
 	/**
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 
716 716
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
717 717
 		foreach($team_members as $team){
718
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
718
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
719 719
 		}
720 720
 	}
721 721
 
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	 */
725 725
 	public function set_safari_brands($id,$safari_brands) {
726 726
 		foreach($safari_brands as $safari_brand){
727
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
727
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
728 728
 		}
729 729
 	}	
730 730
 	
@@ -774,11 +774,11 @@  discard block
 block discarded – undo
774 774
 				'elevation'	=>	'',
775 775
 			);
776 776
 			if(false !== $id && '0' !== $id){
777
-	        	$prev = get_post_meta($id,'location',true);
778
-	        	update_post_meta($id,'location',$location_data,$prev);
779
-	        }else{
780
-	        	add_post_meta($id,'location',$location_data,true);
781
-	        }
777
+				$prev = get_post_meta($id,'location',true);
778
+				update_post_meta($id,'location',$location_data,$prev);
779
+			}else{
780
+				add_post_meta($id,'location',$location_data,true);
781
+			}
782 782
 		}
783 783
 	}
784 784
 	/**
@@ -792,35 +792,35 @@  discard block
 block discarded – undo
792 792
 			if(isset($data[0]['position']['country'])){
793 793
 
794 794
 				if(!$term = term_exists(trim($data[0]['position']['country']), 'location'))
795
-		        {
796
-		            $term = wp_insert_term(trim($data[0]['position']['country']), 'location');
797
-		            if ( is_wp_error($term) ){
798
-		            	echo $term->get_error_message();
799
-		            }
800
-		            else {
801
-		            	wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
802
-		            }
803
-		        }
804
-		        else
805
-		        {
806
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
807
-		        }
808
-		        $country_id = intval($term['term_id']);
809
-		    }
795
+				{
796
+					$term = wp_insert_term(trim($data[0]['position']['country']), 'location');
797
+					if ( is_wp_error($term) ){
798
+						echo $term->get_error_message();
799
+					}
800
+					else {
801
+						wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
802
+					}
803
+				}
804
+				else
805
+				{
806
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
807
+				}
808
+				$country_id = intval($term['term_id']);
809
+			}
810 810
 
811 811
 			if(isset($data[0]['position']['destination'])){
812 812
 
813 813
 				$tax_args = array('parent'=>$country_id);
814 814
 				if(!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
815
-		        {
816
-		            $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
817
-		            if ( is_wp_error($term) ){echo $term->get_error_message();}
818
-		            else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
819
-		        }
820
-		        else
821
-		        {
822
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
823
-		        }				
815
+				{
816
+					$term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
817
+					if ( is_wp_error($term) ){echo $term->get_error_message();}
818
+					else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
819
+				}
820
+				else
821
+				{
822
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
823
+				}				
824 824
 			}		
825 825
 		}
826 826
 	}
@@ -830,31 +830,31 @@  discard block
 block discarded – undo
830 830
 	 */
831 831
 	public function connect_destinations($data,$id) {
832 832
 		if(isset($data[0]['position'])){
833
-		    $destinations = false;
834
-		    if(isset($data[0]['position']['country'])){
835
-		    	$destinations['country'] = $data[0]['position']['country'];
836
-		    }
837
-		    if(isset($data[0]['position']['destination'])){
838
-		    	$destinations['destination'] = $data[0]['position']['destination'];
839
-		    }
833
+			$destinations = false;
834
+			if(isset($data[0]['position']['country'])){
835
+				$destinations['country'] = $data[0]['position']['country'];
836
+			}
837
+			if(isset($data[0]['position']['destination'])){
838
+				$destinations['destination'] = $data[0]['position']['destination'];
839
+			}
840 840
 		    
841
-		    if(false !== $destinations){	
842
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
843
-		    	if(false === $prev_values || !is_array($prev_values)){
844
-		    		$prev_values = array();
845
-		    	}
846
-		    	//print_r($destinations);
841
+			if(false !== $destinations){	
842
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
843
+				if(false === $prev_values || !is_array($prev_values)){
844
+					$prev_values = array();
845
+				}
846
+				//print_r($destinations);
847 847
 				$destinations = array_unique($destinations);
848 848
 				//print_r($destinations);
849
-			    foreach($destinations as $key => $value){
850
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
851
-	                if (null !== $destination) {
852
-	                	if(!in_array($destination->ID,$prev_values)){
853
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
854
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
855
-	                	}
856
-	                } 		    	
857
-			    }	
849
+				foreach($destinations as $key => $value){
850
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
851
+					if (null !== $destination) {
852
+						if(!in_array($destination->ID,$prev_values)){
853
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
854
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
855
+						}
856
+					} 		    	
857
+				}	
858 858
 			}
859 859
 		}
860 860
 	}	
@@ -866,15 +866,15 @@  discard block
 block discarded – undo
866 866
 		$terms = false;
867 867
 		if(isset($data[0]['category'])){
868 868
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
869
-	        {
870
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
871
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
872
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
873
-	        }
874
-	        else
875
-	        {
876
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
877
-	        }				
869
+			{
870
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
871
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
872
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
873
+			}
874
+			else
875
+			{
876
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
877
+			}				
878 878
 		}
879 879
 	}		
880 880
 
@@ -898,25 +898,25 @@  discard block
 block discarded – undo
898 898
 				$temp_room['type'] = 'room';
899 899
 
900 900
 				if(!empty($room['images']) && is_array($room['images'])){
901
-			    	$attachments_args = array(
902
-			    			'post_parent' => $id,
903
-			    			'post_status' => 'inherit',
904
-			    			'post_type' => 'attachment',
905
-			    			'order' => 'ASC',
906
-			    	);   	
907
-			    	$attachments = new WP_Query($attachments_args);
908
-			    	$found_attachments = array();
909
-
910
-			    	if($attachments->have_posts()){
911
-			    		foreach($attachments->posts as $attachment){
912
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
913
-			    		}
914
-			    	}
901
+					$attachments_args = array(
902
+							'post_parent' => $id,
903
+							'post_status' => 'inherit',
904
+							'post_type' => 'attachment',
905
+							'order' => 'ASC',
906
+					);   	
907
+					$attachments = new WP_Query($attachments_args);
908
+					$found_attachments = array();
909
+
910
+					if($attachments->have_posts()){
911
+						foreach($attachments->posts as $attachment){
912
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
913
+						}
914
+					}
915 915
 
916 916
 					$temp_room['gallery'] = array();
917 917
 					foreach($room['images'] as $image_data){
918
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
919
-			    	}
918
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
919
+					}
920 920
 				}
921 921
 				$rooms[] = $temp_room;
922 922
 			}
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 				delete_post_meta($id, 'units');				
926 926
 			}
927 927
 			foreach($rooms as $room){
928
-		        add_post_meta($id,'units',$room,false);			
928
+				add_post_meta($id,'units',$room,false);			
929 929
 			}
930 930
 
931 931
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -935,11 +935,11 @@  discard block
 block discarded – undo
935 935
 			}
936 936
 
937 937
 			if(false !== $id && '0' !== $id){
938
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
939
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
940
-	        }else{
941
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
942
-	        }
938
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
939
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
940
+			}else{
941
+				add_post_meta($id,'number_of_rooms',$room_count,true);
942
+			}
943 943
 		}
944 944
 	}
945 945
 
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 				delete_post_meta($id, 'videos');				
1050 1050
 			}
1051 1051
 			foreach($videos as $video){
1052
-		        add_post_meta($id,'videos',$video,false);			
1052
+				add_post_meta($id,'videos',$video,false);			
1053 1053
 			}
1054 1054
 		}
1055 1055
 	}	
@@ -1078,17 +1078,17 @@  discard block
 block discarded – undo
1078 1078
 
1079 1079
 	function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
1080 1080
 		if(!$term = term_exists($name, $taxonomy))
1081
-        {
1082
-        	if(false !== $parent){ $parent = array('parent'=>$parent); }
1083
-            $term = wp_insert_term(trim($name), $taxonomy,$parent);
1084
-            if ( is_wp_error($term) ){echo $term->get_error_message();}
1085
-            else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1086
-        }
1087
-        else
1088
-        {
1089
-            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1090
-        }
1091
-        return $term['term_id'];
1081
+		{
1082
+			if(false !== $parent){ $parent = array('parent'=>$parent); }
1083
+			$term = wp_insert_term(trim($name), $taxonomy,$parent);
1084
+			if ( is_wp_error($term) ){echo $term->get_error_message();}
1085
+			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1086
+		}
1087
+		else
1088
+		{
1089
+			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1090
+		}
1091
+		return $term['term_id'];
1092 1092
 	}	
1093 1093
 
1094 1094
 	/**
@@ -1096,17 +1096,17 @@  discard block
 block discarded – undo
1096 1096
 	 */
1097 1097
 	public function set_featured_image($data,$id) {
1098 1098
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1099
-	    	$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1099
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1100 1100
 
1101
-	    	if(false !== $this->featured_image){
1102
-	    		delete_post_meta($id,'_thumbnail_id');
1103
-	    		add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1101
+			if(false !== $this->featured_image){
1102
+				delete_post_meta($id,'_thumbnail_id');
1103
+				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1104 1104
 
1105
-	    		if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1106
-	    			add_post_meta($id,'gallery',$this->featured_image,false);
1107
-	    			$this->gallery_meta[] = $this->featured_image;
1108
-	    		}
1109
-	    	}			
1105
+				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1106
+					add_post_meta($id,'gallery',$this->featured_image,false);
1107
+					$this->gallery_meta[] = $this->featured_image;
1108
+				}
1109
+			}			
1110 1110
 		}	
1111 1111
 	}	
1112 1112
 
@@ -1115,18 +1115,18 @@  discard block
 block discarded – undo
1115 1115
 	 */
1116 1116
 	public function set_banner_image($data,$id) {
1117 1117
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1118
-	    	$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1119
-
1120
-	    	if(false !== $this->banner_image){
1121
-	    		delete_post_meta($id,'image_group');
1122
-	    		$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1123
-	    		add_post_meta($id,'image_group',$new_banner,true);
1124
-
1125
-	    		if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1126
-	    			add_post_meta($id,'gallery',$this->banner_image,false);
1127
-	    			$this->gallery_meta[] = $this->banner_image;
1128
-	    		}
1129
-	    	}			
1118
+			$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1119
+
1120
+			if(false !== $this->banner_image){
1121
+				delete_post_meta($id,'image_group');
1122
+				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1123
+				add_post_meta($id,'image_group',$new_banner,true);
1124
+
1125
+				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1126
+					add_post_meta($id,'gallery',$this->banner_image,false);
1127
+					$this->gallery_meta[] = $this->banner_image;
1128
+				}
1129
+			}			
1130 1130
 		}	
1131 1131
 	}		
1132 1132
 
@@ -1136,25 +1136,25 @@  discard block
 block discarded – undo
1136 1136
 	public function create_main_gallery($data,$id) {
1137 1137
 
1138 1138
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1139
-	    	$counter = 0;
1140
-	    	foreach($data[0]['content']['images'] as $image_data){
1141
-	    		if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
1142
-	    		if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
1139
+			$counter = 0;
1140
+			foreach($data[0]['content']['images'] as $image_data){
1141
+				if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
1142
+				if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
1143 1143
 
1144
-	    		$this->gallery_meta[] = $this->attach_image($image_data,$id);
1145
-	    		$counter++;
1146
-	    	}
1144
+				$this->gallery_meta[] = $this->attach_image($image_data,$id);
1145
+				$counter++;
1146
+			}
1147 1147
 
1148
-	    	if(!empty($this->gallery_meta)){
1149
-	    		delete_post_meta($id,'gallery');
1148
+			if(!empty($this->gallery_meta)){
1149
+				delete_post_meta($id,'gallery');
1150 1150
 				$this->gallery_meta = array_unique($this->gallery_meta);
1151
-	    		foreach($this->gallery_meta as $gallery_id){
1152
-	    			if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1153
-	    				add_post_meta($id,'gallery',$gallery_id,false);
1154
-	    			}
1155
-	    		}
1156
-	    	}
1157
-    	}
1151
+				foreach($this->gallery_meta as $gallery_id){
1152
+					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1153
+						add_post_meta($id,'gallery',$gallery_id,false);
1154
+					}
1155
+				}
1156
+			}
1157
+		}
1158 1158
 	}	
1159 1159
 
1160 1160
 	/**
@@ -1163,42 +1163,42 @@  discard block
 block discarded – undo
1163 1163
 	public function attach_image($v=false,$parent_id,$image_sizes=false){
1164 1164
 		if(false !== $v){
1165 1165
 	   		$temp_fragment = explode('/',$v['url_fragment']);
1166
-	    	$url_filename = $temp_fragment[count($temp_fragment)-1];
1167
-	    	$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1166
+			$url_filename = $temp_fragment[count($temp_fragment)-1];
1167
+			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1168 1168
 
1169
-	    	if(in_array($url_filename,$this->found_attachments)){
1170
-	    		return array_search($url_filename,$this->found_attachments);
1171
-	    	}
1169
+			if(in_array($url_filename,$this->found_attachments)){
1170
+				return array_search($url_filename,$this->found_attachments);
1171
+			}
1172 1172
 	    	               
1173
-	        $postdata=array();
1174
-	        if(empty($v['label']))
1175
-	        {
1176
-	            $v['label']='';
1177
-	        }
1178
-	        if(!empty($v['description']))
1179
-	        {
1180
-	            $desc=wp_strip_all_tags($v['description']);
1181
-	            $posdata=array('post_excerpt'=>$desc);
1182
-	        }
1183
-	        if(!empty($v['section']))
1184
-	        {
1185
-	            $desc=wp_strip_all_tags($v['section']);
1186
-	            $posdata=array('post_excerpt'=>$desc);
1187
-	        }
1188
-
1189
-	        $attachID=NULL;  
1190
-	        //Resizor - add option to setting if required
1191
-	        $fragment = str_replace(' ','%20',$v['url_fragment']);
1192
-	        $url = $this->get_scaling_url($image_sizes).$fragment;
1193
-	        $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1194
-
1195
-	        //echo($attachID.' add image');
1196
-	        if($attachID!=NULL)
1197
-	        {
1198
-	            return $attachID;
1199
-	        }
1200
-        }	
1201
-        return 	false;
1173
+			$postdata=array();
1174
+			if(empty($v['label']))
1175
+			{
1176
+				$v['label']='';
1177
+			}
1178
+			if(!empty($v['description']))
1179
+			{
1180
+				$desc=wp_strip_all_tags($v['description']);
1181
+				$posdata=array('post_excerpt'=>$desc);
1182
+			}
1183
+			if(!empty($v['section']))
1184
+			{
1185
+				$desc=wp_strip_all_tags($v['section']);
1186
+				$posdata=array('post_excerpt'=>$desc);
1187
+			}
1188
+
1189
+			$attachID=NULL;  
1190
+			//Resizor - add option to setting if required
1191
+			$fragment = str_replace(' ','%20',$v['url_fragment']);
1192
+			$url = $this->get_scaling_url($image_sizes).$fragment;
1193
+			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1194
+
1195
+			//echo($attachID.' add image');
1196
+			if($attachID!=NULL)
1197
+			{
1198
+				return $attachID;
1199
+			}
1200
+		}	
1201
+		return 	false;
1202 1202
 	}
1203 1203
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1204 1204
 	
Please login to merge, or discard this patch.
Spacing   +375 added lines, -375 removed lines patch added patch discarded remove patch
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
 	public function __construct() {
65 65
 		$this->set_variables();
66 66
 
67
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
68
-		add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));	
69
-		add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));		
67
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
68
+		add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));	
69
+		add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));		
70 70
 
71
-		add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));	
72
-		add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
71
+		add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));	
72
+		add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
73 73
 
74
-		$temp_options = get_option('_lsx-to_settings',false);
75
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
74
+		$temp_options = get_option('_lsx-to_settings', false);
75
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
76 76
 			$this->options = $temp_options[$this->plugin_slug];
77 77
 		}
78 78
 
79
-		$accommodation_options = get_option('wetu_importer_accommodation_settings',false);
80
-		if(false !== $accommodation_options){
79
+		$accommodation_options = get_option('wetu_importer_accommodation_settings', false);
80
+		if (false !== $accommodation_options) {
81 81
 			$this->accommodation_options = $accommodation_options;
82 82
 		}
83 83
 	}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		//	$this->url    = 'https://wetu.com/API/Pins/';
95 95
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
96 96
 		//} elseif ( false !== $this->api_key ) {
97
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
97
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
98 98
 			$this->url_qs = '';
99 99
 		//}
100 100
 	}
@@ -102,27 +102,27 @@  discard block
 block discarded – undo
102 102
 	/**
103 103
 	 * search_form
104 104
 	 */
105
-	public function get_scaling_url($args=array()) {
105
+	public function get_scaling_url($args = array()) {
106 106
 
107 107
 		$defaults = array(
108 108
 			'width' => '640',
109 109
 			'height' => '480',
110 110
 			'cropping' => 'c'
111 111
 		);
112
-		if(false !== $this->options){
113
-			if(isset($this->options['width']) && '' !== $this->options['width']){
112
+		if (false !== $this->options) {
113
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
114 114
 				$defaults['width'] = $this->options['width'];
115 115
 			}
116 116
 
117
-			if(isset($this->options['height']) && '' !== $this->options['height']){
117
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
118 118
 				$defaults['height'] = $this->options['height'];
119 119
 			}
120 120
 
121
-			if(isset($this->options['cropping']) && '' !== $this->options['cropping']){
121
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
122 122
 				$defaults['cropping'] = $this->options['cropping'];
123 123
 			}	
124 124
 		}	
125
-		$args = wp_parse_args($args,$defaults);
125
+		$args = wp_parse_args($args, $defaults);
126 126
 
127 127
 		$cropping = $args['cropping'];
128 128
 		$width = $args['width'];
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 			<form method="get" action="" id="posts-filter">
148 148
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
149 149
 				
150
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
151
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
150
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
151
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
152 152
 				</p>				
153 153
 
154 154
 				<table class="wp-list-table widefat fixed posts">
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 					<tbody id="the-list">
158 158
 						<tr class="post-0 type-tour status-none" id="post-0">
159 159
 							<th class="check-column" scope="row">
160
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
160
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
161 161
 							</th>
162 162
 							<td class="post-title page-title column-title">
163 163
 								<strong>
164
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
164
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
165 165
 								</strong>
166 166
 							</td>
167 167
 							<td class="date column-date">							
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 
176 176
 				</table>
177 177
 
178
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
179
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
178
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
179
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
180 180
 				</p>
181 181
 			</form> 
182 182
 
@@ -188,32 +188,32 @@  discard block
 block discarded – undo
188 188
 						<div class="settings-all" style="width:30%;display:block;float:left;">
189 189
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
190 190
 							<ul>
191
-                                <li><input class="content select-all" <?php $this->checked($this->destination_options,'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All','wetu-importer'); ?></li>
192
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
193
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
194
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li>
195
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
196
-		                        <?php if(class_exists('LSX_TO_Maps')){ ?>
197
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li>
191
+                                <li><input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li>
192
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
193
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
194
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li>
195
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
196
+		                        <?php if (class_exists('LSX_TO_Maps')) { ?>
197
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li>
198 198
 		                        <?php } ?>
199
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations','wetu-importer'); ?></li>
200
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out','wetu-importer'); ?></li>
201
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities','wetu-importer'); ?></li>
202
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly','wetu-importer'); ?></li>
203
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating','wetu-importer'); ?></li>
204
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms','wetu-importer'); ?></li>
205
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests','wetu-importer'); ?></li>
206
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages','wetu-importer'); ?></li>
207
-
208
-		                        <?php if(class_exists('LSX_TO_Videos')){ ?>
209
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li>
199
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations', 'wetu-importer'); ?></li>
200
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out', 'wetu-importer'); ?></li>
201
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities', 'wetu-importer'); ?></li>
202
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly', 'wetu-importer'); ?></li>
203
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating', 'wetu-importer'); ?></li>
204
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms', 'wetu-importer'); ?></li>
205
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests', 'wetu-importer'); ?></li>
206
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages', 'wetu-importer'); ?></li>
207
+
208
+		                        <?php if (class_exists('LSX_TO_Videos')) { ?>
209
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li>
210 210
 		                        <?php } ?>
211 211
 							</ul>
212 212
 							<h4><?php _e('Additional Content'); ?></h4>
213 213
 							<ul>
214
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li>
215
-		                        <?php if(class_exists('LSX_Banners')){ ?>
216
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li>
214
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li>
215
+		                        <?php if (class_exists('LSX_Banners')) { ?>
216
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li>
217 217
 		                        <?php } ?>
218 218
 							</ul>
219 219
 						</div>
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 						<div style="width:30%;display:block;float:left;">
226 226
 							<h3><?php _e('Assign a Safari Brand'); ?></h3> 
227
-							<?php echo $this->taxonomy_checkboxes('accommodation-brand',$this->accommodation_options); ?>
227
+							<?php echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); ?>
228 228
 						</div>	
229 229
 
230 230
 						<br clear="both" />			
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
 
234 234
 					<h3><?php _e('Your List'); ?></h3>
235
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
235
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
236 236
 					<table class="wp-list-table widefat fixed posts">
237 237
 						<?php $this->table_header(); ?>
238 238
 
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 
245 245
 					</table>
246 246
 
247
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
247
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
248 248
 				</form>
249 249
 			</div>
250 250
 
251 251
 			<div style="display:none;" class="completed-list-wrapper">
252
-				<h3><?php _e('Completed'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3>
252
+				<h3><?php _e('Completed'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3>
253 253
 				<ul>
254 254
 				</ul>
255 255
 			</div>
@@ -265,30 +265,30 @@  discard block
 block discarded – undo
265 265
         <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>">
266 266
         	<input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" />
267 267
 
268
-        	<h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3>
268
+        	<h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3>
269 269
         	<div class="normal-search">
270
-        		<input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
270
+        		<input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
271 271
         	</div>
272 272
         	<div class="advanced-search hidden" style="display:none;">
273
-        		<p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p>
273
+        		<p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p>
274 274
         		<textarea rows="10" cols="40" name="bulk-keywords"></textarea>
275
-        		<input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
275
+        		<input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
276 276
         	</div>    
277 277
 
278 278
         	<p>
279
-                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> |
280
-                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> |
281
-                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> |
282
-                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a> |
283
-                <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a>
279
+                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> |
280
+                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> |
281
+                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> |
282
+                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> |
283
+                <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a>
284 284
             </p>
285 285
 
286 286
             <div class="ajax-loader" style="display:none;width:100%;text-align:center;">
287
-            	<img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
287
+            	<img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
288 288
             </div>
289 289
 
290 290
             <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
291
-            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
291
+            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
292 292
             </div>            
293 293
         </form>	
294 294
 	<?php 
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 	 * search_form
299 299
 	 */
300 300
 	public function update_options_form() {
301
-		echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').'</h3>';
301
+		echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').'</h3>';
302 302
 		$accommodation = get_transient('lsx_ti_accommodation');
303
-		if('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])){
303
+		if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) {
304 304
 			$this->update_options();
305 305
 		}
306 306
 		echo '</div>';
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
 	 * Save the list of Accommodation into an option
312 312
 	 */
313 313
 	public function update_options() {
314
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
314
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
315 315
 		$accommodation = json_decode($data, true);
316 316
 
317
-		if(isset($accommodation['error'])){
317
+		if (isset($accommodation['error'])) {
318 318
 		    return $accommodation['error'];
319 319
         }elseif (isset($accommodation) && !empty($accommodation)) {
320
-			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
320
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
321 321
 			return true;
322 322
 		}
323 323
 	}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	/**
326 326
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
327 327
 	 */
328
-	public function find_current_accommodation($post_type='accommodation') {
328
+	public function find_current_accommodation($post_type = 'accommodation') {
329 329
 		global $wpdb;
330 330
 		$return = array();
331 331
 
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 
342 342
 					LIMIT 0,500
343 343
 		");
344
-		if(null !== $current_accommodation && !empty($current_accommodation)){
345
-			foreach($current_accommodation as $accom){
344
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
345
+			foreach ($current_accommodation as $accom) {
346 346
 				$return[$accom->meta_value] = $accom;
347 347
 			}
348 348
 		}
@@ -354,37 +354,37 @@  discard block
 block discarded – undo
354 354
 	 */
355 355
 	public function process_ajax_search() {
356 356
 		$return = false;
357
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation'){
357
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') {
358 358
 			$accommodation = get_transient('lsx_ti_accommodation');
359 359
 
360
-			if ( false !== $accommodation ) {
360
+			if (false !== $accommodation) {
361 361
 				$searched_items = false;
362 362
 
363
-				if(isset($_POST['keyword'] )) {
363
+				if (isset($_POST['keyword'])) {
364 364
 					$keyphrases = $_POST['keyword'];
365
-				}else{
365
+				}else {
366 366
 					$keyphrases = array(0);
367 367
                 }
368 368
 
369
-				if(!is_array($keyphrases)){
369
+				if (!is_array($keyphrases)) {
370 370
 					$keyphrases = array($keyphrases);
371 371
 				}
372
-				foreach($keyphrases as &$keyword){
372
+				foreach ($keyphrases as &$keyword) {
373 373
 					$keyword = ltrim(rtrim($keyword));
374 374
 				}
375 375
 
376 376
 
377 377
 				$post_status = false;
378
-				if(in_array('publish',$keyphrases)){
378
+				if (in_array('publish', $keyphrases)) {
379 379
 					$post_status = 'publish';
380 380
 				}
381
-				if(in_array('pending',$keyphrases)){
381
+				if (in_array('pending', $keyphrases)) {
382 382
 					$post_status = 'pending';
383 383
 				}
384
-				if(in_array('draft',$keyphrases)){
384
+				if (in_array('draft', $keyphrases)) {
385 385
 					$post_status = 'draft';
386 386
 				}
387
-				if(in_array('import',$keyphrases)){
387
+				if (in_array('import', $keyphrases)) {
388 388
 					$post_status = 'import';
389 389
 				}
390 390
 
@@ -392,33 +392,33 @@  discard block
 block discarded – undo
392 392
 
393 393
 					$current_accommodation = $this->find_current_accommodation();
394 394
 
395
-					foreach($accommodation as $row_key => $row){
395
+					foreach ($accommodation as $row_key => $row) {
396 396
 
397 397
 						//If this is a current tour, add its ID to the row.
398 398
 						$row['post_id'] = 0;
399
-						if(false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)){
399
+						if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) {
400 400
 							$row['post_id'] = $current_accommodation[$row['id']]->post_id;
401 401
 						}
402 402
 
403 403
 						//If we are searching for
404
-						if(false !== $post_status){
404
+						if (false !== $post_status) {
405 405
 
406
-							if('import' === $post_status){
406
+							if ('import' === $post_status) {
407 407
 
408
-								if(0 !== $row['post_id']){
408
+								if (0 !== $row['post_id']) {
409 409
 									continue;
410
-								}else{
410
+								}else {
411 411
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
412 412
 								}
413 413
 
414 414
 
415
-							}else{
415
+							}else {
416 416
 
417
-								if(0 === $row['post_id']){
417
+								if (0 === $row['post_id']) {
418 418
 									continue;
419
-								}else{
419
+								}else {
420 420
 									$current_status = get_post_status($row['post_id']);
421
-									if($current_status !== $post_status){
421
+									if ($current_status !== $post_status) {
422 422
 										continue;
423 423
 									}
424 424
 
@@ -426,17 +426,17 @@  discard block
 block discarded – undo
426 426
 								$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
427 427
 							}
428 428
 
429
-						}else{
429
+						}else {
430 430
 							//Search through each keyword.
431
-							foreach($keyphrases as $keyphrase){
431
+							foreach ($keyphrases as $keyphrase) {
432 432
 
433 433
 								//Make sure the keyphrase is turned into an array
434
-								$keywords = explode(" ",$keyphrase);
435
-								if(!is_array($keywords)){
434
+								$keywords = explode(" ", $keyphrase);
435
+								if (!is_array($keywords)) {
436 436
 									$keywords = array($keywords);
437 437
 								}
438 438
 
439
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
439
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
440 440
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
441 441
 								}
442 442
 							}
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 				}
446 446
 
447 447
 
448
-				if(false !== $searched_items){
448
+				if (false !== $searched_items) {
449 449
 					ksort($searched_items);
450 450
 					$return = implode($searched_items);
451 451
 				}
@@ -458,17 +458,17 @@  discard block
 block discarded – undo
458 458
 	/**
459 459
 	 * Does a multine search
460 460
 	 */	
461
-	public function multineedle_stripos($haystack, $needles, $offset=0) {
461
+	public function multineedle_stripos($haystack, $needles, $offset = 0) {
462 462
 		$found = false;
463 463
 		$needle_count = count($needles);
464
-	    foreach($needles as $needle) {
465
-	    	if(false !== stripos($haystack, $needle, $offset)){
464
+	    foreach ($needles as $needle) {
465
+	    	if (false !== stripos($haystack, $needle, $offset)) {
466 466
 	        	$found[] = true;
467 467
 	    	}
468 468
 	    }
469
-	    if(false !== $found && $needle_count === count($found)){ 
469
+	    if (false !== $found && $needle_count === count($found)) { 
470 470
 	    	return true;
471
-		}else{
471
+		}else {
472 472
 			return false;
473 473
 		}
474 474
 	}
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 	/**
477 477
 	 * Formats the row for output on the screen.
478 478
 	 */	
479
-	public function format_row($row = false){
480
-		if(false !== $row){
479
+	public function format_row($row = false) {
480
+		if (false !== $row) {
481 481
 
482 482
 			$status = 'import';
483
-			if(0 !== $row['post_id']){
483
+			if (0 !== $row['post_id']) {
484 484
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
485 485
 			}
486 486
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 					<strong>'.$row['name'].'</strong> - '.$status.'
495 495
 				</td>
496 496
 				<td class="date column-date">
497
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
497
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
498 498
 				</td>
499 499
 				<td class="ssid column-ssid">
500 500
 					'.$row['id'].'
@@ -509,42 +509,42 @@  discard block
 block discarded – undo
509 509
 	 */
510 510
 	public function process_ajax_import() {
511 511
 		$return = false;
512
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])){
512
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) {
513 513
 			
514 514
 			$wetu_id = $_POST['wetu_id'];
515
-			if(isset($_POST['post_id'])){
515
+			if (isset($_POST['post_id'])) {
516 516
 				$post_id = $_POST['post_id'];	
517
-			}else{
517
+			}else {
518 518
 				$post_id = 0;
519 519
 			}
520 520
 
521
-			if(isset($_POST['team_members'])){
521
+			if (isset($_POST['team_members'])) {
522 522
 				$team_members = $_POST['team_members'];	
523
-			}else{
523
+			}else {
524 524
 				$team_members = false;
525 525
 			}
526 526
 
527
-			if(isset($_POST['safari_brands'])){
527
+			if (isset($_POST['safari_brands'])) {
528 528
 				$safari_brands = $_POST['safari_brands'];	
529
-			}else{
529
+			}else {
530 530
 				$safari_brands = false;
531 531
 			}			
532 532
 
533
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
533
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
534 534
 				$content = $_POST['content'];
535
-				add_option('wetu_importer_accommodation_settings',$content);
536
-			}else{
535
+				add_option('wetu_importer_accommodation_settings', $content);
536
+			}else {
537 537
 				delete_option('wetu_importer_accommodation_settings');
538 538
 				$content = false;
539 539
 			}
540 540
 
541
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
542
-            if($jdata)
541
+            $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
542
+            if ($jdata)
543 543
             {
544
-                $adata=json_decode($jdata,true);
545
-                if(!empty($adata))
544
+                $adata = json_decode($jdata, true);
545
+                if (!empty($adata))
546 546
                 {
547
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
547
+                	$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
548 548
                 	$this->format_completed_row($return);
549 549
                 }
550 550
             }
@@ -556,15 +556,15 @@  discard block
 block discarded – undo
556 556
 	/**
557 557
 	 * Formats the row for the completed list.
558 558
 	 */
559
-	public function format_completed_row($response){
559
+	public function format_completed_row($response) {
560 560
 		echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>';
561 561
 	}
562 562
 	/**
563 563
 	 * Connect to wetu
564 564
 	 */
565
-	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
565
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) {
566 566
 
567
-        if(trim($data[0]['type'])=='Accommodation')
567
+        if (trim($data[0]['type']) == 'Accommodation')
568 568
         {
569 569
 	        $post_name = $data_post_content = $data_post_excerpt = '';
570 570
 	        $post = array(
@@ -574,44 +574,44 @@  discard block
 block discarded – undo
574 574
 	        $content_used_general_description = false;
575 575
 
576 576
 	        //Set the post_content
577
-	        if(false !== $importable_content && in_array('description',$importable_content)){
578
-		        if(isset($data[0]['content']['extended_description']))
577
+	        if (false !== $importable_content && in_array('description', $importable_content)) {
578
+		        if (isset($data[0]['content']['extended_description']))
579 579
 		        {
580 580
 		            $data_post_content = $data[0]['content']['extended_description'];
581
-		        }elseif(isset($data[0]['content']['general_description'])){
581
+		        }elseif (isset($data[0]['content']['general_description'])) {
582 582
 		            $data_post_content = $data[0]['content']['general_description'];
583 583
 		            $content_used_general_description = true;
584
-		        }elseif(isset($data[0]['content']['teaser_description'])){
584
+		        }elseif (isset($data[0]['content']['teaser_description'])) {
585 585
 		        	$data_post_content = $data[0]['content']['teaser_description'];
586 586
 		        }
587 587
 	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
588 588
 	        }
589 589
 
590 590
 	        //set the post_excerpt
591
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
592
-		        if(isset($data[0]['content']['teaser_description'])){
591
+	        if (false !== $importable_content && in_array('excerpt', $importable_content)) {
592
+		        if (isset($data[0]['content']['teaser_description'])) {
593 593
 		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
594
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
594
+		        }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
595 595
 		            $data_post_excerpt = $data[0]['content']['general_description'];
596 596
 		        }	   
597 597
 		        $post['post_excerpt'] = $data_post_excerpt;     	
598 598
 	        }
599 599
 
600
-	        if(false !== $id && '0' !== $id){
600
+	        if (false !== $id && '0' !== $id) {
601 601
 	        	$post['ID'] = $id;
602
-				if(isset($data[0]['name'])){
602
+				if (isset($data[0]['name'])) {
603 603
 					$post['post_title'] = $data[0]['name'];
604 604
 	        		$post['post_status'] = 'publish';
605
-					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
605
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
606 606
 				}
607 607
 	        	$id = wp_update_post($post);
608
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
609
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
610
-	        }else{
608
+	        	$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
609
+	        	update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
610
+	        }else {
611 611
 
612 612
 		        //Set the name
613
-		        if(isset($data[0]['name'])){
614
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
613
+		        if (isset($data[0]['name'])) {
614
+		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
615 615
 		        }
616 616
 	        	$post['post_name'] = $post_name;
617 617
 	        	$post['post_title'] = $data[0]['name'];
@@ -619,90 +619,90 @@  discard block
 block discarded – undo
619 619
 	        	$id = wp_insert_post($post);
620 620
 
621 621
 	        	//Save the WETU ID and the Last date it was modified.
622
-	        	if(false !== $id){
623
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
624
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
622
+	        	if (false !== $id) {
623
+	        		add_post_meta($id, 'lsx_wetu_id', $wetu_id);
624
+	        		add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
625 625
 	        	}
626 626
 	        }
627 627
 	        //Setup some default for use in the import
628
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
628
+	        if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
629 629
 				$this->find_attachments($id);
630 630
 			}
631 631
 
632 632
 	        //Set the team member if it is there
633
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
634
-	        	$this->set_team_member($id,$team_members);
633
+	        if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
634
+	        	$this->set_team_member($id, $team_members);
635 635
 	    	}
636 636
 
637 637
 	        //Set the safari brand
638
-	        if(false !== $safari_brands && '' !== $safari_brands){
639
-	        	$this->set_safari_brands($id,$safari_brands);
638
+	        if (false !== $safari_brands && '' !== $safari_brands) {
639
+	        	$this->set_safari_brands($id, $safari_brands);
640 640
 
641 641
 	    	}	    	
642 642
 
643
-	        if(class_exists('LSX_TO_Maps')){
644
-	        	$this->set_map_data($data,$id,9);
645
-	        	$this->set_location_taxonomy($data,$id);
643
+	        if (class_exists('LSX_TO_Maps')) {
644
+	        	$this->set_map_data($data, $id, 9);
645
+	        	$this->set_location_taxonomy($data, $id);
646 646
 	        }
647 647
 
648
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
649
-	        	$this->connect_destinations($data,$id);
648
+	        if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) {
649
+	        	$this->connect_destinations($data, $id);
650 650
 	        }
651 651
 
652
-	        if(false !== $importable_content && in_array('category',$importable_content)){
653
-	        	$this->set_taxonomy_style($data,$id);
652
+	        if (false !== $importable_content && in_array('category', $importable_content)) {
653
+	        	$this->set_taxonomy_style($data, $id);
654 654
 	        }
655 655
 
656 656
 	        //Set the Room Data
657
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
658
-	        	$this->set_room_data($data,$id);
657
+	        if (false !== $importable_content && in_array('rooms', $importable_content)) {
658
+	        	$this->set_room_data($data, $id);
659 659
 	    	}
660 660
 
661 661
 	    	//Set the rating
662
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
663
-	       		$this->set_rating($data,$id);
662
+	    	if (false !== $importable_content && in_array('rating', $importable_content)) {
663
+	       		$this->set_rating($data, $id);
664 664
 	    	}
665 665
 
666 666
 	    	//Set the checkin checkout data
667
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
668
-	        	$this->set_checkin_checkout($data,$id);
667
+	    	if (false !== $importable_content && in_array('checkin', $importable_content)) {
668
+	        	$this->set_checkin_checkout($data, $id);
669 669
 	        }
670 670
 
671 671
 	    	//Set the Spoken Languages
672
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
673
-	       		$this->set_spoken_languages($data,$id);
672
+	    	if (false !== $importable_content && in_array('spoken_languages', $importable_content)) {
673
+	       		$this->set_spoken_languages($data, $id);
674 674
 	    	}
675 675
 
676 676
 	    	//Set the friendly options
677
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
678
-	       		$this->set_friendly($data,$id);
677
+	    	if (false !== $importable_content && in_array('friendly', $importable_content)) {
678
+	       		$this->set_friendly($data, $id);
679 679
 	    	}
680 680
 
681 681
 	    	//Set the special_interests
682
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
683
-	       		$this->set_special_interests($data,$id);
682
+	    	if (false !== $importable_content && in_array('special_interests', $importable_content)) {
683
+	       		$this->set_special_interests($data, $id);
684 684
 	    	}	    		    		        
685 685
 
686 686
 	        //Import the videos
687
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
688
-	        	$this->set_video_data($data,$id);
687
+	        if (false !== $importable_content && in_array('videos', $importable_content)) {
688
+	        	$this->set_video_data($data, $id);
689 689
 	        }
690 690
 
691 691
 	        //Import the facilities
692
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
693
-	        	$this->set_facilities($data,$id);
692
+	        if (false !== $importable_content && in_array('facilities', $importable_content)) {
693
+	        	$this->set_facilities($data, $id);
694 694
 	        }	        
695 695
 
696 696
 	        //Set the featured image
697
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
698
-	        	$this->set_featured_image($data,$id);
697
+	        if (false !== $importable_content && in_array('featured_image', $importable_content)) {
698
+	        	$this->set_featured_image($data, $id);
699 699
 	        }
700
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
701
-	        	$this->set_banner_image($data,$id);
700
+	        if (false !== $importable_content && in_array('banner_image', $importable_content)) {
701
+	        	$this->set_banner_image($data, $id);
702 702
 	        }	        
703 703
 	        //Import the main gallery
704
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
705
-	    		$this->create_main_gallery($data,$id);
704
+	        if (false !== $importable_content && in_array('gallery', $importable_content)) {	    	
705
+	    		$this->create_main_gallery($data, $id);
706 706
 	        }	        	        	        
707 707
         }
708 708
         return $id;
@@ -711,115 +711,115 @@  discard block
 block discarded – undo
711 711
 	/**
712 712
 	 * Set the team memberon each item.
713 713
 	 */
714
-	public function set_team_member($id,$team_members) {
714
+	public function set_team_member($id, $team_members) {
715 715
 
716 716
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
717
-		foreach($team_members as $team){
718
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
717
+		foreach ($team_members as $team) {
718
+        	add_post_meta($id, 'team_to_'.$this->tab_slug, $team);			
719 719
 		}
720 720
 	}
721 721
 
722 722
 	/**
723 723
 	 * Set the safari brand
724 724
 	 */
725
-	public function set_safari_brands($id,$safari_brands) {
726
-		foreach($safari_brands as $safari_brand){
727
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
725
+	public function set_safari_brands($id, $safari_brands) {
726
+		foreach ($safari_brands as $safari_brand) {
727
+        	wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true);			
728 728
 		}
729 729
 	}	
730 730
 	
731 731
 	/**
732 732
 	 * Saves the longitude and lattitude, as well as sets the map marker.
733 733
 	 */
734
-	public function set_map_data($data,$id,$zoom = '10') {
734
+	public function set_map_data($data, $id, $zoom = '10') {
735 735
 		$longitude = $latitude = $address = false;
736 736
 
737
-		if(isset($data[0]['position'])){
737
+		if (isset($data[0]['position'])) {
738 738
 
739
-			if(isset($data[0]['position']['driving_latitude'])){
739
+			if (isset($data[0]['position']['driving_latitude'])) {
740 740
 				$latitude = $data[0]['position']['driving_latitude'];
741
-			}elseif(isset($data[0]['position']['latitude'])){
741
+			}elseif (isset($data[0]['position']['latitude'])) {
742 742
 				$latitude = $data[0]['position']['latitude'];
743 743
 			}
744 744
 
745
-			if(isset($data[0]['position']['driving_longitude'])){
745
+			if (isset($data[0]['position']['driving_longitude'])) {
746 746
 				$longitude = $data[0]['position']['driving_longitude'];
747
-			}elseif(isset($data[0]['position']['longitude'])){
747
+			}elseif (isset($data[0]['position']['longitude'])) {
748 748
 				$longitude = $data[0]['position']['longitude'];
749 749
 			}		
750 750
 
751 751
 		}
752
-		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
753
-			if(isset($data[0]['content']['contact_information']['address'])){
752
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
753
+			if (isset($data[0]['content']['contact_information']['address'])) {
754 754
 				$address = strip_tags($data[0]['content']['contact_information']['address']);
755 755
 
756
-				$address = explode("\n",$address);
757
-				foreach($address as $bitkey => $bit){
756
+				$address = explode("\n", $address);
757
+				foreach ($address as $bitkey => $bit) {
758 758
 					$bit = ltrim(rtrim($bit));
759
-					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
759
+					if (false === $bit || '' === $bit || null === $bit or empty($bit)) {
760 760
 						unset($address[$bitkey]);
761 761
 					}
762 762
 				}
763
-				$address = implode(', ',$address);
763
+				$address = implode(', ', $address);
764 764
 				$address = str_replace(', , ', ', ', $address);
765 765
 			}	
766 766
 		}
767 767
 
768
-		if(false !== $longitude){
768
+		if (false !== $longitude) {
769 769
 			$location_data = array(
770
-				'address'	=>	(string)$address,
771
-				'lat'		=>	(string)$latitude,
772
-				'long'		=>	(string)$longitude,
773
-				'zoom'		=>	(string)$zoom,
770
+				'address'	=>	(string) $address,
771
+				'lat'		=>	(string) $latitude,
772
+				'long'		=>	(string) $longitude,
773
+				'zoom'		=>	(string) $zoom,
774 774
 				'elevation'	=>	'',
775 775
 			);
776
-			if(false !== $id && '0' !== $id){
777
-	        	$prev = get_post_meta($id,'location',true);
778
-	        	update_post_meta($id,'location',$location_data,$prev);
779
-	        }else{
780
-	        	add_post_meta($id,'location',$location_data,true);
776
+			if (false !== $id && '0' !== $id) {
777
+	        	$prev = get_post_meta($id, 'location', true);
778
+	        	update_post_meta($id, 'location', $location_data, $prev);
779
+	        }else {
780
+	        	add_post_meta($id, 'location', $location_data, true);
781 781
 	        }
782 782
 		}
783 783
 	}
784 784
 	/**
785 785
 	 * Saves the longitude and lattitude, as well as sets the map marker.
786 786
 	 */
787
-	public function set_location_taxonomy($data,$id) {
787
+	public function set_location_taxonomy($data, $id) {
788 788
 		$taxonomy = 'location';
789 789
 		$terms = false;
790
-		if(isset($data[0]['position'])){
790
+		if (isset($data[0]['position'])) {
791 791
 			$country_id = 0;
792
-			if(isset($data[0]['position']['country'])){
792
+			if (isset($data[0]['position']['country'])) {
793 793
 
794
-				if(!$term = term_exists(trim($data[0]['position']['country']), 'location'))
794
+				if (!$term = term_exists(trim($data[0]['position']['country']), 'location'))
795 795
 		        {
796 796
 		            $term = wp_insert_term(trim($data[0]['position']['country']), 'location');
797
-		            if ( is_wp_error($term) ){
797
+		            if (is_wp_error($term)) {
798 798
 		            	echo $term->get_error_message();
799 799
 		            }
800 800
 		            else {
801
-		            	wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
801
+		            	wp_set_object_terms($id, intval($term['term_id']), 'location', true);
802 802
 		            }
803 803
 		        }
804 804
 		        else
805 805
 		        {
806
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
806
+		            wp_set_object_terms($id, intval($term['term_id']), 'location', true);
807 807
 		        }
808 808
 		        $country_id = intval($term['term_id']);
809 809
 		    }
810 810
 
811
-			if(isset($data[0]['position']['destination'])){
811
+			if (isset($data[0]['position']['destination'])) {
812 812
 
813 813
 				$tax_args = array('parent'=>$country_id);
814
-				if(!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
814
+				if (!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
815 815
 		        {
816 816
 		            $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
817
-		            if ( is_wp_error($term) ){echo $term->get_error_message();}
818
-		            else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
817
+		            if (is_wp_error($term)) {echo $term->get_error_message(); }
818
+		            else { wp_set_object_terms($id, intval($term['term_id']), 'location', true); }
819 819
 		        }
820 820
 		        else
821 821
 		        {
822
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
822
+		            wp_set_object_terms($id, intval($term['term_id']), 'location', true);
823 823
 		        }				
824 824
 			}		
825 825
 		}
@@ -828,30 +828,30 @@  discard block
 block discarded – undo
828 828
 	/**
829 829
 	 * Connects the destinations post type
830 830
 	 */
831
-	public function connect_destinations($data,$id) {
832
-		if(isset($data[0]['position'])){
831
+	public function connect_destinations($data, $id) {
832
+		if (isset($data[0]['position'])) {
833 833
 		    $destinations = false;
834
-		    if(isset($data[0]['position']['country'])){
834
+		    if (isset($data[0]['position']['country'])) {
835 835
 		    	$destinations['country'] = $data[0]['position']['country'];
836 836
 		    }
837
-		    if(isset($data[0]['position']['destination'])){
837
+		    if (isset($data[0]['position']['destination'])) {
838 838
 		    	$destinations['destination'] = $data[0]['position']['destination'];
839 839
 		    }
840 840
 		    
841
-		    if(false !== $destinations){	
842
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
843
-		    	if(false === $prev_values || !is_array($prev_values)){
841
+		    if (false !== $destinations) {	
842
+		    	$prev_values = get_post_meta($id, 'destination_to_accommodation', false);
843
+		    	if (false === $prev_values || !is_array($prev_values)) {
844 844
 		    		$prev_values = array();
845 845
 		    	}
846 846
 		    	//print_r($destinations);
847 847
 				$destinations = array_unique($destinations);
848 848
 				//print_r($destinations);
849
-			    foreach($destinations as $key => $value){
849
+			    foreach ($destinations as $key => $value) {
850 850
 				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
851 851
 	                if (null !== $destination) {
852
-	                	if(!in_array($destination->ID,$prev_values)){
853
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
854
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
852
+	                	if (!in_array($destination->ID, $prev_values)) {
853
+	                   		add_post_meta($id, 'destination_to_accommodation', $destination->ID, false);
854
+	                   		add_post_meta($destination->ID, 'accommodation_to_destination', $id, false);
855 855
 	                	}
856 856
 	                } 		    	
857 857
 			    }	
@@ -862,18 +862,18 @@  discard block
 block discarded – undo
862 862
 	/**
863 863
 	 * Set the Travel Style
864 864
 	 */
865
-	public function set_taxonomy_style($data,$id) {
865
+	public function set_taxonomy_style($data, $id) {
866 866
 		$terms = false;
867
-		if(isset($data[0]['category'])){
868
-			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
867
+		if (isset($data[0]['category'])) {
868
+			if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
869 869
 	        {
870 870
 	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
871
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
872
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
871
+	            if (is_wp_error($term)) {echo $term->get_error_message(); }
872
+	            else { wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); }
873 873
 	        }
874 874
 	        else
875 875
 	        {
876
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
876
+	            wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
877 877
 	        }				
878 878
 		}
879 879
 	}		
@@ -881,23 +881,23 @@  discard block
 block discarded – undo
881 881
 	/**
882 882
 	 * Saves the room data
883 883
 	 */
884
-	public function set_room_data($data,$id) {
885
-		if(!empty($data[0]['rooms']) && is_array($data[0]['rooms'])){
884
+	public function set_room_data($data, $id) {
885
+		if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) {
886 886
 			$rooms = false;
887 887
 
888
-			foreach($data[0]['rooms'] as $room){
888
+			foreach ($data[0]['rooms'] as $room) {
889 889
 
890 890
 				$temp_room = array();
891
-				if(isset($room['name'])){
891
+				if (isset($room['name'])) {
892 892
 					$temp_room['title'] = $room['name'];
893 893
 				}
894
-				if(isset($room['description'])){
894
+				if (isset($room['description'])) {
895 895
 					$temp_room['description'] = strip_tags($room['description']);
896 896
 				}			
897 897
 				$temp_room['price'] = 0;
898 898
 				$temp_room['type'] = 'room';
899 899
 
900
-				if(!empty($room['images']) && is_array($room['images'])){
900
+				if (!empty($room['images']) && is_array($room['images'])) {
901 901
 			    	$attachments_args = array(
902 902
 			    			'post_parent' => $id,
903 903
 			    			'post_status' => 'inherit',
@@ -907,38 +907,38 @@  discard block
 block discarded – undo
907 907
 			    	$attachments = new WP_Query($attachments_args);
908 908
 			    	$found_attachments = array();
909 909
 
910
-			    	if($attachments->have_posts()){
911
-			    		foreach($attachments->posts as $attachment){
912
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
910
+			    	if ($attachments->have_posts()) {
911
+			    		foreach ($attachments->posts as $attachment) {
912
+			    			$found_attachments[] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
913 913
 			    		}
914 914
 			    	}
915 915
 
916 916
 					$temp_room['gallery'] = array();
917
-					foreach($room['images'] as $image_data){
918
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
917
+					foreach ($room['images'] as $image_data) {
918
+			    		$temp_room['gallery'][] = $this->attach_image($image_data, $id, $found_attachments);
919 919
 			    	}
920 920
 				}
921 921
 				$rooms[] = $temp_room;
922 922
 			}
923 923
 
924
-			if(false !== $id && '0' !== $id){
924
+			if (false !== $id && '0' !== $id) {
925 925
 				delete_post_meta($id, 'units');				
926 926
 			}
927
-			foreach($rooms as $room){
928
-		        add_post_meta($id,'units',$room,false);			
927
+			foreach ($rooms as $room) {
928
+		        add_post_meta($id, 'units', $room, false);			
929 929
 			}
930 930
 
931
-			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
931
+			if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) {
932 932
 				$room_count = $data[0]['features']['rooms'];
933
-			}else{
933
+			}else {
934 934
 				$room_count = count($data[0]['rooms']);
935 935
 			}
936 936
 
937
-			if(false !== $id && '0' !== $id){
938
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
939
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
940
-	        }else{
941
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
937
+			if (false !== $id && '0' !== $id) {
938
+	        	$prev_rooms = get_post_meta($id, 'number_of_rooms', true);
939
+	        	update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms);
940
+	        }else {
941
+	        	add_post_meta($id, 'number_of_rooms', $room_count, true);
942 942
 	        }
943 943
 		}
944 944
 	}
@@ -946,31 +946,31 @@  discard block
 block discarded – undo
946 946
 	/**
947 947
 	 * Set the ratings
948 948
 	 */
949
-	public function set_rating($data,$id) {
949
+	public function set_rating($data, $id) {
950 950
 
951
-		if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){
951
+		if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) {
952 952
 			$rating_type = $data[0]['features']['star_authority'];	
953
-		}else{
953
+		}else {
954 954
 			$rating_type = 'Unspecified2';
955 955
 		}
956
-		$this->save_custom_field($rating_type,'rating_type',$id);
956
+		$this->save_custom_field($rating_type, 'rating_type', $id);
957 957
 
958
-		if(!empty($data[0]['features']) && isset($data[0]['features']['stars'])){
959
-			$this->save_custom_field($data[0]['features']['stars'],'rating',$id,true);	
958
+		if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) {
959
+			$this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true);	
960 960
 		}
961 961
 	}
962 962
 
963 963
 	/**
964 964
 	 * Set the spoken_languages
965 965
 	 */
966
-	public function set_spoken_languages($data,$id) {
967
-		if(!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])){
966
+	public function set_spoken_languages($data, $id) {
967
+		if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) {
968 968
 			$languages = false;
969
-			foreach($data[0]['features']['spoken_languages'] as $spoken_language){
969
+			foreach ($data[0]['features']['spoken_languages'] as $spoken_language) {
970 970
 				$languages[] = sanitize_title($spoken_language);
971 971
 			}
972
-			if(false !== $languages){
973
-				$this->save_custom_field($languages,'spoken_languages',$id);
972
+			if (false !== $languages) {
973
+				$this->save_custom_field($languages, 'spoken_languages', $id);
974 974
 			}
975 975
 		}
976 976
 	}
@@ -978,14 +978,14 @@  discard block
 block discarded – undo
978 978
 	/**
979 979
 	 * Set the friendly
980 980
 	 */
981
-	public function set_friendly($data,$id) {
982
-		if(!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])){
981
+	public function set_friendly($data, $id) {
982
+		if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) {
983 983
 			$friendly_options = false;
984
-			foreach($data[0]['features']['suggested_visitor_types'] as $visitor_type){
984
+			foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) {
985 985
 				$friendly_options[] = sanitize_title($visitor_type);
986 986
 			}
987
-			if(false !== $friendly_options){
988
-				$this->save_custom_field($friendly_options,'suggested_visitor_types',$id);
987
+			if (false !== $friendly_options) {
988
+				$this->save_custom_field($friendly_options, 'suggested_visitor_types', $id);
989 989
 			}
990 990
 		}		
991 991
 	}
@@ -993,14 +993,14 @@  discard block
 block discarded – undo
993 993
 	/**
994 994
 	 * Set the special interests
995 995
 	 */
996
-	public function set_special_interests($data,$id) {
997
-		if(!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])){
996
+	public function set_special_interests($data, $id) {
997
+		if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) {
998 998
 			$interests = false;
999
-			foreach($data[0]['features']['special_interests'] as $special_interest){
999
+			foreach ($data[0]['features']['special_interests'] as $special_interest) {
1000 1000
 				$interests[] = sanitize_title($special_interest);
1001 1001
 			}
1002
-			if(false !== $interests){
1003
-				$this->save_custom_field($interests,'special_interests',$id);
1002
+			if (false !== $interests) {
1003
+				$this->save_custom_field($interests, 'special_interests', $id);
1004 1004
 			}
1005 1005
 		}		
1006 1006
 	}				
@@ -1008,48 +1008,48 @@  discard block
 block discarded – undo
1008 1008
 	/**
1009 1009
 	 * Set the Check in and Check out Date
1010 1010
 	 */
1011
-	public function set_checkin_checkout($data,$id) {
1011
+	public function set_checkin_checkout($data, $id) {
1012 1012
 
1013
-		if(!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])){
1014
-			$time = str_replace('h',':',$data[0]['features']['check_in_time']);
1015
-			$time = date('h:ia',strtotime($time));
1016
-			$this->save_custom_field($time,'checkin_time',$id);
1013
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) {
1014
+			$time = str_replace('h', ':', $data[0]['features']['check_in_time']);
1015
+			$time = date('h:ia', strtotime($time));
1016
+			$this->save_custom_field($time, 'checkin_time', $id);
1017 1017
 		}
1018
-		if(!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])){
1019
-			$time = str_replace('h',':',$data[0]['features']['check_out_time']);
1020
-			$time = date('h:ia',strtotime($time));
1021
-			$this->save_custom_field($time,'checkout_time',$id);
1018
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) {
1019
+			$time = str_replace('h', ':', $data[0]['features']['check_out_time']);
1020
+			$time = date('h:ia', strtotime($time));
1021
+			$this->save_custom_field($time, 'checkout_time', $id);
1022 1022
 		}
1023 1023
 	}	
1024 1024
 
1025 1025
 	/**
1026 1026
 	 * Set the Video date
1027 1027
 	 */
1028
-	public function set_video_data($data,$id) {
1029
-		if(!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])){
1028
+	public function set_video_data($data, $id) {
1029
+		if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) {
1030 1030
 			$videos = false;
1031 1031
 
1032
-			foreach($data[0]['content']['youtube_videos'] as $video){
1032
+			foreach ($data[0]['content']['youtube_videos'] as $video) {
1033 1033
 				$temp_video = array();
1034 1034
 
1035
-				if(isset($video['label'])){
1035
+				if (isset($video['label'])) {
1036 1036
 					$temp_video['title'] = $video['label'];
1037 1037
 				}
1038
-				if(isset($video['description'])){
1038
+				if (isset($video['description'])) {
1039 1039
 					$temp_video['description'] = strip_tags($video['description']);
1040 1040
 				}	
1041
-				if(isset($video['url'])){
1041
+				if (isset($video['url'])) {
1042 1042
 					$temp_video['url'] = $video['url'];
1043 1043
 				}						
1044 1044
 				$temp_video['thumbnail'] = '';
1045 1045
 				$videos[] = $temp_video;
1046 1046
 			}
1047 1047
 
1048
-			if(false !== $id && '0' !== $id){
1048
+			if (false !== $id && '0' !== $id) {
1049 1049
 				delete_post_meta($id, 'videos');				
1050 1050
 			}
1051
-			foreach($videos as $video){
1052
-		        add_post_meta($id,'videos',$video,false);			
1051
+			foreach ($videos as $video) {
1052
+		        add_post_meta($id, 'videos', $video, false);			
1053 1053
 			}
1054 1054
 		}
1055 1055
 	}	
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 	/**
1058 1058
 	 * Set the Facilities
1059 1059
 	 */
1060
-	public function set_facilities($data,$id) {
1060
+	public function set_facilities($data, $id) {
1061 1061
 
1062 1062
 		$parent_facilities = array(
1063 1063
 			'available_services' => 'Available Services',
@@ -1065,28 +1065,28 @@  discard block
 block discarded – undo
1065 1065
 			'room_facilities' => 'Room Facilities',
1066 1066
 			'activities_on_site' => 'Activities on Site'
1067 1067
 		);
1068
-		foreach($parent_facilities as $key => $label){
1068
+		foreach ($parent_facilities as $key => $label) {
1069 1069
 			$terms = false;
1070
-			if(isset($data[0]['features']) && isset($data[0]['features'][$key])){
1071
-				$parent_id = $this->set_term($id,$label,'facility');	
1070
+			if (isset($data[0]['features']) && isset($data[0]['features'][$key])) {
1071
+				$parent_id = $this->set_term($id, $label, 'facility');	
1072 1072
 			}
1073
-			foreach($data[0]['features'][$key] as $child_facility){
1074
-				$this->set_term($id,$child_facility,'facility',$parent_id);
1073
+			foreach ($data[0]['features'][$key] as $child_facility) {
1074
+				$this->set_term($id, $child_facility, 'facility', $parent_id);
1075 1075
 			}
1076 1076
 		}
1077 1077
 	}
1078 1078
 
1079
-	function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
1080
-		if(!$term = term_exists($name, $taxonomy))
1079
+	function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
1080
+		if (!$term = term_exists($name, $taxonomy))
1081 1081
         {
1082
-        	if(false !== $parent){ $parent = array('parent'=>$parent); }
1083
-            $term = wp_insert_term(trim($name), $taxonomy,$parent);
1084
-            if ( is_wp_error($term) ){echo $term->get_error_message();}
1085
-            else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1082
+        	if (false !== $parent) { $parent = array('parent'=>$parent); }
1083
+            $term = wp_insert_term(trim($name), $taxonomy, $parent);
1084
+            if (is_wp_error($term)) {echo $term->get_error_message(); }
1085
+            else { wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); }
1086 1086
         }
1087 1087
         else
1088 1088
         {
1089
-            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1089
+            wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
1090 1090
         }
1091 1091
         return $term['term_id'];
1092 1092
 	}	
@@ -1094,16 +1094,16 @@  discard block
 block discarded – undo
1094 1094
 	/**
1095 1095
 	 * Creates the main gallery data
1096 1096
 	 */
1097
-	public function set_featured_image($data,$id) {
1098
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1099
-	    	$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1097
+	public function set_featured_image($data, $id) {
1098
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1099
+	    	$this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id);
1100 1100
 
1101
-	    	if(false !== $this->featured_image){
1102
-	    		delete_post_meta($id,'_thumbnail_id');
1103
-	    		add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1101
+	    	if (false !== $this->featured_image) {
1102
+	    		delete_post_meta($id, '_thumbnail_id');
1103
+	    		add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
1104 1104
 
1105
-	    		if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1106
-	    			add_post_meta($id,'gallery',$this->featured_image,false);
1105
+	    		if (!empty($this->gallery_meta) && !in_array($this->featured_image, $this->gallery_meta)) {
1106
+	    			add_post_meta($id, 'gallery', $this->featured_image, false);
1107 1107
 	    			$this->gallery_meta[] = $this->featured_image;
1108 1108
 	    		}
1109 1109
 	    	}			
@@ -1113,17 +1113,17 @@  discard block
 block discarded – undo
1113 1113
 	/**
1114 1114
 	 * Sets a banner image
1115 1115
 	 */
1116
-	public function set_banner_image($data,$id) {
1117
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1118
-	    	$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1116
+	public function set_banner_image($data, $id) {
1117
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1118
+	    	$this->banner_image = $this->attach_image($data[0]['content']['images'][1], $id, array('width'=>'1920', 'height'=>'800', 'cropping'=>'c'));
1119 1119
 
1120
-	    	if(false !== $this->banner_image){
1121
-	    		delete_post_meta($id,'image_group');
1120
+	    	if (false !== $this->banner_image) {
1121
+	    		delete_post_meta($id, 'image_group');
1122 1122
 	    		$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1123
-	    		add_post_meta($id,'image_group',$new_banner,true);
1123
+	    		add_post_meta($id, 'image_group', $new_banner, true);
1124 1124
 
1125
-	    		if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1126
-	    			add_post_meta($id,'gallery',$this->banner_image,false);
1125
+	    		if (!empty($this->gallery_meta) && !in_array($this->banner_image, $this->gallery_meta)) {
1126
+	    			add_post_meta($id, 'gallery', $this->banner_image, false);
1127 1127
 	    			$this->gallery_meta[] = $this->banner_image;
1128 1128
 	    		}
1129 1129
 	    	}			
@@ -1133,24 +1133,24 @@  discard block
 block discarded – undo
1133 1133
 	/**
1134 1134
 	 * Creates the main gallery data
1135 1135
 	 */
1136
-	public function create_main_gallery($data,$id) {
1136
+	public function create_main_gallery($data, $id) {
1137 1137
 
1138
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1138
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1139 1139
 	    	$counter = 0;
1140
-	    	foreach($data[0]['content']['images'] as $image_data){
1141
-	    		if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
1142
-	    		if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
1140
+	    	foreach ($data[0]['content']['images'] as $image_data) {
1141
+	    		if ($counter === 0 && false !== $this->featured_image) {$counter++; continue; }
1142
+	    		if ($counter === 1 && false !== $this->banner_image) {$counter++; continue; }
1143 1143
 
1144
-	    		$this->gallery_meta[] = $this->attach_image($image_data,$id);
1144
+	    		$this->gallery_meta[] = $this->attach_image($image_data, $id);
1145 1145
 	    		$counter++;
1146 1146
 	    	}
1147 1147
 
1148
-	    	if(!empty($this->gallery_meta)){
1149
-	    		delete_post_meta($id,'gallery');
1148
+	    	if (!empty($this->gallery_meta)) {
1149
+	    		delete_post_meta($id, 'gallery');
1150 1150
 				$this->gallery_meta = array_unique($this->gallery_meta);
1151
-	    		foreach($this->gallery_meta as $gallery_id){
1152
-	    			if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1153
-	    				add_post_meta($id,'gallery',$gallery_id,false);
1151
+	    		foreach ($this->gallery_meta as $gallery_id) {
1152
+	    			if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) {
1153
+	    				add_post_meta($id, 'gallery', $gallery_id, false);
1154 1154
 	    			}
1155 1155
 	    		}
1156 1156
 	    	}
@@ -1160,53 +1160,53 @@  discard block
 block discarded – undo
1160 1160
 	/**
1161 1161
 	 * Attaches 1 image
1162 1162
 	 */
1163
-	public function attach_image($v=false,$parent_id,$image_sizes=false){
1164
-		if(false !== $v){
1165
-	   		$temp_fragment = explode('/',$v['url_fragment']);
1166
-	    	$url_filename = $temp_fragment[count($temp_fragment)-1];
1167
-	    	$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1168
-
1169
-	    	if(in_array($url_filename,$this->found_attachments)){
1170
-	    		return array_search($url_filename,$this->found_attachments);
1163
+	public function attach_image($v = false, $parent_id, $image_sizes = false) {
1164
+		if (false !== $v) {
1165
+	   		$temp_fragment = explode('/', $v['url_fragment']);
1166
+	    	$url_filename = $temp_fragment[count($temp_fragment) - 1];
1167
+	    	$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
1168
+
1169
+	    	if (in_array($url_filename, $this->found_attachments)) {
1170
+	    		return array_search($url_filename, $this->found_attachments);
1171 1171
 	    	}
1172 1172
 	    	               
1173
-	        $postdata=array();
1174
-	        if(empty($v['label']))
1173
+	        $postdata = array();
1174
+	        if (empty($v['label']))
1175 1175
 	        {
1176
-	            $v['label']='';
1176
+	            $v['label'] = '';
1177 1177
 	        }
1178
-	        if(!empty($v['description']))
1178
+	        if (!empty($v['description']))
1179 1179
 	        {
1180
-	            $desc=wp_strip_all_tags($v['description']);
1181
-	            $posdata=array('post_excerpt'=>$desc);
1180
+	            $desc = wp_strip_all_tags($v['description']);
1181
+	            $posdata = array('post_excerpt'=>$desc);
1182 1182
 	        }
1183
-	        if(!empty($v['section']))
1183
+	        if (!empty($v['section']))
1184 1184
 	        {
1185
-	            $desc=wp_strip_all_tags($v['section']);
1186
-	            $posdata=array('post_excerpt'=>$desc);
1185
+	            $desc = wp_strip_all_tags($v['section']);
1186
+	            $posdata = array('post_excerpt'=>$desc);
1187 1187
 	        }
1188 1188
 
1189
-	        $attachID=NULL;  
1189
+	        $attachID = NULL;  
1190 1190
 	        //Resizor - add option to setting if required
1191
-	        $fragment = str_replace(' ','%20',$v['url_fragment']);
1191
+	        $fragment = str_replace(' ', '%20', $v['url_fragment']);
1192 1192
 	        $url = $this->get_scaling_url($image_sizes).$fragment;
1193
-	        $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1193
+	        $attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
1194 1194
 
1195 1195
 	        //echo($attachID.' add image');
1196
-	        if($attachID!=NULL)
1196
+	        if ($attachID != NULL)
1197 1197
 	        {
1198 1198
 	            return $attachID;
1199 1199
 	        }
1200 1200
         }	
1201 1201
         return 	false;
1202 1202
 	}
1203
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1203
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
1204 1204
 	
1205
-		if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
1205
+		if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
1206 1206
 
1207
-		require_once(ABSPATH . 'wp-admin/includes/file.php');
1208
-		require_once(ABSPATH . 'wp-admin/includes/media.php');
1209
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
1207
+		require_once(ABSPATH.'wp-admin/includes/file.php');
1208
+		require_once(ABSPATH.'wp-admin/includes/media.php');
1209
+		require_once(ABSPATH.'wp-admin/includes/image.php');
1210 1210
 		// Download file to temp location, returns full server path to temp file
1211 1211
 		//$tmp = download_url( $url );
1212 1212
 
@@ -1215,53 +1215,53 @@  discard block
 block discarded – undo
1215 1215
 
1216 1216
 		$image = file_get_contents($url);
1217 1217
 		file_put_contents($tmp, $image);
1218
-		chmod($tmp,'777');
1218
+		chmod($tmp, '777');
1219 1219
 
1220
-		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches);    // fix file filename for query strings
1220
+		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings
1221 1221
 		$url_filename = basename($matches[0]);
1222
-		$url_filename=str_replace('%20','_',$url_filename);
1222
+		$url_filename = str_replace('%20', '_', $url_filename);
1223 1223
 		// extract filename from url for title
1224
-		$url_type = wp_check_filetype($url_filename);                                           // determine file type (ext and mime/type)
1224
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
1225 1225
 		 
1226 1226
 		// override filename if given, reconstruct server path
1227
-		if ( !empty( $filename ) && " " != $filename )
1227
+		if (!empty($filename) && " " != $filename)
1228 1228
 		{
1229 1229
 			$filename = sanitize_file_name($filename);
1230
-			$tmppath = pathinfo( $tmp );      
1230
+			$tmppath = pathinfo($tmp);      
1231 1231
 
1232 1232
 			$extension = '';  
1233
-			if(isset($tmppath['extension'])){
1233
+			if (isset($tmppath['extension'])) {
1234 1234
 				$extension = $tmppath['extension'];
1235 1235
 			}   
1236 1236
 
1237
-			$new = $tmppath['dirname'] . "/". $filename . "." . $extension;
1238
-			rename($tmp, $new);                                                                 // renames temp file on server
1239
-			$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
1237
+			$new = $tmppath['dirname']."/".$filename.".".$extension;
1238
+			rename($tmp, $new); // renames temp file on server
1239
+			$tmp = $new; // push new filename (in path) to be used in file array later
1240 1240
 		}
1241 1241
 
1242 1242
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
1243
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
1243
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
1244 1244
 
1245
-		if ( !empty( $filename) && " " != $filename )
1245
+		if (!empty($filename) && " " != $filename)
1246 1246
 		{
1247
-			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
1247
+			$file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension
1248 1248
 		}
1249 1249
 		else
1250 1250
 		{
1251
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
1251
+			$file_array['name'] = $url_filename; // just use original URL filename
1252 1252
 		}
1253 1253
 
1254 1254
 		// set additional wp_posts columns
1255
-		if ( empty( $post_data['post_title'] ) )
1255
+		if (empty($post_data['post_title']))
1256 1256
 		{
1257 1257
 
1258
-			$url_filename=str_replace('%20',' ',$url_filename);
1258
+			$url_filename = str_replace('%20', ' ', $url_filename);
1259 1259
 
1260
-			$post_data['post_title'] = basename($url_filename, "." . $url_type['ext']);         // just use the original filename (no extension)
1260
+			$post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension)
1261 1261
 		}
1262 1262
 
1263 1263
 		// make sure gets tied to parent
1264
-		if ( empty( $post_data['post_parent'] ) )
1264
+		if (empty($post_data['post_parent']))
1265 1265
 		{
1266 1266
 			$post_data['post_parent'] = $post_id;
1267 1267
 		}
@@ -1269,12 +1269,12 @@  discard block
 block discarded – undo
1269 1269
 		// required libraries for media_handle_sideload
1270 1270
 
1271 1271
 		// do the validation and storage stuff
1272
-		$att_id = media_handle_sideload( $file_array, $post_id, null, $post_data );             // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1272
+		$att_id = media_handle_sideload($file_array, $post_id, null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1273 1273
 		 
1274 1274
 		// If error storing permanently, unlink
1275
-		if ( is_wp_error($att_id) )
1275
+		if (is_wp_error($att_id))
1276 1276
 		{
1277
-			unlink($file_array['tmp_name']);   // clean up
1277
+			unlink($file_array['tmp_name']); // clean up
1278 1278
 			return false; // output wp_error
1279 1279
 			//return $att_id; // output wp_error
1280 1280
 		}
Please login to merge, or discard this patch.
classes/class-admin.php 3 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * Display the importer administration screen
80 80
 	 */
81 81
 	public function display_page() {
82
-        ?>
82
+		?>
83 83
         <div class="wrap">
84 84
             <?php screen_icon(); ?>
85 85
 
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 		            </ul> 
102 102
 	             	            
103 103
             <?php } else {
104
-            	do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
105
-            } ?>
104
+				do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
105
+			} ?>
106 106
         </div>
107 107
         <?php
108 108
 	}
@@ -149,37 +149,37 @@  discard block
 block discarded – undo
149 149
 	 * set_taxonomy with some terms
150 150
 	 */
151 151
 	public function set_taxonomy($taxonomy,$terms,$id) {
152
-        $result=array();
153
-        if(!empty($data))
154
-        {
155
-            foreach($data as $k)
156
-            {
157
-                if($id)
158
-                {
159
-                    if(!$term = term_exists(trim($k), $tax))
160
-                    {
161
-                        $term = wp_insert_term(trim($k), $tax);
162
-                        if ( is_wp_error($term) )
163
-                        {
164
-                            echo $term->get_error_message();
165
-                        }
166
-                        else
167
-                        {
168
-                            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
169
-                        }
170
-                    }
171
-                    else
172
-                    {
173
-                        wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
174
-                    }
175
-                }
176
-                else
177
-                {
178
-                    $result[]=trim($k);
179
-                }
180
-            }
181
-        }
182
-        return $result;
152
+		$result=array();
153
+		if(!empty($data))
154
+		{
155
+			foreach($data as $k)
156
+			{
157
+				if($id)
158
+				{
159
+					if(!$term = term_exists(trim($k), $tax))
160
+					{
161
+						$term = wp_insert_term(trim($k), $tax);
162
+						if ( is_wp_error($term) )
163
+						{
164
+							echo $term->get_error_message();
165
+						}
166
+						else
167
+						{
168
+							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
169
+						}
170
+					}
171
+					else
172
+					{
173
+						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
174
+					}
175
+				}
176
+				else
177
+				{
178
+					$result[]=trim($k);
179
+				}
180
+			}
181
+		}
182
+		return $result;
183 183
 	}
184 184
 
185 185
 	/**
@@ -189,21 +189,21 @@  discard block
 block discarded – undo
189 189
 		if(post_type_exists('team')) { ?>
190 190
     		<ul>
191 191
     			<?php
192
-    				$team_args=array(
193
-    					'post_type'	=>	'team',
194
-    					'post_status' => 'publish',
195
-    					'nopagin' => true,
196
-    					'fields' => 'ids'
197
-    				);
198
-    				$team_members = new WP_Query($team_args);
199
-    					if($team_members->have_posts()){
200
-    						foreach($team_members->posts as $member){ ?>
192
+					$team_args=array(
193
+						'post_type'	=>	'team',
194
+						'post_status' => 'publish',
195
+						'nopagin' => true,
196
+						'fields' => 'ids'
197
+					);
198
+					$team_members = new WP_Query($team_args);
199
+						if($team_members->have_posts()){
200
+							foreach($team_members->posts as $member){ ?>
201 201
     							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
202 202
     						<?php }
203
-    					}else{ ?>
203
+						}else{ ?>
204 204
     							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
205 205
     					<?php }
206
-    				?>
206
+					?>
207 207
     		</ul>
208 208
     	<?php }		
209 209
 	}
@@ -255,36 +255,36 @@  discard block
 block discarded – undo
255 255
 		if(false !== $id){
256 256
 			if(empty($this->found_attachments)){
257 257
 
258
-		    	$attachments_args = array(
259
-		    			'post_parent' => $id,
260
-		    			'post_status' => 'inherit',
261
-		    			'post_type' => 'attachment',
262
-		    			'order' => 'ASC',
263
-                        'nopagin' => 'true',
264
-                        'posts_per_page' => '-1'
265
-		    	);   	
258
+				$attachments_args = array(
259
+						'post_parent' => $id,
260
+						'post_status' => 'inherit',
261
+						'post_type' => 'attachment',
262
+						'order' => 'ASC',
263
+						'nopagin' => 'true',
264
+						'posts_per_page' => '-1'
265
+				);   	
266 266
 		    	 
267
-		    	$attachments = new WP_Query($attachments_args);
268
-		    	if($attachments->have_posts()){
269
-		    		foreach($attachments->posts as $attachment){
270
-		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
271
-		    			$this->gallery_meta[] = $attachment->ID;
272
-		    		}
273
-		    	}
267
+				$attachments = new WP_Query($attachments_args);
268
+				if($attachments->have_posts()){
269
+					foreach($attachments->posts as $attachment){
270
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
271
+						$this->gallery_meta[] = $attachment->ID;
272
+					}
273
+				}
274 274
 			}
275 275
 		}
276 276
 	}
277 277
 
278 278
 	/**
279 279
 	 * Checks to see if an item is checked.
280
-     *
281
-     * @param $haystack array|string
282
-     * @param $needle string
283
-     * @param $echo bool
280
+	 *
281
+	 * @param $haystack array|string
282
+	 * @param $needle string
283
+	 * @param $echo bool
284 284
 	 */
285 285
 	public function checked($haystack=false,$needle='',$echo=true) {
286
-	    $return = $this->itemd($haystack,$needle,'checked');
287
-	    if('' !== $return) {
286
+		$return = $this->itemd($haystack,$needle,'checked');
287
+		if('' !== $return) {
288 288
 			if (true === $echo) {
289 289
 				echo $return;
290 290
 			} else {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 *
299 299
 	 * @param $haystack array|string
300 300
 	 * @param $needle string
301
-     * @param $echo bool
301
+	 * @param $echo bool
302 302
 	 */
303 303
 	public function selected($haystack=false,$needle='',$echo=true) {
304 304
 		$return = $this->itemd($haystack,$needle,'selected');
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @param $haystack array|string
318 318
 	 * @param $needle string
319
-     * @param $type string
320
-     * @param $wrap bool
321
-     * @return $html string
319
+	 * @param $type string
320
+	 * @param $wrap bool
321
+	 * @return $html string
322 322
 	 */
323 323
 	public function itemd($haystack=false,$needle='',$type='',$wrap=true) {
324 324
 		$html = '';
@@ -327,14 +327,14 @@  discard block
 block discarded – undo
327 327
 				$haystack = array($haystack);
328 328
 			}
329 329
 			if (in_array($needle, $haystack)) {
330
-			    if(true === $wrap || 'true' === $wrap) {
330
+				if(true === $wrap || 'true' === $wrap) {
331 331
 					$html = $type . '"' . $type . '"';
332 332
 				}else{
333 333
 					$html = $type;
334
-                }
334
+				}
335 335
 			}
336 336
 		}
337
-        return $html;
337
+		return $html;
338 338
 
339 339
 	}
340 340
 
@@ -344,18 +344,18 @@  discard block
 block discarded – undo
344 344
 	 * @param $tab string
345 345
 	 */
346 346
 	public function navigation($tab='') {
347
-        $post_types = array(
348
-            'tour'              => esc_attr('Tours','wetu-importer'),
349
-            'accommodation'     => esc_attr('Accommodation','wetu-importer'),
350
-            'destination'       => esc_attr('Destinations','wetu-importer'),
351
-        );
347
+		$post_types = array(
348
+			'tour'              => esc_attr('Tours','wetu-importer'),
349
+			'accommodation'     => esc_attr('Accommodation','wetu-importer'),
350
+			'destination'       => esc_attr('Destinations','wetu-importer'),
351
+		);
352 352
 
353 353
 
354 354
 		echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab,'','current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr('Home','wetu-importer').'</a>';
355 355
 		foreach($post_types as $post_type => $label){
356
-		    echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
357
-        }
358
-        echo '</div><br clear="both"/></div>';
356
+			echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
357
+		}
358
+		echo '</div><br clear="both"/></div>';
359 359
 	}
360 360
 }
361 361
 $wetu_importer_admin = new WETU_Importer_Admin();
362 362
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -45,33 +45,33 @@  discard block
 block discarded – undo
45 45
 	 * @access private
46 46
 	 */
47 47
 	public function __construct() {
48
-		add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 );
49
-		add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 );
48
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11);
49
+		add_action('admin_menu', array($this, 'register_importer_page'), 20);
50 50
 	}
51 51
 
52 52
 	/**
53 53
 	 * Registers the admin page which will house the importer form.
54 54
 	 */
55 55
 	public function register_importer_page() {
56
-		add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) );
56
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page'));
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * Enqueue the JS needed to contact wetu and return your result.
61 61
 	 */
62 62
 	public function admin_scripts() {
63
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
63
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
64 64
 			$min = '';
65
-		} else {
65
+		}else {
66 66
 			$min = '.min';
67 67
 		}
68 68
 		$min = '';
69 69
 
70
-		if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){
71
-			wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true );
72
-			wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array(
70
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
71
+			wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true);
72
+			wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array(
73 73
 			'ajax_url' => admin_url('admin-ajax.php'),
74
-			) );			
74
+			));			
75 75
 		}
76 76
 	}			
77 77
 
@@ -83,24 +83,24 @@  discard block
 block discarded – undo
83 83
         <div class="wrap">
84 84
             <?php screen_icon(); ?>
85 85
 
86
-            <?php if(!isset($_GET['tab'])){ ?>
87
-	            <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2>
86
+            <?php if (!isset($_GET['tab'])) { ?>
87
+	            <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2>
88 88
 	            <p>If this is the first time you are running the import, then follow the steps below.</p>
89 89
 	            <ul>
90
-                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours','wetu-importer'); ?></a></li>
91
-	            	<li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation','wetu-importer'); ?></a> that will need to be imported.</li>
92
-                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations','wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
90
+                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours', 'wetu-importer'); ?></a></li>
91
+	            	<li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation', 'wetu-importer'); ?></a> that will need to be imported.</li>
92
+                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations', 'wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
93 93
 	            </ul>
94 94
 
95
-		            <h3><?php _e('Additional Tools','wetu-importer'); ?></h3>
95
+		            <h3><?php _e('Additional Tools', 'wetu-importer'); ?></h3>
96 96
 		            <ul>
97
-		            	<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation','wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.','wetu-importer'); ?></small></li>
98
-		            	<?php if(class_exists('Lsx_Banners')){ ?>
99
-		            		<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images','wetu-importer'); ?></a></li>
97
+		            	<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation', 'wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.', 'wetu-importer'); ?></small></li>
98
+		            	<?php if (class_exists('Lsx_Banners')) { ?>
99
+		            		<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images', 'wetu-importer'); ?></a></li>
100 100
 		            	<?php } ?>
101 101
 		            </ul> 
102 102
 	             	            
103
-            <?php } else {
103
+            <?php }else {
104 104
             	do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
105 105
             } ?>
106 106
         </div>
@@ -148,34 +148,34 @@  discard block
 block discarded – undo
148 148
 	/**
149 149
 	 * set_taxonomy with some terms
150 150
 	 */
151
-	public function set_taxonomy($taxonomy,$terms,$id) {
152
-        $result=array();
153
-        if(!empty($data))
151
+	public function set_taxonomy($taxonomy, $terms, $id) {
152
+        $result = array();
153
+        if (!empty($data))
154 154
         {
155
-            foreach($data as $k)
155
+            foreach ($data as $k)
156 156
             {
157
-                if($id)
157
+                if ($id)
158 158
                 {
159
-                    if(!$term = term_exists(trim($k), $tax))
159
+                    if (!$term = term_exists(trim($k), $tax))
160 160
                     {
161 161
                         $term = wp_insert_term(trim($k), $tax);
162
-                        if ( is_wp_error($term) )
162
+                        if (is_wp_error($term))
163 163
                         {
164 164
                             echo $term->get_error_message();
165 165
                         }
166 166
                         else
167 167
                         {
168
-                            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
168
+                            wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
169 169
                         }
170 170
                     }
171 171
                     else
172 172
                     {
173
-                        wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
173
+                        wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
174 174
                     }
175 175
                 }
176 176
                 else
177 177
                 {
178
-                    $result[]=trim($k);
178
+                    $result[] = trim($k);
179 179
                 }
180 180
             }
181 181
         }
@@ -185,23 +185,23 @@  discard block
 block discarded – undo
185 185
 	/**
186 186
 	 * set_taxonomy with some terms
187 187
 	 */
188
-	public function team_member_checkboxes($selected=array()) {
189
-		if(post_type_exists('team')) { ?>
188
+	public function team_member_checkboxes($selected = array()) {
189
+		if (post_type_exists('team')) { ?>
190 190
     		<ul>
191 191
     			<?php
192
-    				$team_args=array(
192
+    				$team_args = array(
193 193
     					'post_type'	=>	'team',
194 194
     					'post_status' => 'publish',
195 195
     					'nopagin' => true,
196 196
     					'fields' => 'ids'
197 197
     				);
198 198
     				$team_members = new WP_Query($team_args);
199
-    					if($team_members->have_posts()){
200
-    						foreach($team_members->posts as $member){ ?>
201
-    							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
199
+    					if ($team_members->have_posts()) {
200
+    						foreach ($team_members->posts as $member) { ?>
201
+    							<li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
202 202
     						<?php }
203
-    					}else{ ?>
204
-    							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
203
+    					}else { ?>
204
+    							<li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li>
205 205
     					<?php }
206 206
     				?>
207 207
     		</ul>
@@ -211,18 +211,18 @@  discard block
 block discarded – undo
211 211
 	/**
212 212
 	 * set_taxonomy with some terms
213 213
 	 */
214
-	public function taxonomy_checkboxes($taxonomy=false,$selected=array()) {
214
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
215 215
 		$return = '';
216
-		if(false !== $taxonomy){
216
+		if (false !== $taxonomy) {
217 217
 			$return .= '<ul>';
218
-			$terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false));
218
+			$terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false));
219 219
 
220
-			if(!is_wp_error($terms)){
221
-				foreach($terms as $term){
222
-					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
220
+			if (!is_wp_error($terms)) {
221
+				foreach ($terms as $term) {
222
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
223 223
 				}
224
-			}else{
225
-				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
224
+			}else {
225
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>';
226 226
 			}
227 227
 			$return .= '</ul>';
228 228
 		}
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
 	/**
233 233
 	 * Saves the room data
234 234
 	 */
235
-	public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) {
236
-		if(false !== $value){
237
-			if(false !== $decrease){
235
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
236
+		if (false !== $value) {
237
+			if (false !== $decrease) {
238 238
 				$value = intval($value);
239 239
 				$value--;
240 240
 			}
241
-			$prev = get_post_meta($id,$meta_key,true);
241
+			$prev = get_post_meta($id, $meta_key, true);
242 242
 
243
-			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
244
-				update_post_meta($id,$meta_key,$value,$prev);
245
-			}else{
246
-				add_post_meta($id,$meta_key,$value,$unique);
243
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
244
+				update_post_meta($id, $meta_key, $value, $prev);
245
+			}else {
246
+				add_post_meta($id, $meta_key, $value, $unique);
247 247
 			}
248 248
 		}
249 249
 	}
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	/**
252 252
 	 * grabs any attachments for the current item
253 253
 	 */
254
-	public function find_attachments($id=false) {
255
-		if(false !== $id){
256
-			if(empty($this->found_attachments)){
254
+	public function find_attachments($id = false) {
255
+		if (false !== $id) {
256
+			if (empty($this->found_attachments)) {
257 257
 
258 258
 		    	$attachments_args = array(
259 259
 		    			'post_parent' => $id,
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
 		    	);   	
266 266
 		    	 
267 267
 		    	$attachments = new WP_Query($attachments_args);
268
-		    	if($attachments->have_posts()){
269
-		    		foreach($attachments->posts as $attachment){
270
-		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
268
+		    	if ($attachments->have_posts()) {
269
+		    		foreach ($attachments->posts as $attachment) {
270
+		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
271 271
 		    			$this->gallery_meta[] = $attachment->ID;
272 272
 		    		}
273 273
 		    	}
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
      * @param $needle string
283 283
      * @param $echo bool
284 284
 	 */
285
-	public function checked($haystack=false,$needle='',$echo=true) {
286
-	    $return = $this->itemd($haystack,$needle,'checked');
287
-	    if('' !== $return) {
285
+	public function checked($haystack = false, $needle = '', $echo = true) {
286
+	    $return = $this->itemd($haystack, $needle, 'checked');
287
+	    if ('' !== $return) {
288 288
 			if (true === $echo) {
289 289
 				echo $return;
290
-			} else {
290
+			}else {
291 291
 				return $return;
292 292
 			}
293 293
 		}
@@ -300,12 +300,12 @@  discard block
 block discarded – undo
300 300
 	 * @param $needle string
301 301
      * @param $echo bool
302 302
 	 */
303
-	public function selected($haystack=false,$needle='',$echo=true) {
304
-		$return = $this->itemd($haystack,$needle,'selected');
305
-		if('' !== $return) {
303
+	public function selected($haystack = false, $needle = '', $echo = true) {
304
+		$return = $this->itemd($haystack, $needle, 'selected');
305
+		if ('' !== $return) {
306 306
 			if (true === $echo) {
307 307
 				echo $return;
308
-			} else {
308
+			}else {
309 309
 				return $return;
310 310
 			}
311 311
 		}
@@ -320,16 +320,16 @@  discard block
 block discarded – undo
320 320
      * @param $wrap bool
321 321
      * @return $html string
322 322
 	 */
323
-	public function itemd($haystack=false,$needle='',$type='',$wrap=true) {
323
+	public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) {
324 324
 		$html = '';
325
-		if('' !== $type) {
325
+		if ('' !== $type) {
326 326
 			if (!is_array($haystack)) {
327 327
 				$haystack = array($haystack);
328 328
 			}
329 329
 			if (in_array($needle, $haystack)) {
330
-			    if(true === $wrap || 'true' === $wrap) {
331
-					$html = $type . '"' . $type . '"';
332
-				}else{
330
+			    if (true === $wrap || 'true' === $wrap) {
331
+					$html = $type.'"'.$type.'"';
332
+				}else {
333 333
 					$html = $type;
334 334
                 }
335 335
 			}
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
 	 *
344 344
 	 * @param $tab string
345 345
 	 */
346
-	public function navigation($tab='') {
346
+	public function navigation($tab = '') {
347 347
         $post_types = array(
348
-            'tour'              => esc_attr('Tours','wetu-importer'),
349
-            'accommodation'     => esc_attr('Accommodation','wetu-importer'),
350
-            'destination'       => esc_attr('Destinations','wetu-importer'),
348
+            'tour'              => esc_attr('Tours', 'wetu-importer'),
349
+            'accommodation'     => esc_attr('Accommodation', 'wetu-importer'),
350
+            'destination'       => esc_attr('Destinations', 'wetu-importer'),
351 351
         );
352 352
 
353 353
 
354
-		echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab,'','current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr('Home','wetu-importer').'</a>';
355
-		foreach($post_types as $post_type => $label){
356
-		    echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
354
+		echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab, '', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr('Home', 'wetu-importer').'</a>';
355
+		foreach ($post_types as $post_type => $label) {
356
+		    echo ' | <a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
357 357
         }
358 358
         echo '</div><br clear="both"/></div>';
359 359
 	}
Please login to merge, or discard this patch.
Braces   +7 added lines, -10 removed lines patch added patch discarded remove patch
@@ -162,18 +162,15 @@  discard block
 block discarded – undo
162 162
                         if ( is_wp_error($term) )
163 163
                         {
164 164
                             echo $term->get_error_message();
165
-                        }
166
-                        else
165
+                        } else
167 166
                         {
168 167
                             wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
169 168
                         }
170
-                    }
171
-                    else
169
+                    } else
172 170
                     {
173 171
                         wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
174 172
                     }
175
-                }
176
-                else
173
+                } else
177 174
                 {
178 175
                     $result[]=trim($k);
179 176
                 }
@@ -200,7 +197,7 @@  discard block
 block discarded – undo
200 197
     						foreach($team_members->posts as $member){ ?>
201 198
     							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
202 199
     						<?php }
203
-    					}else{ ?>
200
+    					} else{ ?>
204 201
     							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
205 202
     					<?php }
206 203
     				?>
@@ -221,7 +218,7 @@  discard block
 block discarded – undo
221 218
 				foreach($terms as $term){
222 219
 					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
223 220
 				}
224
-			}else{
221
+			} else{
225 222
 				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
226 223
 			}
227 224
 			$return .= '</ul>';
@@ -242,7 +239,7 @@  discard block
 block discarded – undo
242 239
 
243 240
 			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
244 241
 				update_post_meta($id,$meta_key,$value,$prev);
245
-			}else{
242
+			} else{
246 243
 				add_post_meta($id,$meta_key,$value,$unique);
247 244
 			}
248 245
 		}
@@ -329,7 +326,7 @@  discard block
 block discarded – undo
329 326
 			if (in_array($needle, $haystack)) {
330 327
 			    if(true === $wrap || 'true' === $wrap) {
331 328
 					$html = $type . '"' . $type . '"';
332
-				}else{
329
+				} else{
333 330
 					$html = $type;
334 331
                 }
335 332
 			}
Please login to merge, or discard this patch.
classes/class-tours.php 2 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 $this->navigation('tour'); ?>
126 126
 
@@ -249,16 +249,16 @@  discard block
 block discarded – undo
249 249
 			$result = $this->update_options();
250 250
 
251 251
 			if(true === $result){
252
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
253
-			    if(!isset($_GET['refresh_tours'])){
254
-			        echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>';
255
-                }
256
-            }else{
257
-			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
258
-            }
252
+				echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
253
+				if(!isset($_GET['refresh_tours'])){
254
+					echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>';
255
+				}
256
+			}else{
257
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
258
+			}
259 259
 		}else{
260 260
 			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>';
261
-        }
261
+		}
262 262
 		echo '</h3></div>';
263 263
 	}
264 264
 
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 		$tours = json_decode($data, true);
271 271
 
272 272
 		if(isset($tours['error'])){
273
-		    return $tours['error'];
274
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
273
+			return $tours['error'];
274
+		}elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
275 275
 			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
276 276
 			return true;
277 277
 		}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 					$keyphrases = $_POST['keyword'];
321 321
 				}else{
322 322
 					$keyphrases = array(0);
323
-                }
323
+				}
324 324
 
325 325
 				if(!is_array($keyphrases)){
326 326
 					$keyphrases = array($keyphrases);
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
 
350 350
 					foreach($tours as $row_key => $row){
351 351
 
352
-					    if(isset($row['is_disabled']) && true === $row['is_disabled']){
353
-                            continue;
354
-                        }
352
+						if(isset($row['is_disabled']) && true === $row['is_disabled']){
353
+							continue;
354
+						}
355 355
 
356
-                        /*if('Sample' === $row['type']){
356
+						/*if('Sample' === $row['type']){
357 357
                             continue;
358 358
                         }*/
359 359
 
360
-                        //If this is a current tour, add its ID to the row.
360
+						//If this is a current tour, add its ID to the row.
361 361
 						$row['post_id'] = 0;
362 362
 						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
363 363
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
@@ -366,31 +366,31 @@  discard block
 block discarded – undo
366 366
 						//If we are searching for
367 367
 						if(false !== $post_status){
368 368
 
369
-                            if('import' === $post_status){
369
+							if('import' === $post_status){
370 370
 
371 371
 								if(0 !== $row['post_id']){
372
-								    continue;
372
+									continue;
373 373
 								}else{
374 374
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
375
-                                }
375
+								}
376 376
 
377 377
 
378
-                            }else{
378
+							}else{
379 379
 
380 380
 								if(0 === $row['post_id']){
381 381
 									continue;
382 382
 								}else{
383 383
 									$current_status = get_post_status($row['post_id']);
384 384
 									if($current_status !== $post_status){
385
-									    continue;
386
-                                    }
385
+										continue;
386
+									}
387 387
 
388 388
 								}
389 389
 								$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
390 390
 
391
-                            }
391
+							}
392 392
 
393
-                        }else{
393
+						}else{
394 394
 							//Search through each keyword.
395 395
 							foreach($keyphrases as $keyphrase){
396 396
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
405 405
 								}
406 406
 							}
407
-                        }
407
+						}
408 408
 					}		
409 409
 				}
410 410
 
@@ -471,17 +471,17 @@  discard block
 block discarded – undo
471 471
 				$content = false;
472 472
 			}
473 473
 
474
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
474
+			$jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
475 475
 
476
-            if($jdata)
477
-            {
476
+			if($jdata)
477
+			{
478 478
 				$jdata=json_decode($jdata,true);
479
-                if(!empty($jdata))
480
-                {
481
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
482
-                	$this->format_completed_row($return);
483
-                }
484
-            }
479
+				if(!empty($jdata))
480
+				{
481
+					$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
482
+					$this->format_completed_row($return);
483
+				}
484
+			}
485 485
 			die();
486 486
 		}
487 487
 
@@ -489,53 +489,53 @@  discard block
 block discarded – undo
489 489
 
490 490
 	/**
491 491
 	 * Connect to wetu
492
-     *
493
-     * @param $data array
494
-     * @param $wetu_id string
492
+	 *
493
+	 * @param $data array
494
+	 * @param $wetu_id string
495 495
 	 */
496 496
 	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
497
-        $post_name = $data_post_content = $data_post_excerpt = '';
498
-        $post = array(
499
-          'post_type'		=> 'tour',
500
-        );
497
+		$post_name = $data_post_content = $data_post_excerpt = '';
498
+		$post = array(
499
+		  'post_type'		=> 'tour',
500
+		);
501 501
 
502
-        //Set the post_content
502
+		//Set the post_content
503 503
 		$content_used_general_description = false;
504
-        if(false !== $importable_content && in_array('description',$importable_content)){
505
-            $data_post_content = '';
506
-
507
-            if(isset($data['description'])){
508
-                $data_post_content = $data['description'];
509
-            }elseif(isset($data['summary'])){
510
-                $data_post_content = $data['summary'];
511
-            }
512
-            $post['post_content'] = $data_post_content;
513
-        }
514
-
515
-        //Create or update the post
516
-        if(false !== $id && '0' !== $id){
517
-            $post['ID'] = $id;
518
-	        $post['post_status'] = 'publish';
519
-            $id = wp_update_post($post);
520
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
521
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
522
-        }else{
523
-
524
-            //Set the name
525
-            if(isset($data['name'])){
526
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
527
-            }
528
-            $post['post_name'] = $post_name;
529
-            $post['post_title'] = $data['name'];
530
-            $post['post_status'] = 'publish';
531
-            $id = wp_insert_post($post);
532
-
533
-            //Save the WETU ID and the Last date it was modified.
534
-            if(false !== $id){
535
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
536
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
537
-            }
538
-        }
504
+		if(false !== $importable_content && in_array('description',$importable_content)){
505
+			$data_post_content = '';
506
+
507
+			if(isset($data['description'])){
508
+				$data_post_content = $data['description'];
509
+			}elseif(isset($data['summary'])){
510
+				$data_post_content = $data['summary'];
511
+			}
512
+			$post['post_content'] = $data_post_content;
513
+		}
514
+
515
+		//Create or update the post
516
+		if(false !== $id && '0' !== $id){
517
+			$post['ID'] = $id;
518
+			$post['post_status'] = 'publish';
519
+			$id = wp_update_post($post);
520
+			$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
521
+			update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
522
+		}else{
523
+
524
+			//Set the name
525
+			if(isset($data['name'])){
526
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
527
+			}
528
+			$post['post_name'] = $post_name;
529
+			$post['post_title'] = $data['name'];
530
+			$post['post_status'] = 'publish';
531
+			$id = wp_insert_post($post);
532
+
533
+			//Save the WETU ID and the Last date it was modified.
534
+			if(false !== $id){
535
+				add_post_meta($id,'lsx_wetu_id',$wetu_id);
536
+				add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
537
+			}
538
+		}
539 539
 
540 540
 
541 541
 		//Set the price
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
 			$this->set_duration($data,$id);
549 549
 		}
550 550
 
551
-        if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
552
-            $this->process_itineraries($data,$id,$importable_content);
553
-        }
551
+		if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
552
+			$this->process_itineraries($data,$id,$importable_content);
553
+		}
554 554
 
555 555
 		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
556 556
 			$this->process_map_points($data,$id);
@@ -561,24 +561,24 @@  discard block
 block discarded – undo
561 561
 		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))){
562 562
 			$this->find_attachments($id);
563 563
 		}
564
-        //Set the featured image
565
-        //TODO Test These
566
-        if(false !== $importable_content && in_array('featured_image',$importable_content)){
567
-            $this->set_featured_image($data,$id);
568
-        }
564
+		//Set the featured image
565
+		//TODO Test These
566
+		if(false !== $importable_content && in_array('featured_image',$importable_content)){
567
+			$this->set_featured_image($data,$id);
568
+		}
569 569
 
570 570
 		//TODO Test These
571
-        if(false !== $importable_content && in_array('banner_image',$importable_content)){
572
-            $this->set_banner_image($data,$id);
573
-        }
571
+		if(false !== $importable_content && in_array('banner_image',$importable_content)){
572
+			$this->set_banner_image($data,$id);
573
+		}
574 574
 
575 575
 		//TODO Test These
576
-        //Import the main gallery
577
-        if(false !== $importable_content && in_array('gallery',$importable_content)){
578
-            $this->create_main_gallery($data,$id);
579
-        }
576
+		//Import the main gallery
577
+		if(false !== $importable_content && in_array('gallery',$importable_content)){
578
+			$this->create_main_gallery($data,$id);
579
+		}
580 580
 
581
-        return $id;
581
+		return $id;
582 582
 	}
583 583
 
584 584
 	/**
@@ -706,31 +706,31 @@  discard block
 block discarded – undo
706 706
 	 */
707 707
 	public function process_map_points($data,$id) {
708 708
 
709
-	    if(!empty($data['routes'])){
709
+		if(!empty($data['routes'])){
710 710
 
711
-	        delete_post_meta($id,'wetu_map_points');
711
+			delete_post_meta($id,'wetu_map_points');
712 712
 
713
-	        $points = array();
713
+			$points = array();
714 714
 
715
-	        foreach($data['routes'] as $route){
715
+			foreach($data['routes'] as $route){
716 716
 
717 717
 
718
-	            if(isset($route['points']) && '' !== $route['points']){
718
+				if(isset($route['points']) && '' !== $route['points']){
719 719
 
720
-	                $temp_points = explode(';',$route['points']);
721
-	                $point_counter = count($temp_points);
720
+					$temp_points = explode(';',$route['points']);
721
+					$point_counter = count($temp_points);
722 722
 
723 723
 					for ($x = 0; $x <= $point_counter; $x++) {
724
-					    $y = $x+1;
724
+						$y = $x+1;
725 725
 						$points[] = $temp_points[$x].','.$temp_points[$y];
726 726
 						$x++;
727 727
 					}
728 728
 				}
729
-            }
730
-            if(!empty($points)){
729
+			}
730
+			if(!empty($points)){
731 731
 				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
732
-            }
733
-        }
732
+			}
733
+		}
734 734
 
735 735
 	}
736 736
 
@@ -738,17 +738,17 @@  discard block
 block discarded – undo
738 738
 	 * Set the Itinerary Day
739 739
 	 */
740 740
 	public function set_itinerary_day($day,$id) {
741
-        $this->save_custom_field($day,'itinerary',$id,false,false);
741
+		$this->save_custom_field($day,'itinerary',$id,false,false);
742 742
 	}
743 743
 
744 744
 	/**
745 745
 	 * Set the price
746 746
 	 */
747 747
 	public function set_price($data,$id) {
748
-	    //Price
748
+		//Price
749 749
 		if(isset($data['price']) && ''!== $data['price']){
750
-            $price = preg_replace("/[^0-9,.]/", "", $data['price']);
751
-            $this->save_custom_field($price,'price',$id);
750
+			$price = preg_replace("/[^0-9,.]/", "", $data['price']);
751
+			$this->save_custom_field($price,'price',$id);
752 752
 		}
753 753
 
754 754
 		//Price includes
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 			$this->save_custom_field($data['price_includes'],'included',$id);
757 757
 		}
758 758
 
759
-        //Price Excludes
759
+		//Price Excludes
760 760
 		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
761 761
 			$this->save_custom_field($data['price_excludes'],'not_included',$id);
762 762
 		}
@@ -780,35 +780,35 @@  discard block
 block discarded – undo
780 780
 	 */
781 781
 	public function set_accommodation($day,$id) {
782 782
 
783
-	    $ac_id = false;
783
+		$ac_id = false;
784 784
 		$this->current_accommodation = $this->find_current_accommodation();
785 785
 		
786 786
 		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
787 787
 
788 788
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
789
-                $ac_id = $this->current_accommodation[$day['content_entity_id']];
789
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
790 790
 			}else{
791 791
 				$ac_id = wp_insert_post(array(
792
-                    'post_type' => 'accommodation',
793
-                    'post_status' => 'draft',
794
-                    'post_title' => $day['content_entity_id']
795
-                ));
792
+					'post_type' => 'accommodation',
793
+					'post_status' => 'draft',
794
+					'post_title' => $day['content_entity_id']
795
+				));
796 796
 				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
797 797
 			}
798 798
 
799 799
 			if('' !== $ac_id && false !== $ac_id){
800
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
800
+				$this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
801 801
 				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
802
-            }
802
+			}
803 803
 		}
804 804
 		return $ac_id;
805 805
 	}
806 806
 
807 807
 	/**
808 808
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
809
-     *
810
-     * @param $post_type string
811
-     * @return boolean / array
809
+	 *
810
+	 * @param $post_type string
811
+	 * @return boolean / array
812 812
 	 */
813 813
 	public function find_current_accommodation($post_type='accommodation') {
814 814
 		global $wpdb;
@@ -816,16 +816,16 @@  discard block
 block discarded – undo
816 816
 
817 817
 		$return = false;
818 818
 		if(!empty($accommodation)){
819
-		    foreach($accommodation as $key => $acc){
819
+			foreach($accommodation as $key => $acc){
820 820
 				$return[$acc->meta_value] = $acc->post_id;
821
-            }
822
-        }
821
+			}
822
+		}
823 823
 		return $return;
824 824
 	}
825 825
 
826 826
 	/**
827 827
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
828
-     * @return boolean / array
828
+	 * @return boolean / array
829 829
 	 */
830 830
 	public function find_current_destinations() {
831 831
 		return $this->find_current_accommodation('destination');
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
853 853
 				if(false !== $country_wetu_id){
854 854
 					$this->set_country($country_wetu_id, $id);
855
-                }
855
+				}
856 856
 
857 857
 			}else {
858 858
 
@@ -863,27 +863,27 @@  discard block
 block discarded – undo
863 863
 
864 864
 					if (!empty($destination_data) && !isset($destination_data['error'])) {
865 865
 
866
-					    $destination_title = $day['destination_content_entity_id'];
866
+						$destination_title = $day['destination_content_entity_id'];
867 867
 
868
-					    if(isset($destination_data[0]['name'])){
868
+						if(isset($destination_data[0]['name'])){
869 869
 							$destination_title = $destination_data[0]['name'];
870
-                        }
870
+						}
871 871
 
872
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
873
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
872
+						if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
873
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
874 874
 
875 875
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
876
-                        }
876
+						}
877 877
 
878
-                        $dest_post = array(
878
+						$dest_post = array(
879 879
 							'post_type' => 'destination',
880 880
 							'post_status' => 'draft',
881 881
 							'post_title' => $destination_title
882 882
 						);
883 883
 
884
-					    if(false !== $country_id){
884
+						if(false !== $country_id){
885 885
 							$dest_post['post_parent'] = $country_id;
886
-                        }
886
+						}
887 887
 						$dest_id = wp_insert_post($dest_post);
888 888
 
889 889
 						//Make sure we register the
@@ -905,50 +905,50 @@  discard block
 block discarded – undo
905 905
 	 * Connects the destinations post type
906 906
 	 *
907 907
 	 * @param $dest_id string
908
-     * @param $country_id array
908
+	 * @param $country_id array
909 909
 	 * @param $id string
910 910
 	 */
911 911
 	public function set_country($country_wetu_id, $id) {
912
-	    $country_id = false;
912
+		$country_id = false;
913 913
 		$this->current_destinations = $this->find_current_destinations();
914 914
 
915
-        if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
916
-            $country_id = $this->current_destinations[$country_wetu_id];
917
-        } else {
915
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
916
+			$country_id = $this->current_destinations[$country_wetu_id];
917
+		} else {
918 918
 
919
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
919
+			$country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
920 920
 
921
-            if ($country_json) {
922
-                $country_data = json_decode($country_json, true);
921
+			if ($country_json) {
922
+				$country_data = json_decode($country_json, true);
923 923
 
924
-                if (!empty($country_data) && !isset($country_data['error'])) {
924
+				if (!empty($country_data) && !isset($country_data['error'])) {
925 925
 
926 926
 					//Format the title of the destination if its available,  otherwise default to the WETU ID.
927
-                    $country_title = $country_wetu_id;
928
-                    if (isset($country_data[0]['name'])) {
927
+					$country_title = $country_wetu_id;
928
+					if (isset($country_data[0]['name'])) {
929 929
 						$country_title = $country_data[0]['name'];
930
-                    }
930
+					}
931 931
 
932 932
 					$country_id = wp_insert_post(array(
933
-                        'post_type' => 'destination',
934
-                        'post_status' => 'draft',
935
-                        'post_title' => $country_title
936
-                    ));
933
+						'post_type' => 'destination',
934
+						'post_status' => 'draft',
935
+						'post_title' => $country_title
936
+					));
937 937
 					//add the country to the current destination stack
938 938
 					$this->current_destinations[$country_wetu_id] = $country_id;
939 939
 
940 940
 					//Save the wetu field
941
-                    $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
942
-                }
943
-            }
944
-        }
941
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
942
+				}
943
+			}
944
+		}
945 945
 
946
-        if ('' !== $country_id && false !== $country_id) {
947
-            $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
948
-            $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
946
+		if ('' !== $country_id && false !== $country_id) {
947
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
948
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
949 949
 
950
-            return $country_id;
951
-        }
950
+			return $country_id;
951
+		}
952 952
 	}
953 953
 }
954 954
 $wetu_importer_tours = new WETU_Importer_Tours();
955 955
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +201 added lines, -201 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,16 +172,16 @@  discard block
 block discarded – undo
172 172
 						<div class="settings-all" 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 select-all" <?php $this->checked($this->destination_options,'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All','wetu-importer'); ?></li>
176
-								<li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
177
-								<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 select-all" <?php $this->checked($this->destination_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li>
176
+								<li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
177
+								<li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
178 178
 
179
-                                <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li>
180
-                                <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li>
179
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li>
180
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li>
181 181
 
182
-								<li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
182
+								<li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
183 183
 
184
-                                <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
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li>
185 185
 
186 186
 								<?php /*if(class_exists('LSX_TO_Maps')){ ?>
187 187
                                     <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>
@@ -191,18 +191,18 @@  discard block
 block discarded – undo
191 191
                         <div class="settings-all" style="width:30%;display:block;float:left;">
192 192
                             <h3><?php _e('Itinerary Info'); ?></h3>
193 193
                             <ul>
194
-                                <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>
195
-                                <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>
196
-                                <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>
194
+                                <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>
195
+                                <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>
196
+                                <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>
197 197
                             </ul>
198 198
 
199 199
                             <h4><?php _e('Additional Content'); ?></h4>
200 200
                             <ul>
201
-                                <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li>
202
-                                <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li>
201
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li>
202
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li>
203 203
                             </ul>
204 204
                         </div>
205
-                        <?php if(class_exists('LSX_TO_Team')){ ?>
205
+                        <?php if (class_exists('LSX_TO_Team')) { ?>
206 206
                             <div style="width:30%;display:block;float:left;">
207 207
                                 <h3><?php _e('Assign a Team Member'); ?></h3>
208 208
                                 <?php $this->team_member_checkboxes($this->tour_options); ?>
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 
216 216
 					<h3><?php _e('Your List'); ?></h3>
217
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
217
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
218 218
 					<table class="wp-list-table widefat fixed posts">
219 219
 						<?php $this->table_header(); ?>
220 220
 
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 
227 227
 					</table>
228 228
 
229
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
229
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
230 230
 				</form>
231 231
 			</div>
232 232
 
233 233
 			<div style="display:none;" class="completed-list-wrapper">
234
-				<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
+				<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>
235 235
 				<ul>
236 236
 				</ul>
237 237
 			</div>
@@ -244,20 +244,20 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function update_options_form() {
246 246
 		$tours = get_transient('lsx_ti_tours');
247
-		echo '<div class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - ';
248
-		if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){
247
+		echo '<div class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - ';
248
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
249 249
 			$result = $this->update_options();
250 250
 
251
-			if(true === $result){
252
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
253
-			    if(!isset($_GET['refresh_tours'])){
254
-			        echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>';
251
+			if (true === $result) {
252
+			    echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>';
253
+			    if (!isset($_GET['refresh_tours'])) {
254
+			        echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
255 255
                 }
256
-            }else{
256
+            }else {
257 257
 			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
258 258
             }
259
-		}else{
260
-			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>';
259
+		}else {
260
+			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>';
261 261
         }
262 262
 		echo '</h3></div>';
263 263
 	}
@@ -266,13 +266,13 @@  discard block
 block discarded – undo
266 266
 	 * Save the list of Tours into an option
267 267
 	 */
268 268
 	public function update_options() {
269
-		$data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs . '&own=true&type=All' );
269
+		$data = file_get_contents($this->url.'/V7/List?'.$this->url_qs.'&own=true&type=All');
270 270
 		$tours = json_decode($data, true);
271 271
 
272
-		if(isset($tours['error'])){
272
+		if (isset($tours['error'])) {
273 273
 		    return $tours['error'];
274 274
         }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
275
-			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
275
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
276 276
 			return true;
277 277
 		}
278 278
 	}
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 
297 297
 					LIMIT 0,500
298 298
 		");
299
-		if(null !== $current_tours && !empty($current_tours)){
300
-			foreach($current_tours as $tour){
299
+		if (null !== $current_tours && !empty($current_tours)) {
300
+			foreach ($current_tours as $tour) {
301 301
 				$return[$tour->meta_value] = $tour;
302 302
 			}
303 303
 		}
@@ -310,36 +310,36 @@  discard block
 block discarded – undo
310 310
 	public function process_ajax_search() {
311 311
 		$return = false;
312 312
 
313
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){
313
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
314 314
 			$tours = get_transient('lsx_ti_tours');
315
-			if ( false !== $tours) {
315
+			if (false !== $tours) {
316 316
 
317 317
 				$searched_items = false;
318 318
 
319
-				if(isset($_POST['keyword'] )) {
319
+				if (isset($_POST['keyword'])) {
320 320
 					$keyphrases = $_POST['keyword'];
321
-				}else{
321
+				}else {
322 322
 					$keyphrases = array(0);
323 323
                 }
324 324
 
325
-				if(!is_array($keyphrases)){
325
+				if (!is_array($keyphrases)) {
326 326
 					$keyphrases = array($keyphrases);
327 327
 				}
328
-				foreach($keyphrases as &$keyword){
328
+				foreach ($keyphrases as &$keyword) {
329 329
 					$keyword = ltrim(rtrim($keyword));
330 330
 				}
331 331
 
332 332
 				$post_status = false;
333
-				if(in_array('publish',$keyphrases)){
333
+				if (in_array('publish', $keyphrases)) {
334 334
 					$post_status = 'publish';
335 335
 				}
336
-				if(in_array('pending',$keyphrases)){
336
+				if (in_array('pending', $keyphrases)) {
337 337
 					$post_status = 'pending';
338 338
 				}
339
-				if(in_array('draft',$keyphrases)){
339
+				if (in_array('draft', $keyphrases)) {
340 340
 					$post_status = 'draft';
341 341
 				}
342
-				if(in_array('import',$keyphrases)){
342
+				if (in_array('import', $keyphrases)) {
343 343
 					$post_status = 'import';
344 344
 				}
345 345
 
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 				if (!empty($tours)) {
348 348
 					$current_tours = $this->find_current_tours();
349 349
 
350
-					foreach($tours as $row_key => $row){
350
+					foreach ($tours as $row_key => $row) {
351 351
 
352
-					    if(isset($row['is_disabled']) && true === $row['is_disabled']){
352
+					    if (isset($row['is_disabled']) && true === $row['is_disabled']) {
353 353
                             continue;
354 354
                         }
355 355
 
@@ -359,29 +359,29 @@  discard block
 block discarded – undo
359 359
 
360 360
                         //If this is a current tour, add its ID to the row.
361 361
 						$row['post_id'] = 0;
362
-						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
362
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
363 363
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
364 364
 						}
365 365
 
366 366
 						//If we are searching for
367
-						if(false !== $post_status){
367
+						if (false !== $post_status) {
368 368
 
369
-                            if('import' === $post_status){
369
+                            if ('import' === $post_status) {
370 370
 
371
-								if(0 !== $row['post_id']){
371
+								if (0 !== $row['post_id']) {
372 372
 								    continue;
373
-								}else{
373
+								}else {
374 374
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
375 375
                                 }
376 376
 
377 377
 
378
-                            }else{
378
+                            }else {
379 379
 
380
-								if(0 === $row['post_id']){
380
+								if (0 === $row['post_id']) {
381 381
 									continue;
382
-								}else{
382
+								}else {
383 383
 									$current_status = get_post_status($row['post_id']);
384
-									if($current_status !== $post_status){
384
+									if ($current_status !== $post_status) {
385 385
 									    continue;
386 386
                                     }
387 387
 
@@ -390,17 +390,17 @@  discard block
 block discarded – undo
390 390
 
391 391
                             }
392 392
 
393
-                        }else{
393
+                        }else {
394 394
 							//Search through each keyword.
395
-							foreach($keyphrases as $keyphrase){
395
+							foreach ($keyphrases as $keyphrase) {
396 396
 
397 397
 								//Make sure the keyphrase is turned into an array
398
-								$keywords = explode(" ",$keyphrase);
399
-								if(!is_array($keywords)){
398
+								$keywords = explode(" ", $keyphrase);
399
+								if (!is_array($keywords)) {
400 400
 									$keywords = array($keywords);
401 401
 								}
402 402
 
403
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
403
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
404 404
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
405 405
 								}
406 406
 							}
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 					}		
409 409
 				}
410 410
 
411
-				if(false !== $searched_items){
411
+				if (false !== $searched_items) {
412 412
 					ksort($searched_items);
413 413
 					$return = implode($searched_items);
414 414
 				}
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 	/**
422 422
 	 * Formats the row for output on the screen.
423 423
 	 */	
424
-	public function format_row($row = false){
425
-		if(false !== $row){
424
+	public function format_row($row = false) {
425
+		if (false !== $row) {
426 426
 
427 427
 			$status = 'import';
428
-			if(0 !== $row['post_id']){
428
+			if (0 !== $row['post_id']) {
429 429
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
430 430
 			}
431 431
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 					<strong>'.$row['name'].'</strong> - '.$status.'
440 440
 				</td>
441 441
 				<td class="date column-date">
442
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
442
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
443 443
 				</td>
444 444
 				<td class="ssid column-ssid">
445 445
 					'.$row['identifier'].'
@@ -454,31 +454,31 @@  discard block
 block discarded – undo
454 454
 	 */
455 455
 	public function process_ajax_import($force = false) {
456 456
 		$return = false;
457
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){
457
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
458 458
 			
459 459
 			$wetu_id = $_POST['wetu_id'];
460
-			if(isset($_POST['post_id'])){
460
+			if (isset($_POST['post_id'])) {
461 461
 				$post_id = $_POST['post_id'];	
462
-			}else{
462
+			}else {
463 463
 				$post_id = 0;
464 464
 			}
465 465
 
466
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
466
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
467 467
 				$content = $_POST['content'];
468
-				add_option('wetu_importer_tour_settings',$content);
469
-			}else{
468
+				add_option('wetu_importer_tour_settings', $content);
469
+			}else {
470 470
 				delete_option('wetu_importer_tour_settings');
471 471
 				$content = false;
472 472
 			}
473 473
 
474
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
474
+            $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
475 475
 
476
-            if($jdata)
476
+            if ($jdata)
477 477
             {
478
-				$jdata=json_decode($jdata,true);
479
-                if(!empty($jdata))
478
+				$jdata = json_decode($jdata, true);
479
+                if (!empty($jdata))
480 480
                 {
481
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
481
+                	$return = $this->import_row($jdata, $wetu_id, $post_id, $content);
482 482
                 	$this->format_completed_row($return);
483 483
                 }
484 484
             }
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
      * @param $data array
494 494
      * @param $wetu_id string
495 495
 	 */
496
-	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
496
+	public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) {
497 497
         $post_name = $data_post_content = $data_post_excerpt = '';
498 498
         $post = array(
499 499
           'post_type'		=> 'tour',
@@ -501,29 +501,29 @@  discard block
 block discarded – undo
501 501
 
502 502
         //Set the post_content
503 503
 		$content_used_general_description = false;
504
-        if(false !== $importable_content && in_array('description',$importable_content)){
504
+        if (false !== $importable_content && in_array('description', $importable_content)) {
505 505
             $data_post_content = '';
506 506
 
507
-            if(isset($data['description'])){
507
+            if (isset($data['description'])) {
508 508
                 $data_post_content = $data['description'];
509
-            }elseif(isset($data['summary'])){
509
+            }elseif (isset($data['summary'])) {
510 510
                 $data_post_content = $data['summary'];
511 511
             }
512 512
             $post['post_content'] = $data_post_content;
513 513
         }
514 514
 
515 515
         //Create or update the post
516
-        if(false !== $id && '0' !== $id){
516
+        if (false !== $id && '0' !== $id) {
517 517
             $post['ID'] = $id;
518 518
 	        $post['post_status'] = 'publish';
519 519
             $id = wp_update_post($post);
520
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
521
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
522
-        }else{
520
+            $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
521
+            update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date);
522
+        }else {
523 523
 
524 524
             //Set the name
525
-            if(isset($data['name'])){
526
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
525
+            if (isset($data['name'])) {
526
+                $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
527 527
             }
528 528
             $post['post_name'] = $post_name;
529 529
             $post['post_title'] = $data['name'];
@@ -531,51 +531,51 @@  discard block
 block discarded – undo
531 531
             $id = wp_insert_post($post);
532 532
 
533 533
             //Save the WETU ID and the Last date it was modified.
534
-            if(false !== $id){
535
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
536
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
534
+            if (false !== $id) {
535
+                add_post_meta($id, 'lsx_wetu_id', $wetu_id);
536
+                add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']));
537 537
             }
538 538
         }
539 539
 
540 540
 
541 541
 		//Set the price
542
-		if(false !== $importable_content && in_array('price',$importable_content)){
543
-			$this->set_price($data,$id);
542
+		if (false !== $importable_content && in_array('price', $importable_content)) {
543
+			$this->set_price($data, $id);
544 544
 		}
545 545
 
546 546
 		//Set the Duration
547
-		if(false !== $importable_content && in_array('duration',$importable_content)){
548
-			$this->set_duration($data,$id);
547
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
548
+			$this->set_duration($data, $id);
549 549
 		}
550 550
 
551
-        if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
552
-            $this->process_itineraries($data,$id,$importable_content);
551
+        if (in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
552
+            $this->process_itineraries($data, $id, $importable_content);
553 553
         }
554 554
 
555
-		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
556
-			$this->process_map_points($data,$id);
555
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
556
+			$this->process_map_points($data, $id);
557 557
 		}
558 558
 
559 559
 		//TODO Test These
560 560
 		//Setup some default for use in the import
561
-		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
+		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))) {
562 562
 			$this->find_attachments($id);
563 563
 		}
564 564
         //Set the featured image
565 565
         //TODO Test These
566
-        if(false !== $importable_content && in_array('featured_image',$importable_content)){
567
-            $this->set_featured_image($data,$id);
566
+        if (false !== $importable_content && in_array('featured_image', $importable_content)) {
567
+            $this->set_featured_image($data, $id);
568 568
         }
569 569
 
570 570
 		//TODO Test These
571
-        if(false !== $importable_content && in_array('banner_image',$importable_content)){
572
-            $this->set_banner_image($data,$id);
571
+        if (false !== $importable_content && in_array('banner_image', $importable_content)) {
572
+            $this->set_banner_image($data, $id);
573 573
         }
574 574
 
575 575
 		//TODO Test These
576 576
         //Import the main gallery
577
-        if(false !== $importable_content && in_array('gallery',$importable_content)){
578
-            $this->create_main_gallery($data,$id);
577
+        if (false !== $importable_content && in_array('gallery', $importable_content)) {
578
+            $this->create_main_gallery($data, $id);
579 579
         }
580 580
 
581 581
         return $id;
@@ -584,151 +584,151 @@  discard block
 block discarded – undo
584 584
 	/**
585 585
 	 * A loop which runs through each leg on the tour.
586 586
 	 */
587
-	public function process_itineraries($data,$id,$importable_content) {
587
+	public function process_itineraries($data, $id, $importable_content) {
588 588
 		$day_counter = 1;
589 589
 		$leg_counter = 0;
590 590
 
591
-		delete_post_meta($id,'itinerary');
591
+		delete_post_meta($id, 'itinerary');
592 592
 
593
-		if(false !== $importable_content && in_array('accommodation',$importable_content)){
594
-			delete_post_meta($id,'accommodation_to_tour');
593
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
594
+			delete_post_meta($id, 'accommodation_to_tour');
595 595
 		}
596
-		if(false !== $importable_content && in_array('destination',$importable_content)){
597
-			delete_post_meta($id,'destination_to_tour');
598
-			delete_post_meta($id,'departs_from');
599
-			delete_post_meta($id,'ends_in');
596
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
597
+			delete_post_meta($id, 'destination_to_tour');
598
+			delete_post_meta($id, 'departs_from');
599
+			delete_post_meta($id, 'ends_in');
600 600
 		}
601 601
 
602 602
 		$departs_from = false;
603 603
 		$ends_in = false;
604 604
 
605
-		foreach($data['legs'] as $leg){
605
+		foreach ($data['legs'] as $leg) {
606 606
 
607
-			if(isset($leg['days']) && !empty($leg['days'])){
607
+			if (isset($leg['days']) && !empty($leg['days'])) {
608 608
 
609 609
 				//Itinerary Accommodation
610 610
 				$current_accommodation = false;
611
-				if(false !== $importable_content && in_array('accommodation',$importable_content)){
612
-					$current_accommodation = $this->set_accommodation($leg,$id);
611
+				if (false !== $importable_content && in_array('accommodation', $importable_content)) {
612
+					$current_accommodation = $this->set_accommodation($leg, $id);
613 613
 				}
614 614
 
615 615
 				//Itinerary Destination
616 616
 				$current_destination = false;
617
-				if(false !== $importable_content && in_array('destination',$importable_content)){
618
-					$current_destination = $this->set_destination($leg,$id);
617
+				if (false !== $importable_content && in_array('destination', $importable_content)) {
618
+					$current_destination = $this->set_destination($leg, $id);
619 619
 				}
620 620
 
621 621
 				//If the Nights are the same mount of days in the array,  then it isnt "By Destination"
622
-				if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){
622
+				if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) {
623 623
 
624
-					foreach($leg['days'] as $day){
624
+					foreach ($leg['days'] as $day) {
625 625
 
626 626
 						$current_day = array();
627 627
 
628
-						$current_day['title'] =  esc_attr('Day ','wetu-importer').$day_counter;
628
+						$current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter;
629 629
 
630 630
 						//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
631 631
 
632 632
 						//Description
633
-						if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){
633
+						if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
634 634
 							$current_day['description'] = $day['notes'];
635
-						}else{
635
+						}else {
636 636
 							$current_day['description'] = '';
637 637
 						}
638 638
 
639 639
 						//Itinerary Gallery
640
-						if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){
640
+						if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
641 641
 							$current_day['featured_image'] = '';
642
-						}else{
642
+						}else {
643 643
 							$current_day['featured_image'] = '';
644 644
 						}
645 645
 
646 646
 						//Accommodation
647
-						if(false !== $current_accommodation){
647
+						if (false !== $current_accommodation) {
648 648
 							$current_day['accommodation_to_tour'] = array($current_accommodation);
649
-						}else{
649
+						}else {
650 650
 							$current_day['accommodation_to_tour'] = array();
651 651
 						}
652 652
 
653 653
 						//Destination
654
-						if(false !== $current_destination){
654
+						if (false !== $current_destination) {
655 655
 							$current_day['destination_to_tour'] = array($current_destination);
656
-						}else{
656
+						}else {
657 657
 							$current_day['destination_to_tour'] = array();
658 658
 						}
659 659
 
660 660
 						//Included
661
-						if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){
661
+						if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
662 662
 							$current_day['included'] = $day['included'];
663
-						}else{
663
+						}else {
664 664
 							$current_day['included'] = '';
665 665
 						}
666 666
 
667 667
 						//Excluded
668
-						if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){
668
+						if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
669 669
 							$current_day['excluded'] = $day['excluded'];
670
-						}else{
670
+						}else {
671 671
 							$current_day['excluded'] = '';
672 672
 						}
673 673
 
674
-						$this->set_itinerary_day($current_day,$id);
674
+						$this->set_itinerary_day($current_day, $id);
675 675
 						$day_counter++;
676 676
 					}
677 677
 
678
-				}else{
679
-					$day_counter = $day_counter + (int)$leg['nights'];
678
+				}else {
679
+					$day_counter = $day_counter + (int) $leg['nights'];
680 680
 				}
681 681
 
682 682
 			}
683 683
 
684 684
 			//If we are in the first leg,  and the destination was attached then save it as the departure field.
685
-			if( 0 === $leg_counter && false !== $current_destination){
685
+			if (0 === $leg_counter && false !== $current_destination) {
686 686
 				$departs_from = $current_destination;
687 687
 			}
688 688
 
689 689
 			//If its the last leg then save it as the ends in.
690
-			if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){
690
+			if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) {
691 691
 				$ends_in = $current_destination;
692 692
 			}
693 693
 			$leg_counter++;
694 694
 		}
695 695
 
696
-		if(false !== $departs_from){
697
-			add_post_meta($id,'departs_from',$departs_from,true);
696
+		if (false !== $departs_from) {
697
+			add_post_meta($id, 'departs_from', $departs_from, true);
698 698
 		}
699
-		if(false !== $ends_in){
700
-			add_post_meta($id,'ends_in',$ends_in,true);
699
+		if (false !== $ends_in) {
700
+			add_post_meta($id, 'ends_in', $ends_in, true);
701 701
 		}
702 702
 	}
703 703
 
704 704
 	/**
705 705
 	 * Run through your routes and save the points as a KML file.
706 706
 	 */
707
-	public function process_map_points($data,$id) {
707
+	public function process_map_points($data, $id) {
708 708
 
709
-	    if(!empty($data['routes'])){
709
+	    if (!empty($data['routes'])) {
710 710
 
711
-	        delete_post_meta($id,'wetu_map_points');
711
+	        delete_post_meta($id, 'wetu_map_points');
712 712
 
713 713
 	        $points = array();
714 714
 
715
-	        foreach($data['routes'] as $route){
715
+	        foreach ($data['routes'] as $route) {
716 716
 
717 717
 
718
-	            if(isset($route['points']) && '' !== $route['points']){
718
+	            if (isset($route['points']) && '' !== $route['points']) {
719 719
 
720
-	                $temp_points = explode(';',$route['points']);
720
+	                $temp_points = explode(';', $route['points']);
721 721
 	                $point_counter = count($temp_points);
722 722
 
723 723
 					for ($x = 0; $x <= $point_counter; $x++) {
724
-					    $y = $x+1;
724
+					    $y = $x + 1;
725 725
 						$points[] = $temp_points[$x].','.$temp_points[$y];
726 726
 						$x++;
727 727
 					}
728 728
 				}
729 729
             }
730
-            if(!empty($points)){
731
-				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
730
+            if (!empty($points)) {
731
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
732 732
             }
733 733
         }
734 734
 
@@ -737,28 +737,28 @@  discard block
 block discarded – undo
737 737
 	/**
738 738
 	 * Set the Itinerary Day
739 739
 	 */
740
-	public function set_itinerary_day($day,$id) {
741
-        $this->save_custom_field($day,'itinerary',$id,false,false);
740
+	public function set_itinerary_day($day, $id) {
741
+        $this->save_custom_field($day, 'itinerary', $id, false, false);
742 742
 	}
743 743
 
744 744
 	/**
745 745
 	 * Set the price
746 746
 	 */
747
-	public function set_price($data,$id) {
747
+	public function set_price($data, $id) {
748 748
 	    //Price
749
-		if(isset($data['price']) && ''!== $data['price']){
749
+		if (isset($data['price']) && '' !== $data['price']) {
750 750
             $price = preg_replace("/[^0-9,.]/", "", $data['price']);
751
-            $this->save_custom_field($price,'price',$id);
751
+            $this->save_custom_field($price, 'price', $id);
752 752
 		}
753 753
 
754 754
 		//Price includes
755
-		if(isset($data['price_includes']) && ''!== $data['price_includes']){
756
-			$this->save_custom_field($data['price_includes'],'included',$id);
755
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
756
+			$this->save_custom_field($data['price_includes'], 'included', $id);
757 757
 		}
758 758
 
759 759
         //Price Excludes
760
-		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
761
-			$this->save_custom_field($data['price_excludes'],'not_included',$id);
760
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
761
+			$this->save_custom_field($data['price_excludes'], 'not_included', $id);
762 762
 		}
763 763
 
764 764
 	}
@@ -766,11 +766,11 @@  discard block
 block discarded – undo
766 766
 	/**
767 767
 	 * Set the duration
768 768
 	 */
769
-	public function set_duration($data,$id) {
770
-		if(isset($data['days']) && !empty($data['days'])){
769
+	public function set_duration($data, $id) {
770
+		if (isset($data['days']) && !empty($data['days'])) {
771 771
 			$price = $data['days'];
772 772
 			$price = preg_replace("/[^0-9,.]/", "", $price);
773
-			$this->save_custom_field($price,'duration',$id);
773
+			$this->save_custom_field($price, 'duration', $id);
774 774
 		}
775 775
 	}
776 776
 
@@ -778,27 +778,27 @@  discard block
 block discarded – undo
778 778
 	/**
779 779
 	 * Connects the Accommodation if its available
780 780
 	 */
781
-	public function set_accommodation($day,$id) {
781
+	public function set_accommodation($day, $id) {
782 782
 
783 783
 	    $ac_id = false;
784 784
 		$this->current_accommodation = $this->find_current_accommodation();
785 785
 		
786
-		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
786
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
787 787
 
788
-			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
788
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
789 789
                 $ac_id = $this->current_accommodation[$day['content_entity_id']];
790
-			}else{
790
+			}else {
791 791
 				$ac_id = wp_insert_post(array(
792 792
                     'post_type' => 'accommodation',
793 793
                     'post_status' => 'draft',
794 794
                     'post_title' => $day['content_entity_id']
795 795
                 ));
796
-				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
796
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
797 797
 			}
798 798
 
799
-			if('' !== $ac_id && false !== $ac_id){
800
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
801
-				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
799
+			if ('' !== $ac_id && false !== $ac_id) {
800
+			    $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
801
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
802 802
             }
803 803
 		}
804 804
 		return $ac_id;
@@ -810,13 +810,13 @@  discard block
 block discarded – undo
810 810
      * @param $post_type string
811 811
      * @return boolean / array
812 812
 	 */
813
-	public function find_current_accommodation($post_type='accommodation') {
813
+	public function find_current_accommodation($post_type = 'accommodation') {
814 814
 		global $wpdb;
815 815
 		$accommodation = parent::find_current_accommodation($post_type);
816 816
 
817 817
 		$return = false;
818
-		if(!empty($accommodation)){
819
-		    foreach($accommodation as $key => $acc){
818
+		if (!empty($accommodation)) {
819
+		    foreach ($accommodation as $key => $acc) {
820 820
 				$return[$acc->meta_value] = $acc->post_id;
821 821
             }
822 822
         }
@@ -838,25 +838,25 @@  discard block
 block discarded – undo
838 838
 	 * @param $id string
839 839
 	 * @return boolean / string
840 840
 	 */
841
-	public function set_destination($day,$id) {
841
+	public function set_destination($day, $id) {
842 842
 		$dest_id = false;
843 843
 		$country_id = false;
844 844
 		$this->current_destinations = $this->find_current_destinations();
845 845
 
846
-		if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){
846
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
847 847
 
848
-			if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){
848
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
849 849
 				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
850 850
 
851 851
 				$potential_id = wp_get_post_parent_id($dest_id);
852
-				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
853
-				if(false !== $country_wetu_id){
852
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
853
+				if (false !== $country_wetu_id) {
854 854
 					$this->set_country($country_wetu_id, $id);
855 855
                 }
856 856
 
857 857
 			}else {
858 858
 
859
-				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']);
859
+				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']);
860 860
 
861 861
 				if ($destination_json) {
862 862
 					$destination_data = json_decode($destination_json, true);
@@ -865,12 +865,12 @@  discard block
 block discarded – undo
865 865
 
866 866
 					    $destination_title = $day['destination_content_entity_id'];
867 867
 
868
-					    if(isset($destination_data[0]['name'])){
868
+					    if (isset($destination_data[0]['name'])) {
869 869
 							$destination_title = $destination_data[0]['name'];
870 870
                         }
871 871
 
872
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
873
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
872
+					    if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
873
+                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) {
874 874
 
875 875
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
876 876
                         }
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 							'post_title' => $destination_title
882 882
 						);
883 883
 
884
-					    if(false !== $country_id){
884
+					    if (false !== $country_id) {
885 885
 							$dest_post['post_parent'] = $country_id;
886 886
                         }
887 887
 						$dest_id = wp_insert_post($dest_post);
@@ -914,9 +914,9 @@  discard block
 block discarded – undo
914 914
 
915 915
         if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
916 916
             $country_id = $this->current_destinations[$country_wetu_id];
917
-        } else {
917
+        }else {
918 918
 
919
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
919
+            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id);
920 920
 
921 921
             if ($country_json) {
922 922
                 $country_data = json_decode($country_json, true);
Please login to merge, or discard this patch.
classes/class-destination.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * Display the importer administration screen
105 105
 	 */
106 106
 	public function display_page() {
107
-        ?>
107
+		?>
108 108
         <div class="wrap">
109 109
 			<?php $this->navigation('destination'); ?>
110 110
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 					$keyphrases = $_POST['keyword'];
331 331
 				}else{
332 332
 					$keyphrases = array(0);
333
-                }
333
+				}
334 334
 
335 335
 				if(!is_array($keyphrases)){
336 336
 					$keyphrases = array($keyphrases);
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 						//If we are searching for
360 360
 						if(false !== $post_status){
361 361
 
362
-                            $current_status = get_post_status($row->post_id);
363
-                            if($current_status !== $post_status){
364
-                                continue;
365
-                            }
366
-                            $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
362
+							$current_status = get_post_status($row->post_id);
363
+							if($current_status !== $post_status){
364
+								continue;
365
+							}
366
+							$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
367 367
 
368 368
 
369 369
 						}else{
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 				$team_members = false;
446 446
 			}
447 447
 
448
-            $safari_brands = false;
448
+			$safari_brands = false;
449 449
 
450 450
 			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
451 451
 				$content = $_POST['content'];
@@ -456,16 +456,16 @@  discard block
 block discarded – undo
456 456
 				$content = false;
457 457
 			}
458 458
 
459
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
460
-            if($jdata)
461
-            {
462
-                $adata=json_decode($jdata,true);
463
-                if(!empty($adata))
464
-                {
465
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
466
-                	$this->format_completed_row($return);
467
-                }
468
-            }
459
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
460
+			if($jdata)
461
+			{
462
+				$adata=json_decode($jdata,true);
463
+				if(!empty($adata))
464
+				{
465
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
466
+					$this->format_completed_row($return);
467
+				}
468
+			}
469 469
 
470 470
 			die();
471 471
 		}
@@ -477,82 +477,82 @@  discard block
 block discarded – undo
477 477
 	 */
478 478
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
479 479
 
480
-        if(trim($data[0]['type'])=='Destination')
481
-        {
482
-	        $post_name = $data_post_content = $data_post_excerpt = '';
483
-	        $post = array(
484
-	          'post_type'		=> 'destination',
485
-	        );
486
-
487
-	        $content_used_general_description = false;
488
-
489
-	        //Set the post_content
490
-	        if(false !== $importable_content && in_array('description',$importable_content)){
491
-		        if(isset($data[0]['content']['extended_description']))
492
-		        {
493
-		            $data_post_content = $data[0]['content']['extended_description'];
494
-		        }elseif(isset($data[0]['content']['general_description'])){
495
-		            $data_post_content = $data[0]['content']['general_description'];
496
-		            $content_used_general_description = true;
497
-		        }elseif(isset($data[0]['content']['teaser_description'])){
498
-		        	$data_post_content = $data[0]['content']['teaser_description'];
499
-		        }
500
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
501
-	        }
502
-
503
-	        //set the post_excerpt
504
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
505
-		        if(isset($data[0]['content']['teaser_description'])){
506
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
507
-		        }elseif(isset($data[0]['content']['extended_description'])){
480
+		if(trim($data[0]['type'])=='Destination')
481
+		{
482
+			$post_name = $data_post_content = $data_post_excerpt = '';
483
+			$post = array(
484
+			  'post_type'		=> 'destination',
485
+			);
486
+
487
+			$content_used_general_description = false;
488
+
489
+			//Set the post_content
490
+			if(false !== $importable_content && in_array('description',$importable_content)){
491
+				if(isset($data[0]['content']['extended_description']))
492
+				{
493
+					$data_post_content = $data[0]['content']['extended_description'];
494
+				}elseif(isset($data[0]['content']['general_description'])){
495
+					$data_post_content = $data[0]['content']['general_description'];
496
+					$content_used_general_description = true;
497
+				}elseif(isset($data[0]['content']['teaser_description'])){
498
+					$data_post_content = $data[0]['content']['teaser_description'];
499
+				}
500
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
501
+			}
502
+
503
+			//set the post_excerpt
504
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
505
+				if(isset($data[0]['content']['teaser_description'])){
506
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
507
+				}elseif(isset($data[0]['content']['extended_description'])){
508 508
 					$data_post_excerpt = $data[0]['content']['extended_description'];
509 509
 				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
510
-		            $data_post_excerpt = $data[0]['content']['general_description'];
511
-		        }	   
512
-		        $post['post_excerpt'] = $data_post_excerpt;     	
513
-	        }
510
+					$data_post_excerpt = $data[0]['content']['general_description'];
511
+				}	   
512
+				$post['post_excerpt'] = $data_post_excerpt;     	
513
+			}
514 514
 
515
-	        if(false !== $id && '0' !== $id){
516
-	        	$post['ID'] = $id;
515
+			if(false !== $id && '0' !== $id){
516
+				$post['ID'] = $id;
517 517
 				if(isset($data[0]['name'])){
518 518
 					$post['post_title'] = $data[0]['name'];
519 519
 					$post['post_status'] = 'publish';
520 520
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
521 521
 				}
522
-	        	$id = wp_update_post($post);
523
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
524
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
525
-	        }else{
526
-
527
-		        //Set the name
528
-		        if(isset($data[0]['name'])){
529
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
530
-		        }
531
-	        	$post['post_name'] = $post_name;
532
-	        	$post['post_title'] = $data[0]['name'];
533
-	        	$post['post_status'] = 'publish';
534
-	        	$id = wp_insert_post($post);
535
-
536
-	        	//Save the WETU ID and the Last date it was modified.
537
-	        	if(false !== $id){
538
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
539
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
540
-	        	}
541
-	        }
542
-
543
-	        //Set the team member if it is there
544
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
545
-	        	$this->set_team_member($id,$team_members);
546
-	    	}
547
-
548
-	        if(class_exists('LSX_TO_Maps')){
549
-	        	$this->set_map_data($data,$id,4);
550
-	        }
551
-
552
-	        //Set the Room Data
553
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
554
-	        	$this->set_video_data($data,$id);
555
-	    	}
522
+				$id = wp_update_post($post);
523
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
524
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
525
+			}else{
526
+
527
+				//Set the name
528
+				if(isset($data[0]['name'])){
529
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
530
+				}
531
+				$post['post_name'] = $post_name;
532
+				$post['post_title'] = $data[0]['name'];
533
+				$post['post_status'] = 'publish';
534
+				$id = wp_insert_post($post);
535
+
536
+				//Save the WETU ID and the Last date it was modified.
537
+				if(false !== $id){
538
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
539
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
540
+				}
541
+			}
542
+
543
+			//Set the team member if it is there
544
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
545
+				$this->set_team_member($id,$team_members);
546
+			}
547
+
548
+			if(class_exists('LSX_TO_Maps')){
549
+				$this->set_map_data($data,$id,4);
550
+			}
551
+
552
+			//Set the Room Data
553
+			if(false !== $importable_content && in_array('videos',$importable_content)){
554
+				$this->set_video_data($data,$id);
555
+			}
556 556
 
557 557
 			//Set the Electricity
558 558
 			if(false !== $importable_content && in_array('electricity',$importable_content)){
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 			}
598 598
 
599 599
 		}
600
-        return $id;
600
+		return $id;
601 601
 	}
602 602
 
603 603
 	/**
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 
608 608
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
609 609
 		foreach($team_members as $team){
610
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
610
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
611 611
 		}
612 612
 	}
613 613
 	
@@ -658,11 +658,11 @@  discard block
 block discarded – undo
658 658
 				'elevation'	=>	'',
659 659
 			);
660 660
 			if(false !== $id && '0' !== $id){
661
-	        	$prev = get_post_meta($id,'location',true);
662
-	        	update_post_meta($id,'location',$location_data,$prev);
663
-	        }else{
664
-	        	add_post_meta($id,'location',$location_data,true);
665
-	        }
661
+				$prev = get_post_meta($id,'location',true);
662
+				update_post_meta($id,'location',$location_data,$prev);
663
+			}else{
664
+				add_post_meta($id,'location',$location_data,true);
665
+			}
666 666
 		}
667 667
 	}
668 668
 
Please login to merge, or discard this patch.
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
 	public function __construct() {
65 65
 		$this->set_variables();
66 66
 
67
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
67
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
68 68
 
69
-		add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));	
70
-		add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));		
69
+		add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));	
70
+		add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));		
71 71
 
72
-		add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));	
73
-		add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
72
+		add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));	
73
+		add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
74 74
 
75
-		$temp_options = get_option('_lsx-to_settings',false);
76
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
75
+		$temp_options = get_option('_lsx-to_settings', false);
76
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
77 77
 			$this->options = $temp_options[$this->plugin_slug];
78 78
 		}
79 79
 
80
-		$destination_options = get_option('wetu_importer_destination_settings',false);
81
-		if(false !== $destination_options){
80
+		$destination_options = get_option('wetu_importer_destination_settings', false);
81
+		if (false !== $destination_options) {
82 82
 			$this->destination_options = $destination_options;
83 83
 		}
84 84
 	}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		//	$this->url    = 'https://wetu.com/API/Pins/';
96 96
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
97 97
 		//} elseif ( false !== $this->api_key ) {
98
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
98
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
99 99
 			$this->url_qs = '';
100 100
 		//}
101 101
 	}
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 			<form method="get" action="" id="posts-filter">
114 114
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
115 115
 				
116
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
117
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
116
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
117
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
118 118
 				</p>				
119 119
 
120 120
 				<table class="wp-list-table widefat fixed posts">
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 					<tbody id="the-list">
124 124
 						<tr class="post-0 type-tour status-none" id="post-0">
125 125
 							<th class="check-column" scope="row">
126
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
126
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
127 127
 							</th>
128 128
 							<td class="post-title page-title column-title">
129 129
 								<strong>
130
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
130
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
131 131
 								</strong>
132 132
 							</td>
133 133
 							<td class="date column-date">							
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 
142 142
 				</table>
143 143
 
144
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
145
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
144
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
145
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
146 146
 				</p>
147 147
 			</form> 
148 148
 
@@ -154,40 +154,40 @@  discard block
 block discarded – undo
154 154
 						<div class="settings-all" style="width:30%;display:block;float:left;">
155 155
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
156 156
 							<ul>
157
-                                <li><input class="content select-all" <?php $this->checked($this->destination_options,'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All','wetu-importer'); ?></li>
158
-								<li><input class="content" <?php $this->checked($this->destination_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
159
-								<li><input class="content" <?php $this->checked($this->destination_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
160
-                                <li><input class="content" <?php $this->checked($this->destination_options,'gallery'); ?> type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li>
161
-		                        <?php if(class_exists('LSX_TO_Maps')){ ?>
162
-                                    <li><input class="content" <?php $this->checked($this->destination_options,'location'); ?> type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li>
157
+                                <li><input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li>
158
+								<li><input class="content" <?php $this->checked($this->destination_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
159
+								<li><input class="content" <?php $this->checked($this->destination_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
160
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?> type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li>
161
+		                        <?php if (class_exists('LSX_TO_Maps')) { ?>
162
+                                    <li><input class="content" <?php $this->checked($this->destination_options, 'location'); ?> type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li>
163 163
 		                        <?php } ?>
164 164
 
165
-		                        <?php if(class_exists('LSX_TO_Videos')){ ?>
166
-								    <li><input class="content" <?php $this->checked($this->destination_options,'videos'); ?> type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li>
165
+		                        <?php if (class_exists('LSX_TO_Videos')) { ?>
166
+								    <li><input class="content" <?php $this->checked($this->destination_options, 'videos'); ?> type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li>
167 167
 		                        <?php } ?>
168 168
 
169 169
 							</ul>
170 170
                             <h4><?php _e('Additional Content'); ?></h4>
171 171
                             <ul>
172
-                                <li><input class="content" <?php $this->checked($this->destination_options,'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li>
173
-								<?php if(class_exists('LSX_Banners')){ ?>
174
-                                    <li><input class="content" <?php $this->checked($this->destination_options,'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li>
172
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li>
173
+								<?php if (class_exists('LSX_Banners')) { ?>
174
+                                    <li><input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li>
175 175
 								<?php } ?>
176 176
                             </ul>
177 177
 						</div>
178 178
                         <div class="settings-all" style="width:30%;display:block;float:left;">
179 179
                             <h3><?php _e('Travel Information'); ?></h3>
180 180
                             <ul>
181
-                                <li><input class="content" <?php $this->checked($this->destination_options,'electricity'); ?> type="checkbox" name="content[]" value="electricity" /> <?php _e('Electricity','wetu-importer'); ?></li>
182
-                                <li><input class="content" <?php $this->checked($this->destination_options,'banking'); ?> type="checkbox" name="content[]" value="banking" /> <?php _e('Banking','wetu-importer'); ?></li>
183
-                                <li><input class="content" <?php $this->checked($this->destination_options,'cuisine'); ?> type="checkbox" name="content[]" value="cuisine" /> <?php _e('Cuisine','wetu-importer'); ?></li>
184
-                                <li><input class="content" <?php $this->checked($this->destination_options,'climate'); ?> type="checkbox" name="content[]" value="climate" /> <?php _e('Climate','wetu-importer'); ?></li>
185
-                                <li><input class="content" <?php $this->checked($this->destination_options,'transport'); ?> type="checkbox" name="content[]" value="transport" /> <?php _e('Transport','wetu-importer'); ?></li>
186
-                                <li><input class="content" <?php $this->checked($this->destination_options,'dress'); ?> type="checkbox" name="content[]" value="dress" /> <?php _e('Dress','wetu-importer'); ?></li>
181
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?> type="checkbox" name="content[]" value="electricity" /> <?php _e('Electricity', 'wetu-importer'); ?></li>
182
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'banking'); ?> type="checkbox" name="content[]" value="banking" /> <?php _e('Banking', 'wetu-importer'); ?></li>
183
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?> type="checkbox" name="content[]" value="cuisine" /> <?php _e('Cuisine', 'wetu-importer'); ?></li>
184
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'climate'); ?> type="checkbox" name="content[]" value="climate" /> <?php _e('Climate', 'wetu-importer'); ?></li>
185
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'transport'); ?> type="checkbox" name="content[]" value="transport" /> <?php _e('Transport', 'wetu-importer'); ?></li>
186
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?> type="checkbox" name="content[]" value="dress" /> <?php _e('Dress', 'wetu-importer'); ?></li>
187 187
                             </ul>
188 188
                         </div>
189 189
 
190
-		                <?php if(class_exists('LSX_TO_Team')){ ?>
190
+		                <?php if (class_exists('LSX_TO_Team')) { ?>
191 191
                             <div style="width:30%;display:block;float:left;">
192 192
                                 <h3><?php _e('Assign a Team Member'); ?></h3>
193 193
                                 <?php $this->team_member_checkboxes($this->destination_options); ?>
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 
200 200
 
201 201
 					<h3><?php _e('Your List'); ?></h3>
202
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
202
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
203 203
 					<table class="wp-list-table widefat fixed posts">
204 204
 						<?php $this->table_header(); ?>
205 205
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
 					</table>
213 213
 
214
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
214
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
215 215
 				</form>
216 216
 			</div>
217 217
 
@@ -232,31 +232,31 @@  discard block
 block discarded – undo
232 232
         <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>">
233 233
         	<input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" />
234 234
 
235
-        	<h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3>
235
+        	<h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3>
236 236
             <div class="normal-search">
237
-                <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
237
+                <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
238 238
             </div>
239 239
 
240 240
 
241 241
             <div class="advanced-search hidden" style="display:none;">
242
-                <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p>
242
+                <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p>
243 243
                 <textarea rows="10" cols="40" name="bulk-keywords"></textarea>
244
-                <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
244
+                <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
245 245
             </div>
246 246
 
247 247
             <p>
248
-                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> |
249
-                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> |
250
-                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> |
251
-                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a>
248
+                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> |
249
+                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> |
250
+                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> |
251
+                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a>
252 252
             </p>
253 253
 
254 254
             <div class="ajax-loader" style="display:none;width:100%;text-align:center;">
255
-            	<img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
255
+            	<img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
256 256
             </div>
257 257
 
258 258
             <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
259
-            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
259
+            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
260 260
             </div>
261 261
         </form>
262 262
 	<?php
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	/**
293 293
 	 * Grab all the current destination posts via the lsx_wetu_id field.
294 294
 	 */
295
-	public function find_current_destination($post_type='destination') {
295
+	public function find_current_destination($post_type = 'destination') {
296 296
 		global $wpdb;
297 297
 		$return = array();
298 298
 
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 
309 309
 					LIMIT 0,500
310 310
 		");
311
-		if(null !== $current_destination && !empty($current_destination)){
312
-			foreach($current_destination as $accom){
311
+		if (null !== $current_destination && !empty($current_destination)) {
312
+			foreach ($current_destination as $accom) {
313 313
 				$return[$accom->meta_value] = $accom;
314 314
 			}
315 315
 		}
@@ -321,32 +321,32 @@  discard block
 block discarded – undo
321 321
 	 */
322 322
 	public function process_ajax_search() {
323 323
 		$return = false;
324
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination'){
324
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') {
325 325
 
326
-			if ( isset($_POST['keyword'] )) {
326
+			if (isset($_POST['keyword'])) {
327 327
 				$searched_items = false;
328 328
 
329
-				if(isset($_POST['keyword'] )) {
329
+				if (isset($_POST['keyword'])) {
330 330
 					$keyphrases = $_POST['keyword'];
331
-				}else{
331
+				}else {
332 332
 					$keyphrases = array(0);
333 333
                 }
334 334
 
335
-				if(!is_array($keyphrases)){
335
+				if (!is_array($keyphrases)) {
336 336
 					$keyphrases = array($keyphrases);
337 337
 				}
338
-				foreach($keyphrases as &$keyword){
338
+				foreach ($keyphrases as &$keyword) {
339 339
 					$keyword = ltrim(rtrim($keyword));
340 340
 				}
341 341
 
342 342
 				$post_status = false;
343
-				if(in_array('publish',$keyphrases)){
343
+				if (in_array('publish', $keyphrases)) {
344 344
 					$post_status = 'publish';
345 345
 				}
346
-				if(in_array('pending',$keyphrases)){
346
+				if (in_array('pending', $keyphrases)) {
347 347
 					$post_status = 'pending';
348 348
 				}
349
-				if(in_array('draft',$keyphrases)){
349
+				if (in_array('draft', $keyphrases)) {
350 350
 					$post_status = 'draft';
351 351
 				}
352 352
 
@@ -354,29 +354,29 @@  discard block
 block discarded – undo
354 354
 
355 355
 				if (!empty($destination)) {
356 356
 
357
-					foreach($destination as $row){
357
+					foreach ($destination as $row) {
358 358
 
359 359
 						//If we are searching for
360
-						if(false !== $post_status){
360
+						if (false !== $post_status) {
361 361
 
362 362
                             $current_status = get_post_status($row->post_id);
363
-                            if($current_status !== $post_status){
363
+                            if ($current_status !== $post_status) {
364 364
                                 continue;
365 365
                             }
366 366
                             $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
367 367
 
368 368
 
369
-						}else{
369
+						}else {
370 370
 							//Search through each keyword.
371
-							foreach($keyphrases as $keyphrase){
371
+							foreach ($keyphrases as $keyphrase) {
372 372
 
373 373
 								//Make sure the keyphrase is turned into an array
374
-								$keywords = explode(" ",$keyphrase);
375
-								if(!is_array($keywords)){
374
+								$keywords = explode(" ", $keyphrase);
375
+								if (!is_array($keywords)) {
376 376
 									$keywords = array($keywords);
377 377
 								}
378 378
 
379
-								if($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false){
379
+								if ($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false) {
380 380
 									$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
381 381
 								}
382 382
 							}
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 					}		
385 385
 				}
386 386
 
387
-				if(false !== $searched_items){
387
+				if (false !== $searched_items) {
388 388
 					ksort($searched_items);
389 389
 					$return = implode($searched_items);
390 390
 				}
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	/**
398 398
 	 * Formats the row for output on the screen.
399 399
 	 */	
400
-	public function format_row($row = false){
401
-		if(false !== $row){
400
+	public function format_row($row = false) {
401
+		if (false !== $row) {
402 402
 
403 403
 			$status = 'import';
404
-			if(0 !== $row->post_id){
404
+			if (0 !== $row->post_id) {
405 405
 				$status = '<a href="'.admin_url('/post.php?post='.$row->post_id.'&action=edit').'" target="_blank">'.get_post_status($row->post_id).'</a>';
406 406
 			}
407 407
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 					<strong>'.$row->name.'</strong> - '.$status.'
416 416
 				</td>
417 417
 				<td class="date column-date">
418
-					<abbr title="'.date('Y/m/d',strtotime($row->last_modified)).'">'.date('Y/m/d',strtotime($row->last_modified)).'</abbr><br>Last Modified
418
+					<abbr title="'.date('Y/m/d', strtotime($row->last_modified)).'">'.date('Y/m/d', strtotime($row->last_modified)).'</abbr><br>Last Modified
419 419
 				</td>
420 420
 				<td class="ssid column-ssid">
421 421
 					'.$row->meta_value.'
@@ -430,39 +430,39 @@  discard block
 block discarded – undo
430 430
 	 */
431 431
 	public function process_ajax_import() {
432 432
 		$return = false;
433
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])){
433
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) {
434 434
 			
435 435
 			$wetu_id = $_POST['wetu_id'];
436
-			if(isset($_POST['post_id'])){
436
+			if (isset($_POST['post_id'])) {
437 437
 				$post_id = $_POST['post_id'];	
438
-			}else{
438
+			}else {
439 439
 				$post_id = 0;
440 440
 			}
441 441
 
442
-			if(isset($_POST['team_members'])){
442
+			if (isset($_POST['team_members'])) {
443 443
 				$team_members = $_POST['team_members'];	
444
-			}else{
444
+			}else {
445 445
 				$team_members = false;
446 446
 			}
447 447
 
448 448
             $safari_brands = false;
449 449
 
450
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
450
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
451 451
 				$content = $_POST['content'];
452 452
 				delete_option('wetu_importer_destination_settings');
453
-				add_option('wetu_importer_destination_settings',$content);
454
-			}else{
453
+				add_option('wetu_importer_destination_settings', $content);
454
+			}else {
455 455
 				delete_option('wetu_importer_destination_settings');
456 456
 				$content = false;
457 457
 			}
458 458
 
459
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
460
-            if($jdata)
459
+            $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
460
+            if ($jdata)
461 461
             {
462
-                $adata=json_decode($jdata,true);
463
-                if(!empty($adata))
462
+                $adata = json_decode($jdata, true);
463
+                if (!empty($adata))
464 464
                 {
465
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
465
+                	$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
466 466
                 	$this->format_completed_row($return);
467 467
                 }
468 468
             }
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
 	/**
476 476
 	 * Connect to wetu
477 477
 	 */
478
-	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
478
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) {
479 479
 
480
-        if(trim($data[0]['type'])=='Destination')
480
+        if (trim($data[0]['type']) == 'Destination')
481 481
         {
482 482
 	        $post_name = $data_post_content = $data_post_excerpt = '';
483 483
 	        $post = array(
@@ -487,46 +487,46 @@  discard block
 block discarded – undo
487 487
 	        $content_used_general_description = false;
488 488
 
489 489
 	        //Set the post_content
490
-	        if(false !== $importable_content && in_array('description',$importable_content)){
491
-		        if(isset($data[0]['content']['extended_description']))
490
+	        if (false !== $importable_content && in_array('description', $importable_content)) {
491
+		        if (isset($data[0]['content']['extended_description']))
492 492
 		        {
493 493
 		            $data_post_content = $data[0]['content']['extended_description'];
494
-		        }elseif(isset($data[0]['content']['general_description'])){
494
+		        }elseif (isset($data[0]['content']['general_description'])) {
495 495
 		            $data_post_content = $data[0]['content']['general_description'];
496 496
 		            $content_used_general_description = true;
497
-		        }elseif(isset($data[0]['content']['teaser_description'])){
497
+		        }elseif (isset($data[0]['content']['teaser_description'])) {
498 498
 		        	$data_post_content = $data[0]['content']['teaser_description'];
499 499
 		        }
500 500
 	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
501 501
 	        }
502 502
 
503 503
 	        //set the post_excerpt
504
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
505
-		        if(isset($data[0]['content']['teaser_description'])){
504
+	        if (false !== $importable_content && in_array('excerpt', $importable_content)) {
505
+		        if (isset($data[0]['content']['teaser_description'])) {
506 506
 		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
507
-		        }elseif(isset($data[0]['content']['extended_description'])){
507
+		        }elseif (isset($data[0]['content']['extended_description'])) {
508 508
 					$data_post_excerpt = $data[0]['content']['extended_description'];
509
-				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
509
+				}elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
510 510
 		            $data_post_excerpt = $data[0]['content']['general_description'];
511 511
 		        }	   
512 512
 		        $post['post_excerpt'] = $data_post_excerpt;     	
513 513
 	        }
514 514
 
515
-	        if(false !== $id && '0' !== $id){
515
+	        if (false !== $id && '0' !== $id) {
516 516
 	        	$post['ID'] = $id;
517
-				if(isset($data[0]['name'])){
517
+				if (isset($data[0]['name'])) {
518 518
 					$post['post_title'] = $data[0]['name'];
519 519
 					$post['post_status'] = 'publish';
520
-					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
520
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
521 521
 				}
522 522
 	        	$id = wp_update_post($post);
523
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
524
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
525
-	        }else{
523
+	        	$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
524
+	        	update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
525
+	        }else {
526 526
 
527 527
 		        //Set the name
528
-		        if(isset($data[0]['name'])){
529
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
528
+		        if (isset($data[0]['name'])) {
529
+		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
530 530
 		        }
531 531
 	        	$post['post_name'] = $post_name;
532 532
 	        	$post['post_title'] = $data[0]['name'];
@@ -534,65 +534,65 @@  discard block
 block discarded – undo
534 534
 	        	$id = wp_insert_post($post);
535 535
 
536 536
 	        	//Save the WETU ID and the Last date it was modified.
537
-	        	if(false !== $id){
538
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
539
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
537
+	        	if (false !== $id) {
538
+	        		add_post_meta($id, 'lsx_wetu_id', $wetu_id);
539
+	        		add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
540 540
 	        	}
541 541
 	        }
542 542
 
543 543
 	        //Set the team member if it is there
544
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
545
-	        	$this->set_team_member($id,$team_members);
544
+	        if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
545
+	        	$this->set_team_member($id, $team_members);
546 546
 	    	}
547 547
 
548
-	        if(class_exists('LSX_TO_Maps')){
549
-	        	$this->set_map_data($data,$id,4);
548
+	        if (class_exists('LSX_TO_Maps')) {
549
+	        	$this->set_map_data($data, $id, 4);
550 550
 	        }
551 551
 
552 552
 	        //Set the Room Data
553
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
554
-	        	$this->set_video_data($data,$id);
553
+	        if (false !== $importable_content && in_array('videos', $importable_content)) {
554
+	        	$this->set_video_data($data, $id);
555 555
 	    	}
556 556
 
557 557
 			//Set the Electricity
558
-			if(false !== $importable_content && in_array('electricity',$importable_content)){
559
-				$this->set_travel_info($data,$id,'electricity');
558
+			if (false !== $importable_content && in_array('electricity', $importable_content)) {
559
+				$this->set_travel_info($data, $id, 'electricity');
560 560
 			}
561 561
 			//Set the cuisine
562
-			if(false !== $importable_content && in_array('cuisine',$importable_content)){
563
-				$this->set_travel_info($data,$id,'cuisine');
562
+			if (false !== $importable_content && in_array('cuisine', $importable_content)) {
563
+				$this->set_travel_info($data, $id, 'cuisine');
564 564
 			}
565 565
 			//Set the banking
566
-			if(false !== $importable_content && in_array('banking',$importable_content)){
567
-				$this->set_travel_info($data,$id,'banking');
566
+			if (false !== $importable_content && in_array('banking', $importable_content)) {
567
+				$this->set_travel_info($data, $id, 'banking');
568 568
 			}
569 569
 			//Set the transport
570
-			if(false !== $importable_content && in_array('transport',$importable_content)){
571
-				$this->set_travel_info($data,$id,'transport');
570
+			if (false !== $importable_content && in_array('transport', $importable_content)) {
571
+				$this->set_travel_info($data, $id, 'transport');
572 572
 			}
573 573
 			//Set the dress
574
-			if(false !== $importable_content && in_array('dress',$importable_content)){
575
-				$this->set_travel_info($data,$id,'dress');
574
+			if (false !== $importable_content && in_array('dress', $importable_content)) {
575
+				$this->set_travel_info($data, $id, 'dress');
576 576
 			}
577 577
 			//Set the climate
578
-			if(false !== $importable_content && in_array('climate',$importable_content)){
579
-				$this->set_travel_info($data,$id,'climate');
578
+			if (false !== $importable_content && in_array('climate', $importable_content)) {
579
+				$this->set_travel_info($data, $id, 'climate');
580 580
 			}
581 581
 
582 582
 			//Setup some default for use in the import
583
-			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
583
+			if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
584 584
 				$this->find_attachments($id);
585 585
 
586 586
 				//Set the featured image
587
-				if(false !== $importable_content && in_array('featured_image',$importable_content)){
588
-					$this->set_featured_image($data,$id);
587
+				if (false !== $importable_content && in_array('featured_image', $importable_content)) {
588
+					$this->set_featured_image($data, $id);
589 589
 				}
590
-				if(false !== $importable_content && in_array('banner_image',$importable_content)){
591
-					$this->set_banner_image($data,$id);
590
+				if (false !== $importable_content && in_array('banner_image', $importable_content)) {
591
+					$this->set_banner_image($data, $id);
592 592
 				}
593 593
 				//Import the main gallery
594
-				if(false !== $importable_content && in_array('gallery',$importable_content)){
595
-					$this->create_main_gallery($data,$id);
594
+				if (false !== $importable_content && in_array('gallery', $importable_content)) {
595
+					$this->create_main_gallery($data, $id);
596 596
 				}
597 597
 			}
598 598
 
@@ -603,65 +603,65 @@  discard block
 block discarded – undo
603 603
 	/**
604 604
 	 * Set the team memberon each item.
605 605
 	 */
606
-	public function set_team_member($id,$team_members) {
606
+	public function set_team_member($id, $team_members) {
607 607
 
608 608
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
609
-		foreach($team_members as $team){
610
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
609
+		foreach ($team_members as $team) {
610
+        	add_post_meta($id, 'team_to_'.$this->tab_slug, $team);			
611 611
 		}
612 612
 	}
613 613
 	
614 614
 	/**
615 615
 	 * Saves the longitude and lattitude, as well as sets the map marker.
616 616
 	 */
617
-	public function set_map_data($data,$id,$zoom=15) {
617
+	public function set_map_data($data, $id, $zoom = 15) {
618 618
 		$longitude = $latitude = $address = false;
619 619
 
620
-		if(isset($data[0]['position'])){
620
+		if (isset($data[0]['position'])) {
621 621
 
622
-			if(isset($data[0]['position']['driving_latitude'])){
622
+			if (isset($data[0]['position']['driving_latitude'])) {
623 623
 				$latitude = $data[0]['position']['driving_latitude'];
624
-			}elseif(isset($data[0]['position']['latitude'])){
624
+			}elseif (isset($data[0]['position']['latitude'])) {
625 625
 				$latitude = $data[0]['position']['latitude'];
626 626
 			}
627 627
 
628
-			if(isset($data[0]['position']['driving_longitude'])){
628
+			if (isset($data[0]['position']['driving_longitude'])) {
629 629
 				$longitude = $data[0]['position']['driving_longitude'];
630
-			}elseif(isset($data[0]['position']['longitude'])){
630
+			}elseif (isset($data[0]['position']['longitude'])) {
631 631
 				$longitude = $data[0]['position']['longitude'];
632 632
 			}		
633 633
 
634 634
 		}
635
-		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
636
-			if(isset($data[0]['content']['contact_information']['address'])){
635
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
636
+			if (isset($data[0]['content']['contact_information']['address'])) {
637 637
 				$address = strip_tags($data[0]['content']['contact_information']['address']);
638 638
 
639
-				$address = explode("\n",$address);
640
-				foreach($address as $bitkey => $bit){
639
+				$address = explode("\n", $address);
640
+				foreach ($address as $bitkey => $bit) {
641 641
 					$bit = ltrim(rtrim($bit));
642
-					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
642
+					if (false === $bit || '' === $bit || null === $bit or empty($bit)) {
643 643
 						unset($address[$bitkey]);
644 644
 					}
645 645
 				}
646
-				$address = implode(', ',$address);
646
+				$address = implode(', ', $address);
647 647
 				$address = str_replace(', , ', ', ', $address);
648 648
 			}	
649 649
 		}
650 650
 
651 651
 
652
-		if(false !== $longitude){
652
+		if (false !== $longitude) {
653 653
 			$location_data = array(
654
-				'address'	=>	(string)$address,
655
-				'lat'		=>	(string)$latitude,
656
-				'long'		=>	(string)$longitude,
657
-				'zoom'		=>	(string)$zoom,
654
+				'address'	=>	(string) $address,
655
+				'lat'		=>	(string) $latitude,
656
+				'long'		=>	(string) $longitude,
657
+				'zoom'		=>	(string) $zoom,
658 658
 				'elevation'	=>	'',
659 659
 			);
660
-			if(false !== $id && '0' !== $id){
661
-	        	$prev = get_post_meta($id,'location',true);
662
-	        	update_post_meta($id,'location',$location_data,$prev);
663
-	        }else{
664
-	        	add_post_meta($id,'location',$location_data,true);
660
+			if (false !== $id && '0' !== $id) {
661
+	        	$prev = get_post_meta($id, 'location', true);
662
+	        	update_post_meta($id, 'location', $location_data, $prev);
663
+	        }else {
664
+	        	add_post_meta($id, 'location', $location_data, true);
665 665
 	        }
666 666
 		}
667 667
 	}
@@ -669,11 +669,11 @@  discard block
 block discarded – undo
669 669
 	/**
670 670
 	 * Saves the room data
671 671
 	 */
672
-	public function set_travel_info($data,$id,$meta_key) {
672
+	public function set_travel_info($data, $id, $meta_key) {
673 673
 
674
-		if(!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])){
674
+		if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) {
675 675
 			$content = $data[0]['travel_information'][$meta_key];
676
-			$this->save_custom_field($content,$meta_key,$id);
676
+			$this->save_custom_field($content, $meta_key, $id);
677 677
 		}
678 678
 	}
679 679
 
Please login to merge, or discard this patch.