/** * Displays setting form for the given tab. * * @since 1.0.0 * @package GeoDirectory * @global array $geodir_settings Geodirectory settings array. * @global object $wpdb WordPress Database object. * @param string $tab_name Tab name. */ function geodir_admin_option_form($tab_name) { //echo $tab_name.'_array.php' ; global $geodir_settings, $is_default, $mapzoom; if (file_exists(dirname(__FILE__) . '/option-pages/' . $tab_name . '_array.php')) { /** * Contains settings array for given tab. * * @since 1.0.0 * @package GeoDirectory */ include_once 'option-pages/' . $tab_name . '_array.php'; } $listing_type = isset($_REQUEST['listing_type']) ? $_REQUEST['listing_type'] : ''; switch ($tab_name) { case 'general_settings': geodir_admin_fields($geodir_settings['general_settings']); /** * * Update Taxonomy Options * * **/ /*add_action('updated_option_place_prefix','update_listing_prefix'); function update_listing_prefix(){ geodir_register_defaults(); }*/ if (isset($_REQUEST['active_tab']) && ($_REQUEST['active_tab'] == 'dummy_data_settings' || $_REQUEST['active_tab'] == 'csv_upload_settings')) { $hide_save_button = "style='display:none;'"; } else { $hide_save_button = ''; } /** * Filter weather the default save button in the GD admin settings pages should be shown. * * @since 1.0.0 * @param string $hide_save_button The style element, either blank or: style='display:none;'. */ $hide_save_button = apply_filters('geodir_hide_save_button', $hide_save_button); ?> <p class="submit"> <input <?php echo $hide_save_button; ?> name="save" class="button-primary" type="submit" value="<?php _e('Save changes', 'geodirectory'); ?> " /> <input type="hidden" name="subtab" id="last_tab" /> </p> </div> <?php break; case 'design_settings': geodir_admin_fields($geodir_settings['design_settings']); ?> <p class="submit"> <input name="save" class="button-primary" type="submit" value="<?php _e('Save changes', 'geodirectory'); ?> " /> <input type="hidden" name="subtab" id="last_tab" /> </p> </div> <?php break; case 'permalink_settings': geodir_admin_fields($geodir_settings['permalink_settings']); ?> <p class="submit"> <input name="save" class="button-primary" type="submit" value="<?php _e('Save changes', 'geodirectory'); ?> " /> <input type="hidden" name="subtab" id="last_tab" /> </p> </div> <?php break; case 'title_meta_settings': geodir_admin_fields($geodir_settings['title_meta_settings']); ?> <p class="submit"> <input name="save" class="button-primary" type="submit" value="<?php _e('Save changes', 'geodirectory'); ?> " /> <input type="hidden" name="subtab" id="last_tab" /> </p> </div> <?php break; case 'notifications_settings': geodir_admin_fields($geodir_settings['notifications_settings']); ?> <p class="submit"> <input name="save" class="button-primary" type="submit" value="<?php _e('Save changes', 'geodirectory'); ?> " /> <input type="hidden" name="subtab" id="last_tab" /> </p> </div> <?php break; case 'default_location_settings': ?> <div class="inner_content_tab_main"> <div class="gd-content-heading"> <?php global $wpdb; $location_result = geodir_get_default_location(); $prefix = ''; $lat = isset($location_result->city_latitude) ? $location_result->city_latitude : ''; $lng = isset($location_result->city_longitude) ? $location_result->city_longitude : ''; $city = isset($location_result->city) ? $location_result->city : ''; $region = isset($location_result->region) ? $location_result->region : ''; $country = isset($location_result->country) ? $location_result->country : ''; $map_title = __("Set Address On Map", 'geodirectory'); ?> <h3><?php _e('Set Default Location', 'geodirectory'); ?> </h3> <input type="hidden" name="add_location" value="location"> <input type="hidden" name="update_city" value="<?php if (isset($location_result->location_id)) { echo $location_result->location_id; } ?> "> <input type="hidden" name="address" id="<?php echo $prefix; ?> address" value=""> <table class="form-table default_location_form"> <tbody> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('City', 'geodirectory'); ?> </th> <td class="forminp"> <div class="gtd-formfeild required"> <input class="require" type="text" size="80" style="width:440px" id="<?php echo $prefix; ?> city" name="city" value="<?php if (isset($location_result->city)) { echo $location_result->city; } ?> "/> <div class="gd-location_message_error"> <?php _e('This field is required.', 'geodirectory'); ?> </div> </div> <span class="description"></span> </td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Region', 'geodirectory'); ?> </th> <td class="forminp"> <div class="gtd-formfeild required"> <input class="require" type="text" size="80" style="width:440px" id="<?php echo $prefix; ?> region" name="region" value="<?php if (isset($location_result->region)) { echo $location_result->region; } ?> "/> <div class="gd-location_message_error"> <?php _e('This field is required.', 'geodirectory'); ?> </div> </div> <span class="description"></span> </td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Country', 'geodirectory'); ?> </th> <td class="forminp"> <div class="gtd-formfeild required" style="padding-top:10px;"> <?php $country_result = isset($location_result->country) ? $location_result->country : ''; ?> <select id="<?php echo $prefix; ?> country" class="chosen_select" data-location_type="country" name="<?php echo $prefix; ?> country" data-placeholder="<?php _e('Choose a country.', 'geodirectory'); ?> " data-addsearchtermonnorecord="1" data-ajaxchosen="0" data-autoredirect="0" data-showeverywhere="0"> <?php geodir_get_country_dl($country, $prefix); ?> </select> <div class="gd-location_message_error"><?php _e('This field is required.', 'geodirectory'); ?> </div> </div> <span class="description"></span> </td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Set Location on Map', 'geodirectory'); ?> </th> <td class="forminp"> <?php /** * Contains add listing page map functions. * * @since 1.0.0 */ include geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php"; ?> </td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('City Latitude', 'geodirectory'); ?> </th> <td class="forminp"> <div class="gtd-formfeild required" style="padding-top:10px;"> <input type="text" class="require" size="80" style="width:440px" id="<?php echo $prefix; ?> latitude" name="latitude" value="<?php if (isset($location_result->city_latitude)) { echo $location_result->city_latitude; } ?> "/> <div class="gd-location_message_error"><?php _e('This field is required.', 'geodirectory'); ?> </div> </div> <span class="description"></span> </td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('City Longitude', 'geodirectory'); ?> </th> <td class="forminp"> <div class="gtd-formfeild required" style="padding-top:10px;"> <input type="text" class="require" size="80" style="width:440px" id="<?php echo $prefix; ?> longitude" name="longitude" value="<?php if (isset($location_result->city_longitude)) { echo $location_result->city_longitude; } ?> "/> <div class="gd-location_message_error"><?php _e('This field is required.', 'geodirectory'); ?> </div> </div> <span class="description"></span> </td> </tr> <?php if (isset($location_result->location_id) && $location_result->location_id >= 0) { ?> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Action For Listing', 'geodirectory'); ?> </th> <td class="forminp"> <div class="gtd-formfeild" style="padding-top:10px;"> <input style="display:none;" type="radio" name="listing_action" checked="checked" value="delete"/> <label><?php _e('Post will be updated if both city and map marker position has been changed.', 'geodirectory'); ?> </label> </div> </td> </tr> <?php } ?> </tbody> </table> <p class="submit"> <input type="hidden" name="is_default" value="1"/> <input id="location_save" type="submit" value="Save changes" class="button-primary" name="save"> </p> </div> </div> <?php break; case $listing_type . '_fields_settings': geodir_custom_post_type_form(); break; case 'tools_settings': geodir_diagnostic_tools_setting_page(); break; case 'compatibility_settings': geodir_theme_compatibility_setting_page(); break; case 'import_export': geodir_import_export_page(); break; } // end of switch }
/** * This is used to put country , region , city and neighbour dropdown on add/edit listing page. * * @since 1.0.0 * @package GeoDirectory_Location_Manager * * @global object $wpdb WordPress Database object. * @global string $plugin_prefix Geodirectory plugin table prefix. * * @param array $val The array of setting for the custom field. */ 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 : ''; } ?> <div id="geodir_add_listing_all_chosen_container_row" class="geodir_location_add_listing_all_chosen_container" > <?php if (get_option('geodir_enable_country') == 'default') { global $wpdb; $countries_ISO2 = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", $country)); ?> <input type="hidden" name="geodir_location_add_listing_country_val" value="<?php echo $country; ?> " /> <input type="hidden" id="<?php echo $prefix; ?> country" data-country_code="<?php echo $countries_ISO2; ?> " name="<?php echo $prefix; ?> country" value="<?php echo $country; ?> " /> <?php } else { if ($extra_fields['show_country']) { ?> <div id="geodir_<?php echo $prefix . 'country'; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row geodir_location_add_listing_country_chosen_container clearfix"> <label> <?php _e($country_title, GEODIRLOCATION_TEXTDOMAIN); ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <div class="geodir_location_add_listing_country_chosen_div" style="width:57%; float:left;"> <input type="hidden" name="geodir_location_add_listing_country_val" value="<?php echo $country; ?> " /> <select id="<?php echo $prefix; ?> country" class="geodir_location_add_listing_chosen" data-location_type="country" name="<?php echo $prefix; ?> country" data-placeholder="<?php _e('Choose a country.', GEODIRLOCATION_TEXTDOMAIN); ?> " data-addsearchtermonnorecord="1" data-ajaxchosen="0" data-autoredirect="0" data-showeverywhere="0" > <?php if (get_option('geodir_enable_country') == 'multi') { geodir_get_country_dl($country, $prefix); } else { if (get_option('geodir_enable_country') == 'selected') { geodir_get_limited_country_dl($country, $prefix); } } ?> </select> </div> <span class="geodir_message_note"><?php _e('Click on above field and type to filter list', GEODIRLOCATION_TEXTDOMAIN); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php echo $required_msg; ?> </span> <?php } ?> </div> <?php } } // end of show country if if (get_option('geodir_enable_region') == 'default') { ?> <input type="hidden" name="geodir_location_add_listing_region_val" value="<?php echo $region; ?> " /> <input type="hidden" id="<?php echo $prefix; ?> region" name="<?php echo $prefix; ?> region" value="<?php echo $region; ?> " /> <?php } else { if ($extra_fields['show_region']) { ?> <div id="geodir_<?php echo $prefix . 'region'; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row geodir_location_add_listing_region_chosen_container clearfix"> <label> <?php _e($region_title, GEODIRLOCATION_TEXTDOMAIN); ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <div class="geodir_location_add_listing_region_chosen_div" style="width:57%; float:left;"> <input type="hidden" name="geodir_location_add_listing_region_val" value="<?php echo $region; ?> " /> <select id="<?php echo $prefix; ?> region" class="geodir_location_add_listing_chosen" data-location_type="region" name="<?php echo $prefix; ?> region" data-placeholder="<?php _e('Please wait..…', GEODIRLOCATION_TEXTDOMAIN); ?> " <?php if (get_option('geodir_enable_region') == 'selected') { ?> data-ajaxchosen="0" <?php } else { ?> data-ajaxchosen="1" <?php } ?> data-addsearchtermonnorecord="1" data-autoredirect="0" > <?php $selected = ''; $args = array('what' => 'region', 'country_val' => $country, 'region_val' => '', 'echo' => false, 'format' => array('type' => 'array')); if (get_option('location_dropdown_all')) { $args['no_of_records'] = '10000'; } // set limit to 10 thouseand as this is most browsers limit $location_array = geodir_get_location_array($args); // get country val in case of country search to get selected option ?> <option value='' ><?php _e('Select State', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <?php if (!empty($location_array)) { foreach ($location_array as $locations) { $selected = ''; if (strtolower($region) == strtolower($locations->region)) { $selected = " selected='selected' "; } ?> <option <?php echo $selected; ?> value="<?php echo $locations->region; ?> " ><?php echo ucwords($locations->region); ?> </option> <?php } } ?> </select> </div> <span class="geodir_message_note"><?php _e('Click on above field and type to filter list or add a new region', GEODIRLOCATION_TEXTDOMAIN); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php echo $required_msg; ?> </span> <?php } ?> </div> <?php } } //end of show region if (get_option('geodir_enable_city') == 'default') { ?> <input type="hidden" name="geodir_location_add_listing_city_val" value="<?php echo $city; ?> " /> <input type="hidden" id="<?php echo $prefix; ?> city" name="<?php echo $prefix; ?> city" value="<?php echo $city; ?> " /> <?php } else { if ($extra_fields['show_city']) { ?> <div id="geodir_<?php echo $prefix . 'city'; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row geodir_location_add_listing_city_chosen_container clearfix"> <label> <?php _e($city_title, GEODIRLOCATION_TEXTDOMAIN); ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <div class="geodir_location_add_listing_city_chosen_div" style="width:57%; float:left;"> <input type="hidden" name="geodir_location_add_listing_city_val" value="<?php echo $city; ?> " /> <select id="<?php echo $prefix; ?> city" class="geodir_location_add_listing_chosen" data-location_type="city" name="<?php echo $prefix; ?> city" data-placeholder="<?php _e('Please wait..…', GEODIRLOCATION_TEXTDOMAIN); ?> " <?php if (get_option('geodir_enable_city') == 'selected') { ?> data-ajaxchosen="0" <?php } else { ?> data-ajaxchosen="1" <?php } ?> data-addsearchtermonnorecord="1" data-autoredirect="0" > <?php $selected = ''; $args = array('what' => 'city', 'country_val' => $country, 'region_val' => $region, 'echo' => false, 'format' => array('type' => 'array')); if (get_option('location_dropdown_all')) { $args['no_of_records'] = '10000'; } // set limit to 10 thouseand as this is most browsers limit $location_array = geodir_get_location_array($args); // get country val in case of country search to get selected option ?> <option value='' ><?php _e('Select City', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <?php if (!empty($location_array)) { foreach ($location_array as $locations) { $selected = ''; if (strtolower($city) == strtolower($locations->city)) { $selected = " selected='selected' "; } ?> <option <?php echo $selected; ?> value="<?php echo $locations->city; ?> " ><?php echo ucwords($locations->city); ?> </option> <?php } } ?> </select> </div> <span class="geodir_message_note"><?php _e('Click on above field and type to filter list or add a new city', GEODIRLOCATION_TEXTDOMAIN); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php echo $required_msg; ?> </span> <?php } ?> </div> <?php } } // end of show city if if (get_option('location_neighbourhoods') && $is_admin == '1') { global $plugin_prefix; $neighbourhood_options = geodir_get_neighbourhoods_dl(esc_attr(stripslashes($city)), $neighbourhood, false); $neighbourhood_display = ''; if (trim($neighbourhood_options) == '') { $neighbourhood_display = 'style="display:none;"'; } ?> <div id="geodir_<?php echo $prefix . 'neighbourhood'; ?> _row" class="geodir_form_row geodir_location_add_listing_neighbourhood_chosen_container clearfix" <?php echo $neighbourhood_display; ?> > <label><?php _e('Neighbourhood', GEODIRLOCATION_TEXTDOMAIN); ?> </label> <div class="geodir_location_add_listing_neighbourhood_chosen_div" style="width:57%; float:left;"> <select name="<?php echo $prefix . 'neighbourhood'; ?> " class="chosen_select" option-ajaxChosen="false" > <?php echo $neighbourhood_options; ?> </select> </div> <span class="geodir_message_note"><?php _e('Click on above field and type to filter list', GEODIRLOCATION_TEXTDOMAIN); ?> </span> </div> <?php } ?> </div ><!-- end of geodir_location_add_listing_all_chosen_container --> <?php }
<?php $location_result_country = isset($location_result->country) ? $location_result->country : ''; ?> <select id="<?php echo $prefix; ?> country" class="chosen_select"data-location_type="country" name="<?php echo $prefix; ?> country" data-placeholder="<?php _e('Choose a country.', GEODIRLOCATION_TEXTDOMAIN); ?> " data-addsearchtermonnorecord="1" data-ajaxchosen="0" data-autoredirect="0" data-showeverywhere="0" > <?php geodir_get_country_dl($location_result_country, $prefix); ?> <div class="gd-location_message_error"><?php echo GD_LOCATION_FIELD_REQ; ?> </div> <span class="description"></span> </td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"> </th> <td class="forminp"> <div class="gtd-formfeild"> <?php