Passed
Push — master ( 8c8e21...c4fc51 )
by Fernando
10:52
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-admin.php 1 patch
Indentation   +58 added lines, -58 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" 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
 	}
@@ -253,20 +253,20 @@  discard block
 block discarded – undo
253 253
 		if(false !== $id){
254 254
 			if(empty($this->found_attachments)){
255 255
 
256
-		    	$attachments_args = array(
257
-		    			'post_parent' => $id,
258
-		    			'post_status' => 'inherit',
259
-		    			'post_type' => 'attachment',
260
-		    			'order' => 'ASC',
261
-		    	);   	
256
+				$attachments_args = array(
257
+						'post_parent' => $id,
258
+						'post_status' => 'inherit',
259
+						'post_type' => 'attachment',
260
+						'order' => 'ASC',
261
+				);   	
262 262
 		    	 
263
-		    	$attachments = new WP_Query($attachments_args);
264
-		    	if($attachments->have_posts()){
265
-		    		foreach($attachments->posts as $attachment){
266
-		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
267
-		    			$this->gallery_meta[] = $attachment->ID;
268
-		    		}
269
-		    	}
263
+				$attachments = new WP_Query($attachments_args);
264
+				if($attachments->have_posts()){
265
+					foreach($attachments->posts as $attachment){
266
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
267
+						$this->gallery_meta[] = $attachment->ID;
268
+					}
269
+				}
270 270
 			}
271 271
 		}
272 272
 	}		
Please login to merge, or discard this patch.
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
 
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 		$accommodation = json_decode($data, true);
300 300
 
301 301
 		if(isset($accommodation['error'])){
302
-		    return $accommodation['error'];
303
-        }elseif (isset($accommodation) && !empty($accommodation)) {
302
+			return $accommodation['error'];
303
+		}elseif (isset($accommodation) && !empty($accommodation)) {
304 304
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
305 305
 			return true;
306 306
 		}
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 					$keyphrases = $_POST['keyword'];
349 349
 				}else{
350 350
 					$keyphrases = array(0);
351
-                }
351
+				}
352 352
 
353 353
 				if(!is_array($keyphrases)){
354 354
 					$keyphrases = array($keyphrases);
@@ -445,13 +445,13 @@  discard block
 block discarded – undo
445 445
 	public function multineedle_stripos($haystack, $needles, $offset=0) {
446 446
 		$found = false;
447 447
 		$needle_count = count($needles);
448
-	    foreach($needles as $needle) {
449
-	    	if(false !== stripos($haystack, $needle, $offset)){
450
-	        	$found[] = true;
451
-	    	}
452
-	    }
453
-	    if(false !== $found && $needle_count === count($found)){ 
454
-	    	return true;
448
+		foreach($needles as $needle) {
449
+			if(false !== stripos($haystack, $needle, $offset)){
450
+				$found[] = true;
451
+			}
452
+		}
453
+		if(false !== $found && $needle_count === count($found)){ 
454
+			return true;
455 455
 		}else{
456 456
 			return false;
457 457
 		}
@@ -520,16 +520,16 @@  discard block
 block discarded – undo
520 520
 				$content = false;
521 521
 			}
522 522
 
523
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
524
-            if($jdata)
525
-            {
526
-                $adata=json_decode($jdata,true);
527
-                if(!empty($adata))
528
-                {
529
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
530
-                	$this->format_completed_row($return);
531
-                }
532
-            }
523
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
524
+			if($jdata)
525
+			{
526
+				$adata=json_decode($jdata,true);
527
+				if(!empty($adata))
528
+				{
529
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
530
+					$this->format_completed_row($return);
531
+				}
532
+			}
533 533
 
534 534
 			die();
535 535
 		}
@@ -546,148 +546,148 @@  discard block
 block discarded – undo
546 546
 	 */
547 547
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
548 548
 
549
-        if(trim($data[0]['type'])=='Accommodation')
550
-        {
551
-	        $post_name = $data_post_content = $data_post_excerpt = '';
552
-	        $post = array(
553
-	          'post_type'		=> 'accommodation',
554
-	        );
555
-
556
-	        $content_used_general_description = false;
557
-
558
-	        //Set the post_content
559
-	        if(false !== $importable_content && in_array('description',$importable_content)){
560
-		        if(isset($data[0]['content']['extended_description']))
561
-		        {
562
-		            $data_post_content = $data[0]['content']['extended_description'];
563
-		        }elseif(isset($data[0]['content']['general_description'])){
564
-		            $data_post_content = $data[0]['content']['general_description'];
565
-		            $content_used_general_description = true;
566
-		        }elseif(isset($data[0]['content']['teaser_description'])){
567
-		        	$data_post_content = $data[0]['content']['teaser_description'];
568
-		        }
569
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
570
-	        }
571
-
572
-	        //set the post_excerpt
573
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
574
-		        if(isset($data[0]['content']['teaser_description'])){
575
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
576
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
577
-		            $data_post_excerpt = $data[0]['content']['general_description'];
578
-		        }	   
579
-		        $post['post_excerpt'] = $data_post_excerpt;     	
580
-	        }
581
-
582
-	        if(false !== $id && '0' !== $id){
583
-	        	$post['ID'] = $id;
549
+		if(trim($data[0]['type'])=='Accommodation')
550
+		{
551
+			$post_name = $data_post_content = $data_post_excerpt = '';
552
+			$post = array(
553
+			  'post_type'		=> 'accommodation',
554
+			);
555
+
556
+			$content_used_general_description = false;
557
+
558
+			//Set the post_content
559
+			if(false !== $importable_content && in_array('description',$importable_content)){
560
+				if(isset($data[0]['content']['extended_description']))
561
+				{
562
+					$data_post_content = $data[0]['content']['extended_description'];
563
+				}elseif(isset($data[0]['content']['general_description'])){
564
+					$data_post_content = $data[0]['content']['general_description'];
565
+					$content_used_general_description = true;
566
+				}elseif(isset($data[0]['content']['teaser_description'])){
567
+					$data_post_content = $data[0]['content']['teaser_description'];
568
+				}
569
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
570
+			}
571
+
572
+			//set the post_excerpt
573
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
574
+				if(isset($data[0]['content']['teaser_description'])){
575
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
576
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
577
+					$data_post_excerpt = $data[0]['content']['general_description'];
578
+				}	   
579
+				$post['post_excerpt'] = $data_post_excerpt;     	
580
+			}
581
+
582
+			if(false !== $id && '0' !== $id){
583
+				$post['ID'] = $id;
584 584
 				if(isset($data[0]['name'])){
585 585
 					$post['post_title'] = $data[0]['name'];
586
-	        		$post['post_status'] = 'pending';
586
+					$post['post_status'] = 'pending';
587 587
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
588 588
 				}
589
-	        	$id = wp_update_post($post);
590
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
591
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
592
-	        }else{
593
-
594
-		        //Set the name
595
-		        if(isset($data[0]['name'])){
596
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
597
-		        }
598
-	        	$post['post_name'] = $post_name;
599
-	        	$post['post_title'] = $data[0]['name'];
600
-	        	$post['post_status'] = 'pending';
601
-	        	$id = wp_insert_post($post);
602
-
603
-	        	//Save the WETU ID and the Last date it was modified.
604
-	        	if(false !== $id){
605
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
606
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
607
-	        	}
608
-	        }
609
-	        //Setup some default for use in the import
610
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
589
+				$id = wp_update_post($post);
590
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
591
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
592
+			}else{
593
+
594
+				//Set the name
595
+				if(isset($data[0]['name'])){
596
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
597
+				}
598
+				$post['post_name'] = $post_name;
599
+				$post['post_title'] = $data[0]['name'];
600
+				$post['post_status'] = 'pending';
601
+				$id = wp_insert_post($post);
602
+
603
+				//Save the WETU ID and the Last date it was modified.
604
+				if(false !== $id){
605
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
606
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
607
+				}
608
+			}
609
+			//Setup some default for use in the import
610
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
611 611
 				$this->find_attachments($id);
612 612
 			}
613 613
 
614
-	        //Set the team member if it is there
615
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
616
-	        	$this->set_team_member($id,$team_members);
617
-	    	}
618
-
619
-	        //Set the safari brand
620
-	        if(false !== $safari_brands && '' !== $safari_brands){
621
-	        	$this->set_safari_brands($id,$safari_brands);
622
-
623
-	    	}	    	
624
-
625
-	        if(false !== $importable_content && in_array('location',$importable_content)){
626
-	        	$this->set_map_data($data,$id);
627
-	        	$this->set_location_taxonomy($data,$id);
628
-	        }
629
-
630
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
631
-	        	$this->connect_destinations($data,$id);
632
-	        }
633
-
634
-	        if(false !== $importable_content && in_array('category',$importable_content)){
635
-	        	$this->set_taxonomy_style($data,$id);
636
-	        }
637
-
638
-	        //Set the Room Data
639
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
640
-	        	$this->set_room_data($data,$id);
641
-	    	}
642
-
643
-	    	//Set the rating
644
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
645
-	       		$this->set_rating($data,$id);
646
-	    	}
647
-
648
-	    	//Set the checkin checkout data
649
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
650
-	        	$this->set_checkin_checkout($data,$id);
651
-	        }
652
-
653
-	    	//Set the Spoken Languages
654
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
655
-	       		$this->set_spoken_languages($data,$id);
656
-	    	}
657
-
658
-	    	//Set the friendly options
659
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
660
-	       		$this->set_friendly($data,$id);
661
-	    	}
662
-
663
-	    	//Set the special_interests
664
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
665
-	       		$this->set_special_interests($data,$id);
666
-	    	}	    		    		        
667
-
668
-	        //Import the videos
669
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
670
-	        	$this->set_video_data($data,$id);
671
-	        }
672
-
673
-	        //Import the facilities
674
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
675
-	        	$this->set_facilities($data,$id);
676
-	        }	        
677
-
678
-	        //Set the featured image
679
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
680
-	        	$this->set_featured_image($data,$id);
681
-	        }
682
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
683
-	        	$this->set_banner_image($data,$id);
684
-	        }	        
685
-	        //Import the main gallery
686
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
687
-	    		$this->create_main_gallery($data,$id);
688
-	        }	        	        	        
689
-        }
690
-        return $id;
614
+			//Set the team member if it is there
615
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
616
+				$this->set_team_member($id,$team_members);
617
+			}
618
+
619
+			//Set the safari brand
620
+			if(false !== $safari_brands && '' !== $safari_brands){
621
+				$this->set_safari_brands($id,$safari_brands);
622
+
623
+			}	    	
624
+
625
+			if(false !== $importable_content && in_array('location',$importable_content)){
626
+				$this->set_map_data($data,$id);
627
+				$this->set_location_taxonomy($data,$id);
628
+			}
629
+
630
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
631
+				$this->connect_destinations($data,$id);
632
+			}
633
+
634
+			if(false !== $importable_content && in_array('category',$importable_content)){
635
+				$this->set_taxonomy_style($data,$id);
636
+			}
637
+
638
+			//Set the Room Data
639
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
640
+				$this->set_room_data($data,$id);
641
+			}
642
+
643
+			//Set the rating
644
+			if(false !== $importable_content && in_array('rating',$importable_content)){
645
+		   		$this->set_rating($data,$id);
646
+			}
647
+
648
+			//Set the checkin checkout data
649
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
650
+				$this->set_checkin_checkout($data,$id);
651
+			}
652
+
653
+			//Set the Spoken Languages
654
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
655
+		   		$this->set_spoken_languages($data,$id);
656
+			}
657
+
658
+			//Set the friendly options
659
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
660
+		   		$this->set_friendly($data,$id);
661
+			}
662
+
663
+			//Set the special_interests
664
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
665
+		   		$this->set_special_interests($data,$id);
666
+			}	    		    		        
667
+
668
+			//Import the videos
669
+			if(false !== $importable_content && in_array('videos',$importable_content)){
670
+				$this->set_video_data($data,$id);
671
+			}
672
+
673
+			//Import the facilities
674
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
675
+				$this->set_facilities($data,$id);
676
+			}	        
677
+
678
+			//Set the featured image
679
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
680
+				$this->set_featured_image($data,$id);
681
+			}
682
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
683
+				$this->set_banner_image($data,$id);
684
+			}	        
685
+			//Import the main gallery
686
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
687
+				$this->create_main_gallery($data,$id);
688
+			}	        	        	        
689
+		}
690
+		return $id;
691 691
 	}
692 692
 
693 693
 	/**
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 
698 698
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
699 699
 		foreach($team_members as $team){
700
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
700
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
701 701
 		}
702 702
 	}
703 703
 
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 	 */
707 707
 	public function set_safari_brands($id,$safari_brands) {
708 708
 		foreach($safari_brands as $safari_brand){
709
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
709
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
710 710
 		}
711 711
 	}	
712 712
 	
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 				'elevation'	=>	'',
759 759
 			);
760 760
 			if(false !== $id && '0' !== $id){
761
-	        	$prev = get_post_meta($id,'location',true);
762
-	        	update_post_meta($id,'location',$location_data,$prev);
763
-	        }else{
764
-	        	add_post_meta($id,'location',$location_data,true);
765
-	        }
761
+				$prev = get_post_meta($id,'location',true);
762
+				update_post_meta($id,'location',$location_data,$prev);
763
+			}else{
764
+				add_post_meta($id,'location',$location_data,true);
765
+			}
766 766
 		}
767 767
 	}
768 768
 	/**
@@ -776,35 +776,35 @@  discard block
 block discarded – undo
776 776
 			if(isset($data[0]['position']['country'])){
777 777
 
778 778
 				if(!$term = term_exists(trim($data[0]['position']['country']), 'location'))
779
-		        {
780
-		            $term = wp_insert_term(trim($data[0]['position']['country']), 'location');
781
-		            if ( is_wp_error($term) ){
782
-		            	echo $term->get_error_message();
783
-		            }
784
-		            else {
785
-		            	wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
786
-		            }
787
-		        }
788
-		        else
789
-		        {
790
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
791
-		        }
792
-		        $country_id = intval($term['term_id']);
793
-		    }
779
+				{
780
+					$term = wp_insert_term(trim($data[0]['position']['country']), 'location');
781
+					if ( is_wp_error($term) ){
782
+						echo $term->get_error_message();
783
+					}
784
+					else {
785
+						wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
786
+					}
787
+				}
788
+				else
789
+				{
790
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
791
+				}
792
+				$country_id = intval($term['term_id']);
793
+			}
794 794
 
795 795
 			if(isset($data[0]['position']['destination'])){
796 796
 
797 797
 				$tax_args = array('parent'=>$country_id);
798 798
 				if(!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
799
-		        {
800
-		            $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
801
-		            if ( is_wp_error($term) ){echo $term->get_error_message();}
802
-		            else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
803
-		        }
804
-		        else
805
-		        {
806
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
807
-		        }				
799
+				{
800
+					$term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
801
+					if ( is_wp_error($term) ){echo $term->get_error_message();}
802
+					else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
803
+				}
804
+				else
805
+				{
806
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
807
+				}				
808 808
 			}		
809 809
 		}
810 810
 	}
@@ -814,28 +814,28 @@  discard block
 block discarded – undo
814 814
 	 */
815 815
 	public function connect_destinations($data,$id) {
816 816
 		if(isset($data[0]['position'])){
817
-		    $destinations = false;
818
-		    if(isset($data[0]['position']['country'])){
819
-		    	$destinations['country'] = $data[0]['position']['country'];
820
-		    }
821
-		    if(isset($data[0]['position']['destination'])){
822
-		    	$destinations['destination'] = $data[0]['position']['destination'];
823
-		    }
817
+			$destinations = false;
818
+			if(isset($data[0]['position']['country'])){
819
+				$destinations['country'] = $data[0]['position']['country'];
820
+			}
821
+			if(isset($data[0]['position']['destination'])){
822
+				$destinations['destination'] = $data[0]['position']['destination'];
823
+			}
824 824
 		    
825
-		    if(false !== $destinations){	
826
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
827
-		    	if(false === $prev_values || !is_array($prev_values)){
828
-		    		$prev_values = array();
829
-		    	}
830
-			    foreach($destinations as $key => $value){
831
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
832
-	                if (null !== $destination) {
833
-	                	if(!in_array($destination->ID,$prev_values)){
834
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
835
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
836
-	                	}
837
-	                } 		    	
838
-			    }	
825
+			if(false !== $destinations){	
826
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
827
+				if(false === $prev_values || !is_array($prev_values)){
828
+					$prev_values = array();
829
+				}
830
+				foreach($destinations as $key => $value){
831
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
832
+					if (null !== $destination) {
833
+						if(!in_array($destination->ID,$prev_values)){
834
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
835
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
836
+						}
837
+					} 		    	
838
+				}	
839 839
 			}
840 840
 		}
841 841
 	}	
@@ -847,15 +847,15 @@  discard block
 block discarded – undo
847 847
 		$terms = false;
848 848
 		if(isset($data[0]['category'])){
849 849
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
850
-	        {
851
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
852
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
853
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
854
-	        }
855
-	        else
856
-	        {
857
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
858
-	        }				
850
+			{
851
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
852
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
853
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
854
+			}
855
+			else
856
+			{
857
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
858
+			}				
859 859
 		}
860 860
 	}		
861 861
 
@@ -879,25 +879,25 @@  discard block
 block discarded – undo
879 879
 				$temp_room['type'] = 'room';
880 880
 
881 881
 				if(!empty($room['images']) && is_array($room['images'])){
882
-			    	$attachments_args = array(
883
-			    			'post_parent' => $id,
884
-			    			'post_status' => 'inherit',
885
-			    			'post_type' => 'attachment',
886
-			    			'order' => 'ASC',
887
-			    	);   	
888
-			    	$attachments = new WP_Query($attachments_args);
889
-			    	$found_attachments = array();
890
-
891
-			    	if($attachments->have_posts()){
892
-			    		foreach($attachments->posts as $attachment){
893
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
894
-			    		}
895
-			    	}
882
+					$attachments_args = array(
883
+							'post_parent' => $id,
884
+							'post_status' => 'inherit',
885
+							'post_type' => 'attachment',
886
+							'order' => 'ASC',
887
+					);   	
888
+					$attachments = new WP_Query($attachments_args);
889
+					$found_attachments = array();
890
+
891
+					if($attachments->have_posts()){
892
+						foreach($attachments->posts as $attachment){
893
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
894
+						}
895
+					}
896 896
 
897 897
 					$temp_room['gallery'] = array();
898 898
 					foreach($room['images'] as $image_data){
899
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
900
-			    	}
899
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
900
+					}
901 901
 				}
902 902
 				$rooms[] = $temp_room;
903 903
 			}
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 				delete_post_meta($id, 'units');				
907 907
 			}
908 908
 			foreach($rooms as $room){
909
-		        add_post_meta($id,'units',$room,false);			
909
+				add_post_meta($id,'units',$room,false);			
910 910
 			}
911 911
 
912 912
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -916,11 +916,11 @@  discard block
 block discarded – undo
916 916
 			}
917 917
 
918 918
 			if(false !== $id && '0' !== $id){
919
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
920
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
921
-	        }else{
922
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
923
-	        }
919
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
920
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
921
+			}else{
922
+				add_post_meta($id,'number_of_rooms',$room_count,true);
923
+			}
924 924
 		}
925 925
 	}
926 926
 
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 				delete_post_meta($id, 'videos');				
1030 1030
 			}
1031 1031
 			foreach($videos as $video){
1032
-		        add_post_meta($id,'videos',$video,false);			
1032
+				add_post_meta($id,'videos',$video,false);			
1033 1033
 			}
1034 1034
 		}
1035 1035
 	}	
@@ -1058,17 +1058,17 @@  discard block
 block discarded – undo
1058 1058
 
1059 1059
 	function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
1060 1060
 		if(!$term = term_exists($name, $taxonomy))
1061
-        {
1062
-        	if(false !== $parent){ $parent = array('parent'=>$parent); }
1063
-            $term = wp_insert_term(trim($name), $taxonomy,$parent);
1064
-            if ( is_wp_error($term) ){echo $term->get_error_message();}
1065
-            else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1066
-        }
1067
-        else
1068
-        {
1069
-            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1070
-        }
1071
-        return $term['term_id'];
1061
+		{
1062
+			if(false !== $parent){ $parent = array('parent'=>$parent); }
1063
+			$term = wp_insert_term(trim($name), $taxonomy,$parent);
1064
+			if ( is_wp_error($term) ){echo $term->get_error_message();}
1065
+			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1066
+		}
1067
+		else
1068
+		{
1069
+			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1070
+		}
1071
+		return $term['term_id'];
1072 1072
 	}	
1073 1073
 
1074 1074
 	/**
@@ -1076,17 +1076,17 @@  discard block
 block discarded – undo
1076 1076
 	 */
1077 1077
 	public function set_featured_image($data,$id) {
1078 1078
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1079
-	    	$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1079
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1080 1080
 
1081
-	    	if(false !== $this->featured_image){
1082
-	    		delete_post_meta($id,'_thumbnail_id');
1083
-	    		add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1081
+			if(false !== $this->featured_image){
1082
+				delete_post_meta($id,'_thumbnail_id');
1083
+				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1084 1084
 
1085
-	    		if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1086
-	    			add_post_meta($id,'gallery',$this->featured_image,false);
1087
-	    			$this->gallery_meta[] = $this->featured_image;
1088
-	    		}
1089
-	    	}			
1085
+				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1086
+					add_post_meta($id,'gallery',$this->featured_image,false);
1087
+					$this->gallery_meta[] = $this->featured_image;
1088
+				}
1089
+			}			
1090 1090
 		}	
1091 1091
 	}	
1092 1092
 
@@ -1095,18 +1095,18 @@  discard block
 block discarded – undo
1095 1095
 	 */
1096 1096
 	public function set_banner_image($data,$id) {
1097 1097
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1098
-	    	$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1099
-
1100
-	    	if(false !== $this->banner_image){
1101
-	    		delete_post_meta($id,'image_group');
1102
-	    		$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1103
-	    		add_post_meta($id,'image_group',$new_banner,true);
1104
-
1105
-	    		if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1106
-	    			add_post_meta($id,'gallery',$this->banner_image,false);
1107
-	    			$this->gallery_meta[] = $this->banner_image;
1108
-	    		}
1109
-	    	}			
1098
+			$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1099
+
1100
+			if(false !== $this->banner_image){
1101
+				delete_post_meta($id,'image_group');
1102
+				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1103
+				add_post_meta($id,'image_group',$new_banner,true);
1104
+
1105
+				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1106
+					add_post_meta($id,'gallery',$this->banner_image,false);
1107
+					$this->gallery_meta[] = $this->banner_image;
1108
+				}
1109
+			}			
1110 1110
 		}	
1111 1111
 	}		
1112 1112
 
@@ -1117,24 +1117,24 @@  discard block
 block discarded – undo
1117 1117
 
1118 1118
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1119 1119
 
1120
-	    	$counter = 0;
1121
-	    	foreach($data[0]['content']['images'] as $image_data){
1122
-	    		if($counter === 0 && false !== $this->featured_image){continue;}
1123
-	    		if($counter === 1 && false !== $this->banner_image){continue;}
1124
-
1125
-	    		$this->gallery_meta[] = $temp_id = $this->attach_image($image_data,$id);
1126
-	    		$counter++;
1127
-	    	}
1128
-
1129
-	    	if(!empty($this->gallery_meta)){
1130
-	    		delete_post_meta($id,'gallery');
1131
-	    		foreach($this->gallery_meta as $gallery_id){
1132
-	    			if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1133
-	    				add_post_meta($id,'gallery',$gallery_id,false);
1134
-	    			}
1135
-	    		}
1136
-	    	}
1137
-    	}
1120
+			$counter = 0;
1121
+			foreach($data[0]['content']['images'] as $image_data){
1122
+				if($counter === 0 && false !== $this->featured_image){continue;}
1123
+				if($counter === 1 && false !== $this->banner_image){continue;}
1124
+
1125
+				$this->gallery_meta[] = $temp_id = $this->attach_image($image_data,$id);
1126
+				$counter++;
1127
+			}
1128
+
1129
+			if(!empty($this->gallery_meta)){
1130
+				delete_post_meta($id,'gallery');
1131
+				foreach($this->gallery_meta as $gallery_id){
1132
+					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1133
+						add_post_meta($id,'gallery',$gallery_id,false);
1134
+					}
1135
+				}
1136
+			}
1137
+		}
1138 1138
 	}	
1139 1139
 
1140 1140
 	/**
@@ -1143,42 +1143,42 @@  discard block
 block discarded – undo
1143 1143
 	public function attach_image($v=false,$parent_id,$image_sizes=false){
1144 1144
 		if(false !== $v){
1145 1145
 	   		$temp_fragment = explode('/',$v['url_fragment']);
1146
-	    	$url_filename = $temp_fragment[count($temp_fragment)-1];
1147
-	    	$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1146
+			$url_filename = $temp_fragment[count($temp_fragment)-1];
1147
+			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1148 1148
 	
1149
-	    	if(in_array($url_filename,$this->found_attachments)){
1150
-	    		return array_search($url_filename,$this->found_attachments);
1151
-	    	}
1149
+			if(in_array($url_filename,$this->found_attachments)){
1150
+				return array_search($url_filename,$this->found_attachments);
1151
+			}
1152 1152
 	    	               
1153
-	        $postdata=array();
1154
-	        if(empty($v['label']))
1155
-	        {
1156
-	            $v['label']='';
1157
-	        }
1158
-	        if(!empty($v['description']))
1159
-	        {
1160
-	            $desc=wp_strip_all_tags($v['description']);
1161
-	            $posdata=array('post_excerpt'=>$desc);
1162
-	        }
1163
-	        if(!empty($v['section']))
1164
-	        {
1165
-	            $desc=wp_strip_all_tags($v['section']);
1166
-	            $posdata=array('post_excerpt'=>$desc);
1167
-	        }
1168
-
1169
-	        $attachID=NULL;  
1170
-	        //Resizor - add option to setting if required
1171
-	        $fragment = str_replace(' ','%20',$v['url_fragment']);
1172
-	        $url = $this->get_scaling_url($image_sizes).$fragment;
1173
-	        $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1174
-
1175
-	        //echo($attachID.' add image');
1176
-	        if($attachID!=NULL)
1177
-	        {
1178
-	            return $attachID;
1179
-	        }
1180
-        }	
1181
-        return 	false;
1153
+			$postdata=array();
1154
+			if(empty($v['label']))
1155
+			{
1156
+				$v['label']='';
1157
+			}
1158
+			if(!empty($v['description']))
1159
+			{
1160
+				$desc=wp_strip_all_tags($v['description']);
1161
+				$posdata=array('post_excerpt'=>$desc);
1162
+			}
1163
+			if(!empty($v['section']))
1164
+			{
1165
+				$desc=wp_strip_all_tags($v['section']);
1166
+				$posdata=array('post_excerpt'=>$desc);
1167
+			}
1168
+
1169
+			$attachID=NULL;  
1170
+			//Resizor - add option to setting if required
1171
+			$fragment = str_replace(' ','%20',$v['url_fragment']);
1172
+			$url = $this->get_scaling_url($image_sizes).$fragment;
1173
+			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1174
+
1175
+			//echo($attachID.' add image');
1176
+			if($attachID!=NULL)
1177
+			{
1178
+				return $attachID;
1179
+			}
1180
+		}	
1181
+		return 	false;
1182 1182
 	}
1183 1183
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1184 1184
 	
Please login to merge, or discard this patch.
classes/class-destination.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * Display the importer administration screen
91 91
 	 */
92 92
 	public function display_page() {
93
-        ?>
93
+		?>
94 94
         <div class="wrap">
95 95
             <?php screen_icon(); ?>
96 96
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 					$keyphrases = $_POST['keyword'];
308 308
 				}else{
309 309
 					$keyphrases = array(0);
310
-                }
310
+				}
311 311
 
312 312
 				if(!is_array($keyphrases)){
313 313
 					$keyphrases = array($keyphrases);
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 						//If we are searching for
337 337
 						if(false !== $post_status){
338 338
 
339
-                            $current_status = get_post_status($row->post_id);
340
-                            if($current_status !== $post_status){
341
-                                continue;
342
-                            }
343
-                            $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
339
+							$current_status = get_post_status($row->post_id);
340
+							if($current_status !== $post_status){
341
+								continue;
342
+							}
343
+							$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
344 344
 
345 345
 
346 346
 						}else{
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 				$team_members = false;
423 423
 			}
424 424
 
425
-            $safari_brands = false;
425
+			$safari_brands = false;
426 426
 
427 427
 			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
428 428
 				$content = $_POST['content'];	
@@ -430,16 +430,16 @@  discard block
 block discarded – undo
430 430
 				$content = false;
431 431
 			}
432 432
 
433
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
434
-            if($jdata)
435
-            {
436
-                $adata=json_decode($jdata,true);
437
-                if(!empty($adata))
438
-                {
439
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
440
-                	$this->format_completed_row($return);
441
-                }
442
-            }
433
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
434
+			if($jdata)
435
+			{
436
+				$adata=json_decode($jdata,true);
437
+				if(!empty($adata))
438
+				{
439
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
440
+					$this->format_completed_row($return);
441
+				}
442
+			}
443 443
 
444 444
 			die();
445 445
 		}
@@ -451,82 +451,82 @@  discard block
 block discarded – undo
451 451
 	 */
452 452
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
453 453
 
454
-        if(trim($data[0]['type'])=='Destination')
455
-        {
456
-	        $post_name = $data_post_content = $data_post_excerpt = '';
457
-	        $post = array(
458
-	          'post_type'		=> 'destination',
459
-	        );
460
-
461
-	        $content_used_general_description = false;
462
-
463
-	        //Set the post_content
464
-	        if(false !== $importable_content && in_array('description',$importable_content)){
465
-		        if(isset($data[0]['content']['extended_description']))
466
-		        {
467
-		            $data_post_content = $data[0]['content']['extended_description'];
468
-		        }elseif(isset($data[0]['content']['general_description'])){
469
-		            $data_post_content = $data[0]['content']['general_description'];
470
-		            $content_used_general_description = true;
471
-		        }elseif(isset($data[0]['content']['teaser_description'])){
472
-		        	$data_post_content = $data[0]['content']['teaser_description'];
473
-		        }
474
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
475
-	        }
476
-
477
-	        //set the post_excerpt
478
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
479
-		        if(isset($data[0]['content']['teaser_description'])){
480
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
481
-		        }elseif(isset($data[0]['content']['extended_description'])){
454
+		if(trim($data[0]['type'])=='Destination')
455
+		{
456
+			$post_name = $data_post_content = $data_post_excerpt = '';
457
+			$post = array(
458
+			  'post_type'		=> 'destination',
459
+			);
460
+
461
+			$content_used_general_description = false;
462
+
463
+			//Set the post_content
464
+			if(false !== $importable_content && in_array('description',$importable_content)){
465
+				if(isset($data[0]['content']['extended_description']))
466
+				{
467
+					$data_post_content = $data[0]['content']['extended_description'];
468
+				}elseif(isset($data[0]['content']['general_description'])){
469
+					$data_post_content = $data[0]['content']['general_description'];
470
+					$content_used_general_description = true;
471
+				}elseif(isset($data[0]['content']['teaser_description'])){
472
+					$data_post_content = $data[0]['content']['teaser_description'];
473
+				}
474
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
475
+			}
476
+
477
+			//set the post_excerpt
478
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
479
+				if(isset($data[0]['content']['teaser_description'])){
480
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
481
+				}elseif(isset($data[0]['content']['extended_description'])){
482 482
 					$data_post_excerpt = $data[0]['content']['extended_description'];
483 483
 				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
484
-		            $data_post_excerpt = $data[0]['content']['general_description'];
485
-		        }	   
486
-		        $post['post_excerpt'] = $data_post_excerpt;     	
487
-	        }
484
+					$data_post_excerpt = $data[0]['content']['general_description'];
485
+				}	   
486
+				$post['post_excerpt'] = $data_post_excerpt;     	
487
+			}
488 488
 
489
-	        if(false !== $id && '0' !== $id){
490
-	        	$post['ID'] = $id;
489
+			if(false !== $id && '0' !== $id){
490
+				$post['ID'] = $id;
491 491
 				if(isset($data[0]['name'])){
492 492
 					$post['post_title'] = $data[0]['name'];
493 493
 					$post['post_status'] = 'pending';
494 494
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
495 495
 				}
496
-	        	$id = wp_update_post($post);
497
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
498
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
499
-	        }else{
500
-
501
-		        //Set the name
502
-		        if(isset($data[0]['name'])){
503
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
504
-		        }
505
-	        	$post['post_name'] = $post_name;
506
-	        	$post['post_title'] = $data[0]['name'];
507
-	        	$post['post_status'] = 'pending';
508
-	        	$id = wp_insert_post($post);
509
-
510
-	        	//Save the WETU ID and the Last date it was modified.
511
-	        	if(false !== $id){
512
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
513
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
514
-	        	}
515
-	        }
516
-
517
-	        //Set the team member if it is there
518
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
519
-	        	$this->set_team_member($id,$team_members);
520
-	    	}
521
-
522
-	        if(false !== $importable_content && in_array('location',$importable_content)){
523
-	        	$this->set_map_data($data,$id);
524
-	        }
525
-
526
-	        //Set the Room Data
527
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
528
-	        	$this->set_video_data($data,$id);
529
-	    	}
496
+				$id = wp_update_post($post);
497
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
498
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
499
+			}else{
500
+
501
+				//Set the name
502
+				if(isset($data[0]['name'])){
503
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
504
+				}
505
+				$post['post_name'] = $post_name;
506
+				$post['post_title'] = $data[0]['name'];
507
+				$post['post_status'] = 'pending';
508
+				$id = wp_insert_post($post);
509
+
510
+				//Save the WETU ID and the Last date it was modified.
511
+				if(false !== $id){
512
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
513
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
514
+				}
515
+			}
516
+
517
+			//Set the team member if it is there
518
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
519
+				$this->set_team_member($id,$team_members);
520
+			}
521
+
522
+			if(false !== $importable_content && in_array('location',$importable_content)){
523
+				$this->set_map_data($data,$id);
524
+			}
525
+
526
+			//Set the Room Data
527
+			if(false !== $importable_content && in_array('videos',$importable_content)){
528
+				$this->set_video_data($data,$id);
529
+			}
530 530
 
531 531
 			//Set the Electricity
532 532
 			if(false !== $importable_content && in_array('electricity',$importable_content)){
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 				$this->set_travel_info($data,$id,'climate');
554 554
 			}
555 555
 
556
-        }
557
-        return $id;
556
+		}
557
+		return $id;
558 558
 	}
559 559
 
560 560
 	/**
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 
565 565
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
566 566
 		foreach($team_members as $team){
567
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
567
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
568 568
 		}
569 569
 	}
570 570
 	
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
 				'elevation'	=>	'',
617 617
 			);
618 618
 			if(false !== $id && '0' !== $id){
619
-	        	$prev = get_post_meta($id,'location',true);
620
-	        	update_post_meta($id,'location',$location_data,$prev);
621
-	        }else{
622
-	        	add_post_meta($id,'location',$location_data,true);
623
-	        }
619
+				$prev = get_post_meta($id,'location',true);
620
+				update_post_meta($id,'location',$location_data,$prev);
621
+			}else{
622
+				add_post_meta($id,'location',$location_data,true);
623
+			}
624 624
 		}
625 625
 	}
626 626
 
Please login to merge, or discard this patch.
classes/class-tours.php 1 patch
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * Display the importer administration screen
107 107
 	 */
108 108
 	public function display_page() {
109
-        ?>
109
+		?>
110 110
         <div class="wrap">
111 111
             <?php screen_icon(); ?>
112 112
 
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 			$result = $this->update_options();
233 233
 
234 234
 			if(true === $result){
235
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
236
-            }else{
237
-			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
238
-            }
235
+				echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
236
+			}else{
237
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
238
+			}
239 239
 		}else{
240 240
 			echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
241
-        }
241
+		}
242 242
 		echo '</h3></div>';
243 243
 	}
244 244
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 		$tours = json_decode($data, true);
251 251
 
252 252
 		if(isset($tours['error'])){
253
-		    return $tours['error'];
254
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
253
+			return $tours['error'];
254
+		}elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
255 255
 			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
256 256
 			return true;
257 257
 		}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 					$keyphrases = $_POST['keyword'];
301 301
 				}else{
302 302
 					$keyphrases = array(0);
303
-                }
303
+				}
304 304
 
305 305
 				if(!is_array($keyphrases)){
306 306
 					$keyphrases = array($keyphrases);
@@ -329,15 +329,15 @@  discard block
 block discarded – undo
329 329
 
330 330
 					foreach($tours as $row_key => $row){
331 331
 
332
-					    if(isset($row['is_disabled']) && true === $row['is_disabled']){
333
-                            continue;
334
-                        }
332
+						if(isset($row['is_disabled']) && true === $row['is_disabled']){
333
+							continue;
334
+						}
335 335
 
336
-                        if('Sample' === $row['type']){
337
-                            continue;
338
-                        }
336
+						if('Sample' === $row['type']){
337
+							continue;
338
+						}
339 339
 
340
-                        //If this is a current tour, add its ID to the row.
340
+						//If this is a current tour, add its ID to the row.
341 341
 						$row['post_id'] = 0;
342 342
 						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
343 343
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
@@ -346,31 +346,31 @@  discard block
 block discarded – undo
346 346
 						//If we are searching for
347 347
 						if(false !== $post_status){
348 348
 
349
-                            if('import' === $post_status){
349
+							if('import' === $post_status){
350 350
 
351 351
 								if(0 !== $row['post_id']){
352
-								    continue;
352
+									continue;
353 353
 								}else{
354 354
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
355
-                                }
355
+								}
356 356
 
357 357
 
358
-                            }else{
358
+							}else{
359 359
 
360 360
 								if(0 === $row['post_id']){
361 361
 									continue;
362 362
 								}else{
363 363
 									$current_status = get_post_status($row['post_id']);
364 364
 									if($current_status !== $post_status){
365
-									    continue;
366
-                                    }
365
+										continue;
366
+									}
367 367
 
368 368
 								}
369 369
 								$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
370 370
 
371
-                            }
371
+							}
372 372
 
373
-                        }else{
373
+						}else{
374 374
 							//Search through each keyword.
375 375
 							foreach($keyphrases as $keyphrase){
376 376
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
385 385
 								}
386 386
 							}
387
-                        }
387
+						}
388 388
 					}		
389 389
 				}
390 390
 
@@ -449,17 +449,17 @@  discard block
 block discarded – undo
449 449
 				$content = false;
450 450
 			}
451 451
 
452
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
452
+			$jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
453 453
 
454
-            if($jdata)
455
-            {
454
+			if($jdata)
455
+			{
456 456
 				$jdata=json_decode($jdata,true);
457
-                if(!empty($jdata))
458
-                {
459
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
460
-                	$this->format_completed_row($return);
461
-                }
462
-            }
457
+				if(!empty($jdata))
458
+				{
459
+					$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
460
+					$this->format_completed_row($return);
461
+				}
462
+			}
463 463
 			die();
464 464
 		}
465 465
 
@@ -467,61 +467,61 @@  discard block
 block discarded – undo
467 467
 
468 468
 	/**
469 469
 	 * Connect to wetu
470
-     *
471
-     * @param $data array
472
-     * @param $wetu_id string
470
+	 *
471
+	 * @param $data array
472
+	 * @param $wetu_id string
473 473
 	 */
474 474
 	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
475
-        $post_name = $data_post_content = $data_post_excerpt = '';
476
-        $post = array(
477
-          'post_type'		=> 'tour',
478
-        );
475
+		$post_name = $data_post_content = $data_post_excerpt = '';
476
+		$post = array(
477
+		  'post_type'		=> 'tour',
478
+		);
479 479
 
480
-        //Set the post_content
480
+		//Set the post_content
481 481
 		$content_used_general_description = false;
482
-        if(false !== $importable_content && in_array('description',$importable_content)){
483
-            $data_post_content = '';
484
-
485
-            if(isset($data['description'])){
486
-                $data_post_content = $data['description'];
487
-            }elseif(isset($data['summary'])){
488
-                $data_post_content = $data['summary'];
489
-                $content_used_general_description = true;
490
-            }
491
-            $post['post_content'] = wp_strip_all_tags($data_post_content);
492
-        }
493
-
494
-        //set the post_excerpt
495
-        if(false !== $importable_content && in_array('excerpt',$importable_content)){
496
-            if(isset($data['summary']) && false === $content_used_general_description){
497
-                $post['post_excerpt'] = $data['summary'];
498
-            }
499
-        }
500
-
501
-        //Create or update the post
502
-        if(false !== $id && '0' !== $id){
503
-            $post['ID'] = $id;
504
-	        $post['post_status'] = 'pending';
505
-            $id = wp_update_post($post);
506
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
507
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
508
-        }else{
509
-
510
-            //Set the name
511
-            if(isset($data['name'])){
512
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
513
-            }
514
-            $post['post_name'] = $post_name;
515
-            $post['post_title'] = $data['name'];
516
-            $post['post_status'] = 'pending';
517
-            $id = wp_insert_post($post);
518
-
519
-            //Save the WETU ID and the Last date it was modified.
520
-            if(false !== $id){
521
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
522
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
523
-            }
524
-        }
482
+		if(false !== $importable_content && in_array('description',$importable_content)){
483
+			$data_post_content = '';
484
+
485
+			if(isset($data['description'])){
486
+				$data_post_content = $data['description'];
487
+			}elseif(isset($data['summary'])){
488
+				$data_post_content = $data['summary'];
489
+				$content_used_general_description = true;
490
+			}
491
+			$post['post_content'] = wp_strip_all_tags($data_post_content);
492
+		}
493
+
494
+		//set the post_excerpt
495
+		if(false !== $importable_content && in_array('excerpt',$importable_content)){
496
+			if(isset($data['summary']) && false === $content_used_general_description){
497
+				$post['post_excerpt'] = $data['summary'];
498
+			}
499
+		}
500
+
501
+		//Create or update the post
502
+		if(false !== $id && '0' !== $id){
503
+			$post['ID'] = $id;
504
+			$post['post_status'] = 'pending';
505
+			$id = wp_update_post($post);
506
+			$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
507
+			update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
508
+		}else{
509
+
510
+			//Set the name
511
+			if(isset($data['name'])){
512
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
513
+			}
514
+			$post['post_name'] = $post_name;
515
+			$post['post_title'] = $data['name'];
516
+			$post['post_status'] = 'pending';
517
+			$id = wp_insert_post($post);
518
+
519
+			//Save the WETU ID and the Last date it was modified.
520
+			if(false !== $id){
521
+				add_post_meta($id,'lsx_wetu_id',$wetu_id);
522
+				add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
523
+			}
524
+		}
525 525
 
526 526
 
527 527
 		//Set the price
@@ -534,9 +534,9 @@  discard block
 block discarded – undo
534 534
 			$this->set_duration($data,$id);
535 535
 		}
536 536
 
537
-        if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
538
-            $this->process_itineraries($data,$id,$importable_content);
539
-        }
537
+		if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
538
+			$this->process_itineraries($data,$id,$importable_content);
539
+		}
540 540
 
541 541
 		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
542 542
 			$this->process_map_points($data,$id);
@@ -547,24 +547,24 @@  discard block
 block discarded – undo
547 547
 		if(false !== $importable_content && (in_array('itinerary_gallery',$importable_content) || in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
548 548
 			$this->find_attachments($id);
549 549
 		}
550
-        //Set the featured image
551
-        //TODO Test These
552
-        if(false !== $importable_content && in_array('featured_image',$importable_content)){
553
-            $this->set_featured_image($data,$id);
554
-        }
550
+		//Set the featured image
551
+		//TODO Test These
552
+		if(false !== $importable_content && in_array('featured_image',$importable_content)){
553
+			$this->set_featured_image($data,$id);
554
+		}
555 555
 
556 556
 		//TODO Test These
557
-        if(false !== $importable_content && in_array('banner_image',$importable_content)){
558
-            $this->set_banner_image($data,$id);
559
-        }
557
+		if(false !== $importable_content && in_array('banner_image',$importable_content)){
558
+			$this->set_banner_image($data,$id);
559
+		}
560 560
 
561 561
 		//TODO Test These
562
-        //Import the main gallery
563
-        if(false !== $importable_content && in_array('gallery',$importable_content)){
564
-            $this->create_main_gallery($data,$id);
565
-        }
562
+		//Import the main gallery
563
+		if(false !== $importable_content && in_array('gallery',$importable_content)){
564
+			$this->create_main_gallery($data,$id);
565
+		}
566 566
 
567
-        return $id;
567
+		return $id;
568 568
 	}
569 569
 
570 570
 	/**
@@ -652,31 +652,31 @@  discard block
 block discarded – undo
652 652
 	 */
653 653
 	public function process_map_points($data,$id) {
654 654
 
655
-	    if(!empty($data['routes'])){
655
+		if(!empty($data['routes'])){
656 656
 
657
-	        delete_post_meta($id,'wetu_map_points');
657
+			delete_post_meta($id,'wetu_map_points');
658 658
 
659
-	        $points = array();
659
+			$points = array();
660 660
 
661
-	        foreach($data['routes'] as $route){
661
+			foreach($data['routes'] as $route){
662 662
 
663 663
 
664
-	            if(isset($route['points']) && '' !== $route['points']){
664
+				if(isset($route['points']) && '' !== $route['points']){
665 665
 
666
-	                $temp_points = explode(';',$route['points']);
667
-	                $point_counter = count($temp_points);
666
+					$temp_points = explode(';',$route['points']);
667
+					$point_counter = count($temp_points);
668 668
 
669 669
 					for ($x = 0; $x <= $point_counter; $x++) {
670
-					    $y = $x+1;
670
+						$y = $x+1;
671 671
 						$points[] = $temp_points[$x].','.$temp_points[$y];
672 672
 						$x++;
673 673
 					}
674 674
 				}
675
-            }
676
-            if(!empty($points)){
675
+			}
676
+			if(!empty($points)){
677 677
 				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
678
-            }
679
-        }
678
+			}
679
+		}
680 680
 
681 681
 	}
682 682
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	 * Set the Itinerary Day
685 685
 	 */
686 686
 	public function set_itinerary_day($day,$id) {
687
-        $this->save_custom_field($day,'itinerary',$id,false,false);
687
+		$this->save_custom_field($day,'itinerary',$id,false,false);
688 688
 	}
689 689
 
690 690
 	/**
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 	 */
693 693
 	public function set_price($data,$id) {
694 694
 		if(isset($data['price']) && ''!== $data['price']){
695
-            $price = preg_replace("/[^0-9,.]/", "", $data['price']);
696
-            $this->save_custom_field($price,'price',$id);
695
+			$price = preg_replace("/[^0-9,.]/", "", $data['price']);
696
+			$this->save_custom_field($price,'price',$id);
697 697
 		}
698 698
 	}
699 699
 
@@ -714,35 +714,35 @@  discard block
 block discarded – undo
714 714
 	 */
715 715
 	public function set_accommodation($day,$id) {
716 716
 
717
-	    $ac_id = false;
717
+		$ac_id = false;
718 718
 		$this->current_accommodation = $this->find_current_accommodation();
719 719
 		
720 720
 		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
721 721
 
722 722
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
723
-                $ac_id = $this->current_accommodation[$day['content_entity_id']];
723
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
724 724
 			}else{
725 725
 				$ac_id = wp_insert_post(array(
726
-                    'post_type' => 'accommodation',
727
-                    'post_status' => 'draft',
728
-                    'post_title' => $day['content_entity_id']
729
-                ));
726
+					'post_type' => 'accommodation',
727
+					'post_status' => 'draft',
728
+					'post_title' => $day['content_entity_id']
729
+				));
730 730
 				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
731 731
 			}
732 732
 
733 733
 			if('' !== $ac_id && false !== $ac_id){
734
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
734
+				$this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
735 735
 				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
736
-            }
736
+			}
737 737
 		}
738 738
 		return $ac_id;
739 739
 	}
740 740
 
741 741
 	/**
742 742
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
743
-     *
744
-     * @param $post_type string
745
-     * @return boolean / array
743
+	 *
744
+	 * @param $post_type string
745
+	 * @return boolean / array
746 746
 	 */
747 747
 	public function find_current_accommodation($post_type='accommodation') {
748 748
 		global $wpdb;
@@ -750,16 +750,16 @@  discard block
 block discarded – undo
750 750
 
751 751
 		$return = false;
752 752
 		if(!empty($accommodation)){
753
-		    foreach($accommodation as $key => $acc){
753
+			foreach($accommodation as $key => $acc){
754 754
 				$return[$acc->meta_value] = $acc->post_id;
755
-            }
756
-        }
755
+			}
756
+		}
757 757
 		return $return;
758 758
 	}
759 759
 
760 760
 	/**
761 761
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
762
-     * @return boolean / array
762
+	 * @return boolean / array
763 763
 	 */
764 764
 	public function find_current_destinations() {
765 765
 		return $this->find_current_accommodation('destination');
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
787 787
 				if(false !== $country_wetu_id){
788 788
 					$this->set_country($country_wetu_id, $id);
789
-                }
789
+				}
790 790
 
791 791
 			}else {
792 792
 
@@ -797,27 +797,27 @@  discard block
 block discarded – undo
797 797
 
798 798
 					if (!empty($destination_data) && !isset($destination_data['error'])) {
799 799
 
800
-					    $destination_title = $day['destination_content_entity_id'];
800
+						$destination_title = $day['destination_content_entity_id'];
801 801
 
802
-					    if(isset($destination_data[0]['name'])){
802
+						if(isset($destination_data[0]['name'])){
803 803
 							$destination_title = $destination_data[0]['name'];
804
-                        }
804
+						}
805 805
 
806
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
807
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
806
+						if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
807
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
808 808
 
809 809
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
810
-                        }
810
+						}
811 811
 
812
-                        $dest_post = array(
812
+						$dest_post = array(
813 813
 							'post_type' => 'destination',
814 814
 							'post_status' => 'draft',
815 815
 							'post_title' => $destination_title
816 816
 						);
817 817
 
818
-					    if(false !== $country_id){
818
+						if(false !== $country_id){
819 819
 							$dest_post['post_parent'] = $country_id;
820
-                        }
820
+						}
821 821
 						$dest_id = wp_insert_post($dest_post);
822 822
 
823 823
 						$this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id);
@@ -836,45 +836,45 @@  discard block
 block discarded – undo
836 836
 	 * Connects the destinations post type
837 837
 	 *
838 838
 	 * @param $dest_id string
839
-     * @param $country_id array
839
+	 * @param $country_id array
840 840
 	 * @param $id string
841 841
 	 */
842 842
 	public function set_country($country_wetu_id, $id) {
843
-	    $country_id = false;
843
+		$country_id = false;
844 844
 		$this->current_destinations = $this->find_current_destinations();
845 845
 
846
-        if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
847
-            $country_id = $this->current_destinations[$country_wetu_id];
848
-        } else {
846
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
847
+			$country_id = $this->current_destinations[$country_wetu_id];
848
+		} else {
849 849
 
850
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
850
+			$country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
851 851
 
852
-            if ($country_json) {
853
-                $country_data = json_decode($country_json, true);
852
+			if ($country_json) {
853
+				$country_data = json_decode($country_json, true);
854 854
 
855
-                if (!empty($country_data) && !isset($country_data['error'])) {
855
+				if (!empty($country_data) && !isset($country_data['error'])) {
856 856
 
857
-                    $country_title = $country_wetu_id;
858
-                    if (isset($country_data[0]['name'])) {
857
+					$country_title = $country_wetu_id;
858
+					if (isset($country_data[0]['name'])) {
859 859
 						$country_title = $country_data[0]['name'];
860
-                    }
860
+					}
861 861
 
862 862
 					$country_id = wp_insert_post(array(
863
-                        'post_type' => 'destination',
864
-                        'post_status' => 'draft',
865
-                        'post_title' => $country_title
866
-                    ));
867
-                    $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
868
-                }
869
-            }
870
-        }
871
-
872
-        if ('' !== $country_id && false !== $country_id) {
873
-            $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
874
-            $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
875
-
876
-            return $country_id;
877
-        }
863
+						'post_type' => 'destination',
864
+						'post_status' => 'draft',
865
+						'post_title' => $country_title
866
+					));
867
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
868
+				}
869
+			}
870
+		}
871
+
872
+		if ('' !== $country_id && false !== $country_id) {
873
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
874
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
875
+
876
+			return $country_id;
877
+		}
878 878
 	}
879 879
 }
880 880
 $wetu_importer_tours = new WETU_Importer_Tours();
881 881
\ No newline at end of file
Please login to merge, or discard this patch.