Completed
Push — master ( 4d3680...59f15b )
by Warwick
02:39
created
classes/class-connect-accommodation.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 	 */
52 52
 	public function display_page() {
53 53
 		global $post;
54
-        ?>
54
+		?>
55 55
         <div class="wrap">
56 56
 
57 57
             <h3><span class="dashicons dashicons-admin-multisite"></span> <?php _e('Connect your Accommodation','wetu-importer'); ?></h3>
Please login to merge, or discard this patch.
classes/lsx-banners-integration.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * Display the importer administration screen
38 38
 	 */
39 39
 	public function display_page() {
40
-        ?>
40
+		?>
41 41
         <div class="wrap">
42 42
 			
43 43
             <h2><?php _e('Download new banners straight from WETU','wetu-importer'); ?></h2>
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 		$base = rawurlencode($base);
212 212
 	  $type = get_post_mime_type($post_id);
213 213
 	  switch ($type) {
214
-	    case 'image/jpeg':
215
-	    	return $base . ".jpg"; break;
216
-	    case 'image/png':
217
-	    	return $base . ".png"; break;
218
-	    case 'image/gif':
219
-	      	return $base . ".gif"; break;
220
-	    default:
221
-	      return false;
214
+		case 'image/jpeg':
215
+			return $base . ".jpg"; break;
216
+		case 'image/png':
217
+			return $base . ".png"; break;
218
+		case 'image/gif':
219
+		  	return $base . ".gif"; break;
220
+		default:
221
+		  return false;
222 222
 	  }
223 223
 	}	
224 224
 
Please login to merge, or discard this patch.
classes/class-tours.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function set_variables()
99 99
 	{
100
-	    parent::set_variables();
100
+		parent::set_variables();
101 101
 
102 102
 		if ( false !== $this->api_username && false !== $this->api_password ) {
103 103
 			$this->url    = 'https://wetu.com/API/Itinerary/';
@@ -122,7 +122,7 @@  discard block
 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 $this->navigation('tour'); ?>
128 128
 
@@ -254,20 +254,20 @@  discard block
 block discarded – undo
254 254
 			$result = $this->update_options();
255 255
 
256 256
 			if(true === $result){
257
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
258
-                echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
-            }else{
260
-			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
261
-            }
257
+				echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
258
+				echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
+			}else{
260
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
261
+			}
262 262
 		}else{
263 263
 			echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
264
-        }
264
+		}
265 265
 		echo '</h3>';
266 266
 
267 267
 		$form_options = get_option('lsx_ti_tours_api_options');
268 268
 		if(false === $form_options){
269 269
 			$form_options = array(0);
270
-        }
270
+		}
271 271
 		?>
272 272
         <form method="get" class="tour-refresh-form" action="<?php echo admin_url('admin.php'); ?>">
273 273
 
@@ -297,15 +297,15 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	public function update_options() {
299 299
 
300
-	    $own = '';
301
-	    $options = array();
300
+		$own = '';
301
+		$options = array();
302 302
 
303
-	    delete_option('lsx_ti_tours_api_options');
303
+		delete_option('lsx_ti_tours_api_options');
304 304
 
305
-	    if(isset($_GET['own'])){
305
+		if(isset($_GET['own'])){
306 306
 			$this->url_qs .= '&own=true';
307 307
 			$options[] = 'own';
308
-        }
308
+		}
309 309
 
310 310
 		if(isset($_GET['type'])){
311 311
 			$this->url_qs .= '&type='.implode('',$_GET['type']);
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 		$tours = json_decode($data, true);
322 322
 
323 323
 		if(isset($tours['error'])){
324
-		    return $tours['error'];
325
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
324
+			return $tours['error'];
325
+		}elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
326 326
 			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
327 327
 			return true;
328 328
 		}
@@ -525,72 +525,72 @@  discard block
 block discarded – undo
525 525
 				$content = false;
526 526
 			}
527 527
 
528
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
528
+			$jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
529 529
 
530
-            if($jdata)
531
-            {
530
+			if($jdata)
531
+			{
532 532
 				$jdata=json_decode($jdata,true);
533
-                if(!empty($jdata))
534
-                {
535
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
536
-                	$this->format_completed_row($return);
533
+				if(!empty($jdata))
534
+				{
535
+					$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
536
+					$this->format_completed_row($return);
537 537
 					$this->save_queue();
538
-                	$this->cleanup_posts();
539
-                	$this->attach_destination_images($content);
540
-                }
541
-            }
538
+					$this->cleanup_posts();
539
+					$this->attach_destination_images($content);
540
+				}
541
+			}
542 542
 		}
543 543
 	}
544 544
 
545 545
 	/**
546 546
 	 * Connect to wetu
547
-     *
548
-     * @param $data array
549
-     * @param $wetu_id string
547
+	 *
548
+	 * @param $data array
549
+	 * @param $wetu_id string
550 550
 	 */
551 551
 	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
552
-        $post_name = $data_post_content = $data_post_excerpt = '';
553
-        $post = array(
554
-          'post_type'		=> 'tour',
555
-        );
552
+		$post_name = $data_post_content = $data_post_excerpt = '';
553
+		$post = array(
554
+		  'post_type'		=> 'tour',
555
+		);
556 556
 
557
-        //Set the post_content
557
+		//Set the post_content
558 558
 		$content_used_general_description = false;
559
-        if(false !== $importable_content && in_array('description',$importable_content)){
560
-            $data_post_content = '';
561
-
562
-            if(isset($data['description'])){
563
-                $data_post_content = $data['description'];
564
-            }elseif(isset($data['summary'])){
565
-                $data_post_content = $data['summary'];
566
-            }
567
-            $post['post_content'] = $data_post_content;
568
-        }
569
-
570
-        //Create or update the post
571
-        if(false !== $id && '0' !== $id){
572
-            $post['ID'] = $id;
573
-	        $post['post_status'] = 'publish';
574
-            $id = wp_update_post($post);
575
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
576
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
577
-        }else{
578
-
579
-            //Set the name
580
-            if(isset($data['name'])){
581
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
582
-            }
583
-            $post['post_name'] = $post_name;
584
-            $post['post_title'] = $data['name'];
585
-            $post['post_status'] = 'publish';
586
-            $id = wp_insert_post($post);
587
-
588
-            //Save the WETU ID and the Last date it was modified.
589
-            if(false !== $id){
590
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
591
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
592
-            }
593
-        }
559
+		if(false !== $importable_content && in_array('description',$importable_content)){
560
+			$data_post_content = '';
561
+
562
+			if(isset($data['description'])){
563
+				$data_post_content = $data['description'];
564
+			}elseif(isset($data['summary'])){
565
+				$data_post_content = $data['summary'];
566
+			}
567
+			$post['post_content'] = $data_post_content;
568
+		}
569
+
570
+		//Create or update the post
571
+		if(false !== $id && '0' !== $id){
572
+			$post['ID'] = $id;
573
+			$post['post_status'] = 'publish';
574
+			$id = wp_update_post($post);
575
+			$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
576
+			update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
577
+		}else{
578
+
579
+			//Set the name
580
+			if(isset($data['name'])){
581
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
582
+			}
583
+			$post['post_name'] = $post_name;
584
+			$post['post_title'] = $data['name'];
585
+			$post['post_status'] = 'publish';
586
+			$id = wp_insert_post($post);
587
+
588
+			//Save the WETU ID and the Last date it was modified.
589
+			if(false !== $id){
590
+				add_post_meta($id,'lsx_wetu_id',$wetu_id);
591
+				add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
592
+			}
593
+		}
594 594
 
595 595
 
596 596
 		//Set the price
@@ -603,15 +603,15 @@  discard block
 block discarded – undo
603 603
 			$this->set_duration($data,$id);
604 604
 		}
605 605
 
606
-        if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
607
-            $this->process_itineraries($data,$id,$importable_content);
608
-        }
606
+		if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
607
+			$this->process_itineraries($data,$id,$importable_content);
608
+		}
609 609
 
610 610
 		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
611 611
 			$this->set_map_data($data,$id);
612 612
 		}
613 613
 
614
-        return $id;
614
+		return $id;
615 615
 	}
616 616
 
617 617
 	/**
@@ -773,17 +773,17 @@  discard block
 block discarded – undo
773 773
 	 * Set the Itinerary Day
774 774
 	 */
775 775
 	public function set_itinerary_day($day,$id) {
776
-        $this->save_custom_field($day,'itinerary',$id,false,false);
776
+		$this->save_custom_field($day,'itinerary',$id,false,false);
777 777
 	}
778 778
 
779 779
 	/**
780 780
 	 * Set the price
781 781
 	 */
782 782
 	public function set_price($data,$id) {
783
-	    //Price
783
+		//Price
784 784
 		if(isset($data['price']) && ''!== $data['price']){
785
-            $price = preg_replace("/[^0-9,.]/", "", $data['price']);
786
-            $this->save_custom_field($price,'price',$id);
785
+			$price = preg_replace("/[^0-9,.]/", "", $data['price']);
786
+			$this->save_custom_field($price,'price',$id);
787 787
 		}
788 788
 
789 789
 		//Price includes
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 			$this->save_custom_field($data['price_includes'],'included',$id);
792 792
 		}
793 793
 
794
-        //Price Excludes
794
+		//Price Excludes
795 795
 		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
796 796
 			$this->save_custom_field($data['price_excludes'],'not_included',$id);
797 797
 		}
@@ -814,37 +814,37 @@  discard block
 block discarded – undo
814 814
 	 */
815 815
 	public function set_accommodation($day,$id) {
816 816
 
817
-	    $ac_id = false;
817
+		$ac_id = false;
818 818
 		$this->current_accommodation = $this->find_current_accommodation();
819 819
 		
820 820
 		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
821 821
 
822 822
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
823
-                $ac_id = $this->current_accommodation[$day['content_entity_id']];
823
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
824 824
 			}else{
825 825
 				$ac_id = wp_insert_post(array(
826
-                    'post_type' => 'accommodation',
827
-                    'post_status' => 'draft',
828
-                    'post_title' => $day['content_entity_id']
829
-                ));
826
+					'post_type' => 'accommodation',
827
+					'post_status' => 'draft',
828
+					'post_title' => $day['content_entity_id']
829
+				));
830 830
 				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
831 831
 			}
832 832
 
833 833
 			if('' !== $ac_id && false !== $ac_id){
834
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
834
+				$this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
835 835
 				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
836 836
 
837 837
 				$this->queue_item($ac_id);
838
-            }
838
+			}
839 839
 		}
840 840
 		return $ac_id;
841 841
 	}
842 842
 
843 843
 	/**
844 844
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
845
-     *
846
-     * @param $post_type string
847
-     * @return boolean / array
845
+	 *
846
+	 * @param $post_type string
847
+	 * @return boolean / array
848 848
 	 */
849 849
 	public function find_current_accommodation($post_type='accommodation') {
850 850
 		global $wpdb;
@@ -852,16 +852,16 @@  discard block
 block discarded – undo
852 852
 
853 853
 		$return = false;
854 854
 		if(!empty($accommodation)){
855
-		    foreach($accommodation as $key => $acc){
855
+			foreach($accommodation as $key => $acc){
856 856
 				$return[$acc->meta_value] = $acc->post_id;
857
-            }
858
-        }
857
+			}
858
+		}
859 859
 		return $return;
860 860
 	}
861 861
 
862 862
 	/**
863 863
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
864
-     * @return boolean / array
864
+	 * @return boolean / array
865 865
 	 */
866 866
 	public function find_current_destinations() {
867 867
 		return $this->find_current_accommodation('destination');
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
890 890
 				if(false !== $country_wetu_id){
891 891
 					$country_id = $this->set_country($country_wetu_id, $id);
892
-                }
892
+				}
893 893
 
894 894
 			}else {
895 895
 
@@ -900,27 +900,27 @@  discard block
 block discarded – undo
900 900
 
901 901
 					if (!empty($destination_data) && !isset($destination_data['error'])) {
902 902
 
903
-					    $destination_title = $day['destination_content_entity_id'];
903
+						$destination_title = $day['destination_content_entity_id'];
904 904
 
905
-					    if(isset($destination_data[0]['name'])){
905
+						if(isset($destination_data[0]['name'])){
906 906
 							$destination_title = $destination_data[0]['name'];
907
-                        }
907
+						}
908 908
 
909
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
910
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
909
+						if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
910
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
911 911
 
912 912
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
913
-                        }
913
+						}
914 914
 
915
-                        $dest_post = array(
915
+						$dest_post = array(
916 916
 							'post_type' => 'destination',
917 917
 							'post_status' => 'draft',
918 918
 							'post_title' => $destination_title
919 919
 						);
920 920
 
921
-					    if(false !== $country_id){
921
+						if(false !== $country_id){
922 922
 							$dest_post['post_parent'] = $country_id;
923
-                        }
923
+						}
924 924
 						$dest_id = wp_insert_post($dest_post);
925 925
 
926 926
 						//Make sure we register the
@@ -939,20 +939,20 @@  discard block
 block discarded – undo
939 939
 				$this->queue_item($dest_id);
940 940
 
941 941
 				//Save the item to clean up the amount of connections.
942
-                $this->cleanup_posts[$dest_id] = 'tour_to_destination';
942
+				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
943 943
 
944 944
 				// Save the first destination so we can grab the tour featured image and banner
945 945
 				if(0 === $leg_counter){
946
-				    $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']);
947
-                }
946
+					$this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']);
947
+				}
948 948
 
949 949
 				//Add this relation info so we can make sure certain items are set as countries.
950 950
 				if(0 !== $country_id && false !== $country_id){
951
-                    $this->relation_meta[$dest_id] = $country_id;
951
+					$this->relation_meta[$dest_id] = $country_id;
952 952
 					$this->relation_meta[$country_id] = 0;
953
-                }else{
953
+				}else{
954 954
 					$this->relation_meta[$dest_id] = 0;
955
-                }
955
+				}
956 956
 			}
957 957
 		}
958 958
 		return $dest_id;
@@ -962,54 +962,54 @@  discard block
 block discarded – undo
962 962
 	 * Connects the destinations post type
963 963
 	 *
964 964
 	 * @param $dest_id string
965
-     * @param $country_id array
965
+	 * @param $country_id array
966 966
 	 * @param $id string
967
-     *
968
-     * @return string
967
+	 *
968
+	 * @return string
969 969
 	 */
970 970
 	public function set_country($country_wetu_id, $id) {
971
-	    $country_id = false;
971
+		$country_id = false;
972 972
 		$this->current_destinations = $this->find_current_destinations();
973 973
 
974
-        if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
975
-            $country_id = $this->current_destinations[$country_wetu_id];
976
-        } else {
974
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
975
+			$country_id = $this->current_destinations[$country_wetu_id];
976
+		} else {
977 977
 
978
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
978
+			$country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
979 979
 
980
-            if ($country_json) {
981
-                $country_data = json_decode($country_json, true);
980
+			if ($country_json) {
981
+				$country_data = json_decode($country_json, true);
982 982
 
983
-                if (!empty($country_data) && !isset($country_data['error'])) {
983
+				if (!empty($country_data) && !isset($country_data['error'])) {
984 984
 
985 985
 					//Format the title of the destination if its available,  otherwise default to the WETU ID.
986
-                    $country_title = $country_wetu_id;
987
-                    if (isset($country_data[0]['name'])) {
986
+					$country_title = $country_wetu_id;
987
+					if (isset($country_data[0]['name'])) {
988 988
 						$country_title = $country_data[0]['name'];
989
-                    }
989
+					}
990 990
 
991 991
 					$country_id = wp_insert_post(array(
992
-                        'post_type' => 'destination',
993
-                        'post_status' => 'draft',
994
-                        'post_title' => $country_title
995
-                    ));
992
+						'post_type' => 'destination',
993
+						'post_status' => 'draft',
994
+						'post_title' => $country_title
995
+					));
996 996
 					//add the country to the current destination stack
997 997
 					$this->current_destinations[$country_wetu_id] = $country_id;
998 998
 
999 999
 					//Save the wetu field
1000
-                    $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
1001
-                }
1002
-            }
1003
-        }
1004
-
1005
-        if ('' !== $country_id && false !== $country_id) {
1006
-            $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
1007
-            $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
1000
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
1001
+				}
1002
+			}
1003
+		}
1004
+
1005
+		if ('' !== $country_id && false !== $country_id) {
1006
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
1007
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
1008 1008
 			$this->queue_item($country_id);
1009 1009
 			$this->cleanup_posts[$country_id] = 'tour_to_destination';
1010 1010
 
1011
-            return $country_id;
1012
-        }
1011
+			return $country_id;
1012
+		}
1013 1013
 	}
1014 1014
 
1015 1015
 	/**
@@ -1022,9 +1022,9 @@  discard block
 block discarded – undo
1022 1022
 	 * @return string
1023 1023
 	 */
1024 1024
 	public function attach_destination_images($importable_content=array()) {
1025
-	    if(false !== $this->destination_images){
1025
+		if(false !== $this->destination_images){
1026 1026
 
1027
-	        foreach($this->destination_images as $tour => $destination){
1027
+			foreach($this->destination_images as $tour => $destination){
1028 1028
 
1029 1029
 				$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1030 1030
 				$url_qs = '';
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
 						}
1046 1046
 					}
1047 1047
 				}
1048
-            }
1049
-        }
1048
+			}
1049
+		}
1050 1050
 	}
1051 1051
 
1052 1052
 	/**
Please login to merge, or discard this patch.
classes/class-importer.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
 			$this->api_username = false;
211 211
 			$this->api_password = false;
212 212
 
213
-            if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) {
214
-                $this->api_key = $temp_options['api']['wetu_api_key'];
215
-            }
216
-            if (isset($temp_options['api']['wetu_api_username']) && '' !== $temp_options['api']['wetu_api_username']) {
217
-                $this->api_username = $temp_options['api']['wetu_api_username'];
218
-            }
219
-            if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) {
220
-                $this->api_password = $temp_options['api']['wetu_api_password'];
221
-            }
213
+			if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) {
214
+				$this->api_key = $temp_options['api']['wetu_api_key'];
215
+			}
216
+			if (isset($temp_options['api']['wetu_api_username']) && '' !== $temp_options['api']['wetu_api_username']) {
217
+				$this->api_username = $temp_options['api']['wetu_api_username'];
218
+			}
219
+			if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) {
220
+				$this->api_password = $temp_options['api']['wetu_api_password'];
221
+			}
222 222
 
223 223
 			//Set the tab slug
224 224
 			if(isset($_GET['tab']) || isset($_POST['type'])) {
@@ -234,22 +234,22 @@  discard block
 block discarded – undo
234 234
 			}
235 235
 
236 236
 			//Set the scaling options
237
-            if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) {
238
-                $this->scale_images = true;
239
-                $width = '800';
240
-                if (isset($this->options['width']) && '' !== $this->options['width']) {
241
-                    $width = $this->options['width'];
242
-                }
243
-                $height = '600';
244
-                if (isset($this->options['height']) && '' !== $this->options['height']) {
245
-                    $height = $this->options['height'];
246
-                }
247
-                $cropping = 'raw';
248
-                if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
249
-                    $cropping = $this->options['cropping'];
250
-                }
251
-                $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
252
-            }
237
+			if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) {
238
+				$this->scale_images = true;
239
+				$width = '800';
240
+				if (isset($this->options['width']) && '' !== $this->options['width']) {
241
+					$width = $this->options['width'];
242
+				}
243
+				$height = '600';
244
+				if (isset($this->options['height']) && '' !== $this->options['height']) {
245
+					$height = $this->options['height'];
246
+				}
247
+				$cropping = 'raw';
248
+				if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
249
+					$cropping = $this->options['cropping'];
250
+				}
251
+				$this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
252
+			}
253 253
 
254 254
 		}
255 255
 	}
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
 
324 324
 	// DISPLAY FUNCTIONS
325 325
 
326
-    /*
326
+	/*
327 327
      * Load the importer class you want to use
328 328
      */
329
-    public function load_class(){
329
+	public function load_class(){
330 330
 
331 331
 		switch($this->tab_slug){
332 332
 			case 'accommodation':
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 				break;
347 347
 		}
348 348
 
349
-    }
349
+	}
350 350
 
351 351
 	/**
352 352
 	 * Registers the admin page which will house the importer form.
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 				<?php*/
403 403
 			}else{
404 404
 			   $this->current_importer->display_page();
405
-            }; ?>
405
+			}; ?>
406 406
         </div>
407 407
 		<?php
408 408
 	}
@@ -802,12 +802,12 @@  discard block
 block discarded – undo
802 802
 	 */
803 803
 	public function set_featured_image($data,$id) {
804 804
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
805
-		    if('tour' === $this->tab_slug){
806
-		        $key = array_rand($data[0]['content']['images']);
807
-                $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id);
808
-            }else{
805
+			if('tour' === $this->tab_slug){
806
+				$key = array_rand($data[0]['content']['images']);
807
+				$this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id);
808
+			}else{
809 809
 				$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
810
-            }
810
+			}
811 811
 
812 812
 
813 813
 			if(false !== $this->featured_image){
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 	 * Run through the accommodation grabbed from the DB.
1041 1041
 	 */
1042 1042
 	public function process_ajax_search() {
1043
-	    $this->current_importer->process_ajax_search();
1043
+		$this->current_importer->process_ajax_search();
1044 1044
 		die();
1045 1045
 	}
1046 1046
 
Please login to merge, or discard this patch.
classes/class-accommodation.php 1 patch
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function set_variables()
72 72
 	{
73
-	    parent::set_variables();
73
+		parent::set_variables();
74 74
 		// ** This request only works with API KEY **
75 75
 		//if ( false !== $this->api_username && false !== $this->api_password ) {
76 76
 		//	$this->url    = 'https://wetu.com/API/Pins/';
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * Display the importer administration screen
96 96
 	 */
97 97
 	public function display_page() {
98
-        ?>
98
+		?>
99 99
         <div class="wrap">
100 100
             <?php $this->navigation('accommodation'); ?>
101 101
 
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 		$accommodation = json_decode($data, true);
237 237
 
238 238
 		if(isset($accommodation['error'])){
239
-		    return $accommodation['error'];
240
-        }elseif (isset($accommodation) && !empty($accommodation)) {
239
+			return $accommodation['error'];
240
+		}elseif (isset($accommodation) && !empty($accommodation)) {
241 241
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
242 242
 			return true;
243 243
 		}
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 			$accommodation = get_transient('lsx_ti_accommodation');
254 254
 
255 255
 			if(false === $accommodation){
256
-			    $this->update_options();
257
-            }
256
+				$this->update_options();
257
+			}
258 258
 
259 259
 			if ( false !== $accommodation ) {
260 260
 				$searched_items = false;
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 					$keyphrases = $_POST['keyword'];
264 264
 				}else{
265 265
 					$keyphrases = array(0);
266
-                }
266
+				}
267 267
 
268 268
 				if(!is_array($keyphrases)){
269 269
 					$keyphrases = array($keyphrases);
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
 
305 305
 							if('import' === $post_status){
306 306
 
307
-							    if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){
307
+								if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){
308 308
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
309
-                                }else{
310
-							        continue;
311
-                                }
309
+								}else{
310
+									continue;
311
+								}
312 312
 
313 313
 							}else{
314 314
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * Saves the queue to the option.
388 388
 	 */
389 389
 	public function remove_from_queue($id) {
390
-        if (!empty($this->queued_imports)) {
390
+		if (!empty($this->queued_imports)) {
391 391
 
392 392
 			if(($key = array_search($id, $this->queued_imports)) !== false) {
393 393
 				unset($this->queued_imports[$key]);
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 				delete_option('wetu_importer_que');
396 396
 				update_option('wetu_importer_que',$this->queued_imports);
397 397
 			}
398
-        }
398
+		}
399 399
 	}
400 400
 
401 401
 	/**
@@ -433,18 +433,18 @@  discard block
 block discarded – undo
433 433
 				$content = false;
434 434
 			}
435 435
 
436
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
437
-            if($jdata)
438
-            {
439
-                $adata=json_decode($jdata,true);
440
-                if(!empty($adata))
441
-                {
442
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
443
-                	$this->format_completed_row($return);
444
-                	$this->remove_from_queue($return);
436
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
437
+			if($jdata)
438
+			{
439
+				$adata=json_decode($jdata,true);
440
+				if(!empty($adata))
441
+				{
442
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
443
+					$this->format_completed_row($return);
444
+					$this->remove_from_queue($return);
445 445
 					$this->cleanup_posts();
446
-                }
447
-            }
446
+				}
447
+			}
448 448
 		}
449 449
 	}
450 450
 
@@ -454,144 +454,144 @@  discard block
 block discarded – undo
454 454
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
455 455
 
456 456
 
457
-	        $post_name = $data_post_content = $data_post_excerpt = '';
458
-	        $post = array(
459
-	          'post_type'		=> 'accommodation',
460
-	        );
461
-
462
-	        $content_used_general_description = false;
463
-
464
-	        //Set the post_content
465
-	        if(false !== $importable_content && in_array('description',$importable_content)){
466
-		        if(isset($data[0]['content']['extended_description']))
467
-		        {
468
-		            $data_post_content = $data[0]['content']['extended_description'];
469
-		        }elseif(isset($data[0]['content']['general_description'])){
470
-		            $data_post_content = $data[0]['content']['general_description'];
471
-		            $content_used_general_description = true;
472
-		        }elseif(isset($data[0]['content']['teaser_description'])){
473
-		        	$data_post_content = $data[0]['content']['teaser_description'];
474
-		        }
475
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
476
-	        }
477
-
478
-	        //set the post_excerpt
479
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
480
-		        if(isset($data[0]['content']['teaser_description'])){
481
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
482
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
483
-		            $data_post_excerpt = $data[0]['content']['general_description'];
484
-		        }	   
485
-		        $post['post_excerpt'] = $data_post_excerpt;     	
486
-	        }
487
-
488
-	        if(false !== $id && '0' !== $id){
489
-	        	$post['ID'] = $id;
457
+			$post_name = $data_post_content = $data_post_excerpt = '';
458
+			$post = array(
459
+			  'post_type'		=> 'accommodation',
460
+			);
461
+
462
+			$content_used_general_description = false;
463
+
464
+			//Set the post_content
465
+			if(false !== $importable_content && in_array('description',$importable_content)){
466
+				if(isset($data[0]['content']['extended_description']))
467
+				{
468
+					$data_post_content = $data[0]['content']['extended_description'];
469
+				}elseif(isset($data[0]['content']['general_description'])){
470
+					$data_post_content = $data[0]['content']['general_description'];
471
+					$content_used_general_description = true;
472
+				}elseif(isset($data[0]['content']['teaser_description'])){
473
+					$data_post_content = $data[0]['content']['teaser_description'];
474
+				}
475
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
476
+			}
477
+
478
+			//set the post_excerpt
479
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
480
+				if(isset($data[0]['content']['teaser_description'])){
481
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
482
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
483
+					$data_post_excerpt = $data[0]['content']['general_description'];
484
+				}	   
485
+				$post['post_excerpt'] = $data_post_excerpt;     	
486
+			}
487
+
488
+			if(false !== $id && '0' !== $id){
489
+				$post['ID'] = $id;
490 490
 				if(isset($data[0]['name'])){
491 491
 					$post['post_title'] = $data[0]['name'];
492
-	        		$post['post_status'] = 'publish';
492
+					$post['post_status'] = 'publish';
493 493
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
494 494
 				}
495
-	        	$id = wp_update_post($post);
496
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
497
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
498
-	        }else{
499
-
500
-		        //Set the name
501
-		        if(isset($data[0]['name'])){
502
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
503
-		        }
504
-	        	$post['post_name'] = $post_name;
505
-	        	$post['post_title'] = $data[0]['name'];
506
-	        	$post['post_status'] = 'publish';
507
-	        	$id = wp_insert_post($post);
508
-
509
-	        	//Save the WETU ID and the Last date it was modified.
510
-	        	if(false !== $id){
511
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
512
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
513
-	        	}
514
-	        }
515
-	        //Setup some default for use in the import
516
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
495
+				$id = wp_update_post($post);
496
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
497
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
498
+			}else{
499
+
500
+				//Set the name
501
+				if(isset($data[0]['name'])){
502
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
503
+				}
504
+				$post['post_name'] = $post_name;
505
+				$post['post_title'] = $data[0]['name'];
506
+				$post['post_status'] = 'publish';
507
+				$id = wp_insert_post($post);
508
+
509
+				//Save the WETU ID and the Last date it was modified.
510
+				if(false !== $id){
511
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
512
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
513
+				}
514
+			}
515
+			//Setup some default for use in the import
516
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
517 517
 				$this->find_attachments($id);
518 518
 			}
519 519
 
520
-	        //Set the team member if it is there
521
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
522
-	        	$this->set_team_member($id,$team_members);
523
-	    	}
524
-
525
-	        //Set the safari brand
526
-	        if(false !== $safari_brands && '' !== $safari_brands){
527
-	        	$this->set_safari_brands($id,$safari_brands);
528
-
529
-	    	}	    	
530
-
531
-	        if(class_exists('LSX_TO_Maps')){
532
-	        	$this->set_map_data($data,$id,9);
533
-	        }
534
-
535
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
536
-	        	$this->connect_destinations($data,$id);
537
-	        }
538
-
539
-	        if(false !== $importable_content && in_array('category',$importable_content)){
540
-	        	$this->set_taxonomy_style($data,$id);
541
-	        }
542
-
543
-	        //Set the Room Data
544
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
545
-	        	$this->set_room_data($data,$id);
546
-	    	}
547
-
548
-	    	//Set the rating
549
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
550
-	       		$this->set_rating($data,$id);
551
-	    	}
552
-
553
-	    	//Set the checkin checkout data
554
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
555
-	        	$this->set_checkin_checkout($data,$id);
556
-	        }
557
-
558
-	    	//Set the Spoken Languages
559
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
560
-	       		$this->set_spoken_languages($data,$id);
561
-	    	}
562
-
563
-	    	//Set the friendly options
564
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
565
-	       		$this->set_friendly($data,$id);
566
-	    	}
567
-
568
-	    	//Set the special_interests
569
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
570
-	       		$this->set_special_interests($data,$id);
571
-	    	}	    		    		        
572
-
573
-	        //Import the videos
574
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
575
-	        	$this->set_video_data($data,$id);
576
-	        }
577
-
578
-	        //Import the facilities
579
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
580
-	        	$this->set_facilities($data,$id);
581
-	        }	        
582
-
583
-	        //Set the featured image
584
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
585
-	        	$this->set_featured_image($data,$id);
586
-	        }
587
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
588
-	        	$this->set_banner_image($data,$id);
589
-	        }	        
590
-	        //Import the main gallery
591
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
592
-	    		$this->create_main_gallery($data,$id);
593
-	        }
594
-        return $id;
520
+			//Set the team member if it is there
521
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
522
+				$this->set_team_member($id,$team_members);
523
+			}
524
+
525
+			//Set the safari brand
526
+			if(false !== $safari_brands && '' !== $safari_brands){
527
+				$this->set_safari_brands($id,$safari_brands);
528
+
529
+			}	    	
530
+
531
+			if(class_exists('LSX_TO_Maps')){
532
+				$this->set_map_data($data,$id,9);
533
+			}
534
+
535
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
536
+				$this->connect_destinations($data,$id);
537
+			}
538
+
539
+			if(false !== $importable_content && in_array('category',$importable_content)){
540
+				$this->set_taxonomy_style($data,$id);
541
+			}
542
+
543
+			//Set the Room Data
544
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
545
+				$this->set_room_data($data,$id);
546
+			}
547
+
548
+			//Set the rating
549
+			if(false !== $importable_content && in_array('rating',$importable_content)){
550
+		   		$this->set_rating($data,$id);
551
+			}
552
+
553
+			//Set the checkin checkout data
554
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
555
+				$this->set_checkin_checkout($data,$id);
556
+			}
557
+
558
+			//Set the Spoken Languages
559
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
560
+		   		$this->set_spoken_languages($data,$id);
561
+			}
562
+
563
+			//Set the friendly options
564
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
565
+		   		$this->set_friendly($data,$id);
566
+			}
567
+
568
+			//Set the special_interests
569
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
570
+		   		$this->set_special_interests($data,$id);
571
+			}	    		    		        
572
+
573
+			//Import the videos
574
+			if(false !== $importable_content && in_array('videos',$importable_content)){
575
+				$this->set_video_data($data,$id);
576
+			}
577
+
578
+			//Import the facilities
579
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
580
+				$this->set_facilities($data,$id);
581
+			}	        
582
+
583
+			//Set the featured image
584
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
585
+				$this->set_featured_image($data,$id);
586
+			}
587
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
588
+				$this->set_banner_image($data,$id);
589
+			}	        
590
+			//Import the main gallery
591
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
592
+				$this->create_main_gallery($data,$id);
593
+			}
594
+		return $id;
595 595
 	}
596 596
 
597 597
 	/**
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 
602 602
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
603 603
 		foreach($team_members as $team){
604
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
604
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
605 605
 		}
606 606
 	}
607 607
 
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	 */
611 611
 	public function set_safari_brands($id,$safari_brands) {
612 612
 		foreach($safari_brands as $safari_brand){
613
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
613
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
614 614
 		}
615 615
 	}
616 616
 
@@ -619,32 +619,32 @@  discard block
 block discarded – undo
619 619
 	 */
620 620
 	public function connect_destinations($data,$id) {
621 621
 		if(isset($data[0]['position'])){
622
-		    $destinations = false;
623
-		    if(isset($data[0]['position']['country'])){
624
-		    	$destinations['country'] = $data[0]['position']['country'];
625
-		    }
626
-		    if(isset($data[0]['position']['destination'])){
627
-		    	$destinations['destination'] = $data[0]['position']['destination'];
628
-		    }
622
+			$destinations = false;
623
+			if(isset($data[0]['position']['country'])){
624
+				$destinations['country'] = $data[0]['position']['country'];
625
+			}
626
+			if(isset($data[0]['position']['destination'])){
627
+				$destinations['destination'] = $data[0]['position']['destination'];
628
+			}
629 629
 		    
630
-		    if(false !== $destinations){	
631
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
632
-		    	if(false === $prev_values || !is_array($prev_values)){
633
-		    		$prev_values = array();
634
-		    	}
635
-		    	//print_r($destinations);
630
+			if(false !== $destinations){	
631
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
632
+				if(false === $prev_values || !is_array($prev_values)){
633
+					$prev_values = array();
634
+				}
635
+				//print_r($destinations);
636 636
 				$destinations = array_unique($destinations);
637 637
 				//print_r($destinations);
638
-			    foreach($destinations as $key => $value){
639
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
640
-	                if (null !== $destination) {
641
-	                	if(!in_array($destination->ID,$prev_values)){
642
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
643
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
638
+				foreach($destinations as $key => $value){
639
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
640
+					if (null !== $destination) {
641
+						if(!in_array($destination->ID,$prev_values)){
642
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
643
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
644 644
 							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
645
-	                	}
646
-	                } 		    	
647
-			    }	
645
+						}
646
+					} 		    	
647
+				}	
648 648
 			}
649 649
 		}
650 650
 	}	
@@ -656,15 +656,15 @@  discard block
 block discarded – undo
656 656
 		$terms = false;
657 657
 		if(isset($data[0]['category'])){
658 658
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
659
-	        {
660
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
661
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
662
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
663
-	        }
664
-	        else
665
-	        {
666
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
667
-	        }				
659
+			{
660
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
661
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
662
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
663
+			}
664
+			else
665
+			{
666
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
667
+			}				
668 668
 		}
669 669
 	}		
670 670
 
@@ -688,25 +688,25 @@  discard block
 block discarded – undo
688 688
 				$temp_room['type'] = 'room';
689 689
 
690 690
 				if(!empty($room['images']) && is_array($room['images'])){
691
-			    	$attachments_args = array(
692
-			    			'post_parent' => $id,
693
-			    			'post_status' => 'inherit',
694
-			    			'post_type' => 'attachment',
695
-			    			'order' => 'ASC',
696
-			    	);   	
697
-			    	$attachments = new WP_Query($attachments_args);
698
-			    	$found_attachments = array();
699
-
700
-			    	if($attachments->have_posts()){
701
-			    		foreach($attachments->posts as $attachment){
702
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
703
-			    		}
704
-			    	}
691
+					$attachments_args = array(
692
+							'post_parent' => $id,
693
+							'post_status' => 'inherit',
694
+							'post_type' => 'attachment',
695
+							'order' => 'ASC',
696
+					);   	
697
+					$attachments = new WP_Query($attachments_args);
698
+					$found_attachments = array();
699
+
700
+					if($attachments->have_posts()){
701
+						foreach($attachments->posts as $attachment){
702
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
703
+						}
704
+					}
705 705
 
706 706
 					$temp_room['gallery'] = array();
707 707
 					foreach($room['images'] as $image_data){
708
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
709
-			    	}
708
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
709
+					}
710 710
 				}
711 711
 				$rooms[] = $temp_room;
712 712
 			}
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 				delete_post_meta($id, 'units');				
716 716
 			}
717 717
 			foreach($rooms as $room){
718
-		        add_post_meta($id,'units',$room,false);			
718
+				add_post_meta($id,'units',$room,false);			
719 719
 			}
720 720
 
721 721
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
 			}
726 726
 
727 727
 			if(false !== $id && '0' !== $id){
728
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
729
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
730
-	        }else{
731
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
732
-	        }
728
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
729
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
730
+			}else{
731
+				add_post_meta($id,'number_of_rooms',$room_count,true);
732
+			}
733 733
 		}
734 734
 	}
735 735
 
Please login to merge, or discard this patch.