function tt_property_custom_columns($property_column)
{
    global $post;
    switch ($property_column) {
        case 'thumbnail':
            if (has_post_thumbnail($post->ID)) {
                the_post_thumbnail('thumbnail');
            } else {
                _e('-', 'tt');
            }
            break;
        case 'featured':
            if (get_post_meta($post->ID, 'estate_property_featured', true)) {
                _e('Yes', 'tt');
            } else {
                _e('No', 'tt');
            }
            break;
        case 'address':
            $address = get_post_meta($post->ID, 'estate_property_address', true);
            if (!empty($address)) {
                echo $address;
            } else {
                _e('No Address Provided', 'tt');
            }
            break;
        case 'location':
            echo get_the_term_list($post->ID, 'property-location', '', ', ', '');
            break;
        case 'status':
            echo get_the_term_list($post->ID, 'property-status', '', ', ', '');
            break;
        case 'type':
            echo get_the_term_list($post->ID, 'property-type', '', ', ', '');
            break;
        case 'features':
            echo get_the_term_list($post->ID, 'property-features', '', ', ', '');
            break;
        case 'price':
            $properts_price = tt_property_price();
            if (empty($properts_price)) {
                _e('-', 'tt');
            } else {
                echo $properts_price;
            }
            break;
    }
}
예제 #2
0
function tt_map($atts, $content = null)
{
    extract(shortcode_atts(array('address' => '', 'zoomlevel' => '14', 'height' => '500px', 'width' => '100%'), $atts));
    ob_start();
    // Property Query
    if (is_front_page()) {
        $paged = get_query_var('page') ? get_query_var('page') : 1;
    } else {
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    }
    $query_properties_args = array('post_type' => 'property', 'posts_per_page' => -1, 'paged' => $paged);
    $query_properties = new WP_Query($query_properties_args);
    if ($query_properties->have_posts()) {
        $property_string = '';
        $random = rand();
        while ($query_properties->have_posts()) {
            $query_properties->the_post();
            global $post;
            $google_maps = get_post_meta($post->ID, 'estate_property_location', true);
            $coordinate = explode(',', $google_maps);
            // Check If We Have LatLng Coordinates From Google Maps
            if ($google_maps) {
                $property_string .= '{ ';
                $property_string .= 'permalink:"' . get_the_permalink() . '", ';
                $property_string .= 'title:"' . get_the_title() . '", ';
                $property_string .= 'price:"' . tt_property_price() . '", ';
                $property_string .= 'latLng: new google.maps.LatLng(' . $coordinate[0] . ', ' . $coordinate[1] . '), ';
                if (has_post_thumbnail()) {
                    $property_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
                    $property_string .= 'thumbnail: "' . $property_thumbnail[0] . '"';
                } else {
                    $property_string .= 'thumbnail: "//placehold.it/300x100/eee/ccc/&text=.."';
                }
                $property_string .= ' },' . "\n";
            }
        }
        ?>
<script>
var map = null, markers = [], newMarkers_<?php 
        echo $random;
        ?>
 = [], markerCluster = null, infobox = [];

function initMap() {

	<?php 
        echo tt_mapMarkers();
        ?>

	var	mapOptions = {
		center: new google.maps.LatLng(0, 0),
		zoom: <?php 
        echo $zoomlevel;
        ?>
,
		scrollwheel: false,
		streetViewControl: true,
		disableDefaultUI: true
	};
	
	map = new google.maps.Map(document.getElementById("google-map-<?php 
        echo $random;
        ?>
"), mapOptions);
		
	markers = initMarkers(map, [ <?php 
        echo $property_string;
        ?>
 ]);
	
	function initMarkers(map, markerData) {
		    
		for( var i = 0; i < markerData.length; i++ ) {
			
			marker = new google.maps.Marker({
		    map: map,
		    position: markerData[i].latLng,
		    icon: customIcon,
		    animation: google.maps.Animation.DROP
			}),
					  	  
			infoboxOptions = {
			    content: 	'<div class="map-marker-wrapper">'+
			    						'<div class="map-marker-container">'+
				    						'<div class="arrow-down"></div>'+
												'<img src="'+markerData[i].thumbnail+'" />'+
												'<div class="content">'+
												'<a href="'+markerData[i].permalink+'">'+
												'<h5 class="title">'+markerData[i].title+'</h5>'+
												'</a>'+
												markerData[i].price+
												'</div>'+
											'</div>'+
								    '</div>',
			    disableAutoPan: false,
				  pixelOffset: new google.maps.Size(-33, -90),
				  zIndex: null,
				  isHidden: true,
				  alignBottom: true,
				  closeBoxURL: "<?php 
        echo TT_LIB_URI . '/images/close.png';
        ?>
",
				  infoBoxClearance: new google.maps.Size(25, 25)
			};
			
			newMarkers_<?php 
        echo $random;
        ?>
.push(marker);
		
			newMarkers_<?php 
        echo $random;
        ?>
[i].infobox = new InfoBox(infoboxOptions);
			newMarkers_<?php 
        echo $random;
        ?>
[i].infobox.open(map, marker);
		
			google.maps.event.addListener(marker, 'click', (function(marker, i) {
		    return function() {
		    	
		    	if ( newMarkers_<?php 
        echo $random;
        ?>
[i].infobox.getVisible() ) {
			    	newMarkers_<?php 
        echo $random;
        ?>
[i].infobox.hide();
		    	}
		    	else {
			    	jQuery('.infoBox').hide();
			    	newMarkers_<?php 
        echo $random;
        ?>
[i].infobox.show();
		    	}
		    	
		    	newMarkers_<?php 
        echo $random;
        ?>
[i].infobox.open(map, this);
		      map.panTo(markerData[i].latLng);
		      
		    }
			})( marker, i ) ); 
			
			google.maps.event.addListener(map, 'click', function() {
		    jQuery('.infoBox').hide();
		  });
			
		}
		
		var markerCluster_<?php 
        echo $random;
        ?>
 = new MarkerClusterer(map, newMarkers_<?php 
        echo $random;
        ?>
, markerClusterOptions);
		
		return newMarkers_<?php 
        echo $random;
        ?>
;
		
	}
	
	// Spiderfier
	var oms = new OverlappingMarkerSpiderfier(map, { markersWontMove: true, markersWontHide: true, keepSpiderfied: true, legWeight: 5 });
	
	function omsMarkers( markers ) {
	  for ( var i = 0; i < markers.length; i++ ) {
	  	oms.addMarker( markers[i] );
	  }   
	}
	
	omsMarkers(markers);
	
	<?php 
        if ($address) {
            ?>
	var address = '<?php 
            echo $address;
            ?>
';

	// Get latLng from property address and grab it with callback, as geocode calls asynchonous
  function getLatLng(callback) {
	  var geocoder = new google.maps.Geocoder();  	  
	  if ( geocoder ) {	  
		  geocoder.geocode( { 'address': address}, function(results, status ) { 
		    if (status == google.maps.GeocoderStatus.OK) {   	
		    	latLng = results[0].geometry.location;
		    	callback(latLng);
		    }
		    else {
			    alert("Geocoder failed due to: " + status);
		    }  		     
		  });	  
	  }   
  }
  
  getLatLng(function(latLng) {
	  map.setCenter(latLng);  	
  });
  <?php 
        }
        ?>
  
}

google.maps.event.addDomListener(window, 'load', initMap);
google.maps.event.addDomListener(window, 'resize', initMap);

</script>

<div id="map-wrapper">
		
	<div id="map-controls">
		<a href="#" class="control" id="zoom-in" data-toggle="tooltip" title="<?php 
        _e('Zoom In', 'tt');
        ?>
"><i class="fa fa-plus"></i></a>
		<a href="#" class="control" id="zoom-out" data-toggle="tooltip" title="<?php 
        _e('Zoom Out', 'tt');
        ?>
"><i class="fa fa-minus"></i></a>
		<a href="#" class="control" id="map-type" data-toggle="tooltip" title="<?php 
        _e('Map Type', 'tt');
        ?>
">
			<i class="fa fa-image"></i>
			<ul class="list-unstyled">
				<li id="map-type-roadmap"><?php 
        _e('Roadmap', 'tt');
        ?>
</li>
				<li id="map-type-satellite"><?php 
        _e('Satellite', 'tt');
        ?>
</li>
				<li id="map-type-hybrid"><?php 
        _e('Hybrid', 'tt');
        ?>
</li>
				<li id="map-type-terrain"><?php 
        _e('Terrain', 'tt');
        ?>
</li>
			</ul>
		</a>
		<a href="#" class="control" id="current-location" data-toggle="tooltip" title="<?php 
        _e('Radius: 1000m', 'tt');
        ?>
"><i class="fa fa-crosshairs"></i><?php 
        _e('Current Location', 'tt');
        ?>
</a>
	</div>
		
	<div id="google-map-<?php 
        echo $random;
        ?>
" style="height: <?php 
        echo $height;
        ?>
">
		<div class="spinner">
		  <div class="bounce1"></div>
		  <div class="bounce2"></div>
		  <div class="bounce3"></div>
		</div>	
	</div>
	
</div>

<?php 
        wp_reset_query();
    } else {
        ?>
	
<div id="map-no-properties-found">
	<p class="lead text-center"><?php 
        _e('No Properties Found.', 'tt');
        ?>
</p>
</div>
<?php 
    }
    return ob_get_clean();
}
예제 #3
0
"></i></a>
				<?php 
            echo '<a href="#" class="delete-property" data-property-id="' . $post->ID . '"><i class="fa fa-trash" data-toggle="tooltip" title="' . __('Delete Property', 'tt') . '"></i></a>';
        } else {
            if (get_post_status($post->ID) == "pending") {
                ?>
				<a href="<?php 
                echo the_permalink();
                ?>
" target="_blank"><i class="fa fa-clock-o" data-toggle="tooltip" title="<?php 
                _e('Pending', 'tt');
                ?>
"></i></a>
				<?php 
                echo '<a href="#" class="delete-property" data-property-id="' . $post->ID . '"><i class="fa fa-trash" data-toggle="tooltip" title="' . __('Delete Property', 'tt') . '"></i></a>';
                echo tt_paypal_payment_button($post->ID);
            }
        }
    }
    ?>
			<?php 
}
?>
			<div class="price-tag"><?php 
echo tt_property_price();
?>
</div>
		</div>
	</div>
	
</div>
예제 #4
0
								<div class="description">
									<?php 
                the_excerpt();
                ?>
									<?php 
                if (get_the_title()) {
                    ?>
									<div class="arrow-right"></div>
									<?php 
                }
                $size = get_post_meta($post->ID, 'estate_property_size', true);
                $size_unit = get_post_meta($post->ID, 'estate_property_size_unit', true);
                $bedrooms = get_post_meta($post->ID, 'estate_property_bedrooms', true);
                $bathrooms = get_post_meta($post->ID, 'estate_property_bathrooms', true);
                echo '<div class="property-data">';
                echo '<div class="property-price">' . tt_property_price() . '</div>';
                echo '<div class="property-details">';
                if ($bedrooms) {
                    echo '<i class="fa fa-bed"></i>' . $bedrooms . ' ' . _n(__('Bedroom', 'tt'), __('Bedrooms', 'tt'), $bedrooms, 'tt');
                }
                if ($bathrooms) {
                    echo '<i class="fa fa-tint"></i>' . $bathrooms . ' ' . _n(__('Bathroom', 'tt'), __('Bathrooms', 'tt'), $bathrooms, 'tt');
                }
                if ($size) {
                    echo '<i class="fa fa-expand"></i>' . $size . $size_unit;
                }
                echo '</div></div>';
                ?>
								</div>
								<?php 
            }
예제 #5
0
</span>
					<?php 
if ($address) {
    ?>
					<div class="property-address"><?php 
    echo $address;
    ?>
</div>
					<?php 
}
?>
				</h1>
				<div class="clearfix"></div>
				<div class="meta">
					<?php 
echo '<span>' . tt_property_price() . '</span>';
if ($property_type || $property_status) {
    echo '<span class="separator">&middot;</span>';
}
if ($property_type) {
    foreach ($property_type as $type) {
        echo ' <span class="property-type">' . $type->name . '</span>';
        break;
    }
}
if ($property_status) {
    foreach ($property_status as $status) {
        echo ' <span class="property-status">(' . $status->name . ')</span>';
        break;
    }
}
function tt_google_maps_api_multiple_properties()
{
    // Check For Property Search Template
    if (is_page_template('template-property-search.php')) {
        // Build Property Search Query
        $query_properties_args = array();
        $query_properties_args = apply_filters('property_search_args', $query_properties_args);
        $query_properties_args['posts_per_page'] = -1;
    } else {
        global $post, $realty_theme_option;
        $properties_homepage_quantity = intval($realty_theme_option['map-properties-quantity']);
        // Property Map Settings
        $property_map_location = get_post_meta($post->ID, 'estate_property_map_location', false);
        $property_map_status = get_post_meta($post->ID, 'estate_property_map_status', false);
        $property_map_type = get_post_meta($post->ID, 'estate_property_map_type', false);
        $property_map_custom_zoom_level = get_post_meta($post->ID, 'estate_property_map_custom_zoom_level', true);
        if (!$properties_homepage_quantity) {
            $properties_homepage_quantity = -1;
        }
        // Property Query
        if (is_front_page()) {
            $paged = get_query_var('page') ? get_query_var('page') : 1;
        } else {
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        }
        $query_properties_args = array('post_type' => 'property', 'posts_per_page' => $properties_homepage_quantity, 'paged' => $paged);
        $tax_query = array();
        if ($property_map_location) {
            $tax_query[] = array('taxonomy' => 'property-location', 'field' => 'id', 'terms' => $property_map_location);
        }
        if ($property_map_status) {
            $tax_query[] = array('taxonomy' => 'property-status', 'field' => 'id', 'terms' => $property_map_status);
        }
        if ($property_map_type) {
            $tax_query[] = array('taxonomy' => 'property-type', 'field' => 'id', 'terms' => $property_map_type);
        }
        // Count Taxonomy Queries + set their relation for property query
        $tax_count = count($tax_query);
        if ($tax_count > 1) {
            $tax_query['relation'] = 'AND';
        }
        if ($tax_count > 0) {
            $query_properties_args['tax_query'] = $tax_query;
        }
    }
    $query_properties = new WP_Query($query_properties_args);
    //if ( $query_properties->have_posts() ) :
    $property_string = '';
    $i = 0;
    while ($query_properties->have_posts()) {
        $query_properties->the_post();
        global $post;
        $google_maps = get_post_meta($post->ID, 'estate_property_location', true);
        // Check For Map Coordinates
        if ($google_maps) {
            $coordinate = explode(',', $google_maps);
            $property_string .= '{ ';
            $property_string .= 'permalink:"' . urlencode(get_permalink()) . '", ';
            $property_string .= 'title:"' . get_the_title() . '", ';
            $property_string .= 'price:"' . tt_property_price() . '", ';
            $property_string .= 'latLng: new google.maps.LatLng(' . $coordinate[0] . ', ' . $coordinate[1] . '), ';
            if (has_post_thumbnail()) {
                $property_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
                $property_string .= 'thumbnail: "' . $property_thumbnail[0] . '"';
            } else {
                $property_string .= 'thumbnail: "//placehold.it/300x100/eee/ccc/&text=.."';
            }
            $property_string .= ' },' . "\n";
        }
        $i++;
    }
    ?>
<script>
<?php 
    // No Properties Found - Hide Map
    if ($i == 0) {
        ?>
jQuery('#map-wrapper').hide();
<?php 
    }
    ?>
var map = null, markers = [], newMarkers = [], markerCluster = null, bounds = [], infobox = [];

<?php 
    echo tt_mapMarkers();
    ?>

var	mapOptions = {
	center: new google.maps.LatLng(0, 0),
	zoom: 14,
	scrollwheel: false,
	streetViewControl: true,
	disableDefaultUI: true,
};

function initMap() {
	
	map = new google.maps.Map(document.getElementById("google-map"), mapOptions);
	
	bounds = new google.maps.LatLngBounds();
	
	markers = initMarkers(map, [ <?php 
    echo $property_string;
    ?>
 ]);
	
	markerCluster = new MarkerClusterer(map, newMarkers, markerClusterOptions);

	// Maps Fully Loaded: Hide + Remove Spinner
	google.maps.event.addListenerOnce(map, 'idle', function() {
		jQuery('.spinner').fadeTo(800, 0.5);
		setTimeout(function() {
		  jQuery('.spinner').remove();
		}, 800);
	});
	
	// Spiderfier
	var oms = new OverlappingMarkerSpiderfier(map, { markersWontMove: true, markersWontHide: true, keepSpiderfied: true, legWeight: 5 });
	
	function omsMarkers( markers ) {
	  for ( var i = 0; i < markers.length; i++ ) {
	  	oms.addMarker( markers[i] );
	  }   
	}
	
	omsMarkers(markers);
		
}

google.maps.event.addDomListener(window, 'load', initMap);
//google.maps.event.addDomListener(window, 'resize', initMap);

function initMarkers(map, markerData) {
	    
	for( var i = 0; i < markerData.length; i++ ) {
		
		marker = new google.maps.Marker({
	    map: map,
	    position: markerData[i].latLng,
			icon: customIcon,
	    //animation: google.maps.Animation.DROP
		}),
		
		bounds.extend(markerData[i].latLng);
	  
		infoboxOptions = {
	    content: 	'<div class="map-marker-wrapper">'+
	    						'<div class="map-marker-container">'+
		    						'<div class="arrow-down"></div>'+
										'<img src="'+markerData[i].thumbnail+'" />'+
										'<div class="content">'+
										'<a href="'+markerData[i].permalink+'">'+
										'<h5 class="title">'+markerData[i].title+'</h5>'+
										'</a>'+
										markerData[i].price+
										'</div>'+
									'</div>'+
						    '</div>',
	    disableAutoPan: false,
		  pixelOffset: new google.maps.Size(-33, -90),
		  zIndex: null,
		  isHidden: true,
		  alignBottom: true,
		  closeBoxURL: "<?php 
    echo TT_LIB_URI . '/images/close.png';
    ?>
",
		  infoBoxClearance: new google.maps.Size(25, 25)
		};
		
		newMarkers.push(marker);
	
		newMarkers[i].infobox = new InfoBox(infoboxOptions);
		newMarkers[i].infobox.open(map, marker);
	
		google.maps.event.addListener(marker, 'click', (function(marker, i) {
			
	    return function() {
				
	    	if ( newMarkers[i].infobox.getVisible() ) {
		    	newMarkers[i].infobox.setVisible(false);
	    	}
	    	else {
		    	jQuery('.infoBox').hide();
		    	newMarkers[i].infobox.setVisible(true);
	    	}	    	
	    	
	    	newMarkers[i].infobox.open(map, this);
	      map.panTo(markerData[i].latLng);
	      
	    }
	    
		})( marker, i ) );
		
		google.maps.event.addListener(map, 'click', function() {
	    jQuery('.infoBox').hide();
	  });
		
	}
	
	// Set Map Bounds And Max. Zoom Level
	google.maps.event.addListenerOnce(map, 'bounds_changed', function(event) {
		map.fitBounds(bounds);
		<?php 
    if (isset($property_map_custom_zoom_level) && !empty($property_map_custom_zoom_level)) {
        ?>
		this.setZoom(<?php 
        echo $property_map_custom_zoom_level;
        ?>
);
		<?php 
    } else {
        ?>
		if (this.getZoom() > 13) {
	    this.setZoom(13);
	  }
	  <?php 
    }
    ?>
	});
	
	return newMarkers;
	
} // initMarkers();

</script>

<?php 
}
    function widget($args, $instance)
    {
        extract($args);
        // Widget starts to print information
        echo $before_widget;
        $title = apply_filters('widget_title', $instance['title']);
        $amount = empty($instance['amount']) ? '3' : $instance['amount'];
        $amount = intval($amount);
        $random = $instance['random'] ? true : false;
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        // Query Featured Properties
        $args_featured_properties = array('post_type' => 'property', 'posts_per_page' => $amount, 'meta_query' => array(array('key' => 'estate_property_featured', 'value' => 1, 'type' => 'NUMERIC')));
        // Order By:
        if ($random) {
            $args_featured_properties['orderby'] = 'rand';
        }
        $query_featured = new WP_Query($args_featured_properties);
        if ($query_featured->have_posts()) {
            ?>
		<div class="owl-carousel-1 owl-carousel-widget-featured-properties">
			<?php 
            while ($query_featured->have_posts()) {
                $query_featured->the_post();
                global $post;
                $property_location = get_the_terms($post->ID, 'property-location');
                $property_type = get_the_terms($post->ID, 'property-type');
                if ($property_type || $property_location) {
                    $no_property_details = false;
                } else {
                    $no_property_details = true;
                }
                ?>
				<div>
					<a href="<?php 
                the_permalink();
                ?>
">
						<div class="widget-thumbnail">
							<?php 
                if (has_post_thumbnail()) {
                    the_post_thumbnail('property-400-300');
                } else {
                    echo '<img src ="//placehold.it/400x300/eee/ccc/&text=.." />';
                }
                ?>
						</div>
						
						<div class="content-with-details">
							<div <?php 
                if ($no_property_details) {
                    echo 'class="no-details"';
                }
                ?>
>
								<?php 
                the_title('<h5 class="title">', '</h5>');
                ?>
							
								<div class="property-price"><?php 
                echo tt_property_price();
                ?>
</div>							
								<?php 
                if (!$no_property_details) {
                    ?>
								<div class="on-hover">
									<?php 
                    if ($property_type) {
                        foreach ($property_type as $type) {
                            echo '<div class="property-type">' . $type->name . '</div>';
                            break;
                        }
                    }
                    if ($property_location) {
                        foreach ($property_location as $location) {
                            echo '<div class="property-location">' . $location->name . '</div>';
                            break;
                        }
                    }
                    ?>
								</div>
								<?php 
                }
                ?>
							</div>
						</div>
					</a>
				</div>
			<?php 
            }
            ?>
		</div>
		<?php 
            wp_reset_query();
        }
        // Widget ends printing information
        echo $after_widget;
    }
function tt_google_maps_api_single_property()
{
    global $post, $realty_theme_option;
    $property_id = $post->ID;
    // Check For Property Submit Page Template
    if (is_page_template('template-property-submit.php') && isset($_GET['edit']) && !empty($_GET['edit'])) {
        $property_id = $_GET['edit'];
    }
    $address = get_post_meta($property_id, 'estate_property_address', true);
    $google_maps = get_post_meta($property_id, 'estate_property_location', true);
    $coordinate = explode(',', $google_maps);
    if (has_post_thumbnail($property_id)) {
        $property_thumbnail = get_the_post_thumbnail($property_id, 'medium');
    } else {
        $property_thumbnail = '<img src="//placehold.it/300x150/eee/ccc/&text=.." />';
    }
    if (empty($realty_theme_option['property-submit-default-address-latitude'])) {
        $latitude = '51.5286416';
    } else {
        $latitude = $realty_theme_option['property-submit-default-address-latitude'];
    }
    if (empty($realty_theme_option['property-submit-default-address-longitude'])) {
        $longitude = '-0.1015987';
    } else {
        $longitude = $realty_theme_option['property-submit-default-address-longitude'];
    }
    ?>

<script>
var map, marker;

function initMap() {

	var mapOptions = { 
	  center: new google.maps.LatLng( <?php 
    echo $latitude . ',' . $longitude;
    ?>
),
	  zoom: 12,
	  scrollwheel: false,
	  streetViewControl: true,
		disableDefaultUI: true
	};

	map = new google.maps.Map(document.getElementById('google-map'), mapOptions);
	
	<?php 
    echo tt_mapMarkers();
    ?>
	
	var marker = new google.maps.Marker({
    map: map,
    position: new google.maps.LatLng( <?php 
    echo $latitude . ',' . $longitude;
    ?>
),
    icon: customIcon,
    title: '<?php 
    the_title();
    ?>
',
		<?php 
    if (is_page_template('template-property-submit.php')) {
        ?>
    draggable: true
		<?php 
    }
    ?>
  });
	
	var propertyThumbnail = '<?php 
    echo $property_thumbnail;
    ?>
';
  var propertyPrice = '<?php 
    echo tt_property_price();
    ?>
';
  var propertyTitle = '<?php 
    echo '<h5 class="title">' . get_the_title($property_id) . '</h5>';
    ?>
';

	// http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html
	var infobox = new InfoBox({
	  content: 	'<div class="map-marker-wrapper">'+
    						'<div class="map-marker-container">'+
	    						'<div class="arrow-down"></div>'+
									propertyThumbnail+
									'<div class="content">'+
									propertyTitle+
									propertyPrice+
									'</div>'+
								'</div>'+
					    '</div>',
	  disableAutoPan: false,
	  pixelOffset: new google.maps.Size(-33, -90),
	  zIndex: null,
	  alignBottom: true,
	  closeBoxURL: "<?php 
    echo TT_LIB_URI . '/images/close.png';
    ?>
",
	  infoBoxClearance: new google.maps.Size(50, 50)
	});
	
	<?php 
    // Check If We Have LatLng Coordinates From Google Maps
    if ($google_maps) {
        ?>
	//alert("got latlng");
	function getLatLng(callback) {
		latLng = new google.maps.LatLng(<?php 
        echo $coordinate[0];
        ?>
, <?php 
        echo $coordinate[1];
        ?>
);
		callback(latLng);
	}
	<?php 
    } else {
        ?>
	//alert("no latlng");
	<?php 
        if (is_page_template('template-property-submit.php')) {
            ?>
	var address = jQuery('input#property-address').value;
	<?php 
        } else {
            ?>
	var address = '<?php 
            echo $address;
            ?>
';
	<?php 
        }
        ?>
	
	// Get latLng from property address and grab it with callback, as geocode calls asynchonous
  function getLatLng(callback) {
	  var geocoder = new google.maps.Geocoder();  	  
	  if ( geocoder ) {	  
		  geocoder.geocode( { 'address': address}, function(results, status ) { 
		    if (status == google.maps.GeocoderStatus.OK) {   	
		    	latLng = results[0].geometry.location;
		    	callback(latLng);
		    }
		    <?php 
        if (!is_page_template('template-property-submit.php')) {
            ?>
		    else {
			    //alert("Geocoder failed due to: " + status);
		    }  		     
		    <?php 
        }
        ?>
		  });	  
	  }   
  }
  
  <?php 
    }
    ?>

  getLatLng(function(latLng) {
	  
	  marker.setPosition(latLng);
	  map.setCenter(latLng);
	  <?php 
    global $realty_theme_option;
    if ($realty_theme_option['map-default-zoom-level']) {
        echo 'map.setZoom(' . $realty_theme_option['map-default-zoom-level'] . ');';
    } else {
        echo 'map.setZoom(14);';
    }
    ?>
   	
   	google.maps.event.addListener(marker, 'click', function() {
	  	infobox.open(map, marker);
	    map.panTo(latLng);
		});
   	
  });
	
	// Maps Fully Loaded: Hide + Remove Spinner
	google.maps.event.addListenerOnce(map, 'idle', function() {
		jQuery('.spinner').fadeTo(800, 0.5);
		setTimeout(function() {
		  jQuery('.spinner').remove();
		}, 800);
	});
	
	<?php 
    // User Property Submit
    if (is_page_template('template-property-submit.php')) {
        ?>
	// https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete
  var autocompleteInput = document.getElementById('property-address');
  var autocomplete = new google.maps.places.Autocomplete(autocompleteInput);
  
  // Autocomplete
  google.maps.event.addListener(autocomplete, 'place_changed', function() {
  
    infobox.close();
    marker.setVisible(false);
    var place = autocomplete.getPlace();
    if (!place.geometry) {
      return;
    }
    
    // If the place has a geometry, then present it on a map.
    if (place.geometry.viewport) {
      map.fitBounds(place.geometry.viewport);
    } else {
      map.setCenter(place.geometry.location);
      map.setZoom(17);  // Why 17? Because it looks good.
    }
    
    marker.setPosition(place.geometry.location);
    marker.setVisible(true);
    
    // Update Property Coordinates
    var newCoordinates = String( place.geometry.location );
    newCoordinates = newCoordinates.substring( 1, newCoordinates.length-1 );
    //alert( newCoordinates );
    jQuery('#property-coordinates').val(newCoordinates);
  
  });
  
  // After Marker Has Been Dragged To Exact Location
  google.maps.event.addListener(marker, 'dragend', function() {
    var newCoordinatesAfterDragging = String( marker.getPosition() );
    newCoordinatesAfterDragging = newCoordinatesAfterDragging.substring( 1, newCoordinatesAfterDragging.length-1 );
    //alert( newCoordinatesAfterDragging );
    jQuery('#property-coordinates').val(newCoordinatesAfterDragging);
	});
  <?php 
    }
    ?>
	
}

google.maps.event.addDomListener(window, 'load', initMap);
google.maps.event.addDomListener(window, 'resize', initMap);

</script>

<?php 
}
예제 #9
0
function tt_ajax_search()
{
    // Build Property Search Query
    $search_results_args = array();
    $search_results_args = apply_filters('property_search_args', $search_results_args);
    // Query Only Property Owners' Properties On "My Properties" Page Template (Admins Can View Every Property)
    $page_template = get_page_template_slug($_GET['pageid']);
    if ($page_template == 'template-property-submit-listing.php' && !current_user_can('manage_options')) {
        global $current_user;
        get_currentuserinfo();
        $search_results_args['author'] = $current_user->ID;
    }
    $count_results = "0";
    $query_search_results = new WP_Query($search_results_args);
    if (!isset($orderby) || empty($orderby)) {
        $orderby = "date-new";
    }
    if ($query_search_results->have_posts()) {
        $count_results = $query_search_results->found_posts;
        // template-property-search.php
        get_template_part('lib/inc/template/property', 'comparison');
        ?>
	<ul class="row list-unstyled">	
		<?php 
        while ($query_search_results->have_posts()) {
            $query_search_results->the_post();
            global $realty_theme_option;
            $columns = $realty_theme_option['property-listing-columns'];
            if (empty($columns)) {
                $columns = "col-md-6";
            }
            ?>
		<li class="<?php 
            echo $columns;
            ?>
">
			<?php 
            get_template_part('lib/inc/template/property', 'item');
            ?>
		</li>
		<?php 
        }
        ?>
		
	</ul>
	<?php 
        wp_reset_query();
        ?>

	<div id="pagination" class="pagination-true">
	<?php 
        // Built Property Pagination
        $big = 999999999;
        // need an unlikely integer
        $original_request_uri = $_SERVER['REQUEST_URI'];
        $base = $_GET['base'];
        $_SERVER['REQUEST_URI'] = $base;
        if ($realty_theme_option['enable-rtl-support']) {
            $rtl_pagination_right_nav = '<i class="btn btn-default fa fa-angle-left"></i>';
            $rtl_pagination_left_nav = '<i class="btn btn-default fa fa-angle-right"></i>';
        } else {
            $rtl_pagination_right_nav = '<i class="btn btn-default fa fa-angle-right"></i>';
            $rtl_pagination_left_nav = '<i class="btn btn-default fa fa-angle-left"></i>';
        }
        //echo $rtl_pagination_right_nav;
        echo paginate_links(array('total' => $query_search_results->max_num_pages, 'show_all' => true, 'type' => 'list', 'current' => $search_results_args['paged'], 'prev_next' => true, 'prev_text' => __($rtl_pagination_left_nav, 'tt'), 'next_text' => __($rtl_pagination_right_nav, 'tt')));
        $_SERVER['REQUEST_URI'] = $original_request_uri;
        ?>
	</div>
	
	<?php 
    } else {
        ?>
	<p class="lead text-center text-muted"><?php 
        _e('No Properties Match Your Search Criteria.', 'tt');
        ?>
</p>
	<?php 
    }
    ?>
	<script>
	jQuery( '.pagination-true a' ).each(function() {
        	this.href = this.href.replace(jQuery( this ).attr('href'), jQuery( this ).attr('href')+'#property-items');
	  
    });
	jQuery(function($) {
		$('.pagination-true').on('click','a', function(e){
			 e.preventDefault();
			 var link_page = $(this).attr('href');
			 
			$('#property-items').fadeOut(500, function(){
				
				$(this).load(link_page + ' #property-items', function() {
                          $(this).fadeIn(500);
						  window.history.pushState("#property-items", "Properties",link_page );
                });
				 /*jQuery.ajax({
					type: 'POST',
					url: link_page+'#property-items',//ajaxURL,
					//data: 'pagers='+encodeURIComponent(link_page)+'&action=tt_ajax_search',		
					success: function (response) {
						jQuery('#property-items').html(response);
						 jQuery('#property-items').fadeIn(500); // Show response from function tt_ajax_search()
					},
					error: function () {
					console.log( 'failed' );
					}	
		  
			       }); */
				   
	
		     });
	    
        });
    });
	jQuery('.search-results-header, #property-search-results').fadeOut(0);
	<?php 
    // No Results Found
    if ($count_results == "0") {
        ?>
	jQuery('#map-overlay-no-results, #property-search-results').fadeIn();
	<?php 
    } else {
        // AJAX Refresh Property Map Markers
        $search_results_args['posts_per_page'] = -1;
        $query_search_results = new WP_Query($search_results_args);
        if ($query_search_results->have_posts()) {
            $property_string = '';
            $i = 0;
            while ($query_search_results->have_posts()) {
                $query_search_results->the_post();
                global $post;
                $google_maps = get_post_meta($post->ID, 'estate_property_location', true);
                // Check For Map Coordinates
                if ($google_maps) {
                    $coordinate = explode(',', $google_maps);
                    $property_string .= "{ ";
                    $property_string .= 'permalink:"' . urlencode(get_permalink()) . '", ';
                    $property_string .= 'title:"' . get_the_title() . '", ';
                    $property_string .= 'price:"' . tt_property_price() . '", ';
                    $property_string .= 'latLng: new google.maps.LatLng(' . $coordinate[0] . ', ' . $coordinate[1] . '), ';
                    if (has_post_thumbnail()) {
                        $property_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
                        $property_string .= 'thumbnail: "' . $property_thumbnail[0] . '"';
                    } else {
                        $property_string .= 'thumbnail: "//placehold.it/300x100/eee/ccc/&text=.."';
                    }
                    $property_string .= ' },' . "\n";
                }
                $i++;
            }
            wp_reset_query();
        }
        ?>
	// Check: Do we show a map at all?
	if ( jQuery('#google-map').length > 0 ) {		
		bounds = new google.maps.LatLngBounds();
		
		initMarkers(map, [ <?php 
        echo $property_string;
        ?>
 ]);
		markerCluster = new MarkerClusterer(map, newMarkers, markerClusterOptions);
		
		google.maps.event.addListenerOnce(map, 'bounds_changed', function(event) {
			map.fitBounds(bounds);
			if (this.getZoom() > 13) {
		    this.setZoom(13);
		  }
		});
		
		jQuery('#map-overlay-no-results').fadeOut();	
	}
	jQuery('.search-results-header, #property-search-results').fadeIn();
	jQuery('.page-title span').html(<?php 
        echo $count_results;
        ?>
);
	<?php 
    }
    ?>
	
	</script>
	
	<?php 
    die;
}