Code Duplication    Length = 52-52 lines in 2 locations

classes/class-destination.php 1 location

@@ 591-642 (lines=52) @@
588
	/**
589
	 * Saves the longitude and lattitude, as well as sets the map marker.
590
	 */
591
	public function set_map_data($data,$id) {
592
		$longitude = $latitude = $address = false;
593
		$zoom = '15';	
594
595
		if(isset($data[0]['position'])){
596
597
			if(isset($data[0]['position']['driving_latitude'])){
598
				$latitude = $data[0]['position']['driving_latitude'];
599
			}elseif(isset($data[0]['position']['latitude'])){
600
				$latitude = $data[0]['position']['latitude'];
601
			}
602
603
			if(isset($data[0]['position']['driving_longitude'])){
604
				$longitude = $data[0]['position']['driving_longitude'];
605
			}elseif(isset($data[0]['position']['longitude'])){
606
				$longitude = $data[0]['position']['longitude'];
607
			}		
608
609
		}
610
		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
611
			if(isset($data[0]['content']['contact_information']['address'])){
612
				$address = strip_tags($data[0]['content']['contact_information']['address']);
613
614
				$address = explode("\n",$address);
615
				foreach($address as $bitkey => $bit){
616
					$bit = ltrim(rtrim($bit));
617
					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
618
						unset($address[$bitkey]);
619
					}
620
				}
621
				$address = implode(', ',$address);
622
				$address = str_replace(', , ', ', ', $address);
623
			}	
624
		}
625
626
627
		if(false !== $longitude){
628
			$location_data = array(
629
				'address'	=>	$address,
630
				'lat'		=>	$latitude,
631
				'long'		=>	$longitude,
632
				'zoom'		=>	$zoom,
633
				'elevation'	=>	'',
634
			);
635
			if(false !== $id && '0' !== $id){
636
	        	$prev = get_post_meta($id,'location',true);
637
	        	update_post_meta($id,'location',$location_data,$prev);
638
	        }else{
639
	        	add_post_meta($id,'location',$location_data,true);
640
	        }
641
		}
642
	}
643
644
	/**
645
	 * Saves the room data

classes/class-accommodation.php 1 location

@@ 733-784 (lines=52) @@
730
	/**
731
	 * Saves the longitude and lattitude, as well as sets the map marker.
732
	 */
733
	public function set_map_data($data,$id) {
734
		$longitude = $latitude = $address = false;
735
		$zoom = '15';	
736
737
		if(isset($data[0]['position'])){
738
739
			if(isset($data[0]['position']['driving_latitude'])){
740
				$latitude = $data[0]['position']['driving_latitude'];
741
			}elseif(isset($data[0]['position']['latitude'])){
742
				$latitude = $data[0]['position']['latitude'];
743
			}
744
745
			if(isset($data[0]['position']['driving_longitude'])){
746
				$longitude = $data[0]['position']['driving_longitude'];
747
			}elseif(isset($data[0]['position']['longitude'])){
748
				$longitude = $data[0]['position']['longitude'];
749
			}		
750
751
		}
752
		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
753
			if(isset($data[0]['content']['contact_information']['address'])){
754
				$address = strip_tags($data[0]['content']['contact_information']['address']);
755
756
				$address = explode("\n",$address);
757
				foreach($address as $bitkey => $bit){
758
					$bit = ltrim(rtrim($bit));
759
					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
760
						unset($address[$bitkey]);
761
					}
762
				}
763
				$address = implode(', ',$address);
764
				$address = str_replace(', , ', ', ', $address);
765
			}	
766
		}
767
768
769
		if(false !== $longitude){
770
			$location_data = array(
771
				'address'	=>	$address,
772
				'lat'		=>	$latitude,
773
				'long'		=>	$longitude,
774
				'zoom'		=>	$zoom,
775
				'elevation'	=>	'',
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);
782
	        }
783
		}
784
	}
785
	/**
786
	 * Saves the longitude and lattitude, as well as sets the map marker.
787
	 */