Completed
Push — master ( 6435ab...d652f3 )
by Warwick
03:23
created
classes/class-accommodation.php 4 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -414,6 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
 	/**
416 416
 	 * Does a multine search
417
+	 * @param string $haystack
417 418
 	 */	
418 419
 	public function multineedle_stripos($haystack, $needles, $offset=0) {
419 420
 		$found = false;
@@ -664,6 +665,7 @@  discard block
 block discarded – undo
664 665
 
665 666
 	/**
666 667
 	 * Set the team memberon each item.
668
+	 * @param boolean $team_members
667 669
 	 */
668 670
 	public function set_team_member($id,$team_members) {
669 671
 
@@ -675,6 +677,7 @@  discard block
 block discarded – undo
675 677
 
676 678
 	/**
677 679
 	 * Set the safari brand
680
+	 * @param boolean $safari_brands
678 681
 	 */
679 682
 	public function set_safari_brands($id,$safari_brands) {
680 683
 		foreach($safari_brands as $safari_brand){
@@ -1028,6 +1031,9 @@  discard block
 block discarded – undo
1028 1031
 		}
1029 1032
 	}
1030 1033
 
1034
+	/**
1035
+	 * @return boolean
1036
+	 */
1031 1037
 	function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
1032 1038
 		if(!$term = term_exists($name, $taxonomy))
1033 1039
         {
@@ -1152,6 +1158,11 @@  discard block
 block discarded – undo
1152 1158
         }	
1153 1159
         return 	false;
1154 1160
 	}
1161
+
1162
+	/**
1163
+	 * @param string $url
1164
+	 * @param string $thumb
1165
+	 */
1155 1166
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1156 1167
 	
1157 1168
 		if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
Please login to merge, or discard this patch.
Braces   +30 added lines, -39 removed lines patch added patch discarded remove patch
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 		if(isset($accommodation['error'])){
317 317
 		    return $accommodation['error'];
318
-        }elseif (isset($accommodation) && !empty($accommodation)) {
318
+        } elseif (isset($accommodation) && !empty($accommodation)) {
319 319
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
320 320
 			return true;
321 321
 		}
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
 				if(isset($_POST['keyword'] )) {
363 363
 					$keyphrases = $_POST['keyword'];
364
-				}else{
364
+				} else{
365 365
 					$keyphrases = array(0);
366 366
                 }
367 367
 
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
 
407 407
 								if(0 !== $row['post_id']){
408 408
 									continue;
409
-								}else{
409
+								} else{
410 410
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
411 411
 								}
412 412
 
413 413
 
414
-							}else{
414
+							} else{
415 415
 
416 416
 								if(0 === $row['post_id']){
417 417
 									continue;
418
-								}else{
418
+								} else{
419 419
 									$current_status = get_post_status($row['post_id']);
420 420
 									if($current_status !== $post_status){
421 421
 										continue;
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 								$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
426 426
 							}
427 427
 
428
-						}else{
428
+						} else{
429 429
 							//Search through each keyword.
430 430
 							foreach($keyphrases as $keyphrase){
431 431
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	    }
468 468
 	    if(false !== $found && $needle_count === count($found)){ 
469 469
 	    	return true;
470
-		}else{
470
+		} else{
471 471
 			return false;
472 472
 		}
473 473
 	}
@@ -513,26 +513,26 @@  discard block
 block discarded – undo
513 513
 			$wetu_id = $_POST['wetu_id'];
514 514
 			if(isset($_POST['post_id'])){
515 515
 				$post_id = $_POST['post_id'];	
516
-			}else{
516
+			} else{
517 517
 				$post_id = 0;
518 518
 			}
519 519
 
520 520
 			if(isset($_POST['team_members'])){
521 521
 				$team_members = $_POST['team_members'];	
522
-			}else{
522
+			} else{
523 523
 				$team_members = false;
524 524
 			}
525 525
 
526 526
 			if(isset($_POST['safari_brands'])){
527 527
 				$safari_brands = $_POST['safari_brands'];	
528
-			}else{
528
+			} else{
529 529
 				$safari_brands = false;
530 530
 			}			
531 531
 
532 532
 			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
533 533
 				$content = $_POST['content'];
534 534
 				add_option('wetu_importer_accommodation_settings',$content);
535
-			}else{
535
+			} else{
536 536
 				delete_option('wetu_importer_accommodation_settings');
537 537
 				$content = false;
538 538
 			}
@@ -577,10 +577,10 @@  discard block
 block discarded – undo
577 577
 		        if(isset($data[0]['content']['extended_description']))
578 578
 		        {
579 579
 		            $data_post_content = $data[0]['content']['extended_description'];
580
-		        }elseif(isset($data[0]['content']['general_description'])){
580
+		        } elseif(isset($data[0]['content']['general_description'])){
581 581
 		            $data_post_content = $data[0]['content']['general_description'];
582 582
 		            $content_used_general_description = true;
583
-		        }elseif(isset($data[0]['content']['teaser_description'])){
583
+		        } elseif(isset($data[0]['content']['teaser_description'])){
584 584
 		        	$data_post_content = $data[0]['content']['teaser_description'];
585 585
 		        }
586 586
 	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
591 591
 		        if(isset($data[0]['content']['teaser_description'])){
592 592
 		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
593
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
593
+		        } elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
594 594
 		            $data_post_excerpt = $data[0]['content']['general_description'];
595 595
 		        }	   
596 596
 		        $post['post_excerpt'] = $data_post_excerpt;     	
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 	        	$id = wp_update_post($post);
607 607
 	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
608 608
 	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
609
-	        }else{
609
+	        } else{
610 610
 
611 611
 		        //Set the name
612 612
 		        if(isset($data[0]['name'])){
@@ -738,13 +738,13 @@  discard block
 block discarded – undo
738 738
 
739 739
 			if(isset($data[0]['position']['driving_latitude'])){
740 740
 				$latitude = $data[0]['position']['driving_latitude'];
741
-			}elseif(isset($data[0]['position']['latitude'])){
741
+			} elseif(isset($data[0]['position']['latitude'])){
742 742
 				$latitude = $data[0]['position']['latitude'];
743 743
 			}
744 744
 
745 745
 			if(isset($data[0]['position']['driving_longitude'])){
746 746
 				$longitude = $data[0]['position']['driving_longitude'];
747
-			}elseif(isset($data[0]['position']['longitude'])){
747
+			} elseif(isset($data[0]['position']['longitude'])){
748 748
 				$longitude = $data[0]['position']['longitude'];
749 749
 			}		
750 750
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 			if(false !== $id && '0' !== $id){
778 778
 	        	$prev = get_post_meta($id,'location',true);
779 779
 	        	update_post_meta($id,'location',$location_data,$prev);
780
-	        }else{
780
+	        } else{
781 781
 	        	add_post_meta($id,'location',$location_data,true);
782 782
 	        }
783 783
 		}
@@ -797,12 +797,10 @@  discard block
 block discarded – undo
797 797
 		            $term = wp_insert_term(trim($data[0]['position']['country']), 'location');
798 798
 		            if ( is_wp_error($term) ){
799 799
 		            	echo $term->get_error_message();
800
-		            }
801
-		            else {
800
+		            } else {
802 801
 		            	wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
803 802
 		            }
804
-		        }
805
-		        else
803
+		        } else
806 804
 		        {
807 805
 		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
808 806
 		        }
@@ -815,10 +813,8 @@  discard block
 block discarded – undo
815 813
 				if(!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
816 814
 		        {
817 815
 		            $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
818
-		            if ( is_wp_error($term) ){echo $term->get_error_message();}
819
-		            else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
820
-		        }
821
-		        else
816
+		            if ( is_wp_error($term) ){echo $term->get_error_message();} else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
817
+		        } else
822 818
 		        {
823 819
 		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
824 820
 		        }				
@@ -866,10 +862,8 @@  discard block
 block discarded – undo
866 862
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
867 863
 	        {
868 864
 	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
869
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
870
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
871
-	        }
872
-	        else
865
+	            if ( is_wp_error($term) ){echo $term->get_error_message();} else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
866
+	        } else
873 867
 	        {
874 868
 	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
875 869
 	        }				
@@ -928,14 +922,14 @@  discard block
 block discarded – undo
928 922
 
929 923
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
930 924
 				$room_count = $data[0]['features']['rooms'];
931
-			}else{
925
+			} else{
932 926
 				$room_count = count($data[0]['rooms']);
933 927
 			}
934 928
 
935 929
 			if(false !== $id && '0' !== $id){
936 930
 	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
937 931
 	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
938
-	        }else{
932
+	        } else{
939 933
 	        	add_post_meta($id,'number_of_rooms',$room_count,true);
940 934
 	        }
941 935
 		}
@@ -948,7 +942,7 @@  discard block
 block discarded – undo
948 942
 
949 943
 		if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){
950 944
 			$rating_type = $data[0]['features']['star_authority'];	
951
-		}else{
945
+		} else{
952 946
 			$rating_type = 'Unspecified2';
953 947
 		}
954 948
 		$this->save_custom_field($rating_type,'rating_type',$id);
@@ -1078,10 +1072,8 @@  discard block
 block discarded – undo
1078 1072
         {
1079 1073
         	if(false !== $parent){ $parent = array('parent'=>$parent); }
1080 1074
             $term = wp_insert_term(trim($name), $taxonomy,$parent);
1081
-            if ( is_wp_error($term) ){echo $term->get_error_message();}
1082
-            else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1083
-        }
1084
-        else
1075
+            if ( is_wp_error($term) ){echo $term->get_error_message();} else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1076
+        } else
1085 1077
         {
1086 1078
             wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1087 1079
         }
@@ -1242,8 +1234,7 @@  discard block
 block discarded – undo
1242 1234
 		if ( !empty( $filename) && " " != $filename )
1243 1235
 		{
1244 1236
 			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
1245
-		}
1246
-		else
1237
+		} else
1247 1238
 		{
1248 1239
 			$file_array['name'] = $url_filename;                                                // just use original URL filename
1249 1240
 		}
Please login to merge, or discard this 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.
Spacing   +374 added lines, -374 removed lines patch added patch discarded remove patch
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
 	public function __construct() {
65 65
 		$this->set_variables();
66 66
 
67
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
68
-		add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));	
69
-		add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));		
67
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
68
+		add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));	
69
+		add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));		
70 70
 
71
-		add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));	
72
-		add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
71
+		add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));	
72
+		add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
73 73
 
74
-		$temp_options = get_option('_lsx-to_settings',false);
75
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
74
+		$temp_options = get_option('_lsx-to_settings', false);
75
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
76 76
 			$this->options = $temp_options[$this->plugin_slug];
77 77
 		}
78 78
 
79
-		$accommodation_options = get_option('wetu_importer_accommodation_settings',false);
80
-		if(false !== $accommodation_options){
79
+		$accommodation_options = get_option('wetu_importer_accommodation_settings', false);
80
+		if (false !== $accommodation_options) {
81 81
 			$this->accommodation_options = $accommodation_options;
82 82
 		}
83 83
 	}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		//	$this->url    = 'https://wetu.com/API/Pins/';
95 95
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
96 96
 		//} elseif ( false !== $this->api_key ) {
97
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
97
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
98 98
 			$this->url_qs = '';
99 99
 		//}
100 100
 	}
@@ -102,27 +102,27 @@  discard block
 block discarded – undo
102 102
 	/**
103 103
 	 * search_form
104 104
 	 */
105
-	public function get_scaling_url($args=array()) {
105
+	public function get_scaling_url($args = array()) {
106 106
 
107 107
 		$defaults = array(
108 108
 			'width' => '640',
109 109
 			'height' => '480',
110 110
 			'cropping' => 'c'
111 111
 		);
112
-		if(false !== $this->options){
113
-			if(isset($this->options['width']) && '' !== $this->options['width']){
112
+		if (false !== $this->options) {
113
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
114 114
 				$defaults['width'] = $this->options['width'];
115 115
 			}
116 116
 
117
-			if(isset($this->options['height']) && '' !== $this->options['height']){
117
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
118 118
 				$defaults['height'] = $this->options['height'];
119 119
 			}
120 120
 
121
-			if(isset($this->options['cropping']) && '' !== $this->options['cropping']){
121
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
122 122
 				$defaults['cropping'] = $this->options['cropping'];
123 123
 			}	
124 124
 		}	
125
-		$args = wp_parse_args($args,$defaults);
125
+		$args = wp_parse_args($args, $defaults);
126 126
 
127 127
 		$cropping = $args['cropping'];
128 128
 		$width = $args['width'];
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 			<form method="get" action="" id="posts-filter">
148 148
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
149 149
 				
150
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
151
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
150
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
151
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
152 152
 				</p>				
153 153
 
154 154
 				<table class="wp-list-table widefat fixed posts">
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 					<tbody id="the-list">
158 158
 						<tr class="post-0 type-tour status-none" id="post-0">
159 159
 							<th class="check-column" scope="row">
160
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
160
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
161 161
 							</th>
162 162
 							<td class="post-title page-title column-title">
163 163
 								<strong>
164
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
164
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
165 165
 								</strong>
166 166
 							</td>
167 167
 							<td class="date column-date">							
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 
176 176
 				</table>
177 177
 
178
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
179
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
178
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
179
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
180 180
 				</p>
181 181
 			</form> 
182 182
 
@@ -188,31 +188,31 @@  discard block
 block discarded – undo
188 188
 						<div style="width:30%;display:block;float:left;">
189 189
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
190 190
 							<ul>
191
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
192
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
193
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li>
194
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
195
-		                        <?php if(class_exists('LSX_TO_Maps')){ ?>
196
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li>
191
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
192
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
193
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li>
194
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
195
+		                        <?php if (class_exists('LSX_TO_Maps')) { ?>
196
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li>
197 197
 		                        <?php } ?>
198
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations','wetu-importer'); ?></li>
199
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out','wetu-importer'); ?></li>
200
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities','wetu-importer'); ?></li>
201
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly','wetu-importer'); ?></li>
202
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating','wetu-importer'); ?></li>
203
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms','wetu-importer'); ?></li>
204
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests','wetu-importer'); ?></li>
205
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages','wetu-importer'); ?></li>
206
-
207
-		                        <?php if(class_exists('LSX_TO_Videos')){ ?>
208
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li>
198
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations', 'wetu-importer'); ?></li>
199
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out', 'wetu-importer'); ?></li>
200
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities', 'wetu-importer'); ?></li>
201
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly', 'wetu-importer'); ?></li>
202
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating', 'wetu-importer'); ?></li>
203
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms', 'wetu-importer'); ?></li>
204
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests', 'wetu-importer'); ?></li>
205
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages', 'wetu-importer'); ?></li>
206
+
207
+		                        <?php if (class_exists('LSX_TO_Videos')) { ?>
208
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li>
209 209
 		                        <?php } ?>
210 210
 							</ul>
211 211
 							<h4><?php _e('Additional Content'); ?></h4>
212 212
 							<ul>
213
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li>
214
-		                        <?php if(class_exists('LSX_Banners')){ ?>
215
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li>
213
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li>
214
+		                        <?php if (class_exists('LSX_Banners')) { ?>
215
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li>
216 216
 		                        <?php } ?>
217 217
 							</ul>
218 218
 						</div>
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 						<div style="width:30%;display:block;float:left;">
225 225
 							<h3><?php _e('Assign a Safari Brand'); ?></h3> 
226
-							<?php echo $this->taxonomy_checkboxes('accommodation-brand',$this->accommodation_options); ?>
226
+							<?php echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); ?>
227 227
 						</div>	
228 228
 
229 229
 						<br clear="both" />			
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 
233 233
 					<h3><?php _e('Your List'); ?></h3>
234
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
234
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
235 235
 					<table class="wp-list-table widefat fixed posts">
236 236
 						<?php $this->table_header(); ?>
237 237
 
@@ -243,12 +243,12 @@  discard block
 block discarded – undo
243 243
 
244 244
 					</table>
245 245
 
246
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
246
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
247 247
 				</form>
248 248
 			</div>
249 249
 
250 250
 			<div style="display:none;" class="completed-list-wrapper">
251
-				<h3><?php _e('Completed'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3>
251
+				<h3><?php _e('Completed'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3>
252 252
 				<ul>
253 253
 				</ul>
254 254
 			</div>
@@ -264,30 +264,30 @@  discard block
 block discarded – undo
264 264
         <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>">
265 265
         	<input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" />
266 266
 
267
-        	<h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3>
267
+        	<h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3>
268 268
         	<div class="normal-search">
269
-        		<input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
269
+        		<input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
270 270
         	</div>
271 271
         	<div class="advanced-search hidden" style="display:none;">
272
-        		<p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p>
272
+        		<p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p>
273 273
         		<textarea rows="10" cols="40" name="bulk-keywords"></textarea>
274
-        		<input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
274
+        		<input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
275 275
         	</div>    
276 276
 
277 277
         	<p>
278
-                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> |
279
-                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> |
280
-                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> |
281
-                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a> |
282
-                <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a>
278
+                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> |
279
+                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> |
280
+                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> |
281
+                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> |
282
+                <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a>
283 283
             </p>
284 284
 
285 285
             <div class="ajax-loader" style="display:none;width:100%;text-align:center;">
286
-            	<img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
286
+            	<img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
287 287
             </div>
288 288
 
289 289
             <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
290
-            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
290
+            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
291 291
             </div>            
292 292
         </form>	
293 293
 	<?php 
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 	 * search_form
298 298
 	 */
299 299
 	public function update_options_form() {
300
-		echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').'</h3>';
300
+		echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').'</h3>';
301 301
 		$accommodation = get_transient('lsx_ti_accommodation');
302
-		if('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])){
302
+		if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) {
303 303
 			$this->update_options();
304 304
 		}
305 305
 		echo '</div>';
@@ -310,13 +310,13 @@  discard block
 block discarded – undo
310 310
 	 * Save the list of Accommodation into an option
311 311
 	 */
312 312
 	public function update_options() {
313
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
313
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
314 314
 		$accommodation = json_decode($data, true);
315 315
 
316
-		if(isset($accommodation['error'])){
316
+		if (isset($accommodation['error'])) {
317 317
 		    return $accommodation['error'];
318 318
         }elseif (isset($accommodation) && !empty($accommodation)) {
319
-			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
319
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
320 320
 			return true;
321 321
 		}
322 322
 	}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	/**
325 325
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
326 326
 	 */
327
-	public function find_current_accommodation($post_type='accommodation') {
327
+	public function find_current_accommodation($post_type = 'accommodation') {
328 328
 		global $wpdb;
329 329
 		$return = array();
330 330
 
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 
341 341
 					LIMIT 0,500
342 342
 		");
343
-		if(null !== $current_accommodation && !empty($current_accommodation)){
344
-			foreach($current_accommodation as $accom){
343
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
344
+			foreach ($current_accommodation as $accom) {
345 345
 				$return[$accom->meta_value] = $accom;
346 346
 			}
347 347
 		}
@@ -353,37 +353,37 @@  discard block
 block discarded – undo
353 353
 	 */
354 354
 	public function process_ajax_search() {
355 355
 		$return = false;
356
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation'){
356
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') {
357 357
 			$accommodation = get_transient('lsx_ti_accommodation');
358 358
 
359
-			if ( false !== $accommodation ) {
359
+			if (false !== $accommodation) {
360 360
 				$searched_items = false;
361 361
 
362
-				if(isset($_POST['keyword'] )) {
362
+				if (isset($_POST['keyword'])) {
363 363
 					$keyphrases = $_POST['keyword'];
364
-				}else{
364
+				}else {
365 365
 					$keyphrases = array(0);
366 366
                 }
367 367
 
368
-				if(!is_array($keyphrases)){
368
+				if (!is_array($keyphrases)) {
369 369
 					$keyphrases = array($keyphrases);
370 370
 				}
371
-				foreach($keyphrases as &$keyword){
371
+				foreach ($keyphrases as &$keyword) {
372 372
 					$keyword = ltrim(rtrim($keyword));
373 373
 				}
374 374
 
375 375
 
376 376
 				$post_status = false;
377
-				if(in_array('publish',$keyphrases)){
377
+				if (in_array('publish', $keyphrases)) {
378 378
 					$post_status = 'publish';
379 379
 				}
380
-				if(in_array('pending',$keyphrases)){
380
+				if (in_array('pending', $keyphrases)) {
381 381
 					$post_status = 'pending';
382 382
 				}
383
-				if(in_array('draft',$keyphrases)){
383
+				if (in_array('draft', $keyphrases)) {
384 384
 					$post_status = 'draft';
385 385
 				}
386
-				if(in_array('import',$keyphrases)){
386
+				if (in_array('import', $keyphrases)) {
387 387
 					$post_status = 'import';
388 388
 				}
389 389
 
@@ -391,33 +391,33 @@  discard block
 block discarded – undo
391 391
 
392 392
 					$current_accommodation = $this->find_current_accommodation();
393 393
 
394
-					foreach($accommodation as $row_key => $row){
394
+					foreach ($accommodation as $row_key => $row) {
395 395
 
396 396
 						//If this is a current tour, add its ID to the row.
397 397
 						$row['post_id'] = 0;
398
-						if(false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)){
398
+						if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) {
399 399
 							$row['post_id'] = $current_accommodation[$row['id']]->post_id;
400 400
 						}
401 401
 
402 402
 						//If we are searching for
403
-						if(false !== $post_status){
403
+						if (false !== $post_status) {
404 404
 
405
-							if('import' === $post_status){
405
+							if ('import' === $post_status) {
406 406
 
407
-								if(0 !== $row['post_id']){
407
+								if (0 !== $row['post_id']) {
408 408
 									continue;
409
-								}else{
409
+								}else {
410 410
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
411 411
 								}
412 412
 
413 413
 
414
-							}else{
414
+							}else {
415 415
 
416
-								if(0 === $row['post_id']){
416
+								if (0 === $row['post_id']) {
417 417
 									continue;
418
-								}else{
418
+								}else {
419 419
 									$current_status = get_post_status($row['post_id']);
420
-									if($current_status !== $post_status){
420
+									if ($current_status !== $post_status) {
421 421
 										continue;
422 422
 									}
423 423
 
@@ -425,17 +425,17 @@  discard block
 block discarded – undo
425 425
 								$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
426 426
 							}
427 427
 
428
-						}else{
428
+						}else {
429 429
 							//Search through each keyword.
430
-							foreach($keyphrases as $keyphrase){
430
+							foreach ($keyphrases as $keyphrase) {
431 431
 
432 432
 								//Make sure the keyphrase is turned into an array
433
-								$keywords = explode(" ",$keyphrase);
434
-								if(!is_array($keywords)){
433
+								$keywords = explode(" ", $keyphrase);
434
+								if (!is_array($keywords)) {
435 435
 									$keywords = array($keywords);
436 436
 								}
437 437
 
438
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
438
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
439 439
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
440 440
 								}
441 441
 							}
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 				}
445 445
 
446 446
 
447
-				if(false !== $searched_items){
447
+				if (false !== $searched_items) {
448 448
 					ksort($searched_items);
449 449
 					$return = implode($searched_items);
450 450
 				}
@@ -457,17 +457,17 @@  discard block
 block discarded – undo
457 457
 	/**
458 458
 	 * Does a multine search
459 459
 	 */	
460
-	public function multineedle_stripos($haystack, $needles, $offset=0) {
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)){
463
+	    foreach ($needles as $needle) {
464
+	    	if (false !== stripos($haystack, $needle, $offset)) {
465 465
 	        	$found[] = true;
466 466
 	    	}
467 467
 	    }
468
-	    if(false !== $found && $needle_count === count($found)){ 
468
+	    if (false !== $found && $needle_count === count($found)) { 
469 469
 	    	return true;
470
-		}else{
470
+		}else {
471 471
 			return false;
472 472
 		}
473 473
 	}
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
 	/**
476 476
 	 * Formats the row for output on the screen.
477 477
 	 */	
478
-	public function format_row($row = false){
479
-		if(false !== $row){
478
+	public function format_row($row = false) {
479
+		if (false !== $row) {
480 480
 
481 481
 			$status = 'import';
482
-			if(0 !== $row['post_id']){
482
+			if (0 !== $row['post_id']) {
483 483
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
484 484
 			}
485 485
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 					<strong>'.$row['name'].'</strong> - '.$status.'
494 494
 				</td>
495 495
 				<td class="date column-date">
496
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
496
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
497 497
 				</td>
498 498
 				<td class="ssid column-ssid">
499 499
 					'.$row['id'].'
@@ -508,42 +508,42 @@  discard block
 block discarded – undo
508 508
 	 */
509 509
 	public function process_ajax_import() {
510 510
 		$return = false;
511
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])){
511
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) {
512 512
 			
513 513
 			$wetu_id = $_POST['wetu_id'];
514
-			if(isset($_POST['post_id'])){
514
+			if (isset($_POST['post_id'])) {
515 515
 				$post_id = $_POST['post_id'];	
516
-			}else{
516
+			}else {
517 517
 				$post_id = 0;
518 518
 			}
519 519
 
520
-			if(isset($_POST['team_members'])){
520
+			if (isset($_POST['team_members'])) {
521 521
 				$team_members = $_POST['team_members'];	
522
-			}else{
522
+			}else {
523 523
 				$team_members = false;
524 524
 			}
525 525
 
526
-			if(isset($_POST['safari_brands'])){
526
+			if (isset($_POST['safari_brands'])) {
527 527
 				$safari_brands = $_POST['safari_brands'];	
528
-			}else{
528
+			}else {
529 529
 				$safari_brands = false;
530 530
 			}			
531 531
 
532
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
532
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
533 533
 				$content = $_POST['content'];
534
-				add_option('wetu_importer_accommodation_settings',$content);
535
-			}else{
534
+				add_option('wetu_importer_accommodation_settings', $content);
535
+			}else {
536 536
 				delete_option('wetu_importer_accommodation_settings');
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)
540
+            $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
541
+            if ($jdata)
542 542
             {
543
-                $adata=json_decode($jdata,true);
544
-                if(!empty($adata))
543
+                $adata = json_decode($jdata, true);
544
+                if (!empty($adata))
545 545
                 {
546
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
546
+                	$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
547 547
                 	$this->format_completed_row($return);
548 548
                 }
549 549
             }
@@ -555,15 +555,15 @@  discard block
 block discarded – undo
555 555
 	/**
556 556
 	 * Formats the row for the completed list.
557 557
 	 */
558
-	public function format_completed_row($response){
558
+	public function format_completed_row($response) {
559 559
 		echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>';
560 560
 	}
561 561
 	/**
562 562
 	 * Connect to wetu
563 563
 	 */
564
-	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
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')
566
+        if (trim($data[0]['type']) == 'Accommodation')
567 567
         {
568 568
 	        $post_name = $data_post_content = $data_post_excerpt = '';
569 569
 	        $post = array(
@@ -573,44 +573,44 @@  discard block
 block discarded – undo
573 573
 	        $content_used_general_description = false;
574 574
 
575 575
 	        //Set the post_content
576
-	        if(false !== $importable_content && in_array('description',$importable_content)){
577
-		        if(isset($data[0]['content']['extended_description']))
576
+	        if (false !== $importable_content && in_array('description', $importable_content)) {
577
+		        if (isset($data[0]['content']['extended_description']))
578 578
 		        {
579 579
 		            $data_post_content = $data[0]['content']['extended_description'];
580
-		        }elseif(isset($data[0]['content']['general_description'])){
580
+		        }elseif (isset($data[0]['content']['general_description'])) {
581 581
 		            $data_post_content = $data[0]['content']['general_description'];
582 582
 		            $content_used_general_description = true;
583
-		        }elseif(isset($data[0]['content']['teaser_description'])){
583
+		        }elseif (isset($data[0]['content']['teaser_description'])) {
584 584
 		        	$data_post_content = $data[0]['content']['teaser_description'];
585 585
 		        }
586 586
 	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
587 587
 	        }
588 588
 
589 589
 	        //set the post_excerpt
590
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
591
-		        if(isset($data[0]['content']['teaser_description'])){
590
+	        if (false !== $importable_content && in_array('excerpt', $importable_content)) {
591
+		        if (isset($data[0]['content']['teaser_description'])) {
592 592
 		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
593
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
593
+		        }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
594 594
 		            $data_post_excerpt = $data[0]['content']['general_description'];
595 595
 		        }	   
596 596
 		        $post['post_excerpt'] = $data_post_excerpt;     	
597 597
 	        }
598 598
 
599
-	        if(false !== $id && '0' !== $id){
599
+	        if (false !== $id && '0' !== $id) {
600 600
 	        	$post['ID'] = $id;
601
-				if(isset($data[0]['name'])){
601
+				if (isset($data[0]['name'])) {
602 602
 					$post['post_title'] = $data[0]['name'];
603 603
 	        		$post['post_status'] = 'publish';
604
-					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
604
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
605 605
 				}
606 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{
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 610
 
611 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);
612
+		        if (isset($data[0]['name'])) {
613
+		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
614 614
 		        }
615 615
 	        	$post['post_name'] = $post_name;
616 616
 	        	$post['post_title'] = $data[0]['name'];
@@ -618,90 +618,90 @@  discard block
 block discarded – undo
618 618
 	        	$id = wp_insert_post($post);
619 619
 
620 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']));
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 624
 	        	}
625 625
 	        }
626 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))){
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 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);
632
+	        if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
633
+	        	$this->set_team_member($id, $team_members);
634 634
 	    	}
635 635
 
636 636
 	        //Set the safari brand
637
-	        if(false !== $safari_brands && '' !== $safari_brands){
638
-	        	$this->set_safari_brands($id,$safari_brands);
637
+	        if (false !== $safari_brands && '' !== $safari_brands) {
638
+	        	$this->set_safari_brands($id, $safari_brands);
639 639
 
640 640
 	    	}	    	
641 641
 
642
-	        if(class_exists('LSX_TO_Maps')){
643
-	        	$this->set_map_data($data,$id,9);
644
-	        	$this->set_location_taxonomy($data,$id);
642
+	        if (class_exists('LSX_TO_Maps')) {
643
+	        	$this->set_map_data($data, $id, 9);
644
+	        	$this->set_location_taxonomy($data, $id);
645 645
 	        }
646 646
 
647
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
648
-	        	$this->connect_destinations($data,$id);
647
+	        if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) {
648
+	        	$this->connect_destinations($data, $id);
649 649
 	        }
650 650
 
651
-	        if(false !== $importable_content && in_array('category',$importable_content)){
652
-	        	$this->set_taxonomy_style($data,$id);
651
+	        if (false !== $importable_content && in_array('category', $importable_content)) {
652
+	        	$this->set_taxonomy_style($data, $id);
653 653
 	        }
654 654
 
655 655
 	        //Set the Room Data
656
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
657
-	        	$this->set_room_data($data,$id);
656
+	        if (false !== $importable_content && in_array('rooms', $importable_content)) {
657
+	        	$this->set_room_data($data, $id);
658 658
 	    	}
659 659
 
660 660
 	    	//Set the rating
661
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
662
-	       		$this->set_rating($data,$id);
661
+	    	if (false !== $importable_content && in_array('rating', $importable_content)) {
662
+	       		$this->set_rating($data, $id);
663 663
 	    	}
664 664
 
665 665
 	    	//Set the checkin checkout data
666
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
667
-	        	$this->set_checkin_checkout($data,$id);
666
+	    	if (false !== $importable_content && in_array('checkin', $importable_content)) {
667
+	        	$this->set_checkin_checkout($data, $id);
668 668
 	        }
669 669
 
670 670
 	    	//Set the Spoken Languages
671
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
672
-	       		$this->set_spoken_languages($data,$id);
671
+	    	if (false !== $importable_content && in_array('spoken_languages', $importable_content)) {
672
+	       		$this->set_spoken_languages($data, $id);
673 673
 	    	}
674 674
 
675 675
 	    	//Set the friendly options
676
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
677
-	       		$this->set_friendly($data,$id);
676
+	    	if (false !== $importable_content && in_array('friendly', $importable_content)) {
677
+	       		$this->set_friendly($data, $id);
678 678
 	    	}
679 679
 
680 680
 	    	//Set the special_interests
681
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
682
-	       		$this->set_special_interests($data,$id);
681
+	    	if (false !== $importable_content && in_array('special_interests', $importable_content)) {
682
+	       		$this->set_special_interests($data, $id);
683 683
 	    	}	    		    		        
684 684
 
685 685
 	        //Import the videos
686
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
687
-	        	$this->set_video_data($data,$id);
686
+	        if (false !== $importable_content && in_array('videos', $importable_content)) {
687
+	        	$this->set_video_data($data, $id);
688 688
 	        }
689 689
 
690 690
 	        //Import the facilities
691
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
692
-	        	$this->set_facilities($data,$id);
691
+	        if (false !== $importable_content && in_array('facilities', $importable_content)) {
692
+	        	$this->set_facilities($data, $id);
693 693
 	        }	        
694 694
 
695 695
 	        //Set the featured image
696
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
697
-	        	$this->set_featured_image($data,$id);
696
+	        if (false !== $importable_content && in_array('featured_image', $importable_content)) {
697
+	        	$this->set_featured_image($data, $id);
698 698
 	        }
699
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
700
-	        	$this->set_banner_image($data,$id);
699
+	        if (false !== $importable_content && in_array('banner_image', $importable_content)) {
700
+	        	$this->set_banner_image($data, $id);
701 701
 	        }	        
702 702
 	        //Import the main gallery
703
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
704
-	    		$this->create_main_gallery($data,$id);
703
+	        if (false !== $importable_content && in_array('gallery', $importable_content)) {	    	
704
+	    		$this->create_main_gallery($data, $id);
705 705
 	        }	        	        	        
706 706
         }
707 707
         return $id;
@@ -710,115 +710,115 @@  discard block
 block discarded – undo
710 710
 	/**
711 711
 	 * Set the team memberon each item.
712 712
 	 */
713
-	public function set_team_member($id,$team_members) {
713
+	public function set_team_member($id, $team_members) {
714 714
 
715 715
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
716
-		foreach($team_members as $team){
717
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
716
+		foreach ($team_members as $team) {
717
+        	add_post_meta($id, 'team_to_'.$this->tab_slug, $team);			
718 718
 		}
719 719
 	}
720 720
 
721 721
 	/**
722 722
 	 * Set the safari brand
723 723
 	 */
724
-	public function set_safari_brands($id,$safari_brands) {
725
-		foreach($safari_brands as $safari_brand){
726
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
724
+	public function set_safari_brands($id, $safari_brands) {
725
+		foreach ($safari_brands as $safari_brand) {
726
+        	wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true);			
727 727
 		}
728 728
 	}	
729 729
 	
730 730
 	/**
731 731
 	 * Saves the longitude and lattitude, as well as sets the map marker.
732 732
 	 */
733
-	public function set_map_data($data,$id,$zoom = '10') {
733
+	public function set_map_data($data, $id, $zoom = '10') {
734 734
 		$longitude = $latitude = $address = false;
735 735
 
736
-		if(isset($data[0]['position'])){
736
+		if (isset($data[0]['position'])) {
737 737
 
738
-			if(isset($data[0]['position']['driving_latitude'])){
738
+			if (isset($data[0]['position']['driving_latitude'])) {
739 739
 				$latitude = $data[0]['position']['driving_latitude'];
740
-			}elseif(isset($data[0]['position']['latitude'])){
740
+			}elseif (isset($data[0]['position']['latitude'])) {
741 741
 				$latitude = $data[0]['position']['latitude'];
742 742
 			}
743 743
 
744
-			if(isset($data[0]['position']['driving_longitude'])){
744
+			if (isset($data[0]['position']['driving_longitude'])) {
745 745
 				$longitude = $data[0]['position']['driving_longitude'];
746
-			}elseif(isset($data[0]['position']['longitude'])){
746
+			}elseif (isset($data[0]['position']['longitude'])) {
747 747
 				$longitude = $data[0]['position']['longitude'];
748 748
 			}		
749 749
 
750 750
 		}
751
-		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
752
-			if(isset($data[0]['content']['contact_information']['address'])){
751
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
752
+			if (isset($data[0]['content']['contact_information']['address'])) {
753 753
 				$address = strip_tags($data[0]['content']['contact_information']['address']);
754 754
 
755
-				$address = explode("\n",$address);
756
-				foreach($address as $bitkey => $bit){
755
+				$address = explode("\n", $address);
756
+				foreach ($address as $bitkey => $bit) {
757 757
 					$bit = ltrim(rtrim($bit));
758
-					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
758
+					if (false === $bit || '' === $bit || null === $bit or empty($bit)) {
759 759
 						unset($address[$bitkey]);
760 760
 					}
761 761
 				}
762
-				$address = implode(', ',$address);
762
+				$address = implode(', ', $address);
763 763
 				$address = str_replace(', , ', ', ', $address);
764 764
 			}	
765 765
 		}
766 766
 
767
-		if(false !== $longitude){
767
+		if (false !== $longitude) {
768 768
 			$location_data = array(
769
-				'address'	=>	(string)$address,
770
-				'lat'		=>	(string)$latitude,
771
-				'long'		=>	(string)$longitude,
772
-				'zoom'		=>	(string)$zoom,
769
+				'address'	=>	(string) $address,
770
+				'lat'		=>	(string) $latitude,
771
+				'long'		=>	(string) $longitude,
772
+				'zoom'		=>	(string) $zoom,
773 773
 				'elevation'	=>	'',
774 774
 			);
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);
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 780
 	        }
781 781
 		}
782 782
 	}
783 783
 	/**
784 784
 	 * Saves the longitude and lattitude, as well as sets the map marker.
785 785
 	 */
786
-	public function set_location_taxonomy($data,$id) {
786
+	public function set_location_taxonomy($data, $id) {
787 787
 		$taxonomy = 'location';
788 788
 		$terms = false;
789
-		if(isset($data[0]['position'])){
789
+		if (isset($data[0]['position'])) {
790 790
 			$country_id = 0;
791
-			if(isset($data[0]['position']['country'])){
791
+			if (isset($data[0]['position']['country'])) {
792 792
 
793
-				if(!$term = term_exists(trim($data[0]['position']['country']), 'location'))
793
+				if (!$term = term_exists(trim($data[0]['position']['country']), 'location'))
794 794
 		        {
795 795
 		            $term = wp_insert_term(trim($data[0]['position']['country']), 'location');
796
-		            if ( is_wp_error($term) ){
796
+		            if (is_wp_error($term)) {
797 797
 		            	echo $term->get_error_message();
798 798
 		            }
799 799
 		            else {
800
-		            	wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
800
+		            	wp_set_object_terms($id, intval($term['term_id']), 'location', true);
801 801
 		            }
802 802
 		        }
803 803
 		        else
804 804
 		        {
805
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
805
+		            wp_set_object_terms($id, intval($term['term_id']), 'location', true);
806 806
 		        }
807 807
 		        $country_id = intval($term['term_id']);
808 808
 		    }
809 809
 
810
-			if(isset($data[0]['position']['destination'])){
810
+			if (isset($data[0]['position']['destination'])) {
811 811
 
812 812
 				$tax_args = array('parent'=>$country_id);
813
-				if(!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
813
+				if (!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
814 814
 		        {
815 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); }
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 818
 		        }
819 819
 		        else
820 820
 		        {
821
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
821
+		            wp_set_object_terms($id, intval($term['term_id']), 'location', true);
822 822
 		        }				
823 823
 			}		
824 824
 		}
@@ -827,30 +827,30 @@  discard block
 block discarded – undo
827 827
 	/**
828 828
 	 * Connects the destinations post type
829 829
 	 */
830
-	public function connect_destinations($data,$id) {
831
-		if(isset($data[0]['position'])){
830
+	public function connect_destinations($data, $id) {
831
+		if (isset($data[0]['position'])) {
832 832
 		    $destinations = false;
833
-		    if(isset($data[0]['position']['country'])){
833
+		    if (isset($data[0]['position']['country'])) {
834 834
 		    	$destinations['country'] = $data[0]['position']['country'];
835 835
 		    }
836
-		    if(isset($data[0]['position']['destination'])){
836
+		    if (isset($data[0]['position']['destination'])) {
837 837
 		    	$destinations['destination'] = $data[0]['position']['destination'];
838 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)){
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 843
 		    		$prev_values = array();
844 844
 		    	}
845 845
 		    	//print_r($destinations);
846 846
 				$destinations = array_unique($destinations);
847 847
 				//print_r($destinations);
848
-			    foreach($destinations as $key => $value){
848
+			    foreach ($destinations as $key => $value) {
849 849
 				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
850 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);
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 854
 	                	}
855 855
 	                } 		    	
856 856
 			    }	
@@ -861,18 +861,18 @@  discard block
 block discarded – undo
861 861
 	/**
862 862
 	 * Set the Travel Style
863 863
 	 */
864
-	public function set_taxonomy_style($data,$id) {
864
+	public function set_taxonomy_style($data, $id) {
865 865
 		$terms = false;
866
-		if(isset($data[0]['category'])){
867
-			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
866
+		if (isset($data[0]['category'])) {
867
+			if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
868 868
 	        {
869 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); }
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 872
 	        }
873 873
 	        else
874 874
 	        {
875
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
875
+	            wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
876 876
 	        }				
877 877
 		}
878 878
 	}		
@@ -880,23 +880,23 @@  discard block
 block discarded – undo
880 880
 	/**
881 881
 	 * Saves the room data
882 882
 	 */
883
-	public function set_room_data($data,$id) {
884
-		if(!empty($data[0]['rooms']) && is_array($data[0]['rooms'])){
883
+	public function set_room_data($data, $id) {
884
+		if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) {
885 885
 			$rooms = false;
886 886
 
887
-			foreach($data[0]['rooms'] as $room){
887
+			foreach ($data[0]['rooms'] as $room) {
888 888
 
889 889
 				$temp_room = array();
890
-				if(isset($room['name'])){
890
+				if (isset($room['name'])) {
891 891
 					$temp_room['title'] = $room['name'];
892 892
 				}
893
-				if(isset($room['description'])){
893
+				if (isset($room['description'])) {
894 894
 					$temp_room['description'] = strip_tags($room['description']);
895 895
 				}			
896 896
 				$temp_room['price'] = 0;
897 897
 				$temp_room['type'] = 'room';
898 898
 
899
-				if(!empty($room['images']) && is_array($room['images'])){
899
+				if (!empty($room['images']) && is_array($room['images'])) {
900 900
 			    	$attachments_args = array(
901 901
 			    			'post_parent' => $id,
902 902
 			    			'post_status' => 'inherit',
@@ -906,38 +906,38 @@  discard block
 block discarded – undo
906 906
 			    	$attachments = new WP_Query($attachments_args);
907 907
 			    	$found_attachments = array();
908 908
 
909
-			    	if($attachments->have_posts()){
910
-			    		foreach($attachments->posts as $attachment){
911
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
909
+			    	if ($attachments->have_posts()) {
910
+			    		foreach ($attachments->posts as $attachment) {
911
+			    			$found_attachments[] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
912 912
 			    		}
913 913
 			    	}
914 914
 
915 915
 					$temp_room['gallery'] = array();
916
-					foreach($room['images'] as $image_data){
917
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
916
+					foreach ($room['images'] as $image_data) {
917
+			    		$temp_room['gallery'][] = $this->attach_image($image_data, $id, $found_attachments);
918 918
 			    	}
919 919
 				}
920 920
 				$rooms[] = $temp_room;
921 921
 			}
922 922
 
923
-			if(false !== $id && '0' !== $id){
923
+			if (false !== $id && '0' !== $id) {
924 924
 				delete_post_meta($id, 'units');				
925 925
 			}
926
-			foreach($rooms as $room){
927
-		        add_post_meta($id,'units',$room,false);			
926
+			foreach ($rooms as $room) {
927
+		        add_post_meta($id, 'units', $room, false);			
928 928
 			}
929 929
 
930
-			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
930
+			if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) {
931 931
 				$room_count = $data[0]['features']['rooms'];
932
-			}else{
932
+			}else {
933 933
 				$room_count = count($data[0]['rooms']);
934 934
 			}
935 935
 
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);
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 941
 	        }
942 942
 		}
943 943
 	}
@@ -945,31 +945,31 @@  discard block
 block discarded – undo
945 945
 	/**
946 946
 	 * Set the ratings
947 947
 	 */
948
-	public function set_rating($data,$id) {
948
+	public function set_rating($data, $id) {
949 949
 
950
-		if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){
950
+		if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) {
951 951
 			$rating_type = $data[0]['features']['star_authority'];	
952
-		}else{
952
+		}else {
953 953
 			$rating_type = 'Unspecified2';
954 954
 		}
955
-		$this->save_custom_field($rating_type,'rating_type',$id);
955
+		$this->save_custom_field($rating_type, 'rating_type', $id);
956 956
 
957
-		if(!empty($data[0]['features']) && isset($data[0]['features']['stars'])){
958
-			$this->save_custom_field($data[0]['features']['stars'],'rating',$id,true);	
957
+		if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) {
958
+			$this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true);	
959 959
 		}
960 960
 	}
961 961
 
962 962
 	/**
963 963
 	 * Set the spoken_languages
964 964
 	 */
965
-	public function set_spoken_languages($data,$id) {
966
-		if(!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])){
965
+	public function set_spoken_languages($data, $id) {
966
+		if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) {
967 967
 			$languages = false;
968
-			foreach($data[0]['features']['spoken_languages'] as $spoken_language){
968
+			foreach ($data[0]['features']['spoken_languages'] as $spoken_language) {
969 969
 				$languages[] = sanitize_title($spoken_language);
970 970
 			}
971
-			if(false !== $languages){
972
-				$this->save_custom_field($languages,'spoken_languages',$id);
971
+			if (false !== $languages) {
972
+				$this->save_custom_field($languages, 'spoken_languages', $id);
973 973
 			}
974 974
 		}
975 975
 	}
@@ -977,14 +977,14 @@  discard block
 block discarded – undo
977 977
 	/**
978 978
 	 * Set the friendly
979 979
 	 */
980
-	public function set_friendly($data,$id) {
981
-		if(!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])){
980
+	public function set_friendly($data, $id) {
981
+		if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) {
982 982
 			$friendly_options = false;
983
-			foreach($data[0]['features']['suggested_visitor_types'] as $visitor_type){
983
+			foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) {
984 984
 				$friendly_options[] = sanitize_title($visitor_type);
985 985
 			}
986
-			if(false !== $friendly_options){
987
-				$this->save_custom_field($friendly_options,'suggested_visitor_types',$id);
986
+			if (false !== $friendly_options) {
987
+				$this->save_custom_field($friendly_options, 'suggested_visitor_types', $id);
988 988
 			}
989 989
 		}		
990 990
 	}
@@ -992,14 +992,14 @@  discard block
 block discarded – undo
992 992
 	/**
993 993
 	 * Set the special interests
994 994
 	 */
995
-	public function set_special_interests($data,$id) {
996
-		if(!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])){
995
+	public function set_special_interests($data, $id) {
996
+		if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) {
997 997
 			$interests = false;
998
-			foreach($data[0]['features']['special_interests'] as $special_interest){
998
+			foreach ($data[0]['features']['special_interests'] as $special_interest) {
999 999
 				$interests[] = sanitize_title($special_interest);
1000 1000
 			}
1001
-			if(false !== $interests){
1002
-				$this->save_custom_field($interests,'special_interests',$id);
1001
+			if (false !== $interests) {
1002
+				$this->save_custom_field($interests, 'special_interests', $id);
1003 1003
 			}
1004 1004
 		}		
1005 1005
 	}				
@@ -1007,48 +1007,48 @@  discard block
 block discarded – undo
1007 1007
 	/**
1008 1008
 	 * Set the Check in and Check out Date
1009 1009
 	 */
1010
-	public function set_checkin_checkout($data,$id) {
1010
+	public function set_checkin_checkout($data, $id) {
1011 1011
 
1012
-		if(!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])){
1013
-			$time = str_replace('h',':',$data[0]['features']['check_in_time']);
1014
-			$time = date('h:ia',strtotime($time));
1015
-			$this->save_custom_field($time,'checkin_time',$id);
1012
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) {
1013
+			$time = str_replace('h', ':', $data[0]['features']['check_in_time']);
1014
+			$time = date('h:ia', strtotime($time));
1015
+			$this->save_custom_field($time, 'checkin_time', $id);
1016 1016
 		}
1017
-		if(!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])){
1018
-			$time = str_replace('h',':',$data[0]['features']['check_out_time']);
1019
-			$time = date('h:ia',strtotime($time));
1020
-			$this->save_custom_field($time,'checkout_time',$id);
1017
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) {
1018
+			$time = str_replace('h', ':', $data[0]['features']['check_out_time']);
1019
+			$time = date('h:ia', strtotime($time));
1020
+			$this->save_custom_field($time, 'checkout_time', $id);
1021 1021
 		}
1022 1022
 	}	
1023 1023
 
1024 1024
 	/**
1025 1025
 	 * Set the Video date
1026 1026
 	 */
1027
-	public function set_video_data($data,$id) {
1028
-		if(!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])){
1027
+	public function set_video_data($data, $id) {
1028
+		if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) {
1029 1029
 			$videos = false;
1030 1030
 
1031
-			foreach($data[0]['content']['youtube_videos'] as $video){
1031
+			foreach ($data[0]['content']['youtube_videos'] as $video) {
1032 1032
 				$temp_video = array();
1033 1033
 
1034
-				if(isset($video['label'])){
1034
+				if (isset($video['label'])) {
1035 1035
 					$temp_video['title'] = $video['label'];
1036 1036
 				}
1037
-				if(isset($video['description'])){
1037
+				if (isset($video['description'])) {
1038 1038
 					$temp_video['description'] = strip_tags($video['description']);
1039 1039
 				}	
1040
-				if(isset($video['url'])){
1040
+				if (isset($video['url'])) {
1041 1041
 					$temp_video['url'] = $video['url'];
1042 1042
 				}						
1043 1043
 				$temp_video['thumbnail'] = '';
1044 1044
 				$videos[] = $temp_video;
1045 1045
 			}
1046 1046
 
1047
-			if(false !== $id && '0' !== $id){
1047
+			if (false !== $id && '0' !== $id) {
1048 1048
 				delete_post_meta($id, 'videos');				
1049 1049
 			}
1050
-			foreach($videos as $video){
1051
-		        add_post_meta($id,'videos',$video,false);			
1050
+			foreach ($videos as $video) {
1051
+		        add_post_meta($id, 'videos', $video, false);			
1052 1052
 			}
1053 1053
 		}
1054 1054
 	}	
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 	/**
1057 1057
 	 * Set the Facilities
1058 1058
 	 */
1059
-	public function set_facilities($data,$id) {
1059
+	public function set_facilities($data, $id) {
1060 1060
 
1061 1061
 		$parent_facilities = array(
1062 1062
 			'available_services' => 'Available Services',
@@ -1064,28 +1064,28 @@  discard block
 block discarded – undo
1064 1064
 			'room_facilities' => 'Room Facilities',
1065 1065
 			'activities_on_site' => 'Activities on Site'
1066 1066
 		);
1067
-		foreach($parent_facilities as $key => $label){
1067
+		foreach ($parent_facilities as $key => $label) {
1068 1068
 			$terms = false;
1069
-			if(isset($data[0]['features']) && isset($data[0]['features'][$key])){
1070
-				$parent_id = $this->set_term($id,$label,'facility');	
1069
+			if (isset($data[0]['features']) && isset($data[0]['features'][$key])) {
1070
+				$parent_id = $this->set_term($id, $label, 'facility');	
1071 1071
 			}
1072
-			foreach($data[0]['features'][$key] as $child_facility){
1073
-				$this->set_term($id,$child_facility,'facility',$parent_id);
1072
+			foreach ($data[0]['features'][$key] as $child_facility) {
1073
+				$this->set_term($id, $child_facility, 'facility', $parent_id);
1074 1074
 			}
1075 1075
 		}
1076 1076
 	}
1077 1077
 
1078
-	function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
1079
-		if(!$term = term_exists($name, $taxonomy))
1078
+	function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
1079
+		if (!$term = term_exists($name, $taxonomy))
1080 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); }
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 1085
         }
1086 1086
         else
1087 1087
         {
1088
-            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1088
+            wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
1089 1089
         }
1090 1090
         return $term['term_id'];
1091 1091
 	}	
@@ -1093,16 +1093,16 @@  discard block
 block discarded – undo
1093 1093
 	/**
1094 1094
 	 * Creates the main gallery data
1095 1095
 	 */
1096
-	public function set_featured_image($data,$id) {
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);
1096
+	public function set_featured_image($data, $id) {
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);
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);
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 1106
 	    			$this->gallery_meta[] = $this->featured_image;
1107 1107
 	    		}
1108 1108
 	    	}			
@@ -1112,17 +1112,17 @@  discard block
 block discarded – undo
1112 1112
 	/**
1113 1113
 	 * Sets a banner image
1114 1114
 	 */
1115
-	public function set_banner_image($data,$id) {
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'));
1115
+	public function set_banner_image($data, $id) {
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 1118
 
1119
-	    	if(false !== $this->banner_image){
1120
-	    		delete_post_meta($id,'image_group');
1119
+	    	if (false !== $this->banner_image) {
1120
+	    		delete_post_meta($id, 'image_group');
1121 1121
 	    		$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1122
-	    		add_post_meta($id,'image_group',$new_banner,true);
1122
+	    		add_post_meta($id, 'image_group', $new_banner, true);
1123 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);
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 1126
 	    			$this->gallery_meta[] = $this->banner_image;
1127 1127
 	    		}
1128 1128
 	    	}			
@@ -1132,24 +1132,24 @@  discard block
 block discarded – undo
1132 1132
 	/**
1133 1133
 	 * Creates the main gallery data
1134 1134
 	 */
1135
-	public function create_main_gallery($data,$id) {
1135
+	public function create_main_gallery($data, $id) {
1136 1136
 
1137
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1137
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1138 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;}
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);
1143
+	    		$this->gallery_meta[] = $this->attach_image($image_data, $id);
1144 1144
 	    		$counter++;
1145 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);
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 1153
 	    			}
1154 1154
 	    		}
1155 1155
 	    	}
@@ -1159,53 +1159,53 @@  discard block
 block discarded – undo
1159 1159
 	/**
1160 1160
 	 * Attaches 1 image
1161 1161
 	 */
1162
-	public function attach_image($v=false,$parent_id,$image_sizes=false){
1163
-		if(false !== $v){
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);
1167
-
1168
-	    	if(in_array($url_filename,$this->found_attachments)){
1169
-	    		return array_search($url_filename,$this->found_attachments);
1162
+	public function attach_image($v = false, $parent_id, $image_sizes = false) {
1163
+		if (false !== $v) {
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);
1167
+
1168
+	    	if (in_array($url_filename, $this->found_attachments)) {
1169
+	    		return array_search($url_filename, $this->found_attachments);
1170 1170
 	    	}
1171 1171
 	    	               
1172
-	        $postdata=array();
1173
-	        if(empty($v['label']))
1172
+	        $postdata = array();
1173
+	        if (empty($v['label']))
1174 1174
 	        {
1175
-	            $v['label']='';
1175
+	            $v['label'] = '';
1176 1176
 	        }
1177
-	        if(!empty($v['description']))
1177
+	        if (!empty($v['description']))
1178 1178
 	        {
1179
-	            $desc=wp_strip_all_tags($v['description']);
1180
-	            $posdata=array('post_excerpt'=>$desc);
1179
+	            $desc = wp_strip_all_tags($v['description']);
1180
+	            $posdata = array('post_excerpt'=>$desc);
1181 1181
 	        }
1182
-	        if(!empty($v['section']))
1182
+	        if (!empty($v['section']))
1183 1183
 	        {
1184
-	            $desc=wp_strip_all_tags($v['section']);
1185
-	            $posdata=array('post_excerpt'=>$desc);
1184
+	            $desc = wp_strip_all_tags($v['section']);
1185
+	            $posdata = array('post_excerpt'=>$desc);
1186 1186
 	        }
1187 1187
 
1188
-	        $attachID=NULL;  
1188
+	        $attachID = NULL;  
1189 1189
 	        //Resizor - add option to setting if required
1190
-	        $fragment = str_replace(' ','%20',$v['url_fragment']);
1190
+	        $fragment = str_replace(' ', '%20', $v['url_fragment']);
1191 1191
 	        $url = $this->get_scaling_url($image_sizes).$fragment;
1192
-	        $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1192
+	        $attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
1193 1193
 
1194 1194
 	        //echo($attachID.' add image');
1195
-	        if($attachID!=NULL)
1195
+	        if ($attachID != NULL)
1196 1196
 	        {
1197 1197
 	            return $attachID;
1198 1198
 	        }
1199 1199
         }	
1200 1200
         return 	false;
1201 1201
 	}
1202
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1202
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
1203 1203
 	
1204
-		if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
1204
+		if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
1205 1205
 
1206
-		require_once(ABSPATH . 'wp-admin/includes/file.php');
1207
-		require_once(ABSPATH . 'wp-admin/includes/media.php');
1208
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
1206
+		require_once(ABSPATH.'wp-admin/includes/file.php');
1207
+		require_once(ABSPATH.'wp-admin/includes/media.php');
1208
+		require_once(ABSPATH.'wp-admin/includes/image.php');
1209 1209
 		// Download file to temp location, returns full server path to temp file
1210 1210
 		//$tmp = download_url( $url );
1211 1211
 
@@ -1214,53 +1214,53 @@  discard block
 block discarded – undo
1214 1214
 
1215 1215
 		$image = file_get_contents($url);
1216 1216
 		file_put_contents($tmp, $image);
1217
-		chmod($tmp,'777');
1217
+		chmod($tmp, '777');
1218 1218
 
1219
-		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches);    // fix file filename for query strings
1219
+		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings
1220 1220
 		$url_filename = basename($matches[0]);
1221
-		$url_filename=str_replace('%20','_',$url_filename);
1221
+		$url_filename = str_replace('%20', '_', $url_filename);
1222 1222
 		// extract filename from url for title
1223
-		$url_type = wp_check_filetype($url_filename);                                           // determine file type (ext and mime/type)
1223
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
1224 1224
 		 
1225 1225
 		// override filename if given, reconstruct server path
1226
-		if ( !empty( $filename ) && " " != $filename )
1226
+		if (!empty($filename) && " " != $filename)
1227 1227
 		{
1228 1228
 			$filename = sanitize_file_name($filename);
1229
-			$tmppath = pathinfo( $tmp );      
1229
+			$tmppath = pathinfo($tmp);      
1230 1230
 
1231 1231
 			$extension = '';  
1232
-			if(isset($tmppath['extension'])){
1232
+			if (isset($tmppath['extension'])) {
1233 1233
 				$extension = $tmppath['extension'];
1234 1234
 			}   
1235 1235
 
1236
-			$new = $tmppath['dirname'] . "/". $filename . "." . $extension;
1237
-			rename($tmp, $new);                                                                 // renames temp file on server
1238
-			$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
1236
+			$new = $tmppath['dirname']."/".$filename.".".$extension;
1237
+			rename($tmp, $new); // renames temp file on server
1238
+			$tmp = $new; // push new filename (in path) to be used in file array later
1239 1239
 		}
1240 1240
 
1241 1241
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
1242
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
1242
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
1243 1243
 
1244
-		if ( !empty( $filename) && " " != $filename )
1244
+		if (!empty($filename) && " " != $filename)
1245 1245
 		{
1246
-			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
1246
+			$file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension
1247 1247
 		}
1248 1248
 		else
1249 1249
 		{
1250
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
1250
+			$file_array['name'] = $url_filename; // just use original URL filename
1251 1251
 		}
1252 1252
 
1253 1253
 		// set additional wp_posts columns
1254
-		if ( empty( $post_data['post_title'] ) )
1254
+		if (empty($post_data['post_title']))
1255 1255
 		{
1256 1256
 
1257
-			$url_filename=str_replace('%20',' ',$url_filename);
1257
+			$url_filename = str_replace('%20', ' ', $url_filename);
1258 1258
 
1259
-			$post_data['post_title'] = basename($url_filename, "." . $url_type['ext']);         // just use the original filename (no extension)
1259
+			$post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension)
1260 1260
 		}
1261 1261
 
1262 1262
 		// make sure gets tied to parent
1263
-		if ( empty( $post_data['post_parent'] ) )
1263
+		if (empty($post_data['post_parent']))
1264 1264
 		{
1265 1265
 			$post_data['post_parent'] = $post_id;
1266 1266
 		}
@@ -1268,12 +1268,12 @@  discard block
 block discarded – undo
1268 1268
 		// required libraries for media_handle_sideload
1269 1269
 
1270 1270
 		// do the validation and storage stuff
1271
-		$att_id = media_handle_sideload( $file_array, $post_id, null, $post_data );             // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1271
+		$att_id = media_handle_sideload($file_array, $post_id, null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1272 1272
 		 
1273 1273
 		// If error storing permanently, unlink
1274
-		if ( is_wp_error($att_id) )
1274
+		if (is_wp_error($att_id))
1275 1275
 		{
1276
-			unlink($file_array['tmp_name']);   // clean up
1276
+			unlink($file_array['tmp_name']); // clean up
1277 1277
 			return false; // output wp_error
1278 1278
 			//return $att_id; // output wp_error
1279 1279
 		}
Please login to merge, or discard this patch.
classes/class-connect-accommodation.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -207,6 +207,7 @@
 block discarded – undo
207 207
 
208 208
 	/**
209 209
 	 * format the array
210
+	 * @param string $key
210 211
 	 */
211 212
 	public function format_array($array,$key){
212 213
 		$new_array = array();
Please login to merge, or discard this 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.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 									foreach($accommodation as $row_key => $row){
94 94
 										if(stripos(ltrim(rtrim($row->name)), $post->post_title) !== false){
95 95
 											$identifier = $row->id;
96
-										}else{
96
+										} else{
97 97
 											continue;
98 98
 										}
99 99
 									}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 			//remove the extra accommodation
197 197
 			if(null !== $current_accommodation && !empty($current_accommodation)){
198 198
 				$all_accommodation = array_diff($this->format_array($all_accommodation,'ID'), $this->format_array($current_accommodation,'post_id'));
199
-			}elseif(null !== $current_accommodation && empty($current_accommodation)){
199
+			} elseif(null !== $current_accommodation && empty($current_accommodation)){
200 200
 				$all_accommodation = $this->format_array($current_accommodation,'post_id');
201 201
 			}
202 202
 
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
 	 * @access private
36 36
 	 */
37 37
 	public function __construct() {
38
-		$temp_options = get_option('_lsx-to_settings',false);
39
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
38
+		$temp_options = get_option('_lsx-to_settings', false);
39
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
40 40
 			$this->options = $temp_options[$this->plugin_slug];
41 41
 		}
42 42
 		$this->url = 'http://wetu.com/API/Pins/'.$this->options['api_key'].'/List';
43 43
 
44
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
45
-		add_action('wp_ajax_lsx_import_connect_accommodation',array($this,'process_connection'));	
46
-		add_action('wp_ajax_nopriv_lsx_import_connect_accommodation',array($this,'process_connection'));
44
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
45
+		add_action('wp_ajax_lsx_import_connect_accommodation', array($this, 'process_connection'));	
46
+		add_action('wp_ajax_nopriv_lsx_import_connect_accommodation', array($this, 'process_connection'));
47 47
 	}	
48 48
 
49 49
 	/**
@@ -54,30 +54,30 @@  discard block
 block discarded – undo
54 54
         ?>
55 55
         <div class="wrap">
56 56
 
57
-            <h3><span class="dashicons dashicons-admin-multisite"></span> <?php _e('Connect your Accommodation','wetu-importer'); ?></h3>
57
+            <h3><span class="dashicons dashicons-admin-multisite"></span> <?php _e('Connect your Accommodation', 'wetu-importer'); ?></h3>
58 58
 
59 59
 			<form method="get" action="" id="connect-accommodation-filter">
60 60
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />	
61 61
 
62
-				<p><?php _e('Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.','wetu-importer'); ?></p>
62
+				<p><?php _e('Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.', 'wetu-importer'); ?></p>
63 63
 
64 64
 	            <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
65
-	            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
65
+	            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
66 66
 	            </div>  
67 67
 
68 68
 				<?php
69 69
 					$loose_accommodation = $this->find_current_accommodation();
70 70
 				?>
71
-				<p><input class="button button-primary connect" type="button" value="<?php _e('Connect','wetu-importer'); ?>" /></p>
71
+				<p><input class="button button-primary connect" type="button" value="<?php _e('Connect', 'wetu-importer'); ?>" /></p>
72 72
 				<table class="wp-list-table widefat fixed posts">
73 73
 					<?php $this->table_header(); ?>
74 74
 				
75 75
 					<tbody>
76
-						<?php if(false !== $loose_accommodation){ 
76
+						<?php if (false !== $loose_accommodation) { 
77 77
 
78 78
 							$loose_args = array(
79 79
 								'post_type'=>'accommodation',
80
-								'post_status' => array('publish','pending'),
80
+								'post_status' => array('publish', 'pending'),
81 81
 								'nopagin' => true,
82 82
 								'post__in' => $loose_accommodation
83 83
 							);
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 							$accommodation = get_transient('lsx_ti_accommodation');
86 86
 							$identifier = '';
87 87
 
88
-							if($loose_accommodation_query->have_posts() && false !== $accommodation){
89
-								while($loose_accommodation_query->have_posts()){
88
+							if ($loose_accommodation_query->have_posts() && false !== $accommodation) {
89
+								while ($loose_accommodation_query->have_posts()) {
90 90
 									$loose_accommodation_query->the_post();
91 91
 
92
-									foreach($accommodation as $row_key => $row){
93
-										if(stripos(ltrim(rtrim($row->name)), $post->post_title) !== false){
92
+									foreach ($accommodation as $row_key => $row) {
93
+										if (stripos(ltrim(rtrim($row->name)), $post->post_title) !== false) {
94 94
 											$identifier = $row->id;
95
-										}else{
95
+										}else {
96 96
 											continue;
97 97
 										}
98 98
 									}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 				</table>
120 120
 
121
-				<p><input class="button button-primary connect" type="button" value="<?php _e('Connect','wetu-importer'); ?>" /></p>
121
+				<p><input class="button button-primary connect" type="button" value="<?php _e('Connect', 'wetu-importer'); ?>" /></p>
122 122
 
123 123
 			</form> 
124 124
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 					FROM {$wpdb->posts}	
180 180
 					WHERE post_type = 'accommodation'
181 181
 					LIMIT 0,500
182
-		",ARRAY_A);
182
+		", ARRAY_A);
183 183
 
184 184
 		$current_accommodation = $wpdb->get_results("
185 185
 					SELECT key1.post_id
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
 					AND key2.post_type = 'accommodation'
193 193
 
194 194
 					LIMIT 0,500
195
-		",ARRAY_A);
195
+		", ARRAY_A);
196 196
 
197
-		if(null !== $all_accommodation && !empty($all_accommodation)){
197
+		if (null !== $all_accommodation && !empty($all_accommodation)) {
198 198
 			//remove the extra accommodation
199
-			if(null !== $current_accommodation && !empty($current_accommodation)){
200
-				$all_accommodation = array_diff($this->format_array($all_accommodation,'ID'), $this->format_array($current_accommodation,'post_id'));
201
-			}elseif(null !== $current_accommodation && empty($current_accommodation)){
202
-				$all_accommodation = $this->format_array($current_accommodation,'post_id');
199
+			if (null !== $current_accommodation && !empty($current_accommodation)) {
200
+				$all_accommodation = array_diff($this->format_array($all_accommodation, 'ID'), $this->format_array($current_accommodation, 'post_id'));
201
+			}elseif (null !== $current_accommodation && empty($current_accommodation)) {
202
+				$all_accommodation = $this->format_array($current_accommodation, 'post_id');
203 203
 			}
204 204
 
205 205
 			$return = $all_accommodation;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	/**
211 211
 	 * format the array
212 212
 	 */
213
-	public function format_array($array,$key){
213
+	public function format_array($array, $key) {
214 214
 		$new_array = array();
215
-		foreach($array as $value){
215
+		foreach ($array as $value) {
216 216
 			$new_array[] = $value[$key];
217 217
 		}
218 218
 		return $new_array;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	public function process_connection() {
225 225
 		$return = false;
226 226
 
227
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['post_id']) && isset($_POST['wetu_id'])){
227
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['post_id']) && isset($_POST['wetu_id'])) {
228 228
 
229 229
 			$post_id = false;
230 230
 			$matching_id = false;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			$post_id = $_POST['post_id'];
233 233
 			$matching_id = $_POST['wetu_id'];			
234 234
 
235
-			add_post_meta($post_id,'lsx_wetu_id',$matching_id);
235
+			add_post_meta($post_id, 'lsx_wetu_id', $matching_id);
236 236
 			$return = '<li class="post-'.$post_id.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($post_id).'">'.get_the_title($post_id).'</a></li>';
237 237
 		}
238 238
 		print_r($return);
Please login to merge, or discard this patch.
classes/class-tours.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -552,6 +552,7 @@
 block discarded – undo
552 552
 
553 553
 	/**
554 554
 	 * A loop which runs through each leg on the tour.
555
+	 * @param boolean $importable_content
555 556
 	 */
556 557
 	public function process_itineraries($data,$id,$importable_content) {
557 558
 		$day_counter = 1;
Please login to merge, or discard this 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.
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -82,20 +82,20 @@  discard block
 block discarded – undo
82 82
 	public function __construct() {
83 83
 		$this->set_variables();
84 84
 
85
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
86
-		add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));	
87
-		add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));		
85
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
86
+		add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));	
87
+		add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));		
88 88
 
89
-		add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));	
90
-		add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
89
+		add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));	
90
+		add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
91 91
 
92
-		$temp_options = get_option('_lsx-to_settings',false);
93
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
92
+		$temp_options = get_option('_lsx-to_settings', false);
93
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
94 94
 			$this->options = $temp_options[$this->plugin_slug];
95 95
 		}
96 96
 
97
-		$tour_options = get_option('wetu_importer_tour_settings',false);
98
-		if(false !== $tour_options){
97
+		$tour_options = get_option('wetu_importer_tour_settings', false);
98
+		if (false !== $tour_options) {
99 99
 			$this->tour_options = $tour_options;
100 100
         }
101 101
 	}
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	{
108 108
 		parent::set_variables();
109 109
 
110
-		if ( false !== $this->api_username && false !== $this->api_password ) {
110
+		if (false !== $this->api_username && false !== $this->api_password) {
111 111
 			$this->url    = 'https://wetu.com/API/Itinerary/';
112
-			$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
113
-		} elseif ( false !== $this->api_key ) {
114
-			$this->url    = 'https://wetu.com/API/Itinerary/' . $this->api_key;
112
+			$this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password;
113
+		} elseif (false !== $this->api_key) {
114
+			$this->url    = 'https://wetu.com/API/Itinerary/'.$this->api_key;
115 115
 			$this->url_qs = '';
116 116
 		}
117 117
 	}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 			<form method="get" action="" id="posts-filter">
132 132
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
133 133
 				
134
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
135
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
134
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
135
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
136 136
 				</p>				
137 137
 
138 138
 				<table class="wp-list-table widefat fixed posts">
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 					<tbody id="the-list">
142 142
 						<tr class="post-0 type-tour status-none" id="post-0">
143 143
 							<th class="check-column" scope="row">
144
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
144
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
145 145
 							</th>
146 146
 							<td class="post-title page-title column-title">
147 147
 								<strong>
148
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
148
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
149 149
 								</strong>
150 150
 							</td>
151 151
 							<td class="date column-date">							
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 
160 160
 				</table>
161 161
 
162
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
163
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
162
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
163
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
164 164
 				</p>
165 165
 			</form> 
166 166
 
@@ -172,36 +172,36 @@  discard block
 block discarded – undo
172 172
 						<div style="width:30%;display:block;float:left;">
173 173
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
174 174
 							<ul>
175
-								<li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
176
-								<li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
175
+								<li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
176
+								<li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
177 177
 
178
-                                <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li>
179
-                                <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li>
178
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li>
179
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li>
180 180
 
181
-								<li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
181
+								<li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
182 182
 
183
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li>
183
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li>
184 184
 
185
-								<?php if(class_exists('LSX_TO_Maps')){ ?>
186
-                                    <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li>
185
+								<?php if (class_exists('LSX_TO_Maps')) { ?>
186
+                                    <li><input class="content" <?php $this->checked($this->tour_options, 'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)', 'wetu-importer'); ?></li>
187 187
 								<?php } ?>
188 188
 							</ul>
189 189
 						</div>
190 190
                         <div style="width:30%;display:block;float:left;">
191 191
                             <h3><?php _e('Itinerary Info'); ?></h3>
192 192
                             <ul>
193
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li>
194
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included','wetu-importer'); ?></li>
195
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded','wetu-importer'); ?></li>
193
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li>
194
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included', 'wetu-importer'); ?></li>
195
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded', 'wetu-importer'); ?></li>
196 196
                             </ul>
197 197
 
198 198
                             <h4><?php _e('Additional Content'); ?></h4>
199 199
                             <ul>
200
-                                <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li>
201
-                                <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li>
200
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li>
201
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li>
202 202
                             </ul>
203 203
                         </div>
204
-                        <?php if(class_exists('LSX_TO_Team')){ ?>
204
+                        <?php if (class_exists('LSX_TO_Team')) { ?>
205 205
                             <div style="width:30%;display:block;float:left;">
206 206
                                 <h3><?php _e('Assign a Team Member'); ?></h3>
207 207
                                 <?php $this->team_member_checkboxes($this->tour_options); ?>
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
 
215 215
 					<h3><?php _e('Your List'); ?></h3>
216
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
216
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
217 217
 					<table class="wp-list-table widefat fixed posts">
218 218
 						<?php $this->table_header(); ?>
219 219
 
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 
226 226
 					</table>
227 227
 
228
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
228
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
229 229
 				</form>
230 230
 			</div>
231 231
 
232 232
 			<div style="display:none;" class="completed-list-wrapper">
233
-				<h3><?php _e('Completed','wetu-importer'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3>
233
+				<h3><?php _e('Completed', 'wetu-importer'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3>
234 234
 				<ul>
235 235
 				</ul>
236 236
 			</div>
@@ -243,20 +243,20 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public function update_options_form() {
245 245
 		$tours = get_transient('lsx_ti_tours');
246
-		echo '<div class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - ';
247
-		if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){
246
+		echo '<div class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - ';
247
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
248 248
 			$result = $this->update_options();
249 249
 
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>';
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 254
                 }
255
-            }else{
255
+            }else {
256 256
 			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
257 257
             }
258
-		}else{
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>';
258
+		}else {
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
 	}
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 	 * Save the list of Tours into an option
266 266
 	 */
267 267
 	public function update_options() {
268
-		$data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs . '&own=true&type=All' );
268
+		$data = file_get_contents($this->url.'/V7/List?'.$this->url_qs.'&own=true&type=All');
269 269
 		$tours = json_decode($data, true);
270 270
 
271
-		if(isset($tours['error'])){
271
+		if (isset($tours['error'])) {
272 272
 		    return $tours['error'];
273 273
         }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
274
-			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
274
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
275 275
 			return true;
276 276
 		}
277 277
 	}
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 
296 296
 					LIMIT 0,500
297 297
 		");
298
-		if(null !== $current_tours && !empty($current_tours)){
299
-			foreach($current_tours as $tour){
298
+		if (null !== $current_tours && !empty($current_tours)) {
299
+			foreach ($current_tours as $tour) {
300 300
 				$return[$tour->meta_value] = $tour;
301 301
 			}
302 302
 		}
@@ -309,36 +309,36 @@  discard block
 block discarded – undo
309 309
 	public function process_ajax_search() {
310 310
 		$return = false;
311 311
 
312
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){
312
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
313 313
 			$tours = get_transient('lsx_ti_tours');
314
-			if ( false !== $tours) {
314
+			if (false !== $tours) {
315 315
 
316 316
 				$searched_items = false;
317 317
 
318
-				if(isset($_POST['keyword'] )) {
318
+				if (isset($_POST['keyword'])) {
319 319
 					$keyphrases = $_POST['keyword'];
320
-				}else{
320
+				}else {
321 321
 					$keyphrases = array(0);
322 322
                 }
323 323
 
324
-				if(!is_array($keyphrases)){
324
+				if (!is_array($keyphrases)) {
325 325
 					$keyphrases = array($keyphrases);
326 326
 				}
327
-				foreach($keyphrases as &$keyword){
327
+				foreach ($keyphrases as &$keyword) {
328 328
 					$keyword = ltrim(rtrim($keyword));
329 329
 				}
330 330
 
331 331
 				$post_status = false;
332
-				if(in_array('publish',$keyphrases)){
332
+				if (in_array('publish', $keyphrases)) {
333 333
 					$post_status = 'publish';
334 334
 				}
335
-				if(in_array('pending',$keyphrases)){
335
+				if (in_array('pending', $keyphrases)) {
336 336
 					$post_status = 'pending';
337 337
 				}
338
-				if(in_array('draft',$keyphrases)){
338
+				if (in_array('draft', $keyphrases)) {
339 339
 					$post_status = 'draft';
340 340
 				}
341
-				if(in_array('import',$keyphrases)){
341
+				if (in_array('import', $keyphrases)) {
342 342
 					$post_status = 'import';
343 343
 				}
344 344
 
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 				if (!empty($tours)) {
347 347
 					$current_tours = $this->find_current_tours();
348 348
 
349
-					foreach($tours as $row_key => $row){
349
+					foreach ($tours as $row_key => $row) {
350 350
 
351
-					    if(isset($row['is_disabled']) && true === $row['is_disabled']){
351
+					    if (isset($row['is_disabled']) && true === $row['is_disabled']) {
352 352
                             continue;
353 353
                         }
354 354
 
@@ -358,29 +358,29 @@  discard block
 block discarded – undo
358 358
 
359 359
                         //If this is a current tour, add its ID to the row.
360 360
 						$row['post_id'] = 0;
361
-						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
361
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
362 362
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
363 363
 						}
364 364
 
365 365
 						//If we are searching for
366
-						if(false !== $post_status){
366
+						if (false !== $post_status) {
367 367
 
368
-                            if('import' === $post_status){
368
+                            if ('import' === $post_status) {
369 369
 
370
-								if(0 !== $row['post_id']){
370
+								if (0 !== $row['post_id']) {
371 371
 								    continue;
372
-								}else{
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
-								if(0 === $row['post_id']){
379
+								if (0 === $row['post_id']) {
380 380
 									continue;
381
-								}else{
381
+								}else {
382 382
 									$current_status = get_post_status($row['post_id']);
383
-									if($current_status !== $post_status){
383
+									if ($current_status !== $post_status) {
384 384
 									    continue;
385 385
                                     }
386 386
 
@@ -389,17 +389,17 @@  discard block
 block discarded – undo
389 389
 
390 390
                             }
391 391
 
392
-                        }else{
392
+                        }else {
393 393
 							//Search through each keyword.
394
-							foreach($keyphrases as $keyphrase){
394
+							foreach ($keyphrases as $keyphrase) {
395 395
 
396 396
 								//Make sure the keyphrase is turned into an array
397
-								$keywords = explode(" ",$keyphrase);
398
-								if(!is_array($keywords)){
397
+								$keywords = explode(" ", $keyphrase);
398
+								if (!is_array($keywords)) {
399 399
 									$keywords = array($keywords);
400 400
 								}
401 401
 
402
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
402
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
403 403
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
404 404
 								}
405 405
 							}
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 					}		
408 408
 				}
409 409
 
410
-				if(false !== $searched_items){
410
+				if (false !== $searched_items) {
411 411
 					ksort($searched_items);
412 412
 					$return = implode($searched_items);
413 413
 				}
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 	/**
421 421
 	 * Formats the row for output on the screen.
422 422
 	 */	
423
-	public function format_row($row = false){
424
-		if(false !== $row){
423
+	public function format_row($row = false) {
424
+		if (false !== $row) {
425 425
 
426 426
 			$status = 'import';
427
-			if(0 !== $row['post_id']){
427
+			if (0 !== $row['post_id']) {
428 428
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
429 429
 			}
430 430
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 					<strong>'.$row['name'].'</strong> - '.$status.'
439 439
 				</td>
440 440
 				<td class="date column-date">
441
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
441
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
442 442
 				</td>
443 443
 				<td class="ssid column-ssid">
444 444
 					'.$row['identifier'].'
@@ -453,31 +453,31 @@  discard block
 block discarded – undo
453 453
 	 */
454 454
 	public function process_ajax_import($force = false) {
455 455
 		$return = false;
456
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){
456
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
457 457
 			
458 458
 			$wetu_id = $_POST['wetu_id'];
459
-			if(isset($_POST['post_id'])){
459
+			if (isset($_POST['post_id'])) {
460 460
 				$post_id = $_POST['post_id'];	
461
-			}else{
461
+			}else {
462 462
 				$post_id = 0;
463 463
 			}
464 464
 
465
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
465
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
466 466
 				$content = $_POST['content'];
467
-				add_option('wetu_importer_tour_settings',$content);
468
-			}else{
467
+				add_option('wetu_importer_tour_settings', $content);
468
+			}else {
469 469
 				delete_option('wetu_importer_tour_settings');
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)
475
+            if ($jdata)
476 476
             {
477
-				$jdata=json_decode($jdata,true);
478
-                if(!empty($jdata))
477
+				$jdata = json_decode($jdata, true);
478
+                if (!empty($jdata))
479 479
                 {
480
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
480
+                	$return = $this->import_row($jdata, $wetu_id, $post_id, $content);
481 481
                 	$this->format_completed_row($return);
482 482
                 }
483 483
             }
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
      * @param $data array
493 493
      * @param $wetu_id string
494 494
 	 */
495
-	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
495
+	public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) {
496 496
         $post_name = $data_post_content = $data_post_excerpt = '';
497 497
         $post = array(
498 498
           'post_type'		=> 'tour',
@@ -500,29 +500,29 @@  discard block
 block discarded – undo
500 500
 
501 501
         //Set the post_content
502 502
 		$content_used_general_description = false;
503
-        if(false !== $importable_content && in_array('description',$importable_content)){
503
+        if (false !== $importable_content && in_array('description', $importable_content)) {
504 504
             $data_post_content = '';
505 505
 
506
-            if(isset($data['description'])){
506
+            if (isset($data['description'])) {
507 507
                 $data_post_content = $data['description'];
508
-            }elseif(isset($data['summary'])){
508
+            }elseif (isset($data['summary'])) {
509 509
                 $data_post_content = $data['summary'];
510 510
             }
511 511
             $post['post_content'] = $data_post_content;
512 512
         }
513 513
 
514 514
         //Create or update the post
515
-        if(false !== $id && '0' !== $id){
515
+        if (false !== $id && '0' !== $id) {
516 516
             $post['ID'] = $id;
517 517
 	        $post['post_status'] = 'publish';
518 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{
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 522
 
523 523
             //Set the name
524
-            if(isset($data['name'])){
525
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
524
+            if (isset($data['name'])) {
525
+                $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
526 526
             }
527 527
             $post['post_name'] = $post_name;
528 528
             $post['post_title'] = $data['name'];
@@ -530,51 +530,51 @@  discard block
 block discarded – undo
530 530
             $id = wp_insert_post($post);
531 531
 
532 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']));
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 536
             }
537 537
         }
538 538
 
539 539
 
540 540
 		//Set the price
541
-		if(false !== $importable_content && in_array('price',$importable_content)){
542
-			$this->set_price($data,$id);
541
+		if (false !== $importable_content && in_array('price', $importable_content)) {
542
+			$this->set_price($data, $id);
543 543
 		}
544 544
 
545 545
 		//Set the Duration
546
-		if(false !== $importable_content && in_array('duration',$importable_content)){
547
-			$this->set_duration($data,$id);
546
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
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);
550
+        if (in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
551
+            $this->process_itineraries($data, $id, $importable_content);
552 552
         }
553 553
 
554
-		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
555
-			$this->process_map_points($data,$id);
554
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
555
+			$this->process_map_points($data, $id);
556 556
 		}
557 557
 
558 558
 		//TODO Test These
559 559
 		//Setup some default for use in the import
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))){
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 563
         //Set the featured image
564 564
         //TODO Test These
565
-        if(false !== $importable_content && in_array('featured_image',$importable_content)){
566
-            $this->set_featured_image($data,$id);
565
+        if (false !== $importable_content && in_array('featured_image', $importable_content)) {
566
+            $this->set_featured_image($data, $id);
567 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);
570
+        if (false !== $importable_content && in_array('banner_image', $importable_content)) {
571
+            $this->set_banner_image($data, $id);
572 572
         }
573 573
 
574 574
 		//TODO Test These
575 575
         //Import the main gallery
576
-        if(false !== $importable_content && in_array('gallery',$importable_content)){
577
-            $this->create_main_gallery($data,$id);
576
+        if (false !== $importable_content && in_array('gallery', $importable_content)) {
577
+            $this->create_main_gallery($data, $id);
578 578
         }
579 579
 
580 580
         return $id;
@@ -583,151 +583,151 @@  discard block
 block discarded – undo
583 583
 	/**
584 584
 	 * A loop which runs through each leg on the tour.
585 585
 	 */
586
-	public function process_itineraries($data,$id,$importable_content) {
586
+	public function process_itineraries($data, $id, $importable_content) {
587 587
 		$day_counter = 1;
588 588
 		$leg_counter = 0;
589 589
 
590
-		delete_post_meta($id,'itinerary');
590
+		delete_post_meta($id, 'itinerary');
591 591
 
592
-		if(false !== $importable_content && in_array('accommodation',$importable_content)){
593
-			delete_post_meta($id,'accommodation_to_tour');
592
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
593
+			delete_post_meta($id, 'accommodation_to_tour');
594 594
 		}
595
-		if(false !== $importable_content && in_array('destination',$importable_content)){
596
-			delete_post_meta($id,'destination_to_tour');
597
-			delete_post_meta($id,'departs_from');
598
-			delete_post_meta($id,'ends_in');
595
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
596
+			delete_post_meta($id, 'destination_to_tour');
597
+			delete_post_meta($id, 'departs_from');
598
+			delete_post_meta($id, 'ends_in');
599 599
 		}
600 600
 
601 601
 		$departs_from = false;
602 602
 		$ends_in = false;
603 603
 
604
-		foreach($data['legs'] as $leg){
604
+		foreach ($data['legs'] as $leg) {
605 605
 
606
-			if(isset($leg['days']) && !empty($leg['days'])){
606
+			if (isset($leg['days']) && !empty($leg['days'])) {
607 607
 
608 608
 				//Itinerary Accommodation
609 609
 				$current_accommodation = false;
610
-				if(false !== $importable_content && in_array('accommodation',$importable_content)){
611
-					$current_accommodation = $this->set_accommodation($leg,$id);
610
+				if (false !== $importable_content && in_array('accommodation', $importable_content)) {
611
+					$current_accommodation = $this->set_accommodation($leg, $id);
612 612
 				}
613 613
 
614 614
 				//Itinerary Destination
615 615
 				$current_destination = false;
616
-				if(false !== $importable_content && in_array('destination',$importable_content)){
617
-					$current_destination = $this->set_destination($leg,$id);
616
+				if (false !== $importable_content && in_array('destination', $importable_content)) {
617
+					$current_destination = $this->set_destination($leg, $id);
618 618
 				}
619 619
 
620 620
 				//If the Nights are the same mount of days in the array,  then it isnt "By Destination"
621
-				if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){
621
+				if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) {
622 622
 
623
-					foreach($leg['days'] as $day){
623
+					foreach ($leg['days'] as $day) {
624 624
 
625 625
 						$current_day = array();
626 626
 
627
-						$current_day['title'] =  esc_attr('Day ','wetu-importer').$day_counter;
627
+						$current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter;
628 628
 
629 629
 						//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
630 630
 
631 631
 						//Description
632
-						if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){
632
+						if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
633 633
 							$current_day['description'] = $day['notes'];
634
-						}else{
634
+						}else {
635 635
 							$current_day['description'] = '';
636 636
 						}
637 637
 
638 638
 						//Itinerary Gallery
639
-						if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){
639
+						if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
640 640
 							$current_day['featured_image'] = '';
641
-						}else{
641
+						}else {
642 642
 							$current_day['featured_image'] = '';
643 643
 						}
644 644
 
645 645
 						//Accommodation
646
-						if(false !== $current_accommodation){
646
+						if (false !== $current_accommodation) {
647 647
 							$current_day['accommodation_to_tour'] = array($current_accommodation);
648
-						}else{
648
+						}else {
649 649
 							$current_day['accommodation_to_tour'] = array();
650 650
 						}
651 651
 
652 652
 						//Destination
653
-						if(false !== $current_destination){
653
+						if (false !== $current_destination) {
654 654
 							$current_day['destination_to_tour'] = array($current_destination);
655
-						}else{
655
+						}else {
656 656
 							$current_day['destination_to_tour'] = array();
657 657
 						}
658 658
 
659 659
 						//Included
660
-						if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){
660
+						if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
661 661
 							$current_day['included'] = $day['included'];
662
-						}else{
662
+						}else {
663 663
 							$current_day['included'] = '';
664 664
 						}
665 665
 
666 666
 						//Excluded
667
-						if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){
667
+						if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
668 668
 							$current_day['excluded'] = $day['excluded'];
669
-						}else{
669
+						}else {
670 670
 							$current_day['excluded'] = '';
671 671
 						}
672 672
 
673
-						$this->set_itinerary_day($current_day,$id);
673
+						$this->set_itinerary_day($current_day, $id);
674 674
 						$day_counter++;
675 675
 					}
676 676
 
677
-				}else{
678
-					$day_counter = $day_counter + (int)$leg['nights'];
677
+				}else {
678
+					$day_counter = $day_counter + (int) $leg['nights'];
679 679
 				}
680 680
 
681 681
 			}
682 682
 
683 683
 			//If we are in the first leg,  and the destination was attached then save it as the departure field.
684
-			if( 0 === $leg_counter && false !== $current_destination){
684
+			if (0 === $leg_counter && false !== $current_destination) {
685 685
 				$departs_from = $current_destination;
686 686
 			}
687 687
 
688 688
 			//If its the last leg then save it as the ends in.
689
-			if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){
689
+			if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) {
690 690
 				$ends_in = $current_destination;
691 691
 			}
692 692
 			$leg_counter++;
693 693
 		}
694 694
 
695
-		if(false !== $departs_from){
696
-			add_post_meta($id,'departs_from',$departs_from,true);
695
+		if (false !== $departs_from) {
696
+			add_post_meta($id, 'departs_from', $departs_from, true);
697 697
 		}
698
-		if(false !== $ends_in){
699
-			add_post_meta($id,'ends_in',$ends_in,true);
698
+		if (false !== $ends_in) {
699
+			add_post_meta($id, 'ends_in', $ends_in, true);
700 700
 		}
701 701
 	}
702 702
 
703 703
 	/**
704 704
 	 * Run through your routes and save the points as a KML file.
705 705
 	 */
706
-	public function process_map_points($data,$id) {
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 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']);
719
+	                $temp_points = explode(';', $route['points']);
720 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 728
             }
729
-            if(!empty($points)){
730
-				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
729
+            if (!empty($points)) {
730
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
731 731
             }
732 732
         }
733 733
 
@@ -736,28 +736,28 @@  discard block
 block discarded – undo
736 736
 	/**
737 737
 	 * Set the Itinerary Day
738 738
 	 */
739
-	public function set_itinerary_day($day,$id) {
740
-        $this->save_custom_field($day,'itinerary',$id,false,false);
739
+	public function set_itinerary_day($day, $id) {
740
+        $this->save_custom_field($day, 'itinerary', $id, false, false);
741 741
 	}
742 742
 
743 743
 	/**
744 744
 	 * Set the price
745 745
 	 */
746
-	public function set_price($data,$id) {
746
+	public function set_price($data, $id) {
747 747
 	    //Price
748
-		if(isset($data['price']) && ''!== $data['price']){
748
+		if (isset($data['price']) && '' !== $data['price']) {
749 749
             $price = preg_replace("/[^0-9,.]/", "", $data['price']);
750
-            $this->save_custom_field($price,'price',$id);
750
+            $this->save_custom_field($price, 'price', $id);
751 751
 		}
752 752
 
753 753
 		//Price includes
754
-		if(isset($data['price_includes']) && ''!== $data['price_includes']){
755
-			$this->save_custom_field($data['price_includes'],'included',$id);
754
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
755
+			$this->save_custom_field($data['price_includes'], 'included', $id);
756 756
 		}
757 757
 
758 758
         //Price Excludes
759
-		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
760
-			$this->save_custom_field($data['price_excludes'],'not_included',$id);
759
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
760
+			$this->save_custom_field($data['price_excludes'], 'not_included', $id);
761 761
 		}
762 762
 
763 763
 	}
@@ -765,11 +765,11 @@  discard block
 block discarded – undo
765 765
 	/**
766 766
 	 * Set the duration
767 767
 	 */
768
-	public function set_duration($data,$id) {
769
-		if(isset($data['days']) && !empty($data['days'])){
768
+	public function set_duration($data, $id) {
769
+		if (isset($data['days']) && !empty($data['days'])) {
770 770
 			$price = $data['days'];
771 771
 			$price = preg_replace("/[^0-9,.]/", "", $price);
772
-			$this->save_custom_field($price,'duration',$id);
772
+			$this->save_custom_field($price, 'duration', $id);
773 773
 		}
774 774
 	}
775 775
 
@@ -777,27 +777,27 @@  discard block
 block discarded – undo
777 777
 	/**
778 778
 	 * Connects the Accommodation if its available
779 779
 	 */
780
-	public function set_accommodation($day,$id) {
780
+	public function set_accommodation($day, $id) {
781 781
 
782 782
 	    $ac_id = false;
783 783
 		$this->current_accommodation = $this->find_current_accommodation();
784 784
 		
785
-		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
785
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
786 786
 
787
-			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
787
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
788 788
                 $ac_id = $this->current_accommodation[$day['content_entity_id']];
789
-			}else{
789
+			}else {
790 790
 				$ac_id = wp_insert_post(array(
791 791
                     'post_type' => 'accommodation',
792 792
                     'post_status' => 'draft',
793 793
                     'post_title' => $day['content_entity_id']
794 794
                 ));
795
-				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
795
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
796 796
 			}
797 797
 
798
-			if('' !== $ac_id && false !== $ac_id){
799
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
800
-				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
798
+			if ('' !== $ac_id && false !== $ac_id) {
799
+			    $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
800
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
801 801
             }
802 802
 		}
803 803
 		return $ac_id;
@@ -809,13 +809,13 @@  discard block
 block discarded – undo
809 809
      * @param $post_type string
810 810
      * @return boolean / array
811 811
 	 */
812
-	public function find_current_accommodation($post_type='accommodation') {
812
+	public function find_current_accommodation($post_type = 'accommodation') {
813 813
 		global $wpdb;
814 814
 		$accommodation = parent::find_current_accommodation($post_type);
815 815
 
816 816
 		$return = false;
817
-		if(!empty($accommodation)){
818
-		    foreach($accommodation as $key => $acc){
817
+		if (!empty($accommodation)) {
818
+		    foreach ($accommodation as $key => $acc) {
819 819
 				$return[$acc->meta_value] = $acc->post_id;
820 820
             }
821 821
         }
@@ -837,25 +837,25 @@  discard block
 block discarded – undo
837 837
 	 * @param $id string
838 838
 	 * @return boolean / string
839 839
 	 */
840
-	public function set_destination($day,$id) {
840
+	public function set_destination($day, $id) {
841 841
 		$dest_id = false;
842 842
 		$country_id = false;
843 843
 		$this->current_destinations = $this->find_current_destinations();
844 844
 
845
-		if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){
845
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
846 846
 
847
-			if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){
847
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
848 848
 				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
849 849
 
850 850
 				$potential_id = wp_get_post_parent_id($dest_id);
851
-				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
852
-				if(false !== $country_wetu_id){
851
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
852
+				if (false !== $country_wetu_id) {
853 853
 					$this->set_country($country_wetu_id, $id);
854 854
                 }
855 855
 
856 856
 			}else {
857 857
 
858
-				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']);
858
+				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']);
859 859
 
860 860
 				if ($destination_json) {
861 861
 					$destination_data = json_decode($destination_json, true);
@@ -864,12 +864,12 @@  discard block
 block discarded – undo
864 864
 
865 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
                         }
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
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);
@@ -913,9 +913,9 @@  discard block
 block discarded – undo
913 913
 
914 914
         if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
915 915
             $country_id = $this->current_destinations[$country_wetu_id];
916
-        } else {
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 920
             if ($country_json) {
921 921
                 $country_data = json_decode($country_json, true);
Please login to merge, or discard this patch.
Braces   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 			    if(!isset($_GET['refresh_tours'])){
253 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 254
                 }
255
-            }else{
255
+            } else{
256 256
 			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
257 257
             }
258
-		}else{
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>';
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 
271 271
 		if(isset($tours['error'])){
272 272
 		    return $tours['error'];
273
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
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
 		}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 				if(isset($_POST['keyword'] )) {
319 319
 					$keyphrases = $_POST['keyword'];
320
-				}else{
320
+				} else{
321 321
 					$keyphrases = array(0);
322 322
                 }
323 323
 
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 
370 370
 								if(0 !== $row['post_id']){
371 371
 								    continue;
372
-								}else{
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
-								}else{
381
+								} else{
382 382
 									$current_status = get_post_status($row['post_id']);
383 383
 									if($current_status !== $post_status){
384 384
 									    continue;
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
                             }
391 391
 
392
-                        }else{
392
+                        } else{
393 393
 							//Search through each keyword.
394 394
 							foreach($keyphrases as $keyphrase){
395 395
 
@@ -458,14 +458,14 @@  discard block
 block discarded – undo
458 458
 			$wetu_id = $_POST['wetu_id'];
459 459
 			if(isset($_POST['post_id'])){
460 460
 				$post_id = $_POST['post_id'];	
461
-			}else{
461
+			} else{
462 462
 				$post_id = 0;
463 463
 			}
464 464
 
465 465
 			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
466 466
 				$content = $_POST['content'];
467 467
 				add_option('wetu_importer_tour_settings',$content);
468
-			}else{
468
+			} else{
469 469
 				delete_option('wetu_importer_tour_settings');
470 470
 				$content = false;
471 471
 			}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 
506 506
             if(isset($data['description'])){
507 507
                 $data_post_content = $data['description'];
508
-            }elseif(isset($data['summary'])){
508
+            } elseif(isset($data['summary'])){
509 509
                 $data_post_content = $data['summary'];
510 510
             }
511 511
             $post['post_content'] = $data_post_content;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
             $id = wp_update_post($post);
519 519
             $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
520 520
             update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
521
-        }else{
521
+        } else{
522 522
 
523 523
             //Set the name
524 524
             if(isset($data['name'])){
@@ -631,42 +631,42 @@  discard block
 block discarded – undo
631 631
 						//Description
632 632
 						if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){
633 633
 							$current_day['description'] = $day['notes'];
634
-						}else{
634
+						} else{
635 635
 							$current_day['description'] = '';
636 636
 						}
637 637
 
638 638
 						//Itinerary Gallery
639 639
 						if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){
640 640
 							$current_day['featured_image'] = '';
641
-						}else{
641
+						} else{
642 642
 							$current_day['featured_image'] = '';
643 643
 						}
644 644
 
645 645
 						//Accommodation
646 646
 						if(false !== $current_accommodation){
647 647
 							$current_day['accommodation_to_tour'] = array($current_accommodation);
648
-						}else{
648
+						} else{
649 649
 							$current_day['accommodation_to_tour'] = array();
650 650
 						}
651 651
 
652 652
 						//Destination
653 653
 						if(false !== $current_destination){
654 654
 							$current_day['destination_to_tour'] = array($current_destination);
655
-						}else{
655
+						} else{
656 656
 							$current_day['destination_to_tour'] = array();
657 657
 						}
658 658
 
659 659
 						//Included
660 660
 						if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){
661 661
 							$current_day['included'] = $day['included'];
662
-						}else{
662
+						} else{
663 663
 							$current_day['included'] = '';
664 664
 						}
665 665
 
666 666
 						//Excluded
667 667
 						if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){
668 668
 							$current_day['excluded'] = $day['excluded'];
669
-						}else{
669
+						} else{
670 670
 							$current_day['excluded'] = '';
671 671
 						}
672 672
 
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 						$day_counter++;
675 675
 					}
676 676
 
677
-				}else{
677
+				} else{
678 678
 					$day_counter = $day_counter + (int)$leg['nights'];
679 679
 				}
680 680
 
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 
787 787
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
788 788
                 $ac_id = $this->current_accommodation[$day['content_entity_id']];
789
-			}else{
789
+			} else{
790 790
 				$ac_id = wp_insert_post(array(
791 791
                     'post_type' => 'accommodation',
792 792
                     'post_status' => 'draft',
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 					$this->set_country($country_wetu_id, $id);
854 854
                 }
855 855
 
856
-			}else {
856
+			} else {
857 857
 
858 858
 				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']);
859 859
 
Please login to merge, or discard this patch.
classes/lsx-banners-integration.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -222,6 +222,9 @@
 block discarded – undo
222 222
 	  }
223 223
 	}	
224 224
 
225
+	/**
226
+	 * @param string $url
227
+	 */
225 228
 	public function attach_external_image2( $url = null, $post_data = array() ) {
226 229
 	
227 230
 		if ( !$url ) { return new WP_Error('missing', "Need a valid URL"); }
Please login to merge, or discard this 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.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public function __construct() {
29 29
 		
30
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
30
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
31 31
 
32
-		add_action('wp_ajax_lsx_import_sync_banners',array($this,'sync_new_banner'));	
33
-		add_action('wp_ajax_nopriv_lsx_import_sync_banners',array($this,'sync_new_banner'));		
32
+		add_action('wp_ajax_lsx_import_sync_banners', array($this, 'sync_new_banner'));	
33
+		add_action('wp_ajax_nopriv_lsx_import_sync_banners', array($this, 'sync_new_banner'));		
34 34
 	}	
35 35
 
36 36
 	/**
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
         ?>
41 41
         <div class="wrap">
42 42
 			
43
-            <h2><?php _e('Download new banners straight from WETU','wetu-importer'); ?></h2>
43
+            <h2><?php _e('Download new banners straight from WETU', 'wetu-importer'); ?></h2>
44 44
 
45 45
 			<form method="get" action="" id="banners-filter">
46 46
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
47 47
 
48 48
 	           <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
49
-	            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
49
+	            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
50 50
 	            </div>  				
51 51
 				
52 52
 				<table class="wp-list-table widefat fixed posts">
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 					<?php 
65 65
 						$accommodation_args = array(
66 66
 							'post_type' => 'accommodation',
67
-							'post_status' => array('publish','pending','draft','future','private'),
67
+							'post_status' => array('publish', 'pending', 'draft', 'future', 'private'),
68 68
 							'nopagin' => 'true',
69 69
 							'posts_per_page' => '1000',
70 70
 							'meta_query' => array(
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 
90 90
 					<tbody id="the-list">
91 91
 						<?php
92
-							if($accommodation->have_posts()){ 
93
-								while($accommodation->have_posts()) {
92
+							if ($accommodation->have_posts()) { 
93
+								while ($accommodation->have_posts()) {
94 94
 									$accommodation->the_post();
95 95
 								?>
96 96
 								<tr class="post-<?php the_ID(); ?> type-tour status-none" id="post-<?php the_ID(); ?>">	
@@ -99,22 +99,22 @@  discard block
 block discarded – undo
99 99
 									$min_width = '1920';
100 100
 									$min_height = '500';
101 101
 
102
-									$img_group = get_post_meta(get_the_ID(),'image_group',true);
102
+									$img_group = get_post_meta(get_the_ID(), 'image_group', true);
103 103
 
104 104
 									$thumbnails_html = false;
105 105
 
106
-									if(false !== $img_group){
107
-										foreach($img_group['banner_image'] as $banner_image){
108
-											$large = wp_get_attachment_image_src($banner_image,'full');
106
+									if (false !== $img_group) {
107
+										foreach ($img_group['banner_image'] as $banner_image) {
108
+											$large = wp_get_attachment_image_src($banner_image, 'full');
109 109
 											$real_width = $large[1];
110 110
 											$real_height = $large[2];
111 111
 
112 112
 											$status = 'optimized';
113
-											if($real_width < intval($real_width)){
113
+											if ($real_width < intval($real_width)) {
114 114
 												$status = 'width not enough.';
115 115
 											}
116 116
 
117
-											$thumbnail = wp_get_attachment_image_src($banner_image,'thumbnail');
117
+											$thumbnail = wp_get_attachment_image_src($banner_image, 'thumbnail');
118 118
 											$thumbnails_html[] = '
119 119
 												<div style="display:block;float:left;">
120 120
 													<img src="'.$thumbnail[0].'" />
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 										<input type="checkbox" data-identifier="<?php the_ID(); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
129 129
 									</th>
130 130
 
131
-									<td class="post-title page-title column-title"><?php echo '<a href="'.admin_url('/post.php?post='.get_the_ID().'&action=edit').'" target="_blank">';the_title(); echo '</a>'; ?></td>
131
+									<td class="post-title page-title column-title"><?php echo '<a href="'.admin_url('/post.php?post='.get_the_ID().'&action=edit').'" target="_blank">'; the_title(); echo '</a>'; ?></td>
132 132
 
133 133
 									<td colspan="2" class="thumbnails column-thumbnails">
134
-										<?php if(false !== $thumbnails_html){ echo implode('',$thumbnails_html); } else { echo '<p>There was an error retrieving your images.</p>'; } ?>
134
+										<?php if (false !== $thumbnails_html) { echo implode('', $thumbnails_html); }else { echo '<p>There was an error retrieving your images.</p>'; } ?>
135 135
 									</td>
136 136
 								</tr>
137 137
 						<?php 	}
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
 				</table>
154 154
 
155
-				<p><input class="button button-primary download" type="button" value="<?php _e('Download new Banners','wetu-importer'); ?>" />
155
+				<p><input class="button button-primary download" type="button" value="<?php _e('Download new Banners', 'wetu-importer'); ?>" />
156 156
 				</p>
157 157
 			</form>
158 158
         </div>
@@ -164,33 +164,33 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function sync_new_banner() {
166 166
 
167
-		if(isset($_POST['action']) && 'lsx_import_sync_banners' === $_POST['action'] && isset($_POST['post_id'])){
167
+		if (isset($_POST['action']) && 'lsx_import_sync_banners' === $_POST['action'] && isset($_POST['post_id'])) {
168 168
 
169
-			$banners = get_post_meta($_POST['post_id'],'image_group',true);
170
-			$this->wetu_id = get_post_meta($_POST['post_id'],'lsx_wetu_id',true);
169
+			$banners = get_post_meta($_POST['post_id'], 'image_group', true);
170
+			$this->wetu_id = get_post_meta($_POST['post_id'], 'lsx_wetu_id', true);
171 171
 
172 172
 			$new_banner_array = false;
173 173
 			$array_index = 0;
174 174
 
175 175
 
176 176
 
177
-			foreach($banners['banner_image'] as $banner_image){
177
+			foreach ($banners['banner_image'] as $banner_image) {
178 178
 				$image_id = $this->attach_external_image2($this->format_wetu_url($banner_image));
179
-				if(null !== $image_id && '' !== $image_id){
179
+				if (null !== $image_id && '' !== $image_id) {
180 180
 					$new_banner_array['banner_image']['cmb-field-'.$array_index] = $image_id;
181 181
 					$array_index++;
182 182
 				}
183 183
 			}
184 184
 
185
-			if(false !== $new_banner_array){
186
-				delete_post_meta($_POST['post_id'],'image_group');
187
-				add_post_meta($_POST['post_id'],'image_group',$new_banner_array,true);
185
+			if (false !== $new_banner_array) {
186
+				delete_post_meta($_POST['post_id'], 'image_group');
187
+				add_post_meta($_POST['post_id'], 'image_group', $new_banner_array, true);
188 188
 				echo true;
189
-			}else{
189
+			}else {
190 190
 				echo false;
191 191
 			}		
192 192
 
193
-		}else{
193
+		}else {
194 194
 			echo false;
195 195
 		}
196 196
 		die();
@@ -207,28 +207,28 @@  discard block
 block discarded – undo
207 207
 	 * formats the filename
208 208
 	 */
209 209
 	public function format_filename($post_id) {
210
-		$base = str_replace('_',' ',get_the_title($post_id));
210
+		$base = str_replace('_', ' ', get_the_title($post_id));
211 211
 		$base = rawurlencode($base);
212 212
 	  $type = get_post_mime_type($post_id);
213 213
 	  switch ($type) {
214 214
 	    case 'image/jpeg':
215
-	    	return $base . ".jpg"; break;
215
+	    	return $base.".jpg"; break;
216 216
 	    case 'image/png':
217
-	    	return $base . ".png"; break;
217
+	    	return $base.".png"; break;
218 218
 	    case 'image/gif':
219
-	      	return $base . ".gif"; break;
219
+	      	return $base.".gif"; break;
220 220
 	    default:
221 221
 	      return false;
222 222
 	  }
223 223
 	}	
224 224
 
225
-	public function attach_external_image2( $url = null, $post_data = array() ) {
225
+	public function attach_external_image2($url = null, $post_data = array()) {
226 226
 	
227
-		if ( !$url ) { return new WP_Error('missing', "Need a valid URL"); }
227
+		if (!$url) { return new WP_Error('missing', "Need a valid URL"); }
228 228
 
229
-		require_once(ABSPATH . 'wp-admin/includes/file.php');
230
-		require_once(ABSPATH . 'wp-admin/includes/media.php');
231
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
229
+		require_once(ABSPATH.'wp-admin/includes/file.php');
230
+		require_once(ABSPATH.'wp-admin/includes/media.php');
231
+		require_once(ABSPATH.'wp-admin/includes/image.php');
232 232
 
233 233
 		//var_dump($tmp);
234 234
 		$tmp = tempnam("/tmp", "FOO");
@@ -236,37 +236,37 @@  discard block
 block discarded – undo
236 236
 		$image = file_get_contents($url);
237 237
 		print_r($image);
238 238
 		file_put_contents($tmp, $image);
239
-		chmod($tmp,'777');
239
+		chmod($tmp, '777');
240 240
 
241
-		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches);    // fix file filename for query strings
241
+		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings
242 242
 		$url_filename = basename($matches[0]);
243
-		$url_filename=str_replace('%20','_',$url_filename);
243
+		$url_filename = str_replace('%20', '_', $url_filename);
244 244
 		// extract filename from url for title
245
-		$url_type = wp_check_filetype($url_filename);                                           // determine file type (ext and mime/type)
245
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
246 246
 
247 247
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
248
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
248
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
249 249
 
250
-		if ( !empty( $filename) && " " != $filename )
250
+		if (!empty($filename) && " " != $filename)
251 251
 		{
252
-			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
252
+			$file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension
253 253
 		}
254 254
 		else
255 255
 		{
256
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
256
+			$file_array['name'] = $url_filename; // just use original URL filename
257 257
 		}
258 258
 
259 259
 		// set additional wp_posts columns
260
-		if ( empty( $post_data['post_title'] ) )
260
+		if (empty($post_data['post_title']))
261 261
 		{
262 262
 
263
-			$url_filename=str_replace('%20',' ',$url_filename);
263
+			$url_filename = str_replace('%20', ' ', $url_filename);
264 264
 
265
-			$post_data['post_title'] = basename($url_filename, "." . $url_type['ext']);         // just use the original filename (no extension)
265
+			$post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension)
266 266
 		}
267 267
 
268 268
 		// make sure gets tied to parent
269
-		if ( empty( $post_data['post_parent'] ) )
269
+		if (empty($post_data['post_parent']))
270 270
 		{
271 271
 			$post_data['post_parent'] = $_POST['post_id'];
272 272
 		}
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 		// required libraries for media_handle_sideload
275 275
 
276 276
 		// do the validation and storage stuff
277
-		$att_id = media_handle_sideload( $file_array, $_POST['post_id'], null, $post_data );             // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
277
+		$att_id = media_handle_sideload($file_array, $_POST['post_id'], null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
278 278
 		 
279 279
 		// If error storing permanently, unlink
280
-		if ( is_wp_error($att_id) )
280
+		if (is_wp_error($att_id))
281 281
 		{
282
-			unlink($file_array['tmp_name']);   // clean up
282
+			unlink($file_array['tmp_name']); // clean up
283 283
 			return false; // output wp_error
284 284
 			//return $att_id; // output wp_error
285 285
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 				delete_post_meta($_POST['post_id'],'image_group');
187 187
 				add_post_meta($_POST['post_id'],'image_group',$new_banner_array,true);
188 188
 				echo true;
189
-			}else{
189
+			} else{
190 190
 				echo false;
191 191
 			}		
192 192
 
193
-		}else{
193
+		} else{
194 194
 			echo false;
195 195
 		}
196 196
 		die();
@@ -250,8 +250,7 @@  discard block
 block discarded – undo
250 250
 		if ( !empty( $filename) && " " != $filename )
251 251
 		{
252 252
 			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
253
-		}
254
-		else
253
+		} else
255 254
 		{
256 255
 			$file_array['name'] = $url_filename;                                                // just use original URL filename
257 256
 		}
Please login to merge, or discard this patch.
classes/class-importer.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function __construct() {
70 70
 
71
-		add_action( 'admin_init', array( $this, 'compatible_version_check' ) );
71
+		add_action('admin_init', array($this, 'compatible_version_check'));
72 72
 
73 73
 		// Don't run anything else in the plugin, if we're on an incompatible PHP version
74
-		if ( ! self::compatible_version() ) {
74
+		if (!self::compatible_version()) {
75 75
 			return;
76 76
 		}
77 77
 
78 78
 		$this->set_variables();
79 79
 
80
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
80
+		add_action('init', array($this, 'load_plugin_textdomain'));
81 81
 	}
82 82
 	
83 83
 	/**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @since 1.0.0
96 96
 	 */
97 97
 	public static function compatible_version() {
98
-		if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
98
+		if (version_compare(PHP_VERSION, '5.6', '<')) {
99 99
 			return false;
100 100
 		}
101 101
 
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 	 * @since 1.0.0
110 110
 	 */
111 111
 	public function compatible_version_check() {
112
-		if ( ! self::compatible_version() ) {
113
-			if ( is_plugin_active( plugin_basename( WETU_IMPORTER_CORE ) ) ) {
114
-				deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
115
-				add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) );
112
+		if (!self::compatible_version()) {
113
+			if (is_plugin_active(plugin_basename(WETU_IMPORTER_CORE))) {
114
+				deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
115
+				add_action('admin_notices', array($this, 'compatible_version_notice'));
116 116
 				
117
-				if ( isset( $_GET['activate'] ) ) {
118
-					unset( $_GET['activate'] );
117
+				if (isset($_GET['activate'])) {
118
+					unset($_GET['activate']);
119 119
 				}
120 120
 			}
121 121
 		}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function compatible_version_notice() {
130 130
 		$class = 'notice notice-error';
131
-		$message = esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' );
132
-		printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) );
131
+		$message = esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer');
132
+		printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message));
133 133
 	}
134 134
 	
135 135
 	/**
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
 	 * @since 1.0.0
140 140
 	 */
141 141
 	public static function compatible_version_check_on_activation() {
142
-		if ( ! self::compatible_version() ) {
143
-			deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
144
-			wp_die( esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ) );
142
+		if (!self::compatible_version()) {
143
+			deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
144
+			wp_die(esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer'));
145 145
 		}
146 146
 	}
147 147
 
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
 	 * Sets the variables used throughout the plugin.
150 150
 	 */
151 151
 	public function set_variables() {
152
-		$temp_options = get_option('_lsx-to_settings',false);
152
+		$temp_options = get_option('_lsx-to_settings', false);
153 153
 
154
-		if(isset($temp_options[$this->plugin_slug])) {
154
+		if (isset($temp_options[$this->plugin_slug])) {
155 155
 			$this->options = $temp_options[$this->plugin_slug];
156 156
 
157 157
 			$this->api_key = false;
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 					if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
175 175
 						$cropping = $this->options['cropping'];
176 176
 					}
177
-					$this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
177
+					$this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
178 178
 				}
179 179
 			}
180 180
 		}
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @since 1.0.0
187 187
 	 */
188 188
 	public function load_plugin_textdomain() {
189
-		load_plugin_textdomain( 'wetu-importer', FALSE, basename( WETU_IMPORTER_PATH ) . '/languages');
189
+		load_plugin_textdomain('wetu-importer', FALSE, basename(WETU_IMPORTER_PATH).'/languages');
190 190
 	}
191 191
 }
192 192
 $wetu_importer = new WETU_Importer();
Please login to merge, or discard this patch.
wetu-importer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  * Domain Path: /languages/
12 12
  */
13 13
 
14
-define('WETU_IMPORTER_PATH',  plugin_dir_path( __FILE__ ) );
15
-define('WETU_IMPORTER_CORE',  __FILE__ );
16
-define('WETU_IMPORTER_URL',  plugin_dir_url( __FILE__ ) );
17
-define('WETU_IMPORTER_VER',  '1.0.0' );
14
+define('WETU_IMPORTER_PATH', plugin_dir_path(__FILE__));
15
+define('WETU_IMPORTER_CORE', __FILE__);
16
+define('WETU_IMPORTER_URL', plugin_dir_url(__FILE__));
17
+define('WETU_IMPORTER_VER', '1.0.0');
18 18
 
19
-register_activation_hook( WETU_IMPORTER_CORE, array( 'WETU_Importer', 'register_activation_hook' ) );
19
+register_activation_hook(WETU_IMPORTER_CORE, array('WETU_Importer', 'register_activation_hook'));
20 20
 
21 21
 require_once(WETU_IMPORTER_PATH.'classes/class-importer.php');
22 22
 require_once(WETU_IMPORTER_PATH.'classes/class-admin.php');
@@ -26,6 +26,6 @@  discard block
 block discarded – undo
26 26
 require_once(WETU_IMPORTER_PATH.'classes/class-connect-accommodation.php');
27 27
 require_once(WETU_IMPORTER_PATH.'classes/class-settings.php');
28 28
 
29
-if(class_exists('Lsx_Banners')){
29
+if (class_exists('Lsx_Banners')) {
30 30
 	require_once(WETU_IMPORTER_PATH.'classes/lsx-banners-integration.php');
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
classes/class-destination.php 4 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -545,6 +545,7 @@  discard block
 block discarded – undo
545 545
 
546 546
 	/**
547 547
 	 * Set the team memberon each item.
548
+	 * @param boolean $team_members
548 549
 	 */
549 550
 	public function set_team_member($id,$team_members) {
550 551
 
@@ -612,6 +613,7 @@  discard block
 block discarded – undo
612 613
 
613 614
 	/**
614 615
 	 * Saves the room data
616
+	 * @param string $meta_key
615 617
 	 */
616 618
 	public function set_travel_info($data,$id,$meta_key) {
617 619
 
Please login to merge, or discard this patch.
Braces   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
 				if(isset($_POST['keyword'] )) {
329 329
 					$keyphrases = $_POST['keyword'];
330
-				}else{
330
+				} else{
331 331
 					$keyphrases = array(0);
332 332
                 }
333 333
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                             $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
366 366
 
367 367
 
368
-						}else{
368
+						} else{
369 369
 							//Search through each keyword.
370 370
 							foreach($keyphrases as $keyphrase){
371 371
 
@@ -434,13 +434,13 @@  discard block
 block discarded – undo
434 434
 			$wetu_id = $_POST['wetu_id'];
435 435
 			if(isset($_POST['post_id'])){
436 436
 				$post_id = $_POST['post_id'];	
437
-			}else{
437
+			} else{
438 438
 				$post_id = 0;
439 439
 			}
440 440
 
441 441
 			if(isset($_POST['team_members'])){
442 442
 				$team_members = $_POST['team_members'];	
443
-			}else{
443
+			} else{
444 444
 				$team_members = false;
445 445
 			}
446 446
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 				$content = $_POST['content'];
451 451
 				delete_option('wetu_importer_destination_settings');
452 452
 				add_option('wetu_importer_destination_settings',$content);
453
-			}else{
453
+			} else{
454 454
 				delete_option('wetu_importer_destination_settings');
455 455
 				$content = false;
456 456
 			}
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
 		        if(isset($data[0]['content']['extended_description']))
491 491
 		        {
492 492
 		            $data_post_content = $data[0]['content']['extended_description'];
493
-		        }elseif(isset($data[0]['content']['general_description'])){
493
+		        } elseif(isset($data[0]['content']['general_description'])){
494 494
 		            $data_post_content = $data[0]['content']['general_description'];
495 495
 		            $content_used_general_description = true;
496
-		        }elseif(isset($data[0]['content']['teaser_description'])){
496
+		        } elseif(isset($data[0]['content']['teaser_description'])){
497 497
 		        	$data_post_content = $data[0]['content']['teaser_description'];
498 498
 		        }
499 499
 	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
 	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
504 504
 		        if(isset($data[0]['content']['teaser_description'])){
505 505
 		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
506
-		        }elseif(isset($data[0]['content']['extended_description'])){
506
+		        } elseif(isset($data[0]['content']['extended_description'])){
507 507
 					$data_post_excerpt = $data[0]['content']['extended_description'];
508
-				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
508
+				} elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
509 509
 		            $data_post_excerpt = $data[0]['content']['general_description'];
510 510
 		        }	   
511 511
 		        $post['post_excerpt'] = $data_post_excerpt;     	
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 	        	$id = wp_update_post($post);
522 522
 	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
523 523
 	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
524
-	        }else{
524
+	        } else{
525 525
 
526 526
 		        //Set the name
527 527
 		        if(isset($data[0]['name'])){
@@ -621,13 +621,13 @@  discard block
 block discarded – undo
621 621
 
622 622
 			if(isset($data[0]['position']['driving_latitude'])){
623 623
 				$latitude = $data[0]['position']['driving_latitude'];
624
-			}elseif(isset($data[0]['position']['latitude'])){
624
+			} elseif(isset($data[0]['position']['latitude'])){
625 625
 				$latitude = $data[0]['position']['latitude'];
626 626
 			}
627 627
 
628 628
 			if(isset($data[0]['position']['driving_longitude'])){
629 629
 				$longitude = $data[0]['position']['driving_longitude'];
630
-			}elseif(isset($data[0]['position']['longitude'])){
630
+			} elseif(isset($data[0]['position']['longitude'])){
631 631
 				$longitude = $data[0]['position']['longitude'];
632 632
 			}		
633 633
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 			if(false !== $id && '0' !== $id){
661 661
 	        	$prev = get_post_meta($id,'location',true);
662 662
 	        	update_post_meta($id,'location',$location_data,$prev);
663
-	        }else{
663
+	        } else{
664 664
 	        	add_post_meta($id,'location',$location_data,true);
665 665
 	        }
666 666
 		}
Please login to merge, or discard this 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.
Spacing   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
 	public function __construct() {
65 65
 		$this->set_variables();
66 66
 
67
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
67
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
68 68
 
69
-		add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));	
70
-		add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));		
69
+		add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));	
70
+		add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));		
71 71
 
72
-		add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));	
73
-		add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
72
+		add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));	
73
+		add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
74 74
 
75
-		$temp_options = get_option('_lsx-to_settings',false);
76
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
75
+		$temp_options = get_option('_lsx-to_settings', false);
76
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
77 77
 			$this->options = $temp_options[$this->plugin_slug];
78 78
 		}
79 79
 
80
-		$destination_options = get_option('wetu_importer_destination_settings',false);
81
-		if(false !== $destination_options){
80
+		$destination_options = get_option('wetu_importer_destination_settings', false);
81
+		if (false !== $destination_options) {
82 82
 			$this->destination_options = $destination_options;
83 83
 		}
84 84
 	}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		//	$this->url    = 'https://wetu.com/API/Pins/';
96 96
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
97 97
 		//} elseif ( false !== $this->api_key ) {
98
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
98
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
99 99
 			$this->url_qs = '';
100 100
 		//}
101 101
 	}
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 			<form method="get" action="" id="posts-filter">
114 114
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
115 115
 				
116
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
117
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
116
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
117
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
118 118
 				</p>				
119 119
 
120 120
 				<table class="wp-list-table widefat fixed posts">
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 					<tbody id="the-list">
124 124
 						<tr class="post-0 type-tour status-none" id="post-0">
125 125
 							<th class="check-column" scope="row">
126
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
126
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
127 127
 							</th>
128 128
 							<td class="post-title page-title column-title">
129 129
 								<strong>
130
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
130
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
131 131
 								</strong>
132 132
 							</td>
133 133
 							<td class="date column-date">							
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 
142 142
 				</table>
143 143
 
144
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
145
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
144
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
145
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
146 146
 				</p>
147 147
 			</form> 
148 148
 
@@ -154,39 +154,39 @@  discard block
 block discarded – undo
154 154
 						<div style="width:30%;display:block;float:left;">
155 155
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
156 156
 							<ul>
157
-								<li><input class="content" <?php $this->checked($this->destination_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
158
-								<li><input class="content" <?php $this->checked($this->destination_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
159
-                                <li><input class="content" <?php $this->checked($this->destination_options,'gallery'); ?> type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li>
160
-		                        <?php if(class_exists('LSX_TO_Maps')){ ?>
161
-                                    <li><input class="content" <?php $this->checked($this->destination_options,'location'); ?> type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li>
157
+								<li><input class="content" <?php $this->checked($this->destination_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
158
+								<li><input class="content" <?php $this->checked($this->destination_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
159
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?> type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li>
160
+		                        <?php if (class_exists('LSX_TO_Maps')) { ?>
161
+                                    <li><input class="content" <?php $this->checked($this->destination_options, 'location'); ?> type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li>
162 162
 		                        <?php } ?>
163 163
 
164
-		                        <?php if(class_exists('LSX_TO_Videos')){ ?>
165
-								    <li><input class="content" <?php $this->checked($this->destination_options,'videos'); ?> type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li>
164
+		                        <?php if (class_exists('LSX_TO_Videos')) { ?>
165
+								    <li><input class="content" <?php $this->checked($this->destination_options, 'videos'); ?> type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li>
166 166
 		                        <?php } ?>
167 167
 
168 168
 							</ul>
169 169
                             <h4><?php _e('Additional Content'); ?></h4>
170 170
                             <ul>
171
-                                <li><input class="content" <?php $this->checked($this->destination_options,'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li>
172
-								<?php if(class_exists('LSX_Banners')){ ?>
173
-                                    <li><input class="content" <?php $this->checked($this->destination_options,'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li>
171
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li>
172
+								<?php if (class_exists('LSX_Banners')) { ?>
173
+                                    <li><input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li>
174 174
 								<?php } ?>
175 175
                             </ul>
176 176
 						</div>
177 177
                         <div style="width:30%;display:block;float:left;">
178 178
                             <h3><?php _e('Travel Information'); ?></h3>
179 179
                             <ul>
180
-                                <li><input class="content" <?php $this->checked($this->destination_options,'electricity'); ?> type="checkbox" name="content[]" value="electricity" /> <?php _e('Electricity','wetu-importer'); ?></li>
181
-                                <li><input class="content" <?php $this->checked($this->destination_options,'banking'); ?> type="checkbox" name="content[]" value="banking" /> <?php _e('Banking','wetu-importer'); ?></li>
182
-                                <li><input class="content" <?php $this->checked($this->destination_options,'cuisine'); ?> type="checkbox" name="content[]" value="cuisine" /> <?php _e('Cuisine','wetu-importer'); ?></li>
183
-                                <li><input class="content" <?php $this->checked($this->destination_options,'climate'); ?> type="checkbox" name="content[]" value="climate" /> <?php _e('Climate','wetu-importer'); ?></li>
184
-                                <li><input class="content" <?php $this->checked($this->destination_options,'transport'); ?> type="checkbox" name="content[]" value="transport" /> <?php _e('Transport','wetu-importer'); ?></li>
185
-                                <li><input class="content" <?php $this->checked($this->destination_options,'dress'); ?> type="checkbox" name="content[]" value="dress" /> <?php _e('Dress','wetu-importer'); ?></li>
180
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?> type="checkbox" name="content[]" value="electricity" /> <?php _e('Electricity', 'wetu-importer'); ?></li>
181
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'banking'); ?> type="checkbox" name="content[]" value="banking" /> <?php _e('Banking', 'wetu-importer'); ?></li>
182
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?> type="checkbox" name="content[]" value="cuisine" /> <?php _e('Cuisine', 'wetu-importer'); ?></li>
183
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'climate'); ?> type="checkbox" name="content[]" value="climate" /> <?php _e('Climate', 'wetu-importer'); ?></li>
184
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'transport'); ?> type="checkbox" name="content[]" value="transport" /> <?php _e('Transport', 'wetu-importer'); ?></li>
185
+                                <li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?> type="checkbox" name="content[]" value="dress" /> <?php _e('Dress', 'wetu-importer'); ?></li>
186 186
                             </ul>
187 187
                         </div>
188 188
 
189
-		                <?php if(class_exists('LSX_TO_Team')){ ?>
189
+		                <?php if (class_exists('LSX_TO_Team')) { ?>
190 190
                             <div style="width:30%;display:block;float:left;">
191 191
                                 <h3><?php _e('Assign a Team Member'); ?></h3>
192 192
                                 <?php $this->team_member_checkboxes($this->destination_options); ?>
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
 
200 200
 					<h3><?php _e('Your List'); ?></h3>
201
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
201
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
202 202
 					<table class="wp-list-table widefat fixed posts">
203 203
 						<?php $this->table_header(); ?>
204 204
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
 					</table>
212 212
 
213
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
213
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
214 214
 				</form>
215 215
 			</div>
216 216
 
@@ -231,31 +231,31 @@  discard block
 block discarded – undo
231 231
         <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>">
232 232
         	<input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" />
233 233
 
234
-        	<h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3>
234
+        	<h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3>
235 235
             <div class="normal-search">
236
-                <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
236
+                <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
237 237
             </div>
238 238
 
239 239
 
240 240
             <div class="advanced-search hidden" style="display:none;">
241
-                <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p>
241
+                <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p>
242 242
                 <textarea rows="10" cols="40" name="bulk-keywords"></textarea>
243
-                <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
243
+                <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
244 244
             </div>
245 245
 
246 246
             <p>
247
-                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> |
248
-                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> |
249
-                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> |
250
-                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a>
247
+                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> |
248
+                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> |
249
+                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> |
250
+                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a>
251 251
             </p>
252 252
 
253 253
             <div class="ajax-loader" style="display:none;width:100%;text-align:center;">
254
-            	<img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
254
+            	<img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
255 255
             </div>
256 256
 
257 257
             <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
258
-            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
258
+            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
259 259
             </div>
260 260
         </form>
261 261
 	<?php
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	/**
292 292
 	 * Grab all the current destination posts via the lsx_wetu_id field.
293 293
 	 */
294
-	public function find_current_destination($post_type='destination') {
294
+	public function find_current_destination($post_type = 'destination') {
295 295
 		global $wpdb;
296 296
 		$return = array();
297 297
 
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 
308 308
 					LIMIT 0,500
309 309
 		");
310
-		if(null !== $current_destination && !empty($current_destination)){
311
-			foreach($current_destination as $accom){
310
+		if (null !== $current_destination && !empty($current_destination)) {
311
+			foreach ($current_destination as $accom) {
312 312
 				$return[$accom->meta_value] = $accom;
313 313
 			}
314 314
 		}
@@ -320,32 +320,32 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public function process_ajax_search() {
322 322
 		$return = false;
323
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination'){
323
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') {
324 324
 
325
-			if ( isset($_POST['keyword'] )) {
325
+			if (isset($_POST['keyword'])) {
326 326
 				$searched_items = false;
327 327
 
328
-				if(isset($_POST['keyword'] )) {
328
+				if (isset($_POST['keyword'])) {
329 329
 					$keyphrases = $_POST['keyword'];
330
-				}else{
330
+				}else {
331 331
 					$keyphrases = array(0);
332 332
                 }
333 333
 
334
-				if(!is_array($keyphrases)){
334
+				if (!is_array($keyphrases)) {
335 335
 					$keyphrases = array($keyphrases);
336 336
 				}
337
-				foreach($keyphrases as &$keyword){
337
+				foreach ($keyphrases as &$keyword) {
338 338
 					$keyword = ltrim(rtrim($keyword));
339 339
 				}
340 340
 
341 341
 				$post_status = false;
342
-				if(in_array('publish',$keyphrases)){
342
+				if (in_array('publish', $keyphrases)) {
343 343
 					$post_status = 'publish';
344 344
 				}
345
-				if(in_array('pending',$keyphrases)){
345
+				if (in_array('pending', $keyphrases)) {
346 346
 					$post_status = 'pending';
347 347
 				}
348
-				if(in_array('draft',$keyphrases)){
348
+				if (in_array('draft', $keyphrases)) {
349 349
 					$post_status = 'draft';
350 350
 				}
351 351
 
@@ -353,29 +353,29 @@  discard block
 block discarded – undo
353 353
 
354 354
 				if (!empty($destination)) {
355 355
 
356
-					foreach($destination as $row){
356
+					foreach ($destination as $row) {
357 357
 
358 358
 						//If we are searching for
359
-						if(false !== $post_status){
359
+						if (false !== $post_status) {
360 360
 
361 361
                             $current_status = get_post_status($row->post_id);
362
-                            if($current_status !== $post_status){
362
+                            if ($current_status !== $post_status) {
363 363
                                 continue;
364 364
                             }
365 365
                             $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
366 366
 
367 367
 
368
-						}else{
368
+						}else {
369 369
 							//Search through each keyword.
370
-							foreach($keyphrases as $keyphrase){
370
+							foreach ($keyphrases as $keyphrase) {
371 371
 
372 372
 								//Make sure the keyphrase is turned into an array
373
-								$keywords = explode(" ",$keyphrase);
374
-								if(!is_array($keywords)){
373
+								$keywords = explode(" ", $keyphrase);
374
+								if (!is_array($keywords)) {
375 375
 									$keywords = array($keywords);
376 376
 								}
377 377
 
378
-								if($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false){
378
+								if ($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false) {
379 379
 									$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
380 380
 								}
381 381
 							}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 					}		
384 384
 				}
385 385
 
386
-				if(false !== $searched_items){
386
+				if (false !== $searched_items) {
387 387
 					ksort($searched_items);
388 388
 					$return = implode($searched_items);
389 389
 				}
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
 	/**
397 397
 	 * Formats the row for output on the screen.
398 398
 	 */	
399
-	public function format_row($row = false){
400
-		if(false !== $row){
399
+	public function format_row($row = false) {
400
+		if (false !== $row) {
401 401
 
402 402
 			$status = 'import';
403
-			if(0 !== $row->post_id){
403
+			if (0 !== $row->post_id) {
404 404
 				$status = '<a href="'.admin_url('/post.php?post='.$row->post_id.'&action=edit').'" target="_blank">'.get_post_status($row->post_id).'</a>';
405 405
 			}
406 406
 
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 					<strong>'.$row->name.'</strong> - '.$status.'
415 415
 				</td>
416 416
 				<td class="date column-date">
417
-					<abbr title="'.date('Y/m/d',strtotime($row->last_modified)).'">'.date('Y/m/d',strtotime($row->last_modified)).'</abbr><br>Last Modified
417
+					<abbr title="'.date('Y/m/d', strtotime($row->last_modified)).'">'.date('Y/m/d', strtotime($row->last_modified)).'</abbr><br>Last Modified
418 418
 				</td>
419 419
 				<td class="ssid column-ssid">
420 420
 					'.$row->meta_value.'
@@ -429,39 +429,39 @@  discard block
 block discarded – undo
429 429
 	 */
430 430
 	public function process_ajax_import() {
431 431
 		$return = false;
432
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])){
432
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) {
433 433
 			
434 434
 			$wetu_id = $_POST['wetu_id'];
435
-			if(isset($_POST['post_id'])){
435
+			if (isset($_POST['post_id'])) {
436 436
 				$post_id = $_POST['post_id'];	
437
-			}else{
437
+			}else {
438 438
 				$post_id = 0;
439 439
 			}
440 440
 
441
-			if(isset($_POST['team_members'])){
441
+			if (isset($_POST['team_members'])) {
442 442
 				$team_members = $_POST['team_members'];	
443
-			}else{
443
+			}else {
444 444
 				$team_members = false;
445 445
 			}
446 446
 
447 447
             $safari_brands = false;
448 448
 
449
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
449
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
450 450
 				$content = $_POST['content'];
451 451
 				delete_option('wetu_importer_destination_settings');
452
-				add_option('wetu_importer_destination_settings',$content);
453
-			}else{
452
+				add_option('wetu_importer_destination_settings', $content);
453
+			}else {
454 454
 				delete_option('wetu_importer_destination_settings');
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)
458
+            $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
459
+            if ($jdata)
460 460
             {
461
-                $adata=json_decode($jdata,true);
462
-                if(!empty($adata))
461
+                $adata = json_decode($jdata, true);
462
+                if (!empty($adata))
463 463
                 {
464
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
464
+                	$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
465 465
                 	$this->format_completed_row($return);
466 466
                 }
467 467
             }
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 	/**
475 475
 	 * Connect to wetu
476 476
 	 */
477
-	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
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')
479
+        if (trim($data[0]['type']) == 'Destination')
480 480
         {
481 481
 	        $post_name = $data_post_content = $data_post_excerpt = '';
482 482
 	        $post = array(
@@ -486,46 +486,46 @@  discard block
 block discarded – undo
486 486
 	        $content_used_general_description = false;
487 487
 
488 488
 	        //Set the post_content
489
-	        if(false !== $importable_content && in_array('description',$importable_content)){
490
-		        if(isset($data[0]['content']['extended_description']))
489
+	        if (false !== $importable_content && in_array('description', $importable_content)) {
490
+		        if (isset($data[0]['content']['extended_description']))
491 491
 		        {
492 492
 		            $data_post_content = $data[0]['content']['extended_description'];
493
-		        }elseif(isset($data[0]['content']['general_description'])){
493
+		        }elseif (isset($data[0]['content']['general_description'])) {
494 494
 		            $data_post_content = $data[0]['content']['general_description'];
495 495
 		            $content_used_general_description = true;
496
-		        }elseif(isset($data[0]['content']['teaser_description'])){
496
+		        }elseif (isset($data[0]['content']['teaser_description'])) {
497 497
 		        	$data_post_content = $data[0]['content']['teaser_description'];
498 498
 		        }
499 499
 	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
500 500
 	        }
501 501
 
502 502
 	        //set the post_excerpt
503
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
504
-		        if(isset($data[0]['content']['teaser_description'])){
503
+	        if (false !== $importable_content && in_array('excerpt', $importable_content)) {
504
+		        if (isset($data[0]['content']['teaser_description'])) {
505 505
 		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
506
-		        }elseif(isset($data[0]['content']['extended_description'])){
506
+		        }elseif (isset($data[0]['content']['extended_description'])) {
507 507
 					$data_post_excerpt = $data[0]['content']['extended_description'];
508
-				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
508
+				}elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
509 509
 		            $data_post_excerpt = $data[0]['content']['general_description'];
510 510
 		        }	   
511 511
 		        $post['post_excerpt'] = $data_post_excerpt;     	
512 512
 	        }
513 513
 
514
-	        if(false !== $id && '0' !== $id){
514
+	        if (false !== $id && '0' !== $id) {
515 515
 	        	$post['ID'] = $id;
516
-				if(isset($data[0]['name'])){
516
+				if (isset($data[0]['name'])) {
517 517
 					$post['post_title'] = $data[0]['name'];
518 518
 					$post['post_status'] = 'publish';
519
-					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
519
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
520 520
 				}
521 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{
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 525
 
526 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);
527
+		        if (isset($data[0]['name'])) {
528
+		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
529 529
 		        }
530 530
 	        	$post['post_name'] = $post_name;
531 531
 	        	$post['post_title'] = $data[0]['name'];
@@ -533,65 +533,65 @@  discard block
 block discarded – undo
533 533
 	        	$id = wp_insert_post($post);
534 534
 
535 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']));
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 539
 	        	}
540 540
 	        }
541 541
 
542 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);
543
+	        if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
544
+	        	$this->set_team_member($id, $team_members);
545 545
 	    	}
546 546
 
547
-	        if(class_exists('LSX_TO_Maps')){
548
-	        	$this->set_map_data($data,$id,4);
547
+	        if (class_exists('LSX_TO_Maps')) {
548
+	        	$this->set_map_data($data, $id, 4);
549 549
 	        }
550 550
 
551 551
 	        //Set the Room Data
552
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
553
-	        	$this->set_video_data($data,$id);
552
+	        if (false !== $importable_content && in_array('videos', $importable_content)) {
553
+	        	$this->set_video_data($data, $id);
554 554
 	    	}
555 555
 
556 556
 			//Set the Electricity
557
-			if(false !== $importable_content && in_array('electricity',$importable_content)){
558
-				$this->set_travel_info($data,$id,'electricity');
557
+			if (false !== $importable_content && in_array('electricity', $importable_content)) {
558
+				$this->set_travel_info($data, $id, 'electricity');
559 559
 			}
560 560
 			//Set the cuisine
561
-			if(false !== $importable_content && in_array('cuisine',$importable_content)){
562
-				$this->set_travel_info($data,$id,'cuisine');
561
+			if (false !== $importable_content && in_array('cuisine', $importable_content)) {
562
+				$this->set_travel_info($data, $id, 'cuisine');
563 563
 			}
564 564
 			//Set the banking
565
-			if(false !== $importable_content && in_array('banking',$importable_content)){
566
-				$this->set_travel_info($data,$id,'banking');
565
+			if (false !== $importable_content && in_array('banking', $importable_content)) {
566
+				$this->set_travel_info($data, $id, 'banking');
567 567
 			}
568 568
 			//Set the transport
569
-			if(false !== $importable_content && in_array('transport',$importable_content)){
570
-				$this->set_travel_info($data,$id,'transport');
569
+			if (false !== $importable_content && in_array('transport', $importable_content)) {
570
+				$this->set_travel_info($data, $id, 'transport');
571 571
 			}
572 572
 			//Set the dress
573
-			if(false !== $importable_content && in_array('dress',$importable_content)){
574
-				$this->set_travel_info($data,$id,'dress');
573
+			if (false !== $importable_content && in_array('dress', $importable_content)) {
574
+				$this->set_travel_info($data, $id, 'dress');
575 575
 			}
576 576
 			//Set the climate
577
-			if(false !== $importable_content && in_array('climate',$importable_content)){
578
-				$this->set_travel_info($data,$id,'climate');
577
+			if (false !== $importable_content && in_array('climate', $importable_content)) {
578
+				$this->set_travel_info($data, $id, 'climate');
579 579
 			}
580 580
 
581 581
 			//Setup some default for use in the import
582
-			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
582
+			if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
583 583
 				$this->find_attachments($id);
584 584
 
585 585
 				//Set the featured image
586
-				if(false !== $importable_content && in_array('featured_image',$importable_content)){
587
-					$this->set_featured_image($data,$id);
586
+				if (false !== $importable_content && in_array('featured_image', $importable_content)) {
587
+					$this->set_featured_image($data, $id);
588 588
 				}
589
-				if(false !== $importable_content && in_array('banner_image',$importable_content)){
590
-					$this->set_banner_image($data,$id);
589
+				if (false !== $importable_content && in_array('banner_image', $importable_content)) {
590
+					$this->set_banner_image($data, $id);
591 591
 				}
592 592
 				//Import the main gallery
593
-				if(false !== $importable_content && in_array('gallery',$importable_content)){
594
-					$this->create_main_gallery($data,$id);
593
+				if (false !== $importable_content && in_array('gallery', $importable_content)) {
594
+					$this->create_main_gallery($data, $id);
595 595
 				}
596 596
 			}
597 597
 
@@ -602,65 +602,65 @@  discard block
 block discarded – undo
602 602
 	/**
603 603
 	 * Set the team memberon each item.
604 604
 	 */
605
-	public function set_team_member($id,$team_members) {
605
+	public function set_team_member($id, $team_members) {
606 606
 
607 607
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
608
-		foreach($team_members as $team){
609
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
608
+		foreach ($team_members as $team) {
609
+        	add_post_meta($id, 'team_to_'.$this->tab_slug, $team);			
610 610
 		}
611 611
 	}
612 612
 	
613 613
 	/**
614 614
 	 * Saves the longitude and lattitude, as well as sets the map marker.
615 615
 	 */
616
-	public function set_map_data($data,$id,$zoom=15) {
616
+	public function set_map_data($data, $id, $zoom = 15) {
617 617
 		$longitude = $latitude = $address = false;
618 618
 
619
-		if(isset($data[0]['position'])){
619
+		if (isset($data[0]['position'])) {
620 620
 
621
-			if(isset($data[0]['position']['driving_latitude'])){
621
+			if (isset($data[0]['position']['driving_latitude'])) {
622 622
 				$latitude = $data[0]['position']['driving_latitude'];
623
-			}elseif(isset($data[0]['position']['latitude'])){
623
+			}elseif (isset($data[0]['position']['latitude'])) {
624 624
 				$latitude = $data[0]['position']['latitude'];
625 625
 			}
626 626
 
627
-			if(isset($data[0]['position']['driving_longitude'])){
627
+			if (isset($data[0]['position']['driving_longitude'])) {
628 628
 				$longitude = $data[0]['position']['driving_longitude'];
629
-			}elseif(isset($data[0]['position']['longitude'])){
629
+			}elseif (isset($data[0]['position']['longitude'])) {
630 630
 				$longitude = $data[0]['position']['longitude'];
631 631
 			}		
632 632
 
633 633
 		}
634
-		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
635
-			if(isset($data[0]['content']['contact_information']['address'])){
634
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
635
+			if (isset($data[0]['content']['contact_information']['address'])) {
636 636
 				$address = strip_tags($data[0]['content']['contact_information']['address']);
637 637
 
638
-				$address = explode("\n",$address);
639
-				foreach($address as $bitkey => $bit){
638
+				$address = explode("\n", $address);
639
+				foreach ($address as $bitkey => $bit) {
640 640
 					$bit = ltrim(rtrim($bit));
641
-					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
641
+					if (false === $bit || '' === $bit || null === $bit or empty($bit)) {
642 642
 						unset($address[$bitkey]);
643 643
 					}
644 644
 				}
645
-				$address = implode(', ',$address);
645
+				$address = implode(', ', $address);
646 646
 				$address = str_replace(', , ', ', ', $address);
647 647
 			}	
648 648
 		}
649 649
 
650 650
 
651
-		if(false !== $longitude){
651
+		if (false !== $longitude) {
652 652
 			$location_data = array(
653
-				'address'	=>	(string)$address,
654
-				'lat'		=>	(string)$latitude,
655
-				'long'		=>	(string)$longitude,
656
-				'zoom'		=>	(string)$zoom,
653
+				'address'	=>	(string) $address,
654
+				'lat'		=>	(string) $latitude,
655
+				'long'		=>	(string) $longitude,
656
+				'zoom'		=>	(string) $zoom,
657 657
 				'elevation'	=>	'',
658 658
 			);
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);
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 664
 	        }
665 665
 		}
666 666
 	}
@@ -668,11 +668,11 @@  discard block
 block discarded – undo
668 668
 	/**
669 669
 	 * Saves the room data
670 670
 	 */
671
-	public function set_travel_info($data,$id,$meta_key) {
671
+	public function set_travel_info($data, $id, $meta_key) {
672 672
 
673
-		if(!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])){
673
+		if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) {
674 674
 			$content = $data[0]['travel_information'][$meta_key];
675
-			$this->save_custom_field($content,$meta_key,$id);
675
+			$this->save_custom_field($content, $meta_key, $id);
676 676
 		}
677 677
 	}
678 678
 
Please login to merge, or discard this patch.
classes/class-settings.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,24 +17,24 @@  discard block
 block discarded – undo
17 17
 	 * @access private
18 18
 	 */
19 19
 	public function __construct() {
20
-		$temp_options = get_option('_lsx-to_settings',false);
21
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
20
+		$temp_options = get_option('_lsx-to_settings', false);
21
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
22 22
 			$this->options = $temp_options[$this->plugin_slug];
23 23
 			$this->set_variables();
24 24
 		}
25 25
 
26
-		add_filter( 'lsx_to_framework_settings_tabs', array( $this, 'settings_page_array') );
27
-		add_action('lsx_to_framework_api_tab_content',array( $this, 'api_settings'),10,1);
26
+		add_filter('lsx_to_framework_settings_tabs', array($this, 'settings_page_array'));
27
+		add_action('lsx_to_framework_api_tab_content', array($this, 'api_settings'), 10, 1);
28 28
 	}
29 29
 
30 30
 	/**
31 31
 	 * Returns the array of settings to the UIX Class in the lsx framework
32 32
 	 */
33
-	public function settings_page_array($tabs){
33
+	public function settings_page_array($tabs) {
34 34
 		$tabs[$this->plugin_slug] = array(
35
-			'page_title'        => __('Image Scaling','wetu-importer'),
36
-			'page_description'  => __('','wetu-importer'),
37
-			'menu_title'        => __('Importer','wetu-importer'),
35
+			'page_title'        => __('Image Scaling', 'wetu-importer'),
36
+			'page_description'  => __('', 'wetu-importer'),
37
+			'menu_title'        => __('Importer', 'wetu-importer'),
38 38
 			'template'          => WETU_IMPORTER_PATH.'settings/wetu.php',
39 39
 			'default'	 		=> false
40 40
 		);
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * Adds the API key to the API Tab
46 46
 	 */
47
-	public function api_settings($tab='general') {
48
-		if('settings' === $tab){ ?>
47
+	public function api_settings($tab = 'general') {
48
+		if ('settings' === $tab) { ?>
49 49
 			<tr class="form-field-wrap">
50 50
 				<th class="tour-operator_table_heading" style="padding-bottom:0px;" scope="row" colspan="2">
51
-					<h4 style="margin-bottom:0px;"><span><?php _e( 'WETU API', 'wetu-importer' ); ?></span></h4>
51
+					<h4 style="margin-bottom:0px;"><span><?php _e('WETU API', 'wetu-importer'); ?></span></h4>
52 52
 				</th>
53 53
 			</tr>
54 54
 			<tr class="form-field">
55 55
 				<th scope="row">
56
-                    <i class="dashicons-before dashicons-admin-network"></i> <label for="wetu_api_key"> <?php _e( 'Key', 'wetu-importer' ); ?></label>
56
+                    <i class="dashicons-before dashicons-admin-network"></i> <label for="wetu_api_key"> <?php _e('Key', 'wetu-importer'); ?></label>
57 57
 				</th>
58 58
 				<td>
59 59
                     <input type="text" {{#if wetu_api_key}} value="{{wetu_api_key}}" {{/if}} name="wetu_api_key" />
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 			</tr>
62 62
 			<tr class="form-field">
63 63
 				<th scope="row">
64
-                    <i class="dashicons-before dashicons-admin-users"></i> <label for="wetu_api_username"> <?php _e( 'Username', 'wetu-importer' ); ?></label>
64
+                    <i class="dashicons-before dashicons-admin-users"></i> <label for="wetu_api_username"> <?php _e('Username', 'wetu-importer'); ?></label>
65 65
 				</th>
66 66
 				<td>
67 67
                     <input type="text" {{#if wetu_api_username}} value="{{wetu_api_username}}" {{/if}} name="wetu_api_username" />
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			</tr>
70 70
 			<tr class="form-field">
71 71
 				<th scope="row">
72
-                    <i class="dashicons-before dashicons-lock"></i> <label for="wetu_api_password"> <?php _e( 'Password', 'wetu-importer' ); ?></label>
72
+                    <i class="dashicons-before dashicons-lock"></i> <label for="wetu_api_password"> <?php _e('Password', 'wetu-importer'); ?></label>
73 73
 				</th>
74 74
 				<td>
75 75
                     <input type="text" {{#if wetu_api_password}} value="{{wetu_api_password}}" {{/if}} name="wetu_api_password" />
Please login to merge, or discard this patch.
classes/class-admin.php 3 patches
Braces   +6 added lines, -9 removed lines patch added patch discarded remove patch
@@ -161,18 +161,15 @@  discard block
 block discarded – undo
161 161
                         if ( is_wp_error($term) )
162 162
                         {
163 163
                             echo $term->get_error_message();
164
-                        }
165
-                        else
164
+                        } else
166 165
                         {
167 166
                             wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
168 167
                         }
169
-                    }
170
-                    else
168
+                    } else
171 169
                     {
172 170
                         wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
173 171
                     }
174
-                }
175
-                else
172
+                } else
176 173
                 {
177 174
                     $result[]=trim($k);
178 175
                 }
@@ -199,7 +196,7 @@  discard block
 block discarded – undo
199 196
     						foreach($team_members->posts as $member){ ?>
200 197
     							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
201 198
     						<?php }
202
-    					}else{ ?>
199
+    					} else{ ?>
203 200
     							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
204 201
     					<?php }
205 202
     				?>
@@ -220,7 +217,7 @@  discard block
 block discarded – undo
220 217
 				foreach($terms as $term){
221 218
 					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
222 219
 				}
223
-			}else{
220
+			} else{
224 221
 				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
225 222
 			}
226 223
 			$return .= '</ul>';
@@ -241,7 +238,7 @@  discard block
 block discarded – undo
241 238
 
242 239
 			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
243 240
 				update_post_meta($id,$meta_key,$value,$prev);
244
-			}else{
241
+			} else{
245 242
 				add_post_meta($id,$meta_key,$value,$unique);
246 243
 			}
247 244
 		}
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
 	 * @access private
46 46
 	 */
47 47
 	public function __construct() {
48
-		add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 );
49
-		add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 );
48
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11);
49
+		add_action('admin_menu', array($this, 'register_importer_page'), 20);
50 50
 	}
51 51
 
52 52
 	/**
53 53
 	 * Registers the admin page which will house the importer form.
54 54
 	 */
55 55
 	public function register_importer_page() {
56
-		add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) );
56
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page'));
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * Enqueue the JS needed to contact wetu and return your result.
61 61
 	 */
62 62
 	public function admin_scripts() {
63
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
63
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
64 64
 			$min = '';
65
-		} else {
65
+		}else {
66 66
 			$min = '.min';
67 67
 		}
68 68
 
69
-		if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){
70
-			wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true );
71
-			wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array(
69
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
70
+			wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true);
71
+			wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array(
72 72
 			'ajax_url' => admin_url('admin-ajax.php'),
73
-			) );			
73
+			));			
74 74
 		}
75 75
 	}			
76 76
 
@@ -82,24 +82,24 @@  discard block
 block discarded – undo
82 82
         <div class="wrap">
83 83
             <?php screen_icon(); ?>
84 84
 
85
-            <?php if(!isset($_GET['tab'])){ ?>
86
-	            <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2>
85
+            <?php if (!isset($_GET['tab'])) { ?>
86
+	            <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2>
87 87
 	            <p>If this is the first time you are running the import, then follow the steps below.</p>
88 88
 	            <ul>
89
-                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours','wetu-importer'); ?></a></li>
90
-	            	<li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation','wetu-importer'); ?></a> that will need to be imported.</li>
91
-                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations','wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
89
+                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours', 'wetu-importer'); ?></a></li>
90
+	            	<li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation', 'wetu-importer'); ?></a> that will need to be imported.</li>
91
+                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations', 'wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
92 92
 	            </ul>
93 93
 
94
-		            <h3><?php _e('Additional Tools','wetu-importer'); ?></h3>
94
+		            <h3><?php _e('Additional Tools', 'wetu-importer'); ?></h3>
95 95
 		            <ul>
96
-		            	<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation','wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.','wetu-importer'); ?></small></li>
97
-		            	<?php if(class_exists('Lsx_Banners')){ ?>
98
-		            		<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images','wetu-importer'); ?></a></li>
96
+		            	<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation', 'wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.', 'wetu-importer'); ?></small></li>
97
+		            	<?php if (class_exists('Lsx_Banners')) { ?>
98
+		            		<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images', 'wetu-importer'); ?></a></li>
99 99
 		            	<?php } ?>
100 100
 		            </ul> 
101 101
 	             	            
102
-            <?php } else {
102
+            <?php }else {
103 103
             	do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
104 104
             } ?>
105 105
         </div>
@@ -147,34 +147,34 @@  discard block
 block discarded – undo
147 147
 	/**
148 148
 	 * set_taxonomy with some terms
149 149
 	 */
150
-	public function set_taxonomy($taxonomy,$terms,$id) {
151
-        $result=array();
152
-        if(!empty($data))
150
+	public function set_taxonomy($taxonomy, $terms, $id) {
151
+        $result = array();
152
+        if (!empty($data))
153 153
         {
154
-            foreach($data as $k)
154
+            foreach ($data as $k)
155 155
             {
156
-                if($id)
156
+                if ($id)
157 157
                 {
158
-                    if(!$term = term_exists(trim($k), $tax))
158
+                    if (!$term = term_exists(trim($k), $tax))
159 159
                     {
160 160
                         $term = wp_insert_term(trim($k), $tax);
161
-                        if ( is_wp_error($term) )
161
+                        if (is_wp_error($term))
162 162
                         {
163 163
                             echo $term->get_error_message();
164 164
                         }
165 165
                         else
166 166
                         {
167
-                            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
167
+                            wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
168 168
                         }
169 169
                     }
170 170
                     else
171 171
                     {
172
-                        wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
172
+                        wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
173 173
                     }
174 174
                 }
175 175
                 else
176 176
                 {
177
-                    $result[]=trim($k);
177
+                    $result[] = trim($k);
178 178
                 }
179 179
             }
180 180
         }
@@ -184,23 +184,23 @@  discard block
 block discarded – undo
184 184
 	/**
185 185
 	 * set_taxonomy with some terms
186 186
 	 */
187
-	public function team_member_checkboxes($selected=array()) {
188
-		if(post_type_exists('team')) { ?>
187
+	public function team_member_checkboxes($selected = array()) {
188
+		if (post_type_exists('team')) { ?>
189 189
     		<ul>
190 190
     			<?php
191
-    				$team_args=array(
191
+    				$team_args = array(
192 192
     					'post_type'	=>	'team',
193 193
     					'post_status' => 'publish',
194 194
     					'nopagin' => true,
195 195
     					'fields' => 'ids'
196 196
     				);
197 197
     				$team_members = new WP_Query($team_args);
198
-    					if($team_members->have_posts()){
199
-    						foreach($team_members->posts as $member){ ?>
200
-    							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
198
+    					if ($team_members->have_posts()) {
199
+    						foreach ($team_members->posts as $member) { ?>
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{ ?>
203
-    							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
202
+    					}else { ?>
203
+    							<li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li>
204 204
     					<?php }
205 205
     				?>
206 206
     		</ul>
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
 	/**
211 211
 	 * set_taxonomy with some terms
212 212
 	 */
213
-	public function taxonomy_checkboxes($taxonomy=false,$selected=array()) {
213
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
214 214
 		$return = '';
215
-		if(false !== $taxonomy){
215
+		if (false !== $taxonomy) {
216 216
 			$return .= '<ul>';
217
-			$terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false));
217
+			$terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false));
218 218
 
219
-			if(!is_wp_error($terms)){
220
-				foreach($terms as $term){
221
-					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
219
+			if (!is_wp_error($terms)) {
220
+				foreach ($terms as $term) {
221
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
222 222
 				}
223
-			}else{
224
-				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
223
+			}else {
224
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>';
225 225
 			}
226 226
 			$return .= '</ul>';
227 227
 		}
@@ -231,18 +231,18 @@  discard block
 block discarded – undo
231 231
 	/**
232 232
 	 * Saves the room data
233 233
 	 */
234
-	public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) {
235
-		if(false !== $value){
236
-			if(false !== $decrease){
234
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
235
+		if (false !== $value) {
236
+			if (false !== $decrease) {
237 237
 				$value = intval($value);
238 238
 				$value--;
239 239
 			}
240
-			$prev = get_post_meta($id,$meta_key,true);
240
+			$prev = get_post_meta($id, $meta_key, true);
241 241
 
242
-			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
243
-				update_post_meta($id,$meta_key,$value,$prev);
244
-			}else{
245
-				add_post_meta($id,$meta_key,$value,$unique);
242
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
243
+				update_post_meta($id, $meta_key, $value, $prev);
244
+			}else {
245
+				add_post_meta($id, $meta_key, $value, $unique);
246 246
 			}
247 247
 		}
248 248
 	}
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	/**
251 251
 	 * grabs any attachments for the current item
252 252
 	 */
253
-	public function find_attachments($id=false) {
254
-		if(false !== $id){
255
-			if(empty($this->found_attachments)){
253
+	public function find_attachments($id = false) {
254
+		if (false !== $id) {
255
+			if (empty($this->found_attachments)) {
256 256
 
257 257
 		    	$attachments_args = array(
258 258
 		    			'post_parent' => $id,
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
 		    	);   	
265 265
 		    	 
266 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);
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 270
 		    			$this->gallery_meta[] = $attachment->ID;
271 271
 		    		}
272 272
 		    	}
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
      * @param $needle string
284 284
      * @return string
285 285
 	 */
286
-	public function checked($haystack=false,$needle='') {
286
+	public function checked($haystack = false, $needle = '') {
287 287
 	    $return = '';
288
-	    if(!is_array($haystack)){
288
+	    if (!is_array($haystack)) {
289 289
 			$haystack = array($haystack);
290 290
         }
291
-        if(in_array($needle,$haystack)){
291
+        if (in_array($needle, $haystack)) {
292 292
 			$return = 'checked="checked"';
293 293
         }
294 294
 	    echo $return;
Please login to merge, or discard this 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.