Completed
Push — master ( 2ddb6f...b67193 )
by Warwick
09:29 queued 04:49
created
classes/class-accommodation.php 1 patch
Indentation   +324 added lines, -324 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 screen_icon(); ?>
142 142
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 		$accommodation = json_decode($data, true);
315 315
 
316 316
 		if(isset($accommodation['error'])){
317
-		    return $accommodation['error'];
318
-        }elseif (isset($accommodation) && !empty($accommodation)) {
317
+			return $accommodation['error'];
318
+		}elseif (isset($accommodation) && !empty($accommodation)) {
319 319
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
320 320
 			return true;
321 321
 		}
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 					$keyphrases = $_POST['keyword'];
364 364
 				}else{
365 365
 					$keyphrases = array(0);
366
-                }
366
+				}
367 367
 
368 368
 				if(!is_array($keyphrases)){
369 369
 					$keyphrases = array($keyphrases);
@@ -460,13 +460,13 @@  discard block
 block discarded – undo
460 460
 	public function multineedle_stripos($haystack, $needles, $offset=0) {
461 461
 		$found = false;
462 462
 		$needle_count = count($needles);
463
-	    foreach($needles as $needle) {
464
-	    	if(false !== stripos($haystack, $needle, $offset)){
465
-	        	$found[] = true;
466
-	    	}
467
-	    }
468
-	    if(false !== $found && $needle_count === count($found)){ 
469
-	    	return true;
463
+		foreach($needles as $needle) {
464
+			if(false !== stripos($haystack, $needle, $offset)){
465
+				$found[] = true;
466
+			}
467
+		}
468
+		if(false !== $found && $needle_count === count($found)){ 
469
+			return true;
470 470
 		}else{
471 471
 			return false;
472 472
 		}
@@ -537,16 +537,16 @@  discard block
 block discarded – undo
537 537
 				$content = false;
538 538
 			}
539 539
 
540
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
541
-            if($jdata)
542
-            {
543
-                $adata=json_decode($jdata,true);
544
-                if(!empty($adata))
545
-                {
546
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
547
-                	$this->format_completed_row($return);
548
-                }
549
-            }
540
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
541
+			if($jdata)
542
+			{
543
+				$adata=json_decode($jdata,true);
544
+				if(!empty($adata))
545
+				{
546
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
547
+					$this->format_completed_row($return);
548
+				}
549
+			}
550 550
 
551 551
 			die();
552 552
 		}
@@ -563,148 +563,148 @@  discard block
 block discarded – undo
563 563
 	 */
564 564
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
565 565
 
566
-        if(trim($data[0]['type'])=='Accommodation')
567
-        {
568
-	        $post_name = $data_post_content = $data_post_excerpt = '';
569
-	        $post = array(
570
-	          'post_type'		=> 'accommodation',
571
-	        );
572
-
573
-	        $content_used_general_description = false;
574
-
575
-	        //Set the post_content
576
-	        if(false !== $importable_content && in_array('description',$importable_content)){
577
-		        if(isset($data[0]['content']['extended_description']))
578
-		        {
579
-		            $data_post_content = $data[0]['content']['extended_description'];
580
-		        }elseif(isset($data[0]['content']['general_description'])){
581
-		            $data_post_content = $data[0]['content']['general_description'];
582
-		            $content_used_general_description = true;
583
-		        }elseif(isset($data[0]['content']['teaser_description'])){
584
-		        	$data_post_content = $data[0]['content']['teaser_description'];
585
-		        }
586
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
587
-	        }
588
-
589
-	        //set the post_excerpt
590
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
591
-		        if(isset($data[0]['content']['teaser_description'])){
592
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
593
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
594
-		            $data_post_excerpt = $data[0]['content']['general_description'];
595
-		        }	   
596
-		        $post['post_excerpt'] = $data_post_excerpt;     	
597
-	        }
598
-
599
-	        if(false !== $id && '0' !== $id){
600
-	        	$post['ID'] = $id;
566
+		if(trim($data[0]['type'])=='Accommodation')
567
+		{
568
+			$post_name = $data_post_content = $data_post_excerpt = '';
569
+			$post = array(
570
+			  'post_type'		=> 'accommodation',
571
+			);
572
+
573
+			$content_used_general_description = false;
574
+
575
+			//Set the post_content
576
+			if(false !== $importable_content && in_array('description',$importable_content)){
577
+				if(isset($data[0]['content']['extended_description']))
578
+				{
579
+					$data_post_content = $data[0]['content']['extended_description'];
580
+				}elseif(isset($data[0]['content']['general_description'])){
581
+					$data_post_content = $data[0]['content']['general_description'];
582
+					$content_used_general_description = true;
583
+				}elseif(isset($data[0]['content']['teaser_description'])){
584
+					$data_post_content = $data[0]['content']['teaser_description'];
585
+				}
586
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
587
+			}
588
+
589
+			//set the post_excerpt
590
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
591
+				if(isset($data[0]['content']['teaser_description'])){
592
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
593
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
594
+					$data_post_excerpt = $data[0]['content']['general_description'];
595
+				}	   
596
+				$post['post_excerpt'] = $data_post_excerpt;     	
597
+			}
598
+
599
+			if(false !== $id && '0' !== $id){
600
+				$post['ID'] = $id;
601 601
 				if(isset($data[0]['name'])){
602 602
 					$post['post_title'] = $data[0]['name'];
603
-	        		$post['post_status'] = 'publish';
603
+					$post['post_status'] = 'publish';
604 604
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
605 605
 				}
606
-	        	$id = wp_update_post($post);
607
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
608
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
609
-	        }else{
610
-
611
-		        //Set the name
612
-		        if(isset($data[0]['name'])){
613
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
614
-		        }
615
-	        	$post['post_name'] = $post_name;
616
-	        	$post['post_title'] = $data[0]['name'];
617
-	        	$post['post_status'] = 'publish';
618
-	        	$id = wp_insert_post($post);
619
-
620
-	        	//Save the WETU ID and the Last date it was modified.
621
-	        	if(false !== $id){
622
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
623
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
624
-	        	}
625
-	        }
626
-	        //Setup some default for use in the import
627
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
606
+				$id = wp_update_post($post);
607
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
608
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
609
+			}else{
610
+
611
+				//Set the name
612
+				if(isset($data[0]['name'])){
613
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
614
+				}
615
+				$post['post_name'] = $post_name;
616
+				$post['post_title'] = $data[0]['name'];
617
+				$post['post_status'] = 'publish';
618
+				$id = wp_insert_post($post);
619
+
620
+				//Save the WETU ID and the Last date it was modified.
621
+				if(false !== $id){
622
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
623
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
624
+				}
625
+			}
626
+			//Setup some default for use in the import
627
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
628 628
 				$this->find_attachments($id);
629 629
 			}
630 630
 
631
-	        //Set the team member if it is there
632
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
633
-	        	$this->set_team_member($id,$team_members);
634
-	    	}
635
-
636
-	        //Set the safari brand
637
-	        if(false !== $safari_brands && '' !== $safari_brands){
638
-	        	$this->set_safari_brands($id,$safari_brands);
639
-
640
-	    	}	    	
641
-
642
-	        if(class_exists('LSX_TO_Maps')){
643
-	        	$this->set_map_data($data,$id);
644
-	        	$this->set_location_taxonomy($data,$id);
645
-	        }
646
-
647
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
648
-	        	$this->connect_destinations($data,$id);
649
-	        }
650
-
651
-	        if(false !== $importable_content && in_array('category',$importable_content)){
652
-	        	$this->set_taxonomy_style($data,$id);
653
-	        }
654
-
655
-	        //Set the Room Data
656
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
657
-	        	$this->set_room_data($data,$id);
658
-	    	}
659
-
660
-	    	//Set the rating
661
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
662
-	       		$this->set_rating($data,$id);
663
-	    	}
664
-
665
-	    	//Set the checkin checkout data
666
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
667
-	        	$this->set_checkin_checkout($data,$id);
668
-	        }
669
-
670
-	    	//Set the Spoken Languages
671
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
672
-	       		$this->set_spoken_languages($data,$id);
673
-	    	}
674
-
675
-	    	//Set the friendly options
676
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
677
-	       		$this->set_friendly($data,$id);
678
-	    	}
679
-
680
-	    	//Set the special_interests
681
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
682
-	       		$this->set_special_interests($data,$id);
683
-	    	}	    		    		        
684
-
685
-	        //Import the videos
686
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
687
-	        	$this->set_video_data($data,$id);
688
-	        }
689
-
690
-	        //Import the facilities
691
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
692
-	        	$this->set_facilities($data,$id);
693
-	        }	        
694
-
695
-	        //Set the featured image
696
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
697
-	        	$this->set_featured_image($data,$id);
698
-	        }
699
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
700
-	        	$this->set_banner_image($data,$id);
701
-	        }	        
702
-	        //Import the main gallery
703
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
704
-	    		$this->create_main_gallery($data,$id);
705
-	        }	        	        	        
706
-        }
707
-        return $id;
631
+			//Set the team member if it is there
632
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
633
+				$this->set_team_member($id,$team_members);
634
+			}
635
+
636
+			//Set the safari brand
637
+			if(false !== $safari_brands && '' !== $safari_brands){
638
+				$this->set_safari_brands($id,$safari_brands);
639
+
640
+			}	    	
641
+
642
+			if(class_exists('LSX_TO_Maps')){
643
+				$this->set_map_data($data,$id);
644
+				$this->set_location_taxonomy($data,$id);
645
+			}
646
+
647
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
648
+				$this->connect_destinations($data,$id);
649
+			}
650
+
651
+			if(false !== $importable_content && in_array('category',$importable_content)){
652
+				$this->set_taxonomy_style($data,$id);
653
+			}
654
+
655
+			//Set the Room Data
656
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
657
+				$this->set_room_data($data,$id);
658
+			}
659
+
660
+			//Set the rating
661
+			if(false !== $importable_content && in_array('rating',$importable_content)){
662
+		   		$this->set_rating($data,$id);
663
+			}
664
+
665
+			//Set the checkin checkout data
666
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
667
+				$this->set_checkin_checkout($data,$id);
668
+			}
669
+
670
+			//Set the Spoken Languages
671
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
672
+		   		$this->set_spoken_languages($data,$id);
673
+			}
674
+
675
+			//Set the friendly options
676
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
677
+		   		$this->set_friendly($data,$id);
678
+			}
679
+
680
+			//Set the special_interests
681
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
682
+		   		$this->set_special_interests($data,$id);
683
+			}	    		    		        
684
+
685
+			//Import the videos
686
+			if(false !== $importable_content && in_array('videos',$importable_content)){
687
+				$this->set_video_data($data,$id);
688
+			}
689
+
690
+			//Import the facilities
691
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
692
+				$this->set_facilities($data,$id);
693
+			}	        
694
+
695
+			//Set the featured image
696
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
697
+				$this->set_featured_image($data,$id);
698
+			}
699
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
700
+				$this->set_banner_image($data,$id);
701
+			}	        
702
+			//Import the main gallery
703
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
704
+				$this->create_main_gallery($data,$id);
705
+			}	        	        	        
706
+		}
707
+		return $id;
708 708
 	}
709 709
 
710 710
 	/**
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 
715 715
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
716 716
 		foreach($team_members as $team){
717
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
717
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
718 718
 		}
719 719
 	}
720 720
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 */
724 724
 	public function set_safari_brands($id,$safari_brands) {
725 725
 		foreach($safari_brands as $safari_brand){
726
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
726
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
727 727
 		}
728 728
 	}	
729 729
 	
@@ -775,11 +775,11 @@  discard block
 block discarded – undo
775 775
 				'elevation'	=>	'',
776 776
 			);
777 777
 			if(false !== $id && '0' !== $id){
778
-	        	$prev = get_post_meta($id,'location',true);
779
-	        	update_post_meta($id,'location',$location_data,$prev);
780
-	        }else{
781
-	        	add_post_meta($id,'location',$location_data,true);
782
-	        }
778
+				$prev = get_post_meta($id,'location',true);
779
+				update_post_meta($id,'location',$location_data,$prev);
780
+			}else{
781
+				add_post_meta($id,'location',$location_data,true);
782
+			}
783 783
 		}
784 784
 	}
785 785
 	/**
@@ -793,35 +793,35 @@  discard block
 block discarded – undo
793 793
 			if(isset($data[0]['position']['country'])){
794 794
 
795 795
 				if(!$term = term_exists(trim($data[0]['position']['country']), 'location'))
796
-		        {
797
-		            $term = wp_insert_term(trim($data[0]['position']['country']), 'location');
798
-		            if ( is_wp_error($term) ){
799
-		            	echo $term->get_error_message();
800
-		            }
801
-		            else {
802
-		            	wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
803
-		            }
804
-		        }
805
-		        else
806
-		        {
807
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
808
-		        }
809
-		        $country_id = intval($term['term_id']);
810
-		    }
796
+				{
797
+					$term = wp_insert_term(trim($data[0]['position']['country']), 'location');
798
+					if ( is_wp_error($term) ){
799
+						echo $term->get_error_message();
800
+					}
801
+					else {
802
+						wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
803
+					}
804
+				}
805
+				else
806
+				{
807
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
808
+				}
809
+				$country_id = intval($term['term_id']);
810
+			}
811 811
 
812 812
 			if(isset($data[0]['position']['destination'])){
813 813
 
814 814
 				$tax_args = array('parent'=>$country_id);
815 815
 				if(!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
816
-		        {
817
-		            $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
818
-		            if ( is_wp_error($term) ){echo $term->get_error_message();}
819
-		            else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
820
-		        }
821
-		        else
822
-		        {
823
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
824
-		        }				
816
+				{
817
+					$term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
818
+					if ( is_wp_error($term) ){echo $term->get_error_message();}
819
+					else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
820
+				}
821
+				else
822
+				{
823
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
824
+				}				
825 825
 			}		
826 826
 		}
827 827
 	}
@@ -831,28 +831,28 @@  discard block
 block discarded – undo
831 831
 	 */
832 832
 	public function connect_destinations($data,$id) {
833 833
 		if(isset($data[0]['position'])){
834
-		    $destinations = false;
835
-		    if(isset($data[0]['position']['country'])){
836
-		    	$destinations['country'] = $data[0]['position']['country'];
837
-		    }
838
-		    if(isset($data[0]['position']['destination'])){
839
-		    	$destinations['destination'] = $data[0]['position']['destination'];
840
-		    }
834
+			$destinations = false;
835
+			if(isset($data[0]['position']['country'])){
836
+				$destinations['country'] = $data[0]['position']['country'];
837
+			}
838
+			if(isset($data[0]['position']['destination'])){
839
+				$destinations['destination'] = $data[0]['position']['destination'];
840
+			}
841 841
 		    
842
-		    if(false !== $destinations){	
843
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
844
-		    	if(false === $prev_values || !is_array($prev_values)){
845
-		    		$prev_values = array();
846
-		    	}
847
-			    foreach($destinations as $key => $value){
848
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
849
-	                if (null !== $destination) {
850
-	                	if(!in_array($destination->ID,$prev_values)){
851
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
852
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
853
-	                	}
854
-	                } 		    	
855
-			    }	
842
+			if(false !== $destinations){	
843
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
844
+				if(false === $prev_values || !is_array($prev_values)){
845
+					$prev_values = array();
846
+				}
847
+				foreach($destinations as $key => $value){
848
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
849
+					if (null !== $destination) {
850
+						if(!in_array($destination->ID,$prev_values)){
851
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
852
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
853
+						}
854
+					} 		    	
855
+				}	
856 856
 			}
857 857
 		}
858 858
 	}	
@@ -864,15 +864,15 @@  discard block
 block discarded – undo
864 864
 		$terms = false;
865 865
 		if(isset($data[0]['category'])){
866 866
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
867
-	        {
868
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
869
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
870
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
871
-	        }
872
-	        else
873
-	        {
874
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
875
-	        }				
867
+			{
868
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
869
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
870
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
871
+			}
872
+			else
873
+			{
874
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
875
+			}				
876 876
 		}
877 877
 	}		
878 878
 
@@ -896,25 +896,25 @@  discard block
 block discarded – undo
896 896
 				$temp_room['type'] = 'room';
897 897
 
898 898
 				if(!empty($room['images']) && is_array($room['images'])){
899
-			    	$attachments_args = array(
900
-			    			'post_parent' => $id,
901
-			    			'post_status' => 'inherit',
902
-			    			'post_type' => 'attachment',
903
-			    			'order' => 'ASC',
904
-			    	);   	
905
-			    	$attachments = new WP_Query($attachments_args);
906
-			    	$found_attachments = array();
907
-
908
-			    	if($attachments->have_posts()){
909
-			    		foreach($attachments->posts as $attachment){
910
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
911
-			    		}
912
-			    	}
899
+					$attachments_args = array(
900
+							'post_parent' => $id,
901
+							'post_status' => 'inherit',
902
+							'post_type' => 'attachment',
903
+							'order' => 'ASC',
904
+					);   	
905
+					$attachments = new WP_Query($attachments_args);
906
+					$found_attachments = array();
907
+
908
+					if($attachments->have_posts()){
909
+						foreach($attachments->posts as $attachment){
910
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
911
+						}
912
+					}
913 913
 
914 914
 					$temp_room['gallery'] = array();
915 915
 					foreach($room['images'] as $image_data){
916
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
917
-			    	}
916
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
917
+					}
918 918
 				}
919 919
 				$rooms[] = $temp_room;
920 920
 			}
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 				delete_post_meta($id, 'units');				
924 924
 			}
925 925
 			foreach($rooms as $room){
926
-		        add_post_meta($id,'units',$room,false);			
926
+				add_post_meta($id,'units',$room,false);			
927 927
 			}
928 928
 
929 929
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -933,11 +933,11 @@  discard block
 block discarded – undo
933 933
 			}
934 934
 
935 935
 			if(false !== $id && '0' !== $id){
936
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
937
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
938
-	        }else{
939
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
940
-	        }
936
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
937
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
938
+			}else{
939
+				add_post_meta($id,'number_of_rooms',$room_count,true);
940
+			}
941 941
 		}
942 942
 	}
943 943
 
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 				delete_post_meta($id, 'videos');				
1047 1047
 			}
1048 1048
 			foreach($videos as $video){
1049
-		        add_post_meta($id,'videos',$video,false);			
1049
+				add_post_meta($id,'videos',$video,false);			
1050 1050
 			}
1051 1051
 		}
1052 1052
 	}	
@@ -1075,17 +1075,17 @@  discard block
 block discarded – undo
1075 1075
 
1076 1076
 	function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
1077 1077
 		if(!$term = term_exists($name, $taxonomy))
1078
-        {
1079
-        	if(false !== $parent){ $parent = array('parent'=>$parent); }
1080
-            $term = wp_insert_term(trim($name), $taxonomy,$parent);
1081
-            if ( is_wp_error($term) ){echo $term->get_error_message();}
1082
-            else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1083
-        }
1084
-        else
1085
-        {
1086
-            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1087
-        }
1088
-        return $term['term_id'];
1078
+		{
1079
+			if(false !== $parent){ $parent = array('parent'=>$parent); }
1080
+			$term = wp_insert_term(trim($name), $taxonomy,$parent);
1081
+			if ( is_wp_error($term) ){echo $term->get_error_message();}
1082
+			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1083
+		}
1084
+		else
1085
+		{
1086
+			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1087
+		}
1088
+		return $term['term_id'];
1089 1089
 	}	
1090 1090
 
1091 1091
 	/**
@@ -1093,17 +1093,17 @@  discard block
 block discarded – undo
1093 1093
 	 */
1094 1094
 	public function set_featured_image($data,$id) {
1095 1095
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1096
-	    	$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1096
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1097 1097
 
1098
-	    	if(false !== $this->featured_image){
1099
-	    		delete_post_meta($id,'_thumbnail_id');
1100
-	    		add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1098
+			if(false !== $this->featured_image){
1099
+				delete_post_meta($id,'_thumbnail_id');
1100
+				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1101 1101
 
1102
-	    		if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1103
-	    			add_post_meta($id,'gallery',$this->featured_image,false);
1104
-	    			$this->gallery_meta[] = $this->featured_image;
1105
-	    		}
1106
-	    	}			
1102
+				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1103
+					add_post_meta($id,'gallery',$this->featured_image,false);
1104
+					$this->gallery_meta[] = $this->featured_image;
1105
+				}
1106
+			}			
1107 1107
 		}	
1108 1108
 	}	
1109 1109
 
@@ -1112,18 +1112,18 @@  discard block
 block discarded – undo
1112 1112
 	 */
1113 1113
 	public function set_banner_image($data,$id) {
1114 1114
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1115
-	    	$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1116
-
1117
-	    	if(false !== $this->banner_image){
1118
-	    		delete_post_meta($id,'image_group');
1119
-	    		$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1120
-	    		add_post_meta($id,'image_group',$new_banner,true);
1121
-
1122
-	    		if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1123
-	    			add_post_meta($id,'gallery',$this->banner_image,false);
1124
-	    			$this->gallery_meta[] = $this->banner_image;
1125
-	    		}
1126
-	    	}			
1115
+			$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1116
+
1117
+			if(false !== $this->banner_image){
1118
+				delete_post_meta($id,'image_group');
1119
+				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1120
+				add_post_meta($id,'image_group',$new_banner,true);
1121
+
1122
+				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1123
+					add_post_meta($id,'gallery',$this->banner_image,false);
1124
+					$this->gallery_meta[] = $this->banner_image;
1125
+				}
1126
+			}			
1127 1127
 		}	
1128 1128
 	}		
1129 1129
 
@@ -1133,24 +1133,24 @@  discard block
 block discarded – undo
1133 1133
 	public function create_main_gallery($data,$id) {
1134 1134
 
1135 1135
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1136
-	    	$counter = 0;
1137
-	    	foreach($data[0]['content']['images'] as $image_data){
1138
-	    		if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
1139
-	    		if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
1140
-
1141
-	    		$this->gallery_meta[] = $this->attach_image($image_data,$id);
1142
-	    		$counter++;
1143
-	    	}
1144
-
1145
-	    	if(!empty($this->gallery_meta)){
1146
-	    		delete_post_meta($id,'gallery');
1147
-	    		foreach($this->gallery_meta as $gallery_id){
1148
-	    			if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1149
-	    				add_post_meta($id,'gallery',$gallery_id,false);
1150
-	    			}
1151
-	    		}
1152
-	    	}
1153
-    	}
1136
+			$counter = 0;
1137
+			foreach($data[0]['content']['images'] as $image_data){
1138
+				if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
1139
+				if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
1140
+
1141
+				$this->gallery_meta[] = $this->attach_image($image_data,$id);
1142
+				$counter++;
1143
+			}
1144
+
1145
+			if(!empty($this->gallery_meta)){
1146
+				delete_post_meta($id,'gallery');
1147
+				foreach($this->gallery_meta as $gallery_id){
1148
+					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1149
+						add_post_meta($id,'gallery',$gallery_id,false);
1150
+					}
1151
+				}
1152
+			}
1153
+		}
1154 1154
 	}	
1155 1155
 
1156 1156
 	/**
@@ -1159,42 +1159,42 @@  discard block
 block discarded – undo
1159 1159
 	public function attach_image($v=false,$parent_id,$image_sizes=false){
1160 1160
 		if(false !== $v){
1161 1161
 	   		$temp_fragment = explode('/',$v['url_fragment']);
1162
-	    	$url_filename = $temp_fragment[count($temp_fragment)-1];
1163
-	    	$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1162
+			$url_filename = $temp_fragment[count($temp_fragment)-1];
1163
+			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1164 1164
 
1165
-	    	if(in_array($url_filename,$this->found_attachments)){
1166
-	    		return array_search($url_filename,$this->found_attachments);
1167
-	    	}
1165
+			if(in_array($url_filename,$this->found_attachments)){
1166
+				return array_search($url_filename,$this->found_attachments);
1167
+			}
1168 1168
 	    	               
1169
-	        $postdata=array();
1170
-	        if(empty($v['label']))
1171
-	        {
1172
-	            $v['label']='';
1173
-	        }
1174
-	        if(!empty($v['description']))
1175
-	        {
1176
-	            $desc=wp_strip_all_tags($v['description']);
1177
-	            $posdata=array('post_excerpt'=>$desc);
1178
-	        }
1179
-	        if(!empty($v['section']))
1180
-	        {
1181
-	            $desc=wp_strip_all_tags($v['section']);
1182
-	            $posdata=array('post_excerpt'=>$desc);
1183
-	        }
1184
-
1185
-	        $attachID=NULL;  
1186
-	        //Resizor - add option to setting if required
1187
-	        $fragment = str_replace(' ','%20',$v['url_fragment']);
1188
-	        $url = $this->get_scaling_url($image_sizes).$fragment;
1189
-	        $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1190
-
1191
-	        //echo($attachID.' add image');
1192
-	        if($attachID!=NULL)
1193
-	        {
1194
-	            return $attachID;
1195
-	        }
1196
-        }	
1197
-        return 	false;
1169
+			$postdata=array();
1170
+			if(empty($v['label']))
1171
+			{
1172
+				$v['label']='';
1173
+			}
1174
+			if(!empty($v['description']))
1175
+			{
1176
+				$desc=wp_strip_all_tags($v['description']);
1177
+				$posdata=array('post_excerpt'=>$desc);
1178
+			}
1179
+			if(!empty($v['section']))
1180
+			{
1181
+				$desc=wp_strip_all_tags($v['section']);
1182
+				$posdata=array('post_excerpt'=>$desc);
1183
+			}
1184
+
1185
+			$attachID=NULL;  
1186
+			//Resizor - add option to setting if required
1187
+			$fragment = str_replace(' ','%20',$v['url_fragment']);
1188
+			$url = $this->get_scaling_url($image_sizes).$fragment;
1189
+			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1190
+
1191
+			//echo($attachID.' add image');
1192
+			if($attachID!=NULL)
1193
+			{
1194
+				return $attachID;
1195
+			}
1196
+		}	
1197
+		return 	false;
1198 1198
 	}
1199 1199
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1200 1200
 	
Please login to merge, or discard this patch.
classes/class-admin.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * Display the importer administration screen
79 79
 	 */
80 80
 	public function display_page() {
81
-        ?>
81
+		?>
82 82
         <div class="wrap">
83 83
             <?php screen_icon(); ?>
84 84
 
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 		            </ul> 
101 101
 	             	            
102 102
             <?php } else {
103
-            	do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
104
-            } ?>
103
+				do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
104
+			} ?>
105 105
         </div>
106 106
         <?php
107 107
 	}
@@ -148,37 +148,37 @@  discard block
 block discarded – undo
148 148
 	 * set_taxonomy with some terms
149 149
 	 */
150 150
 	public function set_taxonomy($taxonomy,$terms,$id) {
151
-        $result=array();
152
-        if(!empty($data))
153
-        {
154
-            foreach($data as $k)
155
-            {
156
-                if($id)
157
-                {
158
-                    if(!$term = term_exists(trim($k), $tax))
159
-                    {
160
-                        $term = wp_insert_term(trim($k), $tax);
161
-                        if ( is_wp_error($term) )
162
-                        {
163
-                            echo $term->get_error_message();
164
-                        }
165
-                        else
166
-                        {
167
-                            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
168
-                        }
169
-                    }
170
-                    else
171
-                    {
172
-                        wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
173
-                    }
174
-                }
175
-                else
176
-                {
177
-                    $result[]=trim($k);
178
-                }
179
-            }
180
-        }
181
-        return $result;
151
+		$result=array();
152
+		if(!empty($data))
153
+		{
154
+			foreach($data as $k)
155
+			{
156
+				if($id)
157
+				{
158
+					if(!$term = term_exists(trim($k), $tax))
159
+					{
160
+						$term = wp_insert_term(trim($k), $tax);
161
+						if ( is_wp_error($term) )
162
+						{
163
+							echo $term->get_error_message();
164
+						}
165
+						else
166
+						{
167
+							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
168
+						}
169
+					}
170
+					else
171
+					{
172
+						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
173
+					}
174
+				}
175
+				else
176
+				{
177
+					$result[]=trim($k);
178
+				}
179
+			}
180
+		}
181
+		return $result;
182 182
 	}
183 183
 
184 184
 	/**
@@ -188,21 +188,21 @@  discard block
 block discarded – undo
188 188
 		if(post_type_exists('team')) { ?>
189 189
     		<ul>
190 190
     			<?php
191
-    				$team_args=array(
192
-    					'post_type'	=>	'team',
193
-    					'post_status' => 'publish',
194
-    					'nopagin' => true,
195
-    					'fields' => 'ids'
196
-    				);
197
-    				$team_members = new WP_Query($team_args);
198
-    					if($team_members->have_posts()){
199
-    						foreach($team_members->posts as $member){ ?>
191
+					$team_args=array(
192
+						'post_type'	=>	'team',
193
+						'post_status' => 'publish',
194
+						'nopagin' => true,
195
+						'fields' => 'ids'
196
+					);
197
+					$team_members = new WP_Query($team_args);
198
+						if($team_members->have_posts()){
199
+							foreach($team_members->posts as $member){ ?>
200 200
     							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
201 201
     						<?php }
202
-    					}else{ ?>
202
+						}else{ ?>
203 203
     							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
204 204
     					<?php }
205
-    				?>
205
+					?>
206 206
     		</ul>
207 207
     	<?php }		
208 208
 	}
@@ -254,42 +254,42 @@  discard block
 block discarded – undo
254 254
 		if(false !== $id){
255 255
 			if(empty($this->found_attachments)){
256 256
 
257
-		    	$attachments_args = array(
258
-		    			'post_parent' => $id,
259
-		    			'post_status' => 'inherit',
260
-		    			'post_type' => 'attachment',
261
-		    			'order' => 'ASC',
262
-                        'nopagin' => 'true',
263
-                        'posts_per_page' => '-1'
264
-		    	);   	
257
+				$attachments_args = array(
258
+						'post_parent' => $id,
259
+						'post_status' => 'inherit',
260
+						'post_type' => 'attachment',
261
+						'order' => 'ASC',
262
+						'nopagin' => 'true',
263
+						'posts_per_page' => '-1'
264
+				);   	
265 265
 		    	 
266
-		    	$attachments = new WP_Query($attachments_args);
267
-		    	if($attachments->have_posts()){
268
-		    		foreach($attachments->posts as $attachment){
269
-		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
270
-		    			$this->gallery_meta[] = $attachment->ID;
271
-		    		}
272
-		    	}
266
+				$attachments = new WP_Query($attachments_args);
267
+				if($attachments->have_posts()){
268
+					foreach($attachments->posts as $attachment){
269
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
270
+						$this->gallery_meta[] = $attachment->ID;
271
+					}
272
+				}
273 273
 			}
274 274
 		}
275 275
 	}
276 276
 
277 277
 	/**
278 278
 	 * Checks to see if an item is selected.
279
-     *
280
-     * @param $haystack array|string
281
-     * @param $needle string
282
-     * @return string
279
+	 *
280
+	 * @param $haystack array|string
281
+	 * @param $needle string
282
+	 * @return string
283 283
 	 */
284 284
 	public function checked($haystack=false,$needle='') {
285
-	    $return = '';
286
-	    if(!is_array($haystack)){
285
+		$return = '';
286
+		if(!is_array($haystack)){
287 287
 			$haystack = array($haystack);
288
-        }
289
-        if(in_array($needle,$haystack)){
288
+		}
289
+		if(in_array($needle,$haystack)){
290 290
 			$return = 'checked="checked"';
291
-        }
292
-	    echo $return;
291
+		}
292
+		echo $return;
293 293
 	}
294 294
 }
295 295
 $wetu_importer_admin = new WETU_Importer_Admin();
296 296
\ No newline at end of file
Please login to merge, or discard this patch.