Function Reference: geodir_location_address_extra_listing_fields
Summary
This is used to put country , region , city and neighbour dropdown on add/edit listing page.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $plugin_prefix
- (string) (required) Geodirectory plugin table prefix.
- Default: None
Package
GeoDirectory_Location_Manager
Parameters
- $val
- (array) (required) The array of setting for the custom field.
- Default: None
Change Log
Since: 1.0.0
Source File
geodir_location_address_extra_listing_fields() is located in geodir_location_manager/geodir_location_hooks_actions.php [Line: 2186]
Source Code
function geodir_location_address_extra_listing_fields($val) { $name = $val['name']; $site_title = $val['site_title']; $type = $val['type']; $admin_desc = $val['desc']; $option_values = $val['option_values']; $is_required = $val['is_required']; $is_default = $val['is_default']; $is_admin = $val['is_admin']; $required_msg = $val['required_msg']; $extra_fields = unserialize($val['extra_fields']); $prefix = $name.'_'; ($extra_fields['city_lable'] != '') ? $city_title = $extra_fields['city_lable'] : $city_title = ucwords($prefix.' city'); ($extra_fields['region_lable'] != '') ? $region_title = $extra_fields['region_lable'] : $region_title = ucwords($prefix.' region'); ($extra_fields['country_lable'] != '') ? $country_title = $extra_fields['country_lable'] : $country_title = ucwords($prefix.' country'); $city = ''; $region = ''; $country = ''; $neighbourhood = ''; if(isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && isset($_SESSION['listing']) ) { $post = unserialize($_SESSION['listing']); $city = $post[$prefix.'city']; $region = $post[$prefix.'region']; $country = $post[$prefix.'country']; $neighbourhood = isset($post[$prefix.'neighbourhood']) ? $post[$prefix.'neighbourhood'] : ''; } elseif( isset($_REQUEST['pid']) && $_REQUEST['pid']!='' && $post_info = geodir_get_post_info($_REQUEST['pid']) ) { $post_info = (array)$post_info; $city = $post_info[$prefix.'city']; $region = $post_info[$prefix.'region']; $country = $post_info[$prefix.'country']; if(isset($post_info[$prefix.'neighbourhood'])) $neighbourhood = $post_info[$prefix.'neighbourhood']; } elseif(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); $city = isset($location->city) ? $location->city : ''; $region = isset($location->region) ? $location->region : ''; $country = isset($location->country) ? $location->country : ''; } $location = geodir_get_default_location(); if(empty($city)) $city = isset($location->city) ? $location->city : ''; if(empty($region)) $region = isset($location->region) ? $location->region : ''; if(empty($country)) $country = isset($location->country) ? $location->country : ''; ?>get_var($wpdb->prepare("SELECT ISO2 FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country=%s",$country)); ?>>