Completed
Push — master ( 6435ab...d652f3 )
by Warwick
03:23
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   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * Display the importer administration screen
79 79
 	 */
80 80
 	public function display_page() {
81
-        ?>
81
+		?>
82 82
         <div class="wrap">
83 83
             <?php screen_icon(); ?>
84 84
 
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 		            </ul> 
101 101
 	             	            
102 102
             <?php } else {
103
-            	do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
104
-            } ?>
103
+				do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
104
+			} ?>
105 105
         </div>
106 106
         <?php
107 107
 	}
@@ -148,37 +148,37 @@  discard block
 block discarded – undo
148 148
 	 * set_taxonomy with some terms
149 149
 	 */
150 150
 	public function set_taxonomy($taxonomy,$terms,$id) {
151
-        $result=array();
152
-        if(!empty($data))
153
-        {
154
-            foreach($data as $k)
155
-            {
156
-                if($id)
157
-                {
158
-                    if(!$term = term_exists(trim($k), $tax))
159
-                    {
160
-                        $term = wp_insert_term(trim($k), $tax);
161
-                        if ( is_wp_error($term) )
162
-                        {
163
-                            echo $term->get_error_message();
164
-                        }
165
-                        else
166
-                        {
167
-                            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
168
-                        }
169
-                    }
170
-                    else
171
-                    {
172
-                        wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
173
-                    }
174
-                }
175
-                else
176
-                {
177
-                    $result[]=trim($k);
178
-                }
179
-            }
180
-        }
181
-        return $result;
151
+		$result=array();
152
+		if(!empty($data))
153
+		{
154
+			foreach($data as $k)
155
+			{
156
+				if($id)
157
+				{
158
+					if(!$term = term_exists(trim($k), $tax))
159
+					{
160
+						$term = wp_insert_term(trim($k), $tax);
161
+						if ( is_wp_error($term) )
162
+						{
163
+							echo $term->get_error_message();
164
+						}
165
+						else
166
+						{
167
+							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
168
+						}
169
+					}
170
+					else
171
+					{
172
+						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
173
+					}
174
+				}
175
+				else
176
+				{
177
+					$result[]=trim($k);
178
+				}
179
+			}
180
+		}
181
+		return $result;
182 182
 	}
183 183
 
184 184
 	/**
@@ -188,21 +188,21 @@  discard block
 block discarded – undo
188 188
 		if(post_type_exists('team')) { ?>
189 189
     		<ul>
190 190
     			<?php
191
-    				$team_args=array(
192
-    					'post_type'	=>	'team',
193
-    					'post_status' => 'publish',
194
-    					'nopagin' => true,
195
-    					'fields' => 'ids'
196
-    				);
197
-    				$team_members = new WP_Query($team_args);
198
-    					if($team_members->have_posts()){
199
-    						foreach($team_members->posts as $member){ ?>
191
+					$team_args=array(
192
+						'post_type'	=>	'team',
193
+						'post_status' => 'publish',
194
+						'nopagin' => true,
195
+						'fields' => 'ids'
196
+					);
197
+					$team_members = new WP_Query($team_args);
198
+						if($team_members->have_posts()){
199
+							foreach($team_members->posts as $member){ ?>
200 200
     							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
201 201
     						<?php }
202
-    					}else{ ?>
202
+						}else{ ?>
203 203
     							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
204 204
     					<?php }
205
-    				?>
205
+					?>
206 206
     		</ul>
207 207
     	<?php }		
208 208
 	}
@@ -254,42 +254,42 @@  discard block
 block discarded – undo
254 254
 		if(false !== $id){
255 255
 			if(empty($this->found_attachments)){
256 256
 
257
-		    	$attachments_args = array(
258
-		    			'post_parent' => $id,
259
-		    			'post_status' => 'inherit',
260
-		    			'post_type' => 'attachment',
261
-		    			'order' => 'ASC',
262
-                        'nopagin' => 'true',
263
-                        'posts_per_page' => '-1'
264
-		    	);   	
257
+				$attachments_args = array(
258
+						'post_parent' => $id,
259
+						'post_status' => 'inherit',
260
+						'post_type' => 'attachment',
261
+						'order' => 'ASC',
262
+						'nopagin' => 'true',
263
+						'posts_per_page' => '-1'
264
+				);   	
265 265
 		    	 
266
-		    	$attachments = new WP_Query($attachments_args);
267
-		    	if($attachments->have_posts()){
268
-		    		foreach($attachments->posts as $attachment){
269
-		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
270
-		    			$this->gallery_meta[] = $attachment->ID;
271
-		    		}
272
-		    	}
266
+				$attachments = new WP_Query($attachments_args);
267
+				if($attachments->have_posts()){
268
+					foreach($attachments->posts as $attachment){
269
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
270
+						$this->gallery_meta[] = $attachment->ID;
271
+					}
272
+				}
273 273
 			}
274 274
 		}
275 275
 	}
276 276
 
277 277
 	/**
278 278
 	 * Checks to see if an item is selected.
279
-     *
280
-     * @param $haystack array|string
281
-     * @param $needle string
282
-     * @return string
279
+	 *
280
+	 * @param $haystack array|string
281
+	 * @param $needle string
282
+	 * @return string
283 283
 	 */
284 284
 	public function checked($haystack=false,$needle='') {
285
-	    $return = '';
286
-	    if(!is_array($haystack)){
285
+		$return = '';
286
+		if(!is_array($haystack)){
287 287
 			$haystack = array($haystack);
288
-        }
289
-        if(in_array($needle,$haystack)){
288
+		}
289
+		if(in_array($needle,$haystack)){
290 290
 			$return = 'checked="checked"';
291
-        }
292
-	    echo $return;
291
+		}
292
+		echo $return;
293 293
 	}
294 294
 }
295 295
 $wetu_importer_admin = new WETU_Importer_Admin();
296 296
\ No newline at end of file
Please login to merge, or discard this patch.
classes/class-destination.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * Display the importer administration screen
105 105
 	 */
106 106
 	public function display_page() {
107
-        ?>
107
+		?>
108 108
         <div class="wrap">
109 109
             <?php screen_icon(); ?>
110 110
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 					$keyphrases = $_POST['keyword'];
330 330
 				}else{
331 331
 					$keyphrases = array(0);
332
-                }
332
+				}
333 333
 
334 334
 				if(!is_array($keyphrases)){
335 335
 					$keyphrases = array($keyphrases);
@@ -358,11 +358,11 @@  discard block
 block discarded – undo
358 358
 						//If we are searching for
359 359
 						if(false !== $post_status){
360 360
 
361
-                            $current_status = get_post_status($row->post_id);
362
-                            if($current_status !== $post_status){
363
-                                continue;
364
-                            }
365
-                            $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
361
+							$current_status = get_post_status($row->post_id);
362
+							if($current_status !== $post_status){
363
+								continue;
364
+							}
365
+							$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
366 366
 
367 367
 
368 368
 						}else{
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 				$team_members = false;
445 445
 			}
446 446
 
447
-            $safari_brands = false;
447
+			$safari_brands = false;
448 448
 
449 449
 			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
450 450
 				$content = $_POST['content'];
@@ -455,16 +455,16 @@  discard block
 block discarded – undo
455 455
 				$content = false;
456 456
 			}
457 457
 
458
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
459
-            if($jdata)
460
-            {
461
-                $adata=json_decode($jdata,true);
462
-                if(!empty($adata))
463
-                {
464
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
465
-                	$this->format_completed_row($return);
466
-                }
467
-            }
458
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
459
+			if($jdata)
460
+			{
461
+				$adata=json_decode($jdata,true);
462
+				if(!empty($adata))
463
+				{
464
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
465
+					$this->format_completed_row($return);
466
+				}
467
+			}
468 468
 
469 469
 			die();
470 470
 		}
@@ -476,82 +476,82 @@  discard block
 block discarded – undo
476 476
 	 */
477 477
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
478 478
 
479
-        if(trim($data[0]['type'])=='Destination')
480
-        {
481
-	        $post_name = $data_post_content = $data_post_excerpt = '';
482
-	        $post = array(
483
-	          'post_type'		=> 'destination',
484
-	        );
485
-
486
-	        $content_used_general_description = false;
487
-
488
-	        //Set the post_content
489
-	        if(false !== $importable_content && in_array('description',$importable_content)){
490
-		        if(isset($data[0]['content']['extended_description']))
491
-		        {
492
-		            $data_post_content = $data[0]['content']['extended_description'];
493
-		        }elseif(isset($data[0]['content']['general_description'])){
494
-		            $data_post_content = $data[0]['content']['general_description'];
495
-		            $content_used_general_description = true;
496
-		        }elseif(isset($data[0]['content']['teaser_description'])){
497
-		        	$data_post_content = $data[0]['content']['teaser_description'];
498
-		        }
499
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
500
-	        }
501
-
502
-	        //set the post_excerpt
503
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
504
-		        if(isset($data[0]['content']['teaser_description'])){
505
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
506
-		        }elseif(isset($data[0]['content']['extended_description'])){
479
+		if(trim($data[0]['type'])=='Destination')
480
+		{
481
+			$post_name = $data_post_content = $data_post_excerpt = '';
482
+			$post = array(
483
+			  'post_type'		=> 'destination',
484
+			);
485
+
486
+			$content_used_general_description = false;
487
+
488
+			//Set the post_content
489
+			if(false !== $importable_content && in_array('description',$importable_content)){
490
+				if(isset($data[0]['content']['extended_description']))
491
+				{
492
+					$data_post_content = $data[0]['content']['extended_description'];
493
+				}elseif(isset($data[0]['content']['general_description'])){
494
+					$data_post_content = $data[0]['content']['general_description'];
495
+					$content_used_general_description = true;
496
+				}elseif(isset($data[0]['content']['teaser_description'])){
497
+					$data_post_content = $data[0]['content']['teaser_description'];
498
+				}
499
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
500
+			}
501
+
502
+			//set the post_excerpt
503
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
504
+				if(isset($data[0]['content']['teaser_description'])){
505
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
506
+				}elseif(isset($data[0]['content']['extended_description'])){
507 507
 					$data_post_excerpt = $data[0]['content']['extended_description'];
508 508
 				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
509
-		            $data_post_excerpt = $data[0]['content']['general_description'];
510
-		        }	   
511
-		        $post['post_excerpt'] = $data_post_excerpt;     	
512
-	        }
509
+					$data_post_excerpt = $data[0]['content']['general_description'];
510
+				}	   
511
+				$post['post_excerpt'] = $data_post_excerpt;     	
512
+			}
513 513
 
514
-	        if(false !== $id && '0' !== $id){
515
-	        	$post['ID'] = $id;
514
+			if(false !== $id && '0' !== $id){
515
+				$post['ID'] = $id;
516 516
 				if(isset($data[0]['name'])){
517 517
 					$post['post_title'] = $data[0]['name'];
518 518
 					$post['post_status'] = 'publish';
519 519
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
520 520
 				}
521
-	        	$id = wp_update_post($post);
522
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
523
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
524
-	        }else{
525
-
526
-		        //Set the name
527
-		        if(isset($data[0]['name'])){
528
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
529
-		        }
530
-	        	$post['post_name'] = $post_name;
531
-	        	$post['post_title'] = $data[0]['name'];
532
-	        	$post['post_status'] = 'publish';
533
-	        	$id = wp_insert_post($post);
534
-
535
-	        	//Save the WETU ID and the Last date it was modified.
536
-	        	if(false !== $id){
537
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
538
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
539
-	        	}
540
-	        }
541
-
542
-	        //Set the team member if it is there
543
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
544
-	        	$this->set_team_member($id,$team_members);
545
-	    	}
546
-
547
-	        if(class_exists('LSX_TO_Maps')){
548
-	        	$this->set_map_data($data,$id,4);
549
-	        }
550
-
551
-	        //Set the Room Data
552
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
553
-	        	$this->set_video_data($data,$id);
554
-	    	}
521
+				$id = wp_update_post($post);
522
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
523
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
524
+			}else{
525
+
526
+				//Set the name
527
+				if(isset($data[0]['name'])){
528
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
529
+				}
530
+				$post['post_name'] = $post_name;
531
+				$post['post_title'] = $data[0]['name'];
532
+				$post['post_status'] = 'publish';
533
+				$id = wp_insert_post($post);
534
+
535
+				//Save the WETU ID and the Last date it was modified.
536
+				if(false !== $id){
537
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
538
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
539
+				}
540
+			}
541
+
542
+			//Set the team member if it is there
543
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
544
+				$this->set_team_member($id,$team_members);
545
+			}
546
+
547
+			if(class_exists('LSX_TO_Maps')){
548
+				$this->set_map_data($data,$id,4);
549
+			}
550
+
551
+			//Set the Room Data
552
+			if(false !== $importable_content && in_array('videos',$importable_content)){
553
+				$this->set_video_data($data,$id);
554
+			}
555 555
 
556 556
 			//Set the Electricity
557 557
 			if(false !== $importable_content && in_array('electricity',$importable_content)){
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 			}
597 597
 
598 598
 		}
599
-        return $id;
599
+		return $id;
600 600
 	}
601 601
 
602 602
 	/**
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 
607 607
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
608 608
 		foreach($team_members as $team){
609
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
609
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
610 610
 		}
611 611
 	}
612 612
 	
@@ -657,11 +657,11 @@  discard block
 block discarded – undo
657 657
 				'elevation'	=>	'',
658 658
 			);
659 659
 			if(false !== $id && '0' !== $id){
660
-	        	$prev = get_post_meta($id,'location',true);
661
-	        	update_post_meta($id,'location',$location_data,$prev);
662
-	        }else{
663
-	        	add_post_meta($id,'location',$location_data,true);
664
-	        }
660
+				$prev = get_post_meta($id,'location',true);
661
+				update_post_meta($id,'location',$location_data,$prev);
662
+			}else{
663
+				add_post_meta($id,'location',$location_data,true);
664
+			}
665 665
 		}
666 666
 	}
667 667
 
Please login to merge, or discard this patch.
classes/class-accommodation.php 1 patch
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * Display the importer administration screen
137 137
 	 */
138 138
 	public function display_page() {
139
-        ?>
139
+		?>
140 140
         <div class="wrap">
141 141
             <?php screen_icon(); ?>
142 142
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 		$accommodation = json_decode($data, true);
315 315
 
316 316
 		if(isset($accommodation['error'])){
317
-		    return $accommodation['error'];
318
-        }elseif (isset($accommodation) && !empty($accommodation)) {
317
+			return $accommodation['error'];
318
+		}elseif (isset($accommodation) && !empty($accommodation)) {
319 319
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
320 320
 			return true;
321 321
 		}
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 					$keyphrases = $_POST['keyword'];
364 364
 				}else{
365 365
 					$keyphrases = array(0);
366
-                }
366
+				}
367 367
 
368 368
 				if(!is_array($keyphrases)){
369 369
 					$keyphrases = array($keyphrases);
@@ -460,13 +460,13 @@  discard block
 block discarded – undo
460 460
 	public function multineedle_stripos($haystack, $needles, $offset=0) {
461 461
 		$found = false;
462 462
 		$needle_count = count($needles);
463
-	    foreach($needles as $needle) {
464
-	    	if(false !== stripos($haystack, $needle, $offset)){
465
-	        	$found[] = true;
466
-	    	}
467
-	    }
468
-	    if(false !== $found && $needle_count === count($found)){ 
469
-	    	return true;
463
+		foreach($needles as $needle) {
464
+			if(false !== stripos($haystack, $needle, $offset)){
465
+				$found[] = true;
466
+			}
467
+		}
468
+		if(false !== $found && $needle_count === count($found)){ 
469
+			return true;
470 470
 		}else{
471 471
 			return false;
472 472
 		}
@@ -537,16 +537,16 @@  discard block
 block discarded – undo
537 537
 				$content = false;
538 538
 			}
539 539
 
540
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
541
-            if($jdata)
542
-            {
543
-                $adata=json_decode($jdata,true);
544
-                if(!empty($adata))
545
-                {
546
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
547
-                	$this->format_completed_row($return);
548
-                }
549
-            }
540
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
541
+			if($jdata)
542
+			{
543
+				$adata=json_decode($jdata,true);
544
+				if(!empty($adata))
545
+				{
546
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
547
+					$this->format_completed_row($return);
548
+				}
549
+			}
550 550
 
551 551
 			die();
552 552
 		}
@@ -563,148 +563,148 @@  discard block
 block discarded – undo
563 563
 	 */
564 564
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
565 565
 
566
-        if(trim($data[0]['type'])=='Accommodation')
567
-        {
568
-	        $post_name = $data_post_content = $data_post_excerpt = '';
569
-	        $post = array(
570
-	          'post_type'		=> 'accommodation',
571
-	        );
572
-
573
-	        $content_used_general_description = false;
574
-
575
-	        //Set the post_content
576
-	        if(false !== $importable_content && in_array('description',$importable_content)){
577
-		        if(isset($data[0]['content']['extended_description']))
578
-		        {
579
-		            $data_post_content = $data[0]['content']['extended_description'];
580
-		        }elseif(isset($data[0]['content']['general_description'])){
581
-		            $data_post_content = $data[0]['content']['general_description'];
582
-		            $content_used_general_description = true;
583
-		        }elseif(isset($data[0]['content']['teaser_description'])){
584
-		        	$data_post_content = $data[0]['content']['teaser_description'];
585
-		        }
586
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
587
-	        }
588
-
589
-	        //set the post_excerpt
590
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
591
-		        if(isset($data[0]['content']['teaser_description'])){
592
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
593
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
594
-		            $data_post_excerpt = $data[0]['content']['general_description'];
595
-		        }	   
596
-		        $post['post_excerpt'] = $data_post_excerpt;     	
597
-	        }
598
-
599
-	        if(false !== $id && '0' !== $id){
600
-	        	$post['ID'] = $id;
566
+		if(trim($data[0]['type'])=='Accommodation')
567
+		{
568
+			$post_name = $data_post_content = $data_post_excerpt = '';
569
+			$post = array(
570
+			  'post_type'		=> 'accommodation',
571
+			);
572
+
573
+			$content_used_general_description = false;
574
+
575
+			//Set the post_content
576
+			if(false !== $importable_content && in_array('description',$importable_content)){
577
+				if(isset($data[0]['content']['extended_description']))
578
+				{
579
+					$data_post_content = $data[0]['content']['extended_description'];
580
+				}elseif(isset($data[0]['content']['general_description'])){
581
+					$data_post_content = $data[0]['content']['general_description'];
582
+					$content_used_general_description = true;
583
+				}elseif(isset($data[0]['content']['teaser_description'])){
584
+					$data_post_content = $data[0]['content']['teaser_description'];
585
+				}
586
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
587
+			}
588
+
589
+			//set the post_excerpt
590
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
591
+				if(isset($data[0]['content']['teaser_description'])){
592
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
593
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
594
+					$data_post_excerpt = $data[0]['content']['general_description'];
595
+				}	   
596
+				$post['post_excerpt'] = $data_post_excerpt;     	
597
+			}
598
+
599
+			if(false !== $id && '0' !== $id){
600
+				$post['ID'] = $id;
601 601
 				if(isset($data[0]['name'])){
602 602
 					$post['post_title'] = $data[0]['name'];
603
-	        		$post['post_status'] = 'publish';
603
+					$post['post_status'] = 'publish';
604 604
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
605 605
 				}
606
-	        	$id = wp_update_post($post);
607
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
608
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
609
-	        }else{
610
-
611
-		        //Set the name
612
-		        if(isset($data[0]['name'])){
613
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
614
-		        }
615
-	        	$post['post_name'] = $post_name;
616
-	        	$post['post_title'] = $data[0]['name'];
617
-	        	$post['post_status'] = 'publish';
618
-	        	$id = wp_insert_post($post);
619
-
620
-	        	//Save the WETU ID and the Last date it was modified.
621
-	        	if(false !== $id){
622
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
623
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
624
-	        	}
625
-	        }
626
-	        //Setup some default for use in the import
627
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
606
+				$id = wp_update_post($post);
607
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
608
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
609
+			}else{
610
+
611
+				//Set the name
612
+				if(isset($data[0]['name'])){
613
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
614
+				}
615
+				$post['post_name'] = $post_name;
616
+				$post['post_title'] = $data[0]['name'];
617
+				$post['post_status'] = 'publish';
618
+				$id = wp_insert_post($post);
619
+
620
+				//Save the WETU ID and the Last date it was modified.
621
+				if(false !== $id){
622
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
623
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
624
+				}
625
+			}
626
+			//Setup some default for use in the import
627
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
628 628
 				$this->find_attachments($id);
629 629
 			}
630 630
 
631
-	        //Set the team member if it is there
632
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
633
-	        	$this->set_team_member($id,$team_members);
634
-	    	}
635
-
636
-	        //Set the safari brand
637
-	        if(false !== $safari_brands && '' !== $safari_brands){
638
-	        	$this->set_safari_brands($id,$safari_brands);
639
-
640
-	    	}	    	
641
-
642
-	        if(class_exists('LSX_TO_Maps')){
643
-	        	$this->set_map_data($data,$id,9);
644
-	        	$this->set_location_taxonomy($data,$id);
645
-	        }
646
-
647
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
648
-	        	$this->connect_destinations($data,$id);
649
-	        }
650
-
651
-	        if(false !== $importable_content && in_array('category',$importable_content)){
652
-	        	$this->set_taxonomy_style($data,$id);
653
-	        }
654
-
655
-	        //Set the Room Data
656
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
657
-	        	$this->set_room_data($data,$id);
658
-	    	}
659
-
660
-	    	//Set the rating
661
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
662
-	       		$this->set_rating($data,$id);
663
-	    	}
664
-
665
-	    	//Set the checkin checkout data
666
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
667
-	        	$this->set_checkin_checkout($data,$id);
668
-	        }
669
-
670
-	    	//Set the Spoken Languages
671
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
672
-	       		$this->set_spoken_languages($data,$id);
673
-	    	}
674
-
675
-	    	//Set the friendly options
676
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
677
-	       		$this->set_friendly($data,$id);
678
-	    	}
679
-
680
-	    	//Set the special_interests
681
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
682
-	       		$this->set_special_interests($data,$id);
683
-	    	}	    		    		        
684
-
685
-	        //Import the videos
686
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
687
-	        	$this->set_video_data($data,$id);
688
-	        }
689
-
690
-	        //Import the facilities
691
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
692
-	        	$this->set_facilities($data,$id);
693
-	        }	        
694
-
695
-	        //Set the featured image
696
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
697
-	        	$this->set_featured_image($data,$id);
698
-	        }
699
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
700
-	        	$this->set_banner_image($data,$id);
701
-	        }	        
702
-	        //Import the main gallery
703
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
704
-	    		$this->create_main_gallery($data,$id);
705
-	        }	        	        	        
706
-        }
707
-        return $id;
631
+			//Set the team member if it is there
632
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
633
+				$this->set_team_member($id,$team_members);
634
+			}
635
+
636
+			//Set the safari brand
637
+			if(false !== $safari_brands && '' !== $safari_brands){
638
+				$this->set_safari_brands($id,$safari_brands);
639
+
640
+			}	    	
641
+
642
+			if(class_exists('LSX_TO_Maps')){
643
+				$this->set_map_data($data,$id,9);
644
+				$this->set_location_taxonomy($data,$id);
645
+			}
646
+
647
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
648
+				$this->connect_destinations($data,$id);
649
+			}
650
+
651
+			if(false !== $importable_content && in_array('category',$importable_content)){
652
+				$this->set_taxonomy_style($data,$id);
653
+			}
654
+
655
+			//Set the Room Data
656
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
657
+				$this->set_room_data($data,$id);
658
+			}
659
+
660
+			//Set the rating
661
+			if(false !== $importable_content && in_array('rating',$importable_content)){
662
+		   		$this->set_rating($data,$id);
663
+			}
664
+
665
+			//Set the checkin checkout data
666
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
667
+				$this->set_checkin_checkout($data,$id);
668
+			}
669
+
670
+			//Set the Spoken Languages
671
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
672
+		   		$this->set_spoken_languages($data,$id);
673
+			}
674
+
675
+			//Set the friendly options
676
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
677
+		   		$this->set_friendly($data,$id);
678
+			}
679
+
680
+			//Set the special_interests
681
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
682
+		   		$this->set_special_interests($data,$id);
683
+			}	    		    		        
684
+
685
+			//Import the videos
686
+			if(false !== $importable_content && in_array('videos',$importable_content)){
687
+				$this->set_video_data($data,$id);
688
+			}
689
+
690
+			//Import the facilities
691
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
692
+				$this->set_facilities($data,$id);
693
+			}	        
694
+
695
+			//Set the featured image
696
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
697
+				$this->set_featured_image($data,$id);
698
+			}
699
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
700
+				$this->set_banner_image($data,$id);
701
+			}	        
702
+			//Import the main gallery
703
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
704
+				$this->create_main_gallery($data,$id);
705
+			}	        	        	        
706
+		}
707
+		return $id;
708 708
 	}
709 709
 
710 710
 	/**
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 
715 715
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
716 716
 		foreach($team_members as $team){
717
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
717
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
718 718
 		}
719 719
 	}
720 720
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 */
724 724
 	public function set_safari_brands($id,$safari_brands) {
725 725
 		foreach($safari_brands as $safari_brand){
726
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
726
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
727 727
 		}
728 728
 	}	
729 729
 	
@@ -773,11 +773,11 @@  discard block
 block discarded – undo
773 773
 				'elevation'	=>	'',
774 774
 			);
775 775
 			if(false !== $id && '0' !== $id){
776
-	        	$prev = get_post_meta($id,'location',true);
777
-	        	update_post_meta($id,'location',$location_data,$prev);
778
-	        }else{
779
-	        	add_post_meta($id,'location',$location_data,true);
780
-	        }
776
+				$prev = get_post_meta($id,'location',true);
777
+				update_post_meta($id,'location',$location_data,$prev);
778
+			}else{
779
+				add_post_meta($id,'location',$location_data,true);
780
+			}
781 781
 		}
782 782
 	}
783 783
 	/**
@@ -791,35 +791,35 @@  discard block
 block discarded – undo
791 791
 			if(isset($data[0]['position']['country'])){
792 792
 
793 793
 				if(!$term = term_exists(trim($data[0]['position']['country']), 'location'))
794
-		        {
795
-		            $term = wp_insert_term(trim($data[0]['position']['country']), 'location');
796
-		            if ( is_wp_error($term) ){
797
-		            	echo $term->get_error_message();
798
-		            }
799
-		            else {
800
-		            	wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
801
-		            }
802
-		        }
803
-		        else
804
-		        {
805
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
806
-		        }
807
-		        $country_id = intval($term['term_id']);
808
-		    }
794
+				{
795
+					$term = wp_insert_term(trim($data[0]['position']['country']), 'location');
796
+					if ( is_wp_error($term) ){
797
+						echo $term->get_error_message();
798
+					}
799
+					else {
800
+						wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
801
+					}
802
+				}
803
+				else
804
+				{
805
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
806
+				}
807
+				$country_id = intval($term['term_id']);
808
+			}
809 809
 
810 810
 			if(isset($data[0]['position']['destination'])){
811 811
 
812 812
 				$tax_args = array('parent'=>$country_id);
813 813
 				if(!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
814
-		        {
815
-		            $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
816
-		            if ( is_wp_error($term) ){echo $term->get_error_message();}
817
-		            else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
818
-		        }
819
-		        else
820
-		        {
821
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
822
-		        }				
814
+				{
815
+					$term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
816
+					if ( is_wp_error($term) ){echo $term->get_error_message();}
817
+					else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
818
+				}
819
+				else
820
+				{
821
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
822
+				}				
823 823
 			}		
824 824
 		}
825 825
 	}
@@ -829,31 +829,31 @@  discard block
 block discarded – undo
829 829
 	 */
830 830
 	public function connect_destinations($data,$id) {
831 831
 		if(isset($data[0]['position'])){
832
-		    $destinations = false;
833
-		    if(isset($data[0]['position']['country'])){
834
-		    	$destinations['country'] = $data[0]['position']['country'];
835
-		    }
836
-		    if(isset($data[0]['position']['destination'])){
837
-		    	$destinations['destination'] = $data[0]['position']['destination'];
838
-		    }
832
+			$destinations = false;
833
+			if(isset($data[0]['position']['country'])){
834
+				$destinations['country'] = $data[0]['position']['country'];
835
+			}
836
+			if(isset($data[0]['position']['destination'])){
837
+				$destinations['destination'] = $data[0]['position']['destination'];
838
+			}
839 839
 		    
840
-		    if(false !== $destinations){	
841
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
842
-		    	if(false === $prev_values || !is_array($prev_values)){
843
-		    		$prev_values = array();
844
-		    	}
845
-		    	//print_r($destinations);
840
+			if(false !== $destinations){	
841
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
842
+				if(false === $prev_values || !is_array($prev_values)){
843
+					$prev_values = array();
844
+				}
845
+				//print_r($destinations);
846 846
 				$destinations = array_unique($destinations);
847 847
 				//print_r($destinations);
848
-			    foreach($destinations as $key => $value){
849
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
850
-	                if (null !== $destination) {
851
-	                	if(!in_array($destination->ID,$prev_values)){
852
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
853
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
854
-	                	}
855
-	                } 		    	
856
-			    }	
848
+				foreach($destinations as $key => $value){
849
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
850
+					if (null !== $destination) {
851
+						if(!in_array($destination->ID,$prev_values)){
852
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
853
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
854
+						}
855
+					} 		    	
856
+				}	
857 857
 			}
858 858
 		}
859 859
 	}	
@@ -865,15 +865,15 @@  discard block
 block discarded – undo
865 865
 		$terms = false;
866 866
 		if(isset($data[0]['category'])){
867 867
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
868
-	        {
869
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
870
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
871
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
872
-	        }
873
-	        else
874
-	        {
875
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
876
-	        }				
868
+			{
869
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
870
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
871
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
872
+			}
873
+			else
874
+			{
875
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
876
+			}				
877 877
 		}
878 878
 	}		
879 879
 
@@ -897,25 +897,25 @@  discard block
 block discarded – undo
897 897
 				$temp_room['type'] = 'room';
898 898
 
899 899
 				if(!empty($room['images']) && is_array($room['images'])){
900
-			    	$attachments_args = array(
901
-			    			'post_parent' => $id,
902
-			    			'post_status' => 'inherit',
903
-			    			'post_type' => 'attachment',
904
-			    			'order' => 'ASC',
905
-			    	);   	
906
-			    	$attachments = new WP_Query($attachments_args);
907
-			    	$found_attachments = array();
908
-
909
-			    	if($attachments->have_posts()){
910
-			    		foreach($attachments->posts as $attachment){
911
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
912
-			    		}
913
-			    	}
900
+					$attachments_args = array(
901
+							'post_parent' => $id,
902
+							'post_status' => 'inherit',
903
+							'post_type' => 'attachment',
904
+							'order' => 'ASC',
905
+					);   	
906
+					$attachments = new WP_Query($attachments_args);
907
+					$found_attachments = array();
908
+
909
+					if($attachments->have_posts()){
910
+						foreach($attachments->posts as $attachment){
911
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
912
+						}
913
+					}
914 914
 
915 915
 					$temp_room['gallery'] = array();
916 916
 					foreach($room['images'] as $image_data){
917
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
918
-			    	}
917
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
918
+					}
919 919
 				}
920 920
 				$rooms[] = $temp_room;
921 921
 			}
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 				delete_post_meta($id, 'units');				
925 925
 			}
926 926
 			foreach($rooms as $room){
927
-		        add_post_meta($id,'units',$room,false);			
927
+				add_post_meta($id,'units',$room,false);			
928 928
 			}
929 929
 
930 930
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -934,11 +934,11 @@  discard block
 block discarded – undo
934 934
 			}
935 935
 
936 936
 			if(false !== $id && '0' !== $id){
937
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
938
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
939
-	        }else{
940
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
941
-	        }
937
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
938
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
939
+			}else{
940
+				add_post_meta($id,'number_of_rooms',$room_count,true);
941
+			}
942 942
 		}
943 943
 	}
944 944
 
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 				delete_post_meta($id, 'videos');				
1049 1049
 			}
1050 1050
 			foreach($videos as $video){
1051
-		        add_post_meta($id,'videos',$video,false);			
1051
+				add_post_meta($id,'videos',$video,false);			
1052 1052
 			}
1053 1053
 		}
1054 1054
 	}	
@@ -1077,17 +1077,17 @@  discard block
 block discarded – undo
1077 1077
 
1078 1078
 	function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
1079 1079
 		if(!$term = term_exists($name, $taxonomy))
1080
-        {
1081
-        	if(false !== $parent){ $parent = array('parent'=>$parent); }
1082
-            $term = wp_insert_term(trim($name), $taxonomy,$parent);
1083
-            if ( is_wp_error($term) ){echo $term->get_error_message();}
1084
-            else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1085
-        }
1086
-        else
1087
-        {
1088
-            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1089
-        }
1090
-        return $term['term_id'];
1080
+		{
1081
+			if(false !== $parent){ $parent = array('parent'=>$parent); }
1082
+			$term = wp_insert_term(trim($name), $taxonomy,$parent);
1083
+			if ( is_wp_error($term) ){echo $term->get_error_message();}
1084
+			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1085
+		}
1086
+		else
1087
+		{
1088
+			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1089
+		}
1090
+		return $term['term_id'];
1091 1091
 	}	
1092 1092
 
1093 1093
 	/**
@@ -1095,17 +1095,17 @@  discard block
 block discarded – undo
1095 1095
 	 */
1096 1096
 	public function set_featured_image($data,$id) {
1097 1097
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1098
-	    	$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1098
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1099 1099
 
1100
-	    	if(false !== $this->featured_image){
1101
-	    		delete_post_meta($id,'_thumbnail_id');
1102
-	    		add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1100
+			if(false !== $this->featured_image){
1101
+				delete_post_meta($id,'_thumbnail_id');
1102
+				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1103 1103
 
1104
-	    		if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1105
-	    			add_post_meta($id,'gallery',$this->featured_image,false);
1106
-	    			$this->gallery_meta[] = $this->featured_image;
1107
-	    		}
1108
-	    	}			
1104
+				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1105
+					add_post_meta($id,'gallery',$this->featured_image,false);
1106
+					$this->gallery_meta[] = $this->featured_image;
1107
+				}
1108
+			}			
1109 1109
 		}	
1110 1110
 	}	
1111 1111
 
@@ -1114,18 +1114,18 @@  discard block
 block discarded – undo
1114 1114
 	 */
1115 1115
 	public function set_banner_image($data,$id) {
1116 1116
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1117
-	    	$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1118
-
1119
-	    	if(false !== $this->banner_image){
1120
-	    		delete_post_meta($id,'image_group');
1121
-	    		$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1122
-	    		add_post_meta($id,'image_group',$new_banner,true);
1123
-
1124
-	    		if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1125
-	    			add_post_meta($id,'gallery',$this->banner_image,false);
1126
-	    			$this->gallery_meta[] = $this->banner_image;
1127
-	    		}
1128
-	    	}			
1117
+			$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1118
+
1119
+			if(false !== $this->banner_image){
1120
+				delete_post_meta($id,'image_group');
1121
+				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1122
+				add_post_meta($id,'image_group',$new_banner,true);
1123
+
1124
+				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1125
+					add_post_meta($id,'gallery',$this->banner_image,false);
1126
+					$this->gallery_meta[] = $this->banner_image;
1127
+				}
1128
+			}			
1129 1129
 		}	
1130 1130
 	}		
1131 1131
 
@@ -1135,25 +1135,25 @@  discard block
 block discarded – undo
1135 1135
 	public function create_main_gallery($data,$id) {
1136 1136
 
1137 1137
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1138
-	    	$counter = 0;
1139
-	    	foreach($data[0]['content']['images'] as $image_data){
1140
-	    		if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
1141
-	    		if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
1138
+			$counter = 0;
1139
+			foreach($data[0]['content']['images'] as $image_data){
1140
+				if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
1141
+				if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
1142 1142
 
1143
-	    		$this->gallery_meta[] = $this->attach_image($image_data,$id);
1144
-	    		$counter++;
1145
-	    	}
1143
+				$this->gallery_meta[] = $this->attach_image($image_data,$id);
1144
+				$counter++;
1145
+			}
1146 1146
 
1147
-	    	if(!empty($this->gallery_meta)){
1148
-	    		delete_post_meta($id,'gallery');
1147
+			if(!empty($this->gallery_meta)){
1148
+				delete_post_meta($id,'gallery');
1149 1149
 				$this->gallery_meta = array_unique($this->gallery_meta);
1150
-	    		foreach($this->gallery_meta as $gallery_id){
1151
-	    			if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1152
-	    				add_post_meta($id,'gallery',$gallery_id,false);
1153
-	    			}
1154
-	    		}
1155
-	    	}
1156
-    	}
1150
+				foreach($this->gallery_meta as $gallery_id){
1151
+					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1152
+						add_post_meta($id,'gallery',$gallery_id,false);
1153
+					}
1154
+				}
1155
+			}
1156
+		}
1157 1157
 	}	
1158 1158
 
1159 1159
 	/**
@@ -1162,42 +1162,42 @@  discard block
 block discarded – undo
1162 1162
 	public function attach_image($v=false,$parent_id,$image_sizes=false){
1163 1163
 		if(false !== $v){
1164 1164
 	   		$temp_fragment = explode('/',$v['url_fragment']);
1165
-	    	$url_filename = $temp_fragment[count($temp_fragment)-1];
1166
-	    	$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1165
+			$url_filename = $temp_fragment[count($temp_fragment)-1];
1166
+			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1167 1167
 
1168
-	    	if(in_array($url_filename,$this->found_attachments)){
1169
-	    		return array_search($url_filename,$this->found_attachments);
1170
-	    	}
1168
+			if(in_array($url_filename,$this->found_attachments)){
1169
+				return array_search($url_filename,$this->found_attachments);
1170
+			}
1171 1171
 	    	               
1172
-	        $postdata=array();
1173
-	        if(empty($v['label']))
1174
-	        {
1175
-	            $v['label']='';
1176
-	        }
1177
-	        if(!empty($v['description']))
1178
-	        {
1179
-	            $desc=wp_strip_all_tags($v['description']);
1180
-	            $posdata=array('post_excerpt'=>$desc);
1181
-	        }
1182
-	        if(!empty($v['section']))
1183
-	        {
1184
-	            $desc=wp_strip_all_tags($v['section']);
1185
-	            $posdata=array('post_excerpt'=>$desc);
1186
-	        }
1187
-
1188
-	        $attachID=NULL;  
1189
-	        //Resizor - add option to setting if required
1190
-	        $fragment = str_replace(' ','%20',$v['url_fragment']);
1191
-	        $url = $this->get_scaling_url($image_sizes).$fragment;
1192
-	        $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1193
-
1194
-	        //echo($attachID.' add image');
1195
-	        if($attachID!=NULL)
1196
-	        {
1197
-	            return $attachID;
1198
-	        }
1199
-        }	
1200
-        return 	false;
1172
+			$postdata=array();
1173
+			if(empty($v['label']))
1174
+			{
1175
+				$v['label']='';
1176
+			}
1177
+			if(!empty($v['description']))
1178
+			{
1179
+				$desc=wp_strip_all_tags($v['description']);
1180
+				$posdata=array('post_excerpt'=>$desc);
1181
+			}
1182
+			if(!empty($v['section']))
1183
+			{
1184
+				$desc=wp_strip_all_tags($v['section']);
1185
+				$posdata=array('post_excerpt'=>$desc);
1186
+			}
1187
+
1188
+			$attachID=NULL;  
1189
+			//Resizor - add option to setting if required
1190
+			$fragment = str_replace(' ','%20',$v['url_fragment']);
1191
+			$url = $this->get_scaling_url($image_sizes).$fragment;
1192
+			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1193
+
1194
+			//echo($attachID.' add image');
1195
+			if($attachID!=NULL)
1196
+			{
1197
+				return $attachID;
1198
+			}
1199
+		}	
1200
+		return 	false;
1201 1201
 	}
1202 1202
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1203 1203
 	
Please login to merge, or discard this patch.
classes/class-tours.php 1 patch
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		$tour_options = get_option('wetu_importer_tour_settings',false);
98 98
 		if(false !== $tour_options){
99 99
 			$this->tour_options = $tour_options;
100
-        }
100
+		}
101 101
 	}
102 102
 
103 103
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * Display the importer administration screen
121 121
 	 */
122 122
 	public function display_page() {
123
-        ?>
123
+		?>
124 124
         <div class="wrap">
125 125
             <?php screen_icon(); ?>
126 126
 
@@ -248,16 +248,16 @@  discard block
 block discarded – undo
248 248
 			$result = $this->update_options();
249 249
 
250 250
 			if(true === $result){
251
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
252
-			    if(!isset($_GET['refresh_tours'])){
253
-			        echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>';
254
-                }
255
-            }else{
256
-			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
257
-            }
251
+				echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
252
+				if(!isset($_GET['refresh_tours'])){
253
+					echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>';
254
+				}
255
+			}else{
256
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
257
+			}
258 258
 		}else{
259 259
 			echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>';
260
-        }
260
+		}
261 261
 		echo '</h3></div>';
262 262
 	}
263 263
 
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 		$tours = json_decode($data, true);
270 270
 
271 271
 		if(isset($tours['error'])){
272
-		    return $tours['error'];
273
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
272
+			return $tours['error'];
273
+		}elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
274 274
 			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
275 275
 			return true;
276 276
 		}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 					$keyphrases = $_POST['keyword'];
320 320
 				}else{
321 321
 					$keyphrases = array(0);
322
-                }
322
+				}
323 323
 
324 324
 				if(!is_array($keyphrases)){
325 325
 					$keyphrases = array($keyphrases);
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 
349 349
 					foreach($tours as $row_key => $row){
350 350
 
351
-					    if(isset($row['is_disabled']) && true === $row['is_disabled']){
352
-                            continue;
353
-                        }
351
+						if(isset($row['is_disabled']) && true === $row['is_disabled']){
352
+							continue;
353
+						}
354 354
 
355
-                        /*if('Sample' === $row['type']){
355
+						/*if('Sample' === $row['type']){
356 356
                             continue;
357 357
                         }*/
358 358
 
359
-                        //If this is a current tour, add its ID to the row.
359
+						//If this is a current tour, add its ID to the row.
360 360
 						$row['post_id'] = 0;
361 361
 						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
362 362
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
@@ -365,31 +365,31 @@  discard block
 block discarded – undo
365 365
 						//If we are searching for
366 366
 						if(false !== $post_status){
367 367
 
368
-                            if('import' === $post_status){
368
+							if('import' === $post_status){
369 369
 
370 370
 								if(0 !== $row['post_id']){
371
-								    continue;
371
+									continue;
372 372
 								}else{
373 373
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
374
-                                }
374
+								}
375 375
 
376 376
 
377
-                            }else{
377
+							}else{
378 378
 
379 379
 								if(0 === $row['post_id']){
380 380
 									continue;
381 381
 								}else{
382 382
 									$current_status = get_post_status($row['post_id']);
383 383
 									if($current_status !== $post_status){
384
-									    continue;
385
-                                    }
384
+										continue;
385
+									}
386 386
 
387 387
 								}
388 388
 								$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
389 389
 
390
-                            }
390
+							}
391 391
 
392
-                        }else{
392
+						}else{
393 393
 							//Search through each keyword.
394 394
 							foreach($keyphrases as $keyphrase){
395 395
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
404 404
 								}
405 405
 							}
406
-                        }
406
+						}
407 407
 					}		
408 408
 				}
409 409
 
@@ -470,17 +470,17 @@  discard block
 block discarded – undo
470 470
 				$content = false;
471 471
 			}
472 472
 
473
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
473
+			$jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
474 474
 
475
-            if($jdata)
476
-            {
475
+			if($jdata)
476
+			{
477 477
 				$jdata=json_decode($jdata,true);
478
-                if(!empty($jdata))
479
-                {
480
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
481
-                	$this->format_completed_row($return);
482
-                }
483
-            }
478
+				if(!empty($jdata))
479
+				{
480
+					$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
481
+					$this->format_completed_row($return);
482
+				}
483
+			}
484 484
 			die();
485 485
 		}
486 486
 
@@ -488,53 +488,53 @@  discard block
 block discarded – undo
488 488
 
489 489
 	/**
490 490
 	 * Connect to wetu
491
-     *
492
-     * @param $data array
493
-     * @param $wetu_id string
491
+	 *
492
+	 * @param $data array
493
+	 * @param $wetu_id string
494 494
 	 */
495 495
 	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
496
-        $post_name = $data_post_content = $data_post_excerpt = '';
497
-        $post = array(
498
-          'post_type'		=> 'tour',
499
-        );
496
+		$post_name = $data_post_content = $data_post_excerpt = '';
497
+		$post = array(
498
+		  'post_type'		=> 'tour',
499
+		);
500 500
 
501
-        //Set the post_content
501
+		//Set the post_content
502 502
 		$content_used_general_description = false;
503
-        if(false !== $importable_content && in_array('description',$importable_content)){
504
-            $data_post_content = '';
505
-
506
-            if(isset($data['description'])){
507
-                $data_post_content = $data['description'];
508
-            }elseif(isset($data['summary'])){
509
-                $data_post_content = $data['summary'];
510
-            }
511
-            $post['post_content'] = $data_post_content;
512
-        }
513
-
514
-        //Create or update the post
515
-        if(false !== $id && '0' !== $id){
516
-            $post['ID'] = $id;
517
-	        $post['post_status'] = 'publish';
518
-            $id = wp_update_post($post);
519
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
520
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
521
-        }else{
522
-
523
-            //Set the name
524
-            if(isset($data['name'])){
525
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
526
-            }
527
-            $post['post_name'] = $post_name;
528
-            $post['post_title'] = $data['name'];
529
-            $post['post_status'] = 'publish';
530
-            $id = wp_insert_post($post);
531
-
532
-            //Save the WETU ID and the Last date it was modified.
533
-            if(false !== $id){
534
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
535
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
536
-            }
537
-        }
503
+		if(false !== $importable_content && in_array('description',$importable_content)){
504
+			$data_post_content = '';
505
+
506
+			if(isset($data['description'])){
507
+				$data_post_content = $data['description'];
508
+			}elseif(isset($data['summary'])){
509
+				$data_post_content = $data['summary'];
510
+			}
511
+			$post['post_content'] = $data_post_content;
512
+		}
513
+
514
+		//Create or update the post
515
+		if(false !== $id && '0' !== $id){
516
+			$post['ID'] = $id;
517
+			$post['post_status'] = 'publish';
518
+			$id = wp_update_post($post);
519
+			$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
520
+			update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
521
+		}else{
522
+
523
+			//Set the name
524
+			if(isset($data['name'])){
525
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
526
+			}
527
+			$post['post_name'] = $post_name;
528
+			$post['post_title'] = $data['name'];
529
+			$post['post_status'] = 'publish';
530
+			$id = wp_insert_post($post);
531
+
532
+			//Save the WETU ID and the Last date it was modified.
533
+			if(false !== $id){
534
+				add_post_meta($id,'lsx_wetu_id',$wetu_id);
535
+				add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
536
+			}
537
+		}
538 538
 
539 539
 
540 540
 		//Set the price
@@ -547,9 +547,9 @@  discard block
 block discarded – undo
547 547
 			$this->set_duration($data,$id);
548 548
 		}
549 549
 
550
-        if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
551
-            $this->process_itineraries($data,$id,$importable_content);
552
-        }
550
+		if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
551
+			$this->process_itineraries($data,$id,$importable_content);
552
+		}
553 553
 
554 554
 		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
555 555
 			$this->process_map_points($data,$id);
@@ -560,24 +560,24 @@  discard block
 block discarded – undo
560 560
 		if(false !== $importable_content && (in_array('itinerary_gallery',$importable_content) || in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
561 561
 			$this->find_attachments($id);
562 562
 		}
563
-        //Set the featured image
564
-        //TODO Test These
565
-        if(false !== $importable_content && in_array('featured_image',$importable_content)){
566
-            $this->set_featured_image($data,$id);
567
-        }
563
+		//Set the featured image
564
+		//TODO Test These
565
+		if(false !== $importable_content && in_array('featured_image',$importable_content)){
566
+			$this->set_featured_image($data,$id);
567
+		}
568 568
 
569 569
 		//TODO Test These
570
-        if(false !== $importable_content && in_array('banner_image',$importable_content)){
571
-            $this->set_banner_image($data,$id);
572
-        }
570
+		if(false !== $importable_content && in_array('banner_image',$importable_content)){
571
+			$this->set_banner_image($data,$id);
572
+		}
573 573
 
574 574
 		//TODO Test These
575
-        //Import the main gallery
576
-        if(false !== $importable_content && in_array('gallery',$importable_content)){
577
-            $this->create_main_gallery($data,$id);
578
-        }
575
+		//Import the main gallery
576
+		if(false !== $importable_content && in_array('gallery',$importable_content)){
577
+			$this->create_main_gallery($data,$id);
578
+		}
579 579
 
580
-        return $id;
580
+		return $id;
581 581
 	}
582 582
 
583 583
 	/**
@@ -705,31 +705,31 @@  discard block
 block discarded – undo
705 705
 	 */
706 706
 	public function process_map_points($data,$id) {
707 707
 
708
-	    if(!empty($data['routes'])){
708
+		if(!empty($data['routes'])){
709 709
 
710
-	        delete_post_meta($id,'wetu_map_points');
710
+			delete_post_meta($id,'wetu_map_points');
711 711
 
712
-	        $points = array();
712
+			$points = array();
713 713
 
714
-	        foreach($data['routes'] as $route){
714
+			foreach($data['routes'] as $route){
715 715
 
716 716
 
717
-	            if(isset($route['points']) && '' !== $route['points']){
717
+				if(isset($route['points']) && '' !== $route['points']){
718 718
 
719
-	                $temp_points = explode(';',$route['points']);
720
-	                $point_counter = count($temp_points);
719
+					$temp_points = explode(';',$route['points']);
720
+					$point_counter = count($temp_points);
721 721
 
722 722
 					for ($x = 0; $x <= $point_counter; $x++) {
723
-					    $y = $x+1;
723
+						$y = $x+1;
724 724
 						$points[] = $temp_points[$x].','.$temp_points[$y];
725 725
 						$x++;
726 726
 					}
727 727
 				}
728
-            }
729
-            if(!empty($points)){
728
+			}
729
+			if(!empty($points)){
730 730
 				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
731
-            }
732
-        }
731
+			}
732
+		}
733 733
 
734 734
 	}
735 735
 
@@ -737,17 +737,17 @@  discard block
 block discarded – undo
737 737
 	 * Set the Itinerary Day
738 738
 	 */
739 739
 	public function set_itinerary_day($day,$id) {
740
-        $this->save_custom_field($day,'itinerary',$id,false,false);
740
+		$this->save_custom_field($day,'itinerary',$id,false,false);
741 741
 	}
742 742
 
743 743
 	/**
744 744
 	 * Set the price
745 745
 	 */
746 746
 	public function set_price($data,$id) {
747
-	    //Price
747
+		//Price
748 748
 		if(isset($data['price']) && ''!== $data['price']){
749
-            $price = preg_replace("/[^0-9,.]/", "", $data['price']);
750
-            $this->save_custom_field($price,'price',$id);
749
+			$price = preg_replace("/[^0-9,.]/", "", $data['price']);
750
+			$this->save_custom_field($price,'price',$id);
751 751
 		}
752 752
 
753 753
 		//Price includes
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 			$this->save_custom_field($data['price_includes'],'included',$id);
756 756
 		}
757 757
 
758
-        //Price Excludes
758
+		//Price Excludes
759 759
 		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
760 760
 			$this->save_custom_field($data['price_excludes'],'not_included',$id);
761 761
 		}
@@ -779,35 +779,35 @@  discard block
 block discarded – undo
779 779
 	 */
780 780
 	public function set_accommodation($day,$id) {
781 781
 
782
-	    $ac_id = false;
782
+		$ac_id = false;
783 783
 		$this->current_accommodation = $this->find_current_accommodation();
784 784
 		
785 785
 		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
786 786
 
787 787
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
788
-                $ac_id = $this->current_accommodation[$day['content_entity_id']];
788
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
789 789
 			}else{
790 790
 				$ac_id = wp_insert_post(array(
791
-                    'post_type' => 'accommodation',
792
-                    'post_status' => 'draft',
793
-                    'post_title' => $day['content_entity_id']
794
-                ));
791
+					'post_type' => 'accommodation',
792
+					'post_status' => 'draft',
793
+					'post_title' => $day['content_entity_id']
794
+				));
795 795
 				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
796 796
 			}
797 797
 
798 798
 			if('' !== $ac_id && false !== $ac_id){
799
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
799
+				$this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
800 800
 				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
801
-            }
801
+			}
802 802
 		}
803 803
 		return $ac_id;
804 804
 	}
805 805
 
806 806
 	/**
807 807
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
808
-     *
809
-     * @param $post_type string
810
-     * @return boolean / array
808
+	 *
809
+	 * @param $post_type string
810
+	 * @return boolean / array
811 811
 	 */
812 812
 	public function find_current_accommodation($post_type='accommodation') {
813 813
 		global $wpdb;
@@ -815,16 +815,16 @@  discard block
 block discarded – undo
815 815
 
816 816
 		$return = false;
817 817
 		if(!empty($accommodation)){
818
-		    foreach($accommodation as $key => $acc){
818
+			foreach($accommodation as $key => $acc){
819 819
 				$return[$acc->meta_value] = $acc->post_id;
820
-            }
821
-        }
820
+			}
821
+		}
822 822
 		return $return;
823 823
 	}
824 824
 
825 825
 	/**
826 826
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
827
-     * @return boolean / array
827
+	 * @return boolean / array
828 828
 	 */
829 829
 	public function find_current_destinations() {
830 830
 		return $this->find_current_accommodation('destination');
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
852 852
 				if(false !== $country_wetu_id){
853 853
 					$this->set_country($country_wetu_id, $id);
854
-                }
854
+				}
855 855
 
856 856
 			}else {
857 857
 
@@ -862,27 +862,27 @@  discard block
 block discarded – undo
862 862
 
863 863
 					if (!empty($destination_data) && !isset($destination_data['error'])) {
864 864
 
865
-					    $destination_title = $day['destination_content_entity_id'];
865
+						$destination_title = $day['destination_content_entity_id'];
866 866
 
867
-					    if(isset($destination_data[0]['name'])){
867
+						if(isset($destination_data[0]['name'])){
868 868
 							$destination_title = $destination_data[0]['name'];
869
-                        }
869
+						}
870 870
 
871
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
872
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
871
+						if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
872
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
873 873
 
874 874
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
875
-                        }
875
+						}
876 876
 
877
-                        $dest_post = array(
877
+						$dest_post = array(
878 878
 							'post_type' => 'destination',
879 879
 							'post_status' => 'draft',
880 880
 							'post_title' => $destination_title
881 881
 						);
882 882
 
883
-					    if(false !== $country_id){
883
+						if(false !== $country_id){
884 884
 							$dest_post['post_parent'] = $country_id;
885
-                        }
885
+						}
886 886
 						$dest_id = wp_insert_post($dest_post);
887 887
 
888 888
 						//Make sure we register the
@@ -904,50 +904,50 @@  discard block
 block discarded – undo
904 904
 	 * Connects the destinations post type
905 905
 	 *
906 906
 	 * @param $dest_id string
907
-     * @param $country_id array
907
+	 * @param $country_id array
908 908
 	 * @param $id string
909 909
 	 */
910 910
 	public function set_country($country_wetu_id, $id) {
911
-	    $country_id = false;
911
+		$country_id = false;
912 912
 		$this->current_destinations = $this->find_current_destinations();
913 913
 
914
-        if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
915
-            $country_id = $this->current_destinations[$country_wetu_id];
916
-        } else {
914
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
915
+			$country_id = $this->current_destinations[$country_wetu_id];
916
+		} else {
917 917
 
918
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
918
+			$country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
919 919
 
920
-            if ($country_json) {
921
-                $country_data = json_decode($country_json, true);
920
+			if ($country_json) {
921
+				$country_data = json_decode($country_json, true);
922 922
 
923
-                if (!empty($country_data) && !isset($country_data['error'])) {
923
+				if (!empty($country_data) && !isset($country_data['error'])) {
924 924
 
925 925
 					//Format the title of the destination if its available,  otherwise default to the WETU ID.
926
-                    $country_title = $country_wetu_id;
927
-                    if (isset($country_data[0]['name'])) {
926
+					$country_title = $country_wetu_id;
927
+					if (isset($country_data[0]['name'])) {
928 928
 						$country_title = $country_data[0]['name'];
929
-                    }
929
+					}
930 930
 
931 931
 					$country_id = wp_insert_post(array(
932
-                        'post_type' => 'destination',
933
-                        'post_status' => 'draft',
934
-                        'post_title' => $country_title
935
-                    ));
932
+						'post_type' => 'destination',
933
+						'post_status' => 'draft',
934
+						'post_title' => $country_title
935
+					));
936 936
 					//add the country to the current destination stack
937 937
 					$this->current_destinations[$country_wetu_id] = $country_id;
938 938
 
939 939
 					//Save the wetu field
940
-                    $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
941
-                }
942
-            }
943
-        }
940
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
941
+				}
942
+			}
943
+		}
944 944
 
945
-        if ('' !== $country_id && false !== $country_id) {
946
-            $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
947
-            $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
945
+		if ('' !== $country_id && false !== $country_id) {
946
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
947
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
948 948
 
949
-            return $country_id;
950
-        }
949
+			return $country_id;
950
+		}
951 951
 	}
952 952
 }
953 953
 $wetu_importer_tours = new WETU_Importer_Tours();
954 954
\ No newline at end of file
Please login to merge, or discard this patch.