Function Reference: geodir_location_update_marker_address
Summary
Updates marker address.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
Package
GeoDirectory_Location_Manager
Parameters
- $prefix
- (string) (required) Identifier used as a prefix for field name.
- Default: None
Change Log
Since: 1.0.0
Filters
‘geodir_default_latitude’ [Line: 2743]
‘geodir_default_longitude’ [Line: 2744]
Source File
geodir_location_update_marker_address() is located in geodir_location_manager/geodir_location_hooks_actions.php [Line: 2703]
Source Code
function geodir_location_update_marker_address($prefix='') { global $pagenow, $wpdb; if(((is_page() && geodir_is_page('add-listing') )) || (is_admin() && ( $pagenow == 'post.php' || isset($_REQUEST['post_type'])))){ $country_option = get_option('geodir_enable_country'); $region_option = get_option('geodir_enable_region'); $city_option = get_option('geodir_enable_city'); $default_country = ''; $default_region = ''; $default_city = ''; if(isset($_SESSION['gd_multi_location'])) { if(isset($_SESSION['gd_city']) && $_SESSION['gd_city'] != '' ) $location = geodir_get_locations('city',$_SESSION['gd_city']); elseif(isset($_SESSION['gd_region']) && $_SESSION['gd_region'] != '' ) $location = geodir_get_locations('region',$_SESSION['gd_region']); elseif(isset($_SESSION['gd_country']) && $_SESSION['gd_country'] != '' ) $location = geodir_get_locations('country',$_SESSION['gd_country']); if(isset($location) && $location) $location = end($location); $default_city = isset($location->city) ? $location->city : ''; $default_region = isset($location->region) ? $location->region : ''; $default_country = isset($location->country) ? $location->country : ''; } $location = geodir_get_default_location(); if(empty($default_city)) $default_city = isset($location->city) ? $location->city : ''; if(empty($default_region)) $default_region = isset($location->region) ? $location->region : ''; if(empty($default_country)) $default_country = isset($location->country) ? $location->country : ''; $default_lat = apply_filters('geodir_default_latitude', $location->city_latitude, true); $default_lng = apply_filters('geodir_default_longitude', $location->city_longitude, true); $selected_countries = array(); if(get_option('geodir_selected_countries')) $selected_countries = get_option('geodir_selected_countries'); $selected_regions = array(); if(get_option('geodir_selected_regions')) $selected_regions = get_option('geodir_selected_regions'); $selected_cities = array(); if(get_option('geodir_selected_cities')) $selected_cities = get_option('geodir_selected_cities'); ?> var error = false; get_var($wpdb->prepare("SELECT ISO2 FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country=%s",$default_country)); ?> if('' != getCountryISO && error == false){ alert(''); error = true; } 1){ $selected_countries_string = sprintf(__('Please choose any address of the (%s) countries only.',GEODIRECTORY_TEXTDOMAIN), implode(',',$selected_countries)); }else{ $selected_countries_string = sprintf(__('Please choose any address of the (%s) country only.',GEODIRECTORY_TEXTDOMAIN), implode(',',$selected_countries)); } }else{ $selected_countries_string = __('No countries available.',GEODIRECTORY_TEXTDOMAIN); } $countriesP = implode(',', array_fill(0, count($selected_countries), '%s')); $countries_ISO2 = $wpdb->get_results($wpdb->prepare("SELECT ISO2 FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country IN ($countriesP)",$selected_countries)); $cISO_arr = array(); foreach($countries_ISO2 as $cIOS2){ $cISO_arr[] = $cIOS2->ISO2; } ?> var country_array = ; //country_array = jQuery.map(country_array, String.toLowerCase); if(jQuery.inArray( getCountryISO, country_array ) == -1 && error == false){ alert(''); error = true; } if(getCountry && getCity && error == false){ jQuery.post( "", { country: getCountry, state: getState, city: getCity }) .done(function( data ) { if(jQuery.trim(data) != '') getState = data; if('' != getState.toLowerCase() && error == false){ alert(''); error = true; } 1){ $selected_regions_string = sprintf(__('Please choose any address of the (%s) regions only.',GEODIRECTORY_TEXTDOMAIN), implode(',',$selected_regions)); }else{ $selected_regions_string = sprintf(__('Please choose any address of the (%s) region only.',GEODIRECTORY_TEXTDOMAIN), implode(',',$selected_regions)); } } ?> var region_array = ; region_array = jQuery.map(region_array, String.toLowerCase); if(jQuery.inArray( getState.toLowerCase(), region_array ) == -1 && error == false && region_array.length > 0){ alert(''); error = true; } if('' != getCity.toLowerCase() && error == false){ alert(''); error = true; } 1){ $selected_cities_string = sprintf(__('Please choose any address of the (%s) cities only.',GEODIRECTORY_TEXTDOMAIN), implode(',',$selected_cities)); }else{ $selected_cities_string = sprintf(__('Please choose any address of the (%s) city only.',GEODIRECTORY_TEXTDOMAIN), implode(',',$selected_cities)); } } ?> var city_array = ; city_array = jQuery.map(city_array, String.toLowerCase); if(jQuery.inArray( getCity.toLowerCase(), city_array ) == -1 && error == false && city_array.length > 0){ alert(''); error = true; } }); } if(error == false){ if((jQuery.trim(old_country) != jQuery.trim(getCountry))){ jQuery('# option').remove(); if(jQuery("# option:contains('"+getState+"')").length == 0){ jQuery("#").append(''); } jQuery('# option[value="'+getState+'"]').attr("selected",true); jQuery("#").trigger("chosen:updated"); jQuery('# option').remove(); if(jQuery("# option:contains('"+getCity+"')").length == 0){ jQuery("#").append(''); } jQuery('# option[value="'+getCity+'"]').attr("selected",true); jQuery("#").trigger("chosen:updated"); } if(jQuery.trim(old_region) != jQuery.trim(getState)){ jQuery('# option').remove(); if(jQuery("# option:contains('"+getCity+"')").length == 0){ jQuery("#").append(''); } jQuery('# option[value="'+getCity+'"]').attr("selected",true); jQuery("#").trigger("chosen:updated"); } if (getCountry){ jQuery('# option[value="'+getCountry+'"]').attr("selected",true); jQuery("#").trigger("chosen:updated"); } if(getZip){ if(getCountryISO=='SK'){geodir_region_fix(getCountryISO,getZip,''); } } if (getState){ if(jQuery("# option:contains('"+getState+"')").length == 0){ jQuery("#").append(''); } jQuery('# option[value="'+getState+'"]').attr("selected",true); jQuery("#").trigger("chosen:updated"); } if (getCity){ if(jQuery("# option:contains('"+getCity+"')").length == 0){ jQuery("#").append(''); } jQuery('# option[value="'+getCity+'"]').attr("selected",true); jQuery("#").trigger("chosen:updated"); jQuery('select.geodir_location_add_listing_chosen').each(function(){ if(jQuery(this).attr('id') == ''){ jQuery(this).change(); } }); } }else{ geodir_set_map_default_location('', '', ''); return false; } if(error){ geodir_set_map_default_location('', '', ''); return false; } if (getCity){ if(jQuery('input[id="hood_name"]').attr('id')){ //jQuery("#hood_name").val(getCity); } } //geodir_get_neighbourhood_dl(getCity);