Code Duplication    Length = 52-52 lines in 2 locations

classes/class-accommodation.php 1 location

@@ 702-753 (lines=52) @@
699
	/**
700
	 * Saves the longitude and lattitude, as well as sets the map marker.
701
	 */
702
	public function set_map_data($data,$id) {
703
		$longitude = $latitude = $address = false;
704
		$zoom = '15';	
705
706
		if(isset($data[0]['position'])){
707
708
			if(isset($data[0]['position']['driving_latitude'])){
709
				$latitude = $data[0]['position']['driving_latitude'];
710
			}elseif(isset($data[0]['position']['latitude'])){
711
				$latitude = $data[0]['position']['latitude'];
712
			}
713
714
			if(isset($data[0]['position']['driving_longitude'])){
715
				$longitude = $data[0]['position']['driving_longitude'];
716
			}elseif(isset($data[0]['position']['longitude'])){
717
				$longitude = $data[0]['position']['longitude'];
718
			}		
719
720
		}
721
		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
722
			if(isset($data[0]['content']['contact_information']['address'])){
723
				$address = strip_tags($data[0]['content']['contact_information']['address']);
724
725
				$address = explode("\n",$address);
726
				foreach($address as $bitkey => $bit){
727
					$bit = ltrim(rtrim($bit));
728
					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
729
						unset($address[$bitkey]);
730
					}
731
				}
732
				$address = implode(', ',$address);
733
				$address = str_replace(', , ', ', ', $address);
734
			}	
735
		}
736
737
738
		if(false !== $longitude){
739
			$location_data = array(
740
				'address'	=>	$address,
741
				'lat'		=>	$latitude,
742
				'long'		=>	$longitude,
743
				'zoom'		=>	$zoom,
744
				'elevation'	=>	'',
745
			);
746
			if(false !== $id && '0' !== $id){
747
	        	$prev = get_post_meta($id,'location',true);
748
	        	update_post_meta($id,'location',$location_data,$prev);
749
	        }else{
750
	        	add_post_meta($id,'location',$location_data,true);
751
	        }
752
		}
753
	}
754
	/**
755
	 * Saves the longitude and lattitude, as well as sets the map marker.
756
	 */

classes/class-destination.php 1 location

@@ 560-611 (lines=52) @@
557
	/**
558
	 * Saves the longitude and lattitude, as well as sets the map marker.
559
	 */
560
	public function set_map_data($data,$id) {
561
		$longitude = $latitude = $address = false;
562
		$zoom = '15';	
563
564
		if(isset($data[0]['position'])){
565
566
			if(isset($data[0]['position']['driving_latitude'])){
567
				$latitude = $data[0]['position']['driving_latitude'];
568
			}elseif(isset($data[0]['position']['latitude'])){
569
				$latitude = $data[0]['position']['latitude'];
570
			}
571
572
			if(isset($data[0]['position']['driving_longitude'])){
573
				$longitude = $data[0]['position']['driving_longitude'];
574
			}elseif(isset($data[0]['position']['longitude'])){
575
				$longitude = $data[0]['position']['longitude'];
576
			}		
577
578
		}
579
		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
580
			if(isset($data[0]['content']['contact_information']['address'])){
581
				$address = strip_tags($data[0]['content']['contact_information']['address']);
582
583
				$address = explode("\n",$address);
584
				foreach($address as $bitkey => $bit){
585
					$bit = ltrim(rtrim($bit));
586
					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
587
						unset($address[$bitkey]);
588
					}
589
				}
590
				$address = implode(', ',$address);
591
				$address = str_replace(', , ', ', ', $address);
592
			}	
593
		}
594
595
596
		if(false !== $longitude){
597
			$location_data = array(
598
				'address'	=>	$address,
599
				'lat'		=>	$latitude,
600
				'long'		=>	$longitude,
601
				'zoom'		=>	$zoom,
602
				'elevation'	=>	'',
603
			);
604
			if(false !== $id && '0' !== $id){
605
	        	$prev = get_post_meta($id,'location',true);
606
	        	update_post_meta($id,'location',$location_data,$prev);
607
	        }else{
608
	        	add_post_meta($id,'location',$location_data,true);
609
	        }
610
		}
611
	}
612
613
	/**
614
	 * Saves the room data