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