Example #1
0
function dt_geodir_add_custom_fields($fieldsets = array(), $fields = array(), $filters = array(), $fields_to_remove = array())
{
    // Field Set
    if (!empty($fieldsets)) {
        foreach ($fieldsets as $fieldset_index => $fieldset) {
            $check_geodir_field_set = dt_geodir_check_fieldset_exists($fieldset['site_title'], $fieldset['listing_type']);
            if (!$check_geodir_field_set) {
                geodir_custom_field_save($fieldset);
            }
        }
    }
    // Custom Fields
    if (!empty($fields)) {
        foreach ($fields as $field_index => $field) {
            $check_cf_exists = dt_geodir_check_custom_field_exists($field['htmlvar_name'], $field['listing_type']);
            if (!$check_cf_exists) {
                geodir_custom_field_save($field);
            }
        }
    }
    // Advance Search Filters
    if (!empty($filters) && function_exists('geodir_load_translation_geodiradvancesearch')) {
        foreach ($filters as $filter_index => $filter) {
            geodir_custom_advance_search_field_save($filter);
        }
    }
    // Fields to delete
    if (!empty($fields_to_remove)) {
        foreach ($fields_to_remove as $field_key => $field_names) {
            foreach ($field_names as $field_name) {
                dt_geodir_delete_custom_field($field_name, $field_key);
            }
        }
    }
}
 /**
  * Inserts default custom fields table data into database.
  *
  * @since 1.0.0
  * @package GeoDirectory
  */
 function geodir_create_default_fields()
 {
     $fields = array();
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'VARCHAR', 'field_type' => 'taxonomy', 'admin_title' => __('Category', 'geodirectory'), 'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'), 'site_title' => __('Category', 'geodirectory'), 'htmlvar_name' => 'gd_placecategory', 'default_value' => '', 'is_default' => '1', 'is_admin' => '1', 'is_required' => '1', 'clabels' => __('Category', 'geodirectory'));
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'VARCHAR', 'field_type' => 'address', 'admin_title' => __('Address', 'geodirectory'), 'admin_desc' => ADDRESS_MSG, 'site_title' => __('Address', 'geodirectory'), 'htmlvar_name' => 'post', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'is_required' => '1', 'required_msg' => __('Address fields are required', 'geodirectory'), 'clabels' => __('Address', 'geodirectory'), 'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'), 'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'), 'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'), 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'), 'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'), 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'), 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', 'show_latlng' => 1));
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'VARCHAR', 'field_type' => 'text', 'admin_title' => __('Time', 'geodirectory'), 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'), 'site_title' => __('Time', 'geodirectory'), 'htmlvar_name' => 'timing', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'clabels' => __('Time', 'geodirectory'));
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'VARCHAR', 'field_type' => 'phone', 'admin_title' => __('Phone', 'geodirectory'), 'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'), 'site_title' => __('Phone', 'geodirectory'), 'htmlvar_name' => 'contact', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'clabels' => __('Phone', 'geodirectory'));
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'VARCHAR', 'field_type' => 'email', 'admin_title' => __('Email', 'geodirectory'), 'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'), 'site_title' => __('Email', 'geodirectory'), 'htmlvar_name' => 'email', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'clabels' => __('Email', 'geodirectory'));
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'VARCHAR', 'field_type' => 'url', 'admin_title' => __('Website', 'geodirectory'), 'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'), 'site_title' => __('Website', 'geodirectory'), 'htmlvar_name' => 'website', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'clabels' => __('Website', 'geodirectory'));
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'VARCHAR', 'field_type' => 'url', 'admin_title' => __('Twitter', 'geodirectory'), 'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'), 'site_title' => __('Twitter', 'geodirectory'), 'htmlvar_name' => 'twitter', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'clabels' => __('Twitter', 'geodirectory'));
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'VARCHAR', 'field_type' => 'url', 'admin_title' => __('Facebook', 'geodirectory'), 'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'), 'site_title' => __('Facebook', 'geodirectory'), 'htmlvar_name' => 'facebook', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'clabels' => __('Facebook', 'geodirectory'));
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'TEXT', 'field_type' => 'textarea', 'admin_title' => __('Video', 'geodirectory'), 'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'), 'site_title' => __('Video', 'geodirectory'), 'htmlvar_name' => 'video', 'default_value' => '', 'option_values' => '', 'is_default' => '0', 'is_admin' => '1', 'clabels' => __('Video', 'geodirectory'));
     $fields[] = array('listing_type' => 'gd_place', 'data_type' => 'TEXT', 'field_type' => 'textarea', 'admin_title' => __('Special Offers', 'geodirectory'), 'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'), 'site_title' => __('Special Offers', 'geodirectory'), 'htmlvar_name' => 'special_offers', 'default_value' => '', 'option_values' => '', 'is_default' => '0', 'is_admin' => '1', 'clabels' => __('Special Offers', 'geodirectory'));
     /**
      * Filter the array of default custom fields DB table data.
      *
      * @since 1.0.0
      * @param string $fields The default custom fields as an array.
      */
     $fields = apply_filters('geodir_before_default_custom_fields_saved', $fields);
     foreach ($fields as $field_index => $field) {
         geodir_custom_field_save($field);
     }
 }
Example #3
0
/* ---- Save field  ---- */
if ($field_id != '' && $field_action == 'submit' && isset($_REQUEST['_wpnonce']) && isset($_REQUEST['create_field']) && isset($_REQUEST['manage_field_type']) && $_REQUEST['manage_field_type'] == 'custom_fields') {
    if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'custom_fields_' . $field_id)) {
        return;
    }
    foreach ($_REQUEST as $pkey => $pval) {
        if (is_array($_REQUEST[$pkey])) {
            $tags = 'skip_field';
        } else {
            $tags = '';
        }
        if ($tags != 'skip_field') {
            $_REQUEST[$pkey] = strip_tags($_REQUEST[$pkey], $tags);
        }
    }
    $return = geodir_custom_field_save($_REQUEST);
    if (is_int($return)) {
        $lastid = $return;
        geodir_custom_field_adminhtml($field_type, $lastid, 'submit');
    } else {
        echo $return;
    }
}
/* ---- Save sort field  ---- */
if ($field_id != '' && $field_action == 'submit' && isset($_REQUEST['_wpnonce']) && isset($_REQUEST['create_field']) && isset($_REQUEST['manage_field_type']) && $_REQUEST['manage_field_type'] == 'sorting_options') {
    if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'custom_fields_' . $field_id)) {
        return;
    }
    foreach ($_REQUEST as $pkey => $pval) {
        if (is_array($_REQUEST[$pkey])) {
            $tags = 'skip_field';
Example #4
0
function geodir_cp_create_default_fields($custom_post_type, $package_id = '')
{
    $fields = array();
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'VARCHAR', 'field_type' => 'taxonomy', 'admin_title' => __('Category', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => __('Select listing category from here. Select at least one category', GEODIR_CP_TEXTDOMAIN), 'site_title' => __('Category', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => $custom_post_type . 'category', 'default_value' => '', 'is_default' => '1', 'is_admin' => '1', 'is_required' => '1', 'show_on_pkg' => array($package_id), 'clabels' => __('Category', GEODIR_CP_TEXTDOMAIN));
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'VARCHAR', 'field_type' => 'address', 'admin_title' => __('Address', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => ADDRESS_MSG, 'site_title' => __('Address', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => 'post', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'show_on_pkg' => array($package_id), 'is_required' => '1', 'required_msg' => __('Address fields are required', GEODIR_CP_TEXTDOMAIN), 'clabels' => 'Address', 'extra' => array('show_city' => 1, 'city_lable' => __('City', GEODIR_CP_TEXTDOMAIN), 'show_region' => 1, 'region_lable' => __('Region', GEODIR_CP_TEXTDOMAIN), 'show_country' => 1, 'country_lable' => __('Country', GEODIR_CP_TEXTDOMAIN), 'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', GEODIR_CP_TEXTDOMAIN), 'show_map' => 1, 'map_lable' => __('Set Address On Map', GEODIR_CP_TEXTDOMAIN), 'show_mapview' => 1, 'mapview_lable' => __('Select Map View', GEODIR_CP_TEXTDOMAIN), 'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden', 'show_latlng' => 1));
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'VARCHAR', 'field_type' => 'text', 'admin_title' => __('Time', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', GEODIR_CP_TEXTDOMAIN), 'site_title' => __('Time', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => 'timing', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'show_on_pkg' => array($package_id), 'clabels' => __('Time', GEODIR_CP_TEXTDOMAIN));
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'VARCHAR', 'field_type' => 'phone', 'admin_title' => __('Phone', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => __('You can enter phone number,cell phone number etc.', GEODIR_CP_TEXTDOMAIN), 'site_title' => __('Phone', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => 'contact', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'show_on_pkg' => array($package_id), 'clabels' => __('Phone', GEODIR_CP_TEXTDOMAIN));
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'VARCHAR', 'field_type' => 'email', 'admin_title' => __('Email', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => __('You can enter your business or listing email.', GEODIR_CP_TEXTDOMAIN), 'site_title' => __('Email', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => 'email', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'show_on_pkg' => array($package_id), 'clabels' => __('Email', GEODIR_CP_TEXTDOMAIN));
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'VARCHAR', 'field_type' => 'url', 'admin_title' => __('Website', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => __('You can enter your business or listing website.', GEODIR_CP_TEXTDOMAIN), 'site_title' => __('Website', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => 'website', 'default_value' => '', 'is_default' => '1', 'is_admin' => '1', 'show_on_pkg' => array($package_id), 'clabels' => __('Website', GEODIR_CP_TEXTDOMAIN));
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'VARCHAR', 'field_type' => 'url', 'admin_title' => __('Twitter', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => __('You can enter your business or listing twitter url.', GEODIR_CP_TEXTDOMAIN), 'site_title' => __('Twitter', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => 'twitter', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'show_on_pkg' => array($package_id), 'clabels' => __('Twitter', GEODIR_CP_TEXTDOMAIN));
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'VARCHAR', 'field_type' => 'url', 'admin_title' => __('Facebook', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => __('You can enter your business or listing facebook url.', GEODIR_CP_TEXTDOMAIN), 'site_title' => __('Facebook', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => 'facebook', 'default_value' => '', 'option_values' => '', 'is_default' => '1', 'is_admin' => '1', 'show_on_pkg' => array($package_id), 'clabels' => __('Facebook', GEODIR_CP_TEXTDOMAIN));
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'TEXT', 'field_type' => 'textarea', 'admin_title' => __('Video', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => __('Add video code here, YouTube etc.', GEODIR_CP_TEXTDOMAIN), 'site_title' => __('Video', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => 'video', 'default_value' => '', 'option_values' => '', 'is_default' => '0', 'is_admin' => '1', 'show_on_pkg' => array($package_id), 'clabels' => __('Video', GEODIR_CP_TEXTDOMAIN));
    $fields[] = array('listing_type' => $custom_post_type, 'data_type' => 'TEXT', 'field_type' => 'textarea', 'admin_title' => __('Special Offers', GEODIR_CP_TEXTDOMAIN), 'admin_desc' => __('Note: List out any special offers (optional)', GEODIR_CP_TEXTDOMAIN), 'site_title' => __('Special Offers', GEODIR_CP_TEXTDOMAIN), 'htmlvar_name' => 'special_offers', 'default_value' => '', 'option_values' => '', 'is_default' => '0', 'is_admin' => '1', 'show_on_pkg' => array($package_id), 'clabels' => __('Special Offers', GEODIR_CP_TEXTDOMAIN));
    $fields = apply_filters('geodir_add_custom_field', $fields, $custom_post_type, $package_id);
    foreach ($fields as $field_index => $field) {
        geodir_custom_field_save($field);
    }
}