Passed
Push — master ( ace7b0...2939bf )
by Warwick
03:18
created
classes/class-accommodation.php 1 patch
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * Display the importer administration screen
123 123
 	 */
124 124
 	public function display_page() {
125
-        ?>
125
+		?>
126 126
         <div class="wrap">
127 127
             <?php screen_icon(); ?>
128 128
 
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 		$accommodation = json_decode($data, true);
301 301
 
302 302
 		if(isset($accommodation['error'])){
303
-		    return $accommodation['error'];
304
-        }elseif (isset($accommodation) && !empty($accommodation)) {
303
+			return $accommodation['error'];
304
+		}elseif (isset($accommodation) && !empty($accommodation)) {
305 305
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
306 306
 			return true;
307 307
 		}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 					$keyphrases = $_POST['keyword'];
350 350
 				}else{
351 351
 					$keyphrases = array(0);
352
-                }
352
+				}
353 353
 
354 354
 				if(!is_array($keyphrases)){
355 355
 					$keyphrases = array($keyphrases);
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 	public function multineedle_stripos($haystack, $needles, $offset=0) {
447 447
 		$found = false;
448 448
 		$needle_count = count($needles);
449
-	    foreach($needles as $needle) {
450
-	    	if(false !== stripos($haystack, $needle, $offset)){
451
-	        	$found[] = true;
452
-	    	}
453
-	    }
454
-	    if(false !== $found && $needle_count === count($found)){ 
455
-	    	return true;
449
+		foreach($needles as $needle) {
450
+			if(false !== stripos($haystack, $needle, $offset)){
451
+				$found[] = true;
452
+			}
453
+		}
454
+		if(false !== $found && $needle_count === count($found)){ 
455
+			return true;
456 456
 		}else{
457 457
 			return false;
458 458
 		}
@@ -521,16 +521,16 @@  discard block
 block discarded – undo
521 521
 				$content = false;
522 522
 			}
523 523
 
524
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
525
-            if($jdata)
526
-            {
527
-                $adata=json_decode($jdata,true);
528
-                if(!empty($adata))
529
-                {
530
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
531
-                	$this->format_completed_row($return);
532
-                }
533
-            }
524
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
525
+			if($jdata)
526
+			{
527
+				$adata=json_decode($jdata,true);
528
+				if(!empty($adata))
529
+				{
530
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
531
+					$this->format_completed_row($return);
532
+				}
533
+			}
534 534
 
535 535
 			die();
536 536
 		}
@@ -547,148 +547,148 @@  discard block
 block discarded – undo
547 547
 	 */
548 548
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
549 549
 
550
-        if(trim($data[0]['type'])=='Accommodation')
551
-        {
552
-	        $post_name = $data_post_content = $data_post_excerpt = '';
553
-	        $post = array(
554
-	          'post_type'		=> 'accommodation',
555
-	        );
556
-
557
-	        $content_used_general_description = false;
558
-
559
-	        //Set the post_content
560
-	        if(false !== $importable_content && in_array('description',$importable_content)){
561
-		        if(isset($data[0]['content']['extended_description']))
562
-		        {
563
-		            $data_post_content = $data[0]['content']['extended_description'];
564
-		        }elseif(isset($data[0]['content']['general_description'])){
565
-		            $data_post_content = $data[0]['content']['general_description'];
566
-		            $content_used_general_description = true;
567
-		        }elseif(isset($data[0]['content']['teaser_description'])){
568
-		        	$data_post_content = $data[0]['content']['teaser_description'];
569
-		        }
570
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
571
-	        }
572
-
573
-	        //set the post_excerpt
574
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
575
-		        if(isset($data[0]['content']['teaser_description'])){
576
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
577
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
578
-		            $data_post_excerpt = $data[0]['content']['general_description'];
579
-		        }	   
580
-		        $post['post_excerpt'] = $data_post_excerpt;     	
581
-	        }
582
-
583
-	        if(false !== $id && '0' !== $id){
584
-	        	$post['ID'] = $id;
550
+		if(trim($data[0]['type'])=='Accommodation')
551
+		{
552
+			$post_name = $data_post_content = $data_post_excerpt = '';
553
+			$post = array(
554
+			  'post_type'		=> 'accommodation',
555
+			);
556
+
557
+			$content_used_general_description = false;
558
+
559
+			//Set the post_content
560
+			if(false !== $importable_content && in_array('description',$importable_content)){
561
+				if(isset($data[0]['content']['extended_description']))
562
+				{
563
+					$data_post_content = $data[0]['content']['extended_description'];
564
+				}elseif(isset($data[0]['content']['general_description'])){
565
+					$data_post_content = $data[0]['content']['general_description'];
566
+					$content_used_general_description = true;
567
+				}elseif(isset($data[0]['content']['teaser_description'])){
568
+					$data_post_content = $data[0]['content']['teaser_description'];
569
+				}
570
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
571
+			}
572
+
573
+			//set the post_excerpt
574
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
575
+				if(isset($data[0]['content']['teaser_description'])){
576
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
577
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
578
+					$data_post_excerpt = $data[0]['content']['general_description'];
579
+				}	   
580
+				$post['post_excerpt'] = $data_post_excerpt;     	
581
+			}
582
+
583
+			if(false !== $id && '0' !== $id){
584
+				$post['ID'] = $id;
585 585
 				if(isset($data[0]['name'])){
586 586
 					$post['post_title'] = $data[0]['name'];
587
-	        		$post['post_status'] = 'publish';
587
+					$post['post_status'] = 'publish';
588 588
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
589 589
 				}
590
-	        	$id = wp_update_post($post);
591
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
592
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
593
-	        }else{
594
-
595
-		        //Set the name
596
-		        if(isset($data[0]['name'])){
597
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
598
-		        }
599
-	        	$post['post_name'] = $post_name;
600
-	        	$post['post_title'] = $data[0]['name'];
601
-	        	$post['post_status'] = 'publish';
602
-	        	$id = wp_insert_post($post);
603
-
604
-	        	//Save the WETU ID and the Last date it was modified.
605
-	        	if(false !== $id){
606
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
607
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
608
-	        	}
609
-	        }
610
-	        //Setup some default for use in the import
611
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
590
+				$id = wp_update_post($post);
591
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
592
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
593
+			}else{
594
+
595
+				//Set the name
596
+				if(isset($data[0]['name'])){
597
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
598
+				}
599
+				$post['post_name'] = $post_name;
600
+				$post['post_title'] = $data[0]['name'];
601
+				$post['post_status'] = 'publish';
602
+				$id = wp_insert_post($post);
603
+
604
+				//Save the WETU ID and the Last date it was modified.
605
+				if(false !== $id){
606
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
607
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
608
+				}
609
+			}
610
+			//Setup some default for use in the import
611
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
612 612
 				$this->find_attachments($id);
613 613
 			}
614 614
 
615
-	        //Set the team member if it is there
616
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
617
-	        	$this->set_team_member($id,$team_members);
618
-	    	}
619
-
620
-	        //Set the safari brand
621
-	        if(false !== $safari_brands && '' !== $safari_brands){
622
-	        	$this->set_safari_brands($id,$safari_brands);
623
-
624
-	    	}	    	
625
-
626
-	        if(class_exists('LSX_TO_Maps')){
627
-	        	$this->set_map_data($data,$id);
628
-	        	$this->set_location_taxonomy($data,$id);
629
-	        }
630
-
631
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
632
-	        	$this->connect_destinations($data,$id);
633
-	        }
634
-
635
-	        if(false !== $importable_content && in_array('category',$importable_content)){
636
-	        	$this->set_taxonomy_style($data,$id);
637
-	        }
638
-
639
-	        //Set the Room Data
640
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
641
-	        	$this->set_room_data($data,$id);
642
-	    	}
643
-
644
-	    	//Set the rating
645
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
646
-	       		$this->set_rating($data,$id);
647
-	    	}
648
-
649
-	    	//Set the checkin checkout data
650
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
651
-	        	$this->set_checkin_checkout($data,$id);
652
-	        }
653
-
654
-	    	//Set the Spoken Languages
655
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
656
-	       		$this->set_spoken_languages($data,$id);
657
-	    	}
658
-
659
-	    	//Set the friendly options
660
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
661
-	       		$this->set_friendly($data,$id);
662
-	    	}
663
-
664
-	    	//Set the special_interests
665
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
666
-	       		$this->set_special_interests($data,$id);
667
-	    	}	    		    		        
668
-
669
-	        //Import the videos
670
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
671
-	        	$this->set_video_data($data,$id);
672
-	        }
673
-
674
-	        //Import the facilities
675
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
676
-	        	$this->set_facilities($data,$id);
677
-	        }	        
678
-
679
-	        //Set the featured image
680
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
681
-	        	$this->set_featured_image($data,$id);
682
-	        }
683
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
684
-	        	$this->set_banner_image($data,$id);
685
-	        }	        
686
-	        //Import the main gallery
687
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
688
-	    		$this->create_main_gallery($data,$id);
689
-	        }	        	        	        
690
-        }
691
-        return $id;
615
+			//Set the team member if it is there
616
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
617
+				$this->set_team_member($id,$team_members);
618
+			}
619
+
620
+			//Set the safari brand
621
+			if(false !== $safari_brands && '' !== $safari_brands){
622
+				$this->set_safari_brands($id,$safari_brands);
623
+
624
+			}	    	
625
+
626
+			if(class_exists('LSX_TO_Maps')){
627
+				$this->set_map_data($data,$id);
628
+				$this->set_location_taxonomy($data,$id);
629
+			}
630
+
631
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
632
+				$this->connect_destinations($data,$id);
633
+			}
634
+
635
+			if(false !== $importable_content && in_array('category',$importable_content)){
636
+				$this->set_taxonomy_style($data,$id);
637
+			}
638
+
639
+			//Set the Room Data
640
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
641
+				$this->set_room_data($data,$id);
642
+			}
643
+
644
+			//Set the rating
645
+			if(false !== $importable_content && in_array('rating',$importable_content)){
646
+		   		$this->set_rating($data,$id);
647
+			}
648
+
649
+			//Set the checkin checkout data
650
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
651
+				$this->set_checkin_checkout($data,$id);
652
+			}
653
+
654
+			//Set the Spoken Languages
655
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
656
+		   		$this->set_spoken_languages($data,$id);
657
+			}
658
+
659
+			//Set the friendly options
660
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
661
+		   		$this->set_friendly($data,$id);
662
+			}
663
+
664
+			//Set the special_interests
665
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
666
+		   		$this->set_special_interests($data,$id);
667
+			}	    		    		        
668
+
669
+			//Import the videos
670
+			if(false !== $importable_content && in_array('videos',$importable_content)){
671
+				$this->set_video_data($data,$id);
672
+			}
673
+
674
+			//Import the facilities
675
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
676
+				$this->set_facilities($data,$id);
677
+			}	        
678
+
679
+			//Set the featured image
680
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
681
+				$this->set_featured_image($data,$id);
682
+			}
683
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
684
+				$this->set_banner_image($data,$id);
685
+			}	        
686
+			//Import the main gallery
687
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
688
+				$this->create_main_gallery($data,$id);
689
+			}	        	        	        
690
+		}
691
+		return $id;
692 692
 	}
693 693
 
694 694
 	/**
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 
699 699
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
700 700
 		foreach($team_members as $team){
701
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
701
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
702 702
 		}
703 703
 	}
704 704
 
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 	 */
708 708
 	public function set_safari_brands($id,$safari_brands) {
709 709
 		foreach($safari_brands as $safari_brand){
710
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
710
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
711 711
 		}
712 712
 	}	
713 713
 	
@@ -759,11 +759,11 @@  discard block
 block discarded – undo
759 759
 				'elevation'	=>	'',
760 760
 			);
761 761
 			if(false !== $id && '0' !== $id){
762
-	        	$prev = get_post_meta($id,'location',true);
763
-	        	update_post_meta($id,'location',$location_data,$prev);
764
-	        }else{
765
-	        	add_post_meta($id,'location',$location_data,true);
766
-	        }
762
+				$prev = get_post_meta($id,'location',true);
763
+				update_post_meta($id,'location',$location_data,$prev);
764
+			}else{
765
+				add_post_meta($id,'location',$location_data,true);
766
+			}
767 767
 		}
768 768
 	}
769 769
 	/**
@@ -777,35 +777,35 @@  discard block
 block discarded – undo
777 777
 			if(isset($data[0]['position']['country'])){
778 778
 
779 779
 				if(!$term = term_exists(trim($data[0]['position']['country']), 'location'))
780
-		        {
781
-		            $term = wp_insert_term(trim($data[0]['position']['country']), 'location');
782
-		            if ( is_wp_error($term) ){
783
-		            	echo $term->get_error_message();
784
-		            }
785
-		            else {
786
-		            	wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
787
-		            }
788
-		        }
789
-		        else
790
-		        {
791
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
792
-		        }
793
-		        $country_id = intval($term['term_id']);
794
-		    }
780
+				{
781
+					$term = wp_insert_term(trim($data[0]['position']['country']), 'location');
782
+					if ( is_wp_error($term) ){
783
+						echo $term->get_error_message();
784
+					}
785
+					else {
786
+						wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
787
+					}
788
+				}
789
+				else
790
+				{
791
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
792
+				}
793
+				$country_id = intval($term['term_id']);
794
+			}
795 795
 
796 796
 			if(isset($data[0]['position']['destination'])){
797 797
 
798 798
 				$tax_args = array('parent'=>$country_id);
799 799
 				if(!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
800
-		        {
801
-		            $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
802
-		            if ( is_wp_error($term) ){echo $term->get_error_message();}
803
-		            else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
804
-		        }
805
-		        else
806
-		        {
807
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
808
-		        }				
800
+				{
801
+					$term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
802
+					if ( is_wp_error($term) ){echo $term->get_error_message();}
803
+					else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
804
+				}
805
+				else
806
+				{
807
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
808
+				}				
809 809
 			}		
810 810
 		}
811 811
 	}
@@ -815,28 +815,28 @@  discard block
 block discarded – undo
815 815
 	 */
816 816
 	public function connect_destinations($data,$id) {
817 817
 		if(isset($data[0]['position'])){
818
-		    $destinations = false;
819
-		    if(isset($data[0]['position']['country'])){
820
-		    	$destinations['country'] = $data[0]['position']['country'];
821
-		    }
822
-		    if(isset($data[0]['position']['destination'])){
823
-		    	$destinations['destination'] = $data[0]['position']['destination'];
824
-		    }
818
+			$destinations = false;
819
+			if(isset($data[0]['position']['country'])){
820
+				$destinations['country'] = $data[0]['position']['country'];
821
+			}
822
+			if(isset($data[0]['position']['destination'])){
823
+				$destinations['destination'] = $data[0]['position']['destination'];
824
+			}
825 825
 		    
826
-		    if(false !== $destinations){	
827
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
828
-		    	if(false === $prev_values || !is_array($prev_values)){
829
-		    		$prev_values = array();
830
-		    	}
831
-			    foreach($destinations as $key => $value){
832
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
833
-	                if (null !== $destination) {
834
-	                	if(!in_array($destination->ID,$prev_values)){
835
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
836
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
837
-	                	}
838
-	                } 		    	
839
-			    }	
826
+			if(false !== $destinations){	
827
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
828
+				if(false === $prev_values || !is_array($prev_values)){
829
+					$prev_values = array();
830
+				}
831
+				foreach($destinations as $key => $value){
832
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
833
+					if (null !== $destination) {
834
+						if(!in_array($destination->ID,$prev_values)){
835
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
836
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
837
+						}
838
+					} 		    	
839
+				}	
840 840
 			}
841 841
 		}
842 842
 	}	
@@ -848,15 +848,15 @@  discard block
 block discarded – undo
848 848
 		$terms = false;
849 849
 		if(isset($data[0]['category'])){
850 850
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
851
-	        {
852
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
853
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
854
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
855
-	        }
856
-	        else
857
-	        {
858
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
859
-	        }				
851
+			{
852
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
853
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
854
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
855
+			}
856
+			else
857
+			{
858
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
859
+			}				
860 860
 		}
861 861
 	}		
862 862
 
@@ -880,25 +880,25 @@  discard block
 block discarded – undo
880 880
 				$temp_room['type'] = 'room';
881 881
 
882 882
 				if(!empty($room['images']) && is_array($room['images'])){
883
-			    	$attachments_args = array(
884
-			    			'post_parent' => $id,
885
-			    			'post_status' => 'inherit',
886
-			    			'post_type' => 'attachment',
887
-			    			'order' => 'ASC',
888
-			    	);   	
889
-			    	$attachments = new WP_Query($attachments_args);
890
-			    	$found_attachments = array();
891
-
892
-			    	if($attachments->have_posts()){
893
-			    		foreach($attachments->posts as $attachment){
894
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
895
-			    		}
896
-			    	}
883
+					$attachments_args = array(
884
+							'post_parent' => $id,
885
+							'post_status' => 'inherit',
886
+							'post_type' => 'attachment',
887
+							'order' => 'ASC',
888
+					);   	
889
+					$attachments = new WP_Query($attachments_args);
890
+					$found_attachments = array();
891
+
892
+					if($attachments->have_posts()){
893
+						foreach($attachments->posts as $attachment){
894
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
895
+						}
896
+					}
897 897
 
898 898
 					$temp_room['gallery'] = array();
899 899
 					foreach($room['images'] as $image_data){
900
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
901
-			    	}
900
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
901
+					}
902 902
 				}
903 903
 				$rooms[] = $temp_room;
904 904
 			}
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 				delete_post_meta($id, 'units');				
908 908
 			}
909 909
 			foreach($rooms as $room){
910
-		        add_post_meta($id,'units',$room,false);			
910
+				add_post_meta($id,'units',$room,false);			
911 911
 			}
912 912
 
913 913
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -917,11 +917,11 @@  discard block
 block discarded – undo
917 917
 			}
918 918
 
919 919
 			if(false !== $id && '0' !== $id){
920
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
921
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
922
-	        }else{
923
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
924
-	        }
920
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
921
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
922
+			}else{
923
+				add_post_meta($id,'number_of_rooms',$room_count,true);
924
+			}
925 925
 		}
926 926
 	}
927 927
 
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 				delete_post_meta($id, 'videos');				
1031 1031
 			}
1032 1032
 			foreach($videos as $video){
1033
-		        add_post_meta($id,'videos',$video,false);			
1033
+				add_post_meta($id,'videos',$video,false);			
1034 1034
 			}
1035 1035
 		}
1036 1036
 	}	
@@ -1059,17 +1059,17 @@  discard block
 block discarded – undo
1059 1059
 
1060 1060
 	function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
1061 1061
 		if(!$term = term_exists($name, $taxonomy))
1062
-        {
1063
-        	if(false !== $parent){ $parent = array('parent'=>$parent); }
1064
-            $term = wp_insert_term(trim($name), $taxonomy,$parent);
1065
-            if ( is_wp_error($term) ){echo $term->get_error_message();}
1066
-            else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1067
-        }
1068
-        else
1069
-        {
1070
-            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1071
-        }
1072
-        return $term['term_id'];
1062
+		{
1063
+			if(false !== $parent){ $parent = array('parent'=>$parent); }
1064
+			$term = wp_insert_term(trim($name), $taxonomy,$parent);
1065
+			if ( is_wp_error($term) ){echo $term->get_error_message();}
1066
+			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1067
+		}
1068
+		else
1069
+		{
1070
+			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1071
+		}
1072
+		return $term['term_id'];
1073 1073
 	}	
1074 1074
 
1075 1075
 	/**
@@ -1077,17 +1077,17 @@  discard block
 block discarded – undo
1077 1077
 	 */
1078 1078
 	public function set_featured_image($data,$id) {
1079 1079
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1080
-	    	$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1080
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1081 1081
 
1082
-	    	if(false !== $this->featured_image){
1083
-	    		delete_post_meta($id,'_thumbnail_id');
1084
-	    		add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1082
+			if(false !== $this->featured_image){
1083
+				delete_post_meta($id,'_thumbnail_id');
1084
+				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1085 1085
 
1086
-	    		if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1087
-	    			add_post_meta($id,'gallery',$this->featured_image,false);
1088
-	    			$this->gallery_meta[] = $this->featured_image;
1089
-	    		}
1090
-	    	}			
1086
+				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1087
+					add_post_meta($id,'gallery',$this->featured_image,false);
1088
+					$this->gallery_meta[] = $this->featured_image;
1089
+				}
1090
+			}			
1091 1091
 		}	
1092 1092
 	}	
1093 1093
 
@@ -1096,18 +1096,18 @@  discard block
 block discarded – undo
1096 1096
 	 */
1097 1097
 	public function set_banner_image($data,$id) {
1098 1098
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1099
-	    	$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1100
-
1101
-	    	if(false !== $this->banner_image){
1102
-	    		delete_post_meta($id,'image_group');
1103
-	    		$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1104
-	    		add_post_meta($id,'image_group',$new_banner,true);
1105
-
1106
-	    		if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1107
-	    			add_post_meta($id,'gallery',$this->banner_image,false);
1108
-	    			$this->gallery_meta[] = $this->banner_image;
1109
-	    		}
1110
-	    	}			
1099
+			$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1100
+
1101
+			if(false !== $this->banner_image){
1102
+				delete_post_meta($id,'image_group');
1103
+				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1104
+				add_post_meta($id,'image_group',$new_banner,true);
1105
+
1106
+				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1107
+					add_post_meta($id,'gallery',$this->banner_image,false);
1108
+					$this->gallery_meta[] = $this->banner_image;
1109
+				}
1110
+			}			
1111 1111
 		}	
1112 1112
 	}		
1113 1113
 
@@ -1118,24 +1118,24 @@  discard block
 block discarded – undo
1118 1118
 
1119 1119
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1120 1120
 
1121
-	    	$counter = 0;
1122
-	    	foreach($data[0]['content']['images'] as $image_data){
1123
-	    		if($counter === 0 && false !== $this->featured_image){continue;}
1124
-	    		if($counter === 1 && false !== $this->banner_image){continue;}
1125
-
1126
-	    		$this->gallery_meta[] = $temp_id = $this->attach_image($image_data,$id);
1127
-	    		$counter++;
1128
-	    	}
1129
-
1130
-	    	if(!empty($this->gallery_meta)){
1131
-	    		delete_post_meta($id,'gallery');
1132
-	    		foreach($this->gallery_meta as $gallery_id){
1133
-	    			if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1134
-	    				add_post_meta($id,'gallery',$gallery_id,false);
1135
-	    			}
1136
-	    		}
1137
-	    	}
1138
-    	}
1121
+			$counter = 0;
1122
+			foreach($data[0]['content']['images'] as $image_data){
1123
+				if($counter === 0 && false !== $this->featured_image){continue;}
1124
+				if($counter === 1 && false !== $this->banner_image){continue;}
1125
+
1126
+				$this->gallery_meta[] = $temp_id = $this->attach_image($image_data,$id);
1127
+				$counter++;
1128
+			}
1129
+
1130
+			if(!empty($this->gallery_meta)){
1131
+				delete_post_meta($id,'gallery');
1132
+				foreach($this->gallery_meta as $gallery_id){
1133
+					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1134
+						add_post_meta($id,'gallery',$gallery_id,false);
1135
+					}
1136
+				}
1137
+			}
1138
+		}
1139 1139
 	}	
1140 1140
 
1141 1141
 	/**
@@ -1144,42 +1144,42 @@  discard block
 block discarded – undo
1144 1144
 	public function attach_image($v=false,$parent_id,$image_sizes=false){
1145 1145
 		if(false !== $v){
1146 1146
 	   		$temp_fragment = explode('/',$v['url_fragment']);
1147
-	    	$url_filename = $temp_fragment[count($temp_fragment)-1];
1148
-	    	$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1147
+			$url_filename = $temp_fragment[count($temp_fragment)-1];
1148
+			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1149 1149
 	
1150
-	    	if(in_array($url_filename,$this->found_attachments)){
1151
-	    		return array_search($url_filename,$this->found_attachments);
1152
-	    	}
1150
+			if(in_array($url_filename,$this->found_attachments)){
1151
+				return array_search($url_filename,$this->found_attachments);
1152
+			}
1153 1153
 	    	               
1154
-	        $postdata=array();
1155
-	        if(empty($v['label']))
1156
-	        {
1157
-	            $v['label']='';
1158
-	        }
1159
-	        if(!empty($v['description']))
1160
-	        {
1161
-	            $desc=wp_strip_all_tags($v['description']);
1162
-	            $posdata=array('post_excerpt'=>$desc);
1163
-	        }
1164
-	        if(!empty($v['section']))
1165
-	        {
1166
-	            $desc=wp_strip_all_tags($v['section']);
1167
-	            $posdata=array('post_excerpt'=>$desc);
1168
-	        }
1169
-
1170
-	        $attachID=NULL;  
1171
-	        //Resizor - add option to setting if required
1172
-	        $fragment = str_replace(' ','%20',$v['url_fragment']);
1173
-	        $url = $this->get_scaling_url($image_sizes).$fragment;
1174
-	        $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1175
-
1176
-	        //echo($attachID.' add image');
1177
-	        if($attachID!=NULL)
1178
-	        {
1179
-	            return $attachID;
1180
-	        }
1181
-        }	
1182
-        return 	false;
1154
+			$postdata=array();
1155
+			if(empty($v['label']))
1156
+			{
1157
+				$v['label']='';
1158
+			}
1159
+			if(!empty($v['description']))
1160
+			{
1161
+				$desc=wp_strip_all_tags($v['description']);
1162
+				$posdata=array('post_excerpt'=>$desc);
1163
+			}
1164
+			if(!empty($v['section']))
1165
+			{
1166
+				$desc=wp_strip_all_tags($v['section']);
1167
+				$posdata=array('post_excerpt'=>$desc);
1168
+			}
1169
+
1170
+			$attachID=NULL;  
1171
+			//Resizor - add option to setting if required
1172
+			$fragment = str_replace(' ','%20',$v['url_fragment']);
1173
+			$url = $this->get_scaling_url($image_sizes).$fragment;
1174
+			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1175
+
1176
+			//echo($attachID.' add image');
1177
+			if($attachID!=NULL)
1178
+			{
1179
+				return $attachID;
1180
+			}
1181
+		}	
1182
+		return 	false;
1183 1183
 	}
1184 1184
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1185 1185
 	
Please login to merge, or discard this patch.