Function Reference: geodir_get_custom_fields_type

Summary

Get custom fields info using listing post type.

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None

Package

GeoDirectory

Parameters

$listing_type
(string) (required) The listing post type.

Default: None

Return Values

(mixed|void|array)
  • custom fields info as an array.

Change Log

Since: 1.0.0

Filters

‘geodir_get_custom_fields_type’ [Line: 3105]

Source File

geodir_get_custom_fields_type() is located in geodirectory-functions/post_functions.php [Line: 3055]

Source Code

function geodir_get_custom_fields_type($listing_type = '')
{

    global $wpdb;

    if ($listing_type == '')
        $listing_type = 'gd_place';

    $fields_info = array();

    $get_data = $wpdb->get_results(
        $wpdb->prepare(
            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
            array($listing_type)
        )
    );

    if (!empty($get_data)) {

        foreach ($get_data as $data) {

            if ($data->field_type == 'address') {

                $extra_fields = unserialize($data->extra_fields);

                $prefix = $data->htmlvar_name . '_';

                $fields_info[$prefix . 'address'] = $data->field_type;

                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
                    $fields_info[$prefix . 'zip'] = $data->field_type;

            } else {

                $fields_info[$data->htmlvar_name] = $data->field_type;

            }

        }

    }

    /**
     * Filter to modify custom fields info using listing post type.
     *
     * @since 1.0.0
     * @package GeoDirectory
     * @return array $fields_info Custom fields info.
     * @param string $listing_type The listing post type.
     */
    return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
}