Function Reference: geodir_cfi_address

Summary

Get the html input for the custom field: address

Parameters

$html
(string) (required) The html to be filtered.

Default: None
$cf
(array) (required) The custom field array details.

Default: None

Return Values

(string)
  • The html to output for the custom field.

Change Log

Since: 1.6.6

Actions

‘geodir_address_extra_listing_fields’ [Line: 1095]

Filters

‘geodir_custom_field_input_address_{$html_var}’ [Line: 984]

‘geodir_default_latitude’ [Line: 1055]

‘geodir_default_longitude’ [Line: 1064]

Source File

geodir_cfi_address() is located in geodirectory-functions/custom_fields_input_functions.php [Line: 971]

Source Code

function geodir_cfi_address($html,$cf){

    $html_var = $cf['htmlvar_name'];

    // Check if there is a custom field specific filter.
    if(has_filter("geodir_custom_field_input_address_{$html_var}")){
        /**
         * Filter the address html by individual custom field.
         *
         * @param string $html The html to filter.
         * @param array $cf The custom field array.
         * @since 1.6.6
         */
        $html = apply_filters("geodir_custom_field_input_address_{$html_var}",$html,$cf);
    }

    // If no html then we run the standard output.
    if(empty($html)) {

        global $gd_session;
        ob_start(); // Start  buffering;
        $value = geodir_get_cf_value($cf);
        $name = $cf['name'];
        $type = $cf['type'];
        $admin_desc = $cf['desc'];
        $is_required = $cf['is_required'];
        $required_msg = $cf['required_msg'];
        $site_title = $cf['site_title'];
        $is_admin = $cf['is_admin'];
        $extra_fields = stripslashes_deep(unserialize($cf['extra_fields']));
        $prefix = $name . '_';

        ($site_title != '') ? $address_title = $site_title : $address_title = geodir_ucwords($prefix . ' address');
        ($extra_fields['zip_lable'] != '') ? $zip_title = $extra_fields['zip_lable'] : $zip_title = geodir_ucwords($prefix . ' zip/post code ');
        ($extra_fields['map_lable'] != '') ? $map_title = $extra_fields['map_lable'] : $map_title = geodir_ucwords('set address on map');
        ($extra_fields['mapview_lable'] != '') ? $mapview_title = $extra_fields['mapview_lable'] : $mapview_title = geodir_ucwords($prefix . ' mapview');

        $address = '';
        $zip = '';
        $mapview = '';
        $mapzoom = '';
        $lat = '';
        $lng = '';

        if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
            $post = $gd_ses_listing;
            $address = $post[$prefix . 'address'];
            $zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : '';
            $lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : '';
            $lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : '';
            $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : '';
            $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : '';
        } else if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $post_info = geodir_get_post_info($_REQUEST['pid'])) {
            $post_info = (array)$post_info;

            $address = $post_info[$prefix . 'address'];
            $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : '';
            $lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : '';
            $lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : '';
            $mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : '';
            $mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : '';
        }

        $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 : '';

        $lat_lng_blank = false;
        if (empty($lat) && empty($lng)) {
            $lat_lng_blank = true;
        }

        if (empty($lat)) $lat = isset($location->city_latitude) ? $location->city_latitude : '';
        if (empty($lng)) $lng = isset($location->city_longitude) ? $location->city_longitude : '';

        /**
         * Filter the default latitude.
         *
         * @since 1.0.0
         *
         * @param float $lat Default latitude.
         * @param bool $is_admin For admin use only?.
         */
        $lat = apply_filters('geodir_default_latitude', $lat, $is_admin);
        /**
         * Filter the default longitude.
         *
         * @since 1.0.0
         *
         * @param float $lat Default longitude.
         * @param bool $is_admin For admin use only?.
         */
        $lng = apply_filters('geodir_default_longitude', $lng, $is_admin);

        $locate_me = !empty($extra_fields['show_map']) && geodir_map_name() != 'none' ? true : false;
        $locate_me_class = $locate_me ? ' gd-form-control' : '';
        ?>
        
>
>
value="ROADMAP" size="25"/> value="SATELLITE" size="25"/> value="HYBRID" size="25"/> value="TERRAIN" size="25"/>