当前位置: 首页>>代码示例>>PHP>>正文


PHP geodir_get_default_location函数代码示例

本文整理汇总了PHP中geodir_get_default_location函数的典型用法代码示例。如果您正苦于以下问题:PHP geodir_get_default_location函数的具体用法?PHP geodir_get_default_location怎么用?PHP geodir_get_default_location使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了geodir_get_default_location函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: geodir_location_action_listings_description

/**
 * Adds listing description to the page.
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 *
 * @global object $wpdb WordPress Database object.
 * @global object $wp_query WordPress Query object.
 */
function geodir_location_action_listings_description()
{
    global $wpdb, $wp_query;
    $current_term = $wp_query->get_queried_object();
    $gd_post_type = geodir_get_current_posttype();
    if (isset($current_term->term_id) && $current_term->term_id != '') {
        $term_desc = term_description($current_term->term_id, $gd_post_type . '_tags');
        $saved_data = stripslashes(get_tax_meta($current_term->term_id, 'ct_cat_top_desc', false, $gd_post_type));
        if ($term_desc && !$saved_data) {
            $saved_data = $term_desc;
        }
        $default_location = geodir_get_default_location();
        $location_type = geodir_what_is_current_location();
        $replace_location = __('Everywhere', GEODIRLOCATION_TEXTDOMAIN);
        $gd_country = get_query_var('gd_country');
        $gd_region = get_query_var('gd_region');
        $gd_city = get_query_var('gd_city');
        $current_location = '';
        if ($gd_country != '') {
            $location_type = 'country';
            $current_location = get_actual_location_name('country', $gd_country, true);
        }
        if ($gd_region != '') {
            $location_type = 'region';
            $current_location = get_actual_location_name('region', $gd_region);
        }
        if ($gd_city != '') {
            $location_type = 'city';
            $current_location = get_actual_location_name('city', $gd_city);
        }
        if ($location_type == 'city') {
            $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
            $option_name = 'geodir_cat_loc_' . $gd_post_type . '_' . $current_term->term_id;
            $cat_loc_option = get_option($option_name);
            $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
            if (!$gd_cat_loc_default && $gd_city != '') {
                $post_type = $gd_post_type;
                $term_id = $current_term->term_id;
                $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
                $location_id = $wpdb->get_var($sql);
                if ($location_id > 0) {
                    $option_name = 'geodir_cat_loc_' . $post_type . '_' . $term_id . '_' . $location_id;
                    $option = get_option($option_name);
                    $gd_cat_loc_desc = !empty($option) && isset($option['gd_cat_loc_desc']) ? trim($option['gd_cat_loc_desc']) : '';
                    if ($gd_cat_loc_desc != '') {
                        $saved_data = stripslashes_deep($gd_cat_loc_desc);
                    }
                }
            }
        } else {
            if ($location_type == 'region') {
                $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
            } else {
                if ($location_type == 'country') {
                    $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
                    $replace_location = __($replace_location, GEODIRECTORY_TEXTDOMAIN);
                }
            }
        }
        $replace_location = $current_location != '' ? $current_location : $replace_location;
        $saved_data = str_replace('%location%', $replace_location, $saved_data);
        $cat_description = apply_filters('the_content', $saved_data);
        if ($cat_description) {
            echo '<div class="term_description">' . $cat_description . '</div>';
        }
    }
}
开发者ID:poweronio,项目名称:mbsite,代码行数:76,代码来源:geodir_location_hooks_actions.php

示例2: apply_filters

 * Filter the map restriction for specific address only
 *
 * @since 1.0.0
 *
 * @param bool $var Whether to ristrict the map for specific address only.
 */
$is_map_restrict = apply_filters('geodir_add_listing_map_restrict', true);
/**
 * Filter the auto change address fields values when moving the map pin
 *
 * @since 1.4.8
 *
 * @param bool $var Whether to change the country, state, city values in fields.
 */
$auto_change_address_fields_pin_move = apply_filters('geodir_auto_change_address_fields_pin_move', true);
$default_location = geodir_get_default_location();
$defaultcity = isset($default_location->city) ? $default_location->city : '';
$lat_lng_blank = false;
if ($lat == '' && $lng == '') {
    $lat_lng_blank = true;
    $city = $defaultcity;
    $region = isset($default_location->region) ? $default_location->region : '';
    $country = isset($default_location->country) ? $default_location->country : '';
    $lng = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
    $lat = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
}
$default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
$default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
if (is_admin() && isset($_REQUEST['tab']) && $mapzoom == '') {
    $mapzoom = 4;
    if (isset($_REQUEST['add_hood'])) {
开发者ID:bangjojo,项目名称:wp,代码行数:31,代码来源:map_on_add_listing_page.php

示例3: geodir_ajax_import_csv


//.........这里部分代码省略.........
                            if (!empty($buffer[$c])) {
                                $image_names[] = $buffer[$c];
                            }
                        }
                        if ($customKeyarray[$c] == 'alive_days') {
                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
                                $submitdata = date('Y-m-d');
                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
                            } else {
                                $gd_post_info['expire_date'] = 'Never';
                            }
                        }
                        if ($customKeyarray[$c] == 'post_city') {
                            $post_city = addslashes($buffer[$c]);
                        }
                        if ($customKeyarray[$c] == 'post_region') {
                            $post_region = addslashes($buffer[$c]);
                        }
                        if ($customKeyarray[$c] == 'post_country') {
                            $post_country = addslashes($buffer[$c]);
                        }
                        if ($customKeyarray[$c] == 'post_latitude') {
                            $post_latitude = addslashes($buffer[$c]);
                        }
                        if ($customKeyarray[$c] == 'post_longitude') {
                            $post_longitude = addslashes($buffer[$c]);
                        }
                        // Post status
                        if ($customKeyarray[$c] == 'post_status') {
                            $post_status = sanitize_key($buffer[$c]);
                        }
                    }
                    /* ================ before array create ============== */
                    $location_result = geodir_get_default_location();
                    if (!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '' || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
                        $blank_address++;
                        continue;
                    } else {
                        if ($location_result->location_id == 0) {
                            if (geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city) || geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region) || geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country)) {
                                $address_invalid++;
                                continue;
                            }
                        }
                    }
                    // Default post status
                    $default_status = 'publish';
                    $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
                    $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
                    $my_post['post_title'] = $post_title;
                    $my_post['post_content'] = $post_desc;
                    $my_post['post_type'] = addslashes($buffer[5]);
                    $my_post['post_author'] = $current_post_author;
                    $my_post['post_status'] = $post_status;
                    $my_post['post_category'] = $catids_arr;
                    $my_post['post_tags'] = $tag_arr;
                    $gd_post_info['post_tags'] = $tag_arr;
                    $gd_post_info['post_title'] = $post_title;
                    $gd_post_info['post_status'] = $post_status;
                    $gd_post_info['submit_time'] = time();
                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
                    $last_postid = wp_insert_post($my_post);
                    $countpost++;
                    // Check if we need to save post location as new location
                    if ($location_result->location_id > 0) {
                        if (isset($post_city) && isset($post_region)) {
开发者ID:kkoppenhaver,项目名称:geodirectory,代码行数:67,代码来源:admin_hooks_actions.php

示例4: widget

        /**
         *
         * @global object $wpdb WordPress Database object.
         *
         * @param array $args
         * @param array $instance
         */
        public function widget($args, $instance)
        {
            extract($args, EXTR_SKIP);
            echo $before_widget;
            $title = empty($instance['title']) ? $instance['category_title'] : apply_filters('widget_title', $instance['title']);
            $hood_post_type = empty($instance['hood_post_type']) ? 'gd_place' : apply_filters('widget_hood_post_type', $instance['hood_post_type']);
            $hood_category = empty($instance['hood_category']) ? '0' : apply_filters('widget_hood_category', $instance['hood_category']);
            $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
            $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
            $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_layout', $instance['add_location_filter']);
            $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
            $character_count = empty($instance['character_count']) ? 20 : apply_filters('widget_list_sort', $instance['character_count']);
            if (empty($title) || $title == 'All') {
                $title .= ' Neighbourhood ' . get_post_type_plural_label($hood_post_type);
            }
            global $wpdb, $post, $geodir_post_type;
            if ($geodir_post_type == '') {
                $geodir_post_type = 'gd_place';
            }
            $all_postypes = geodir_get_posttypes();
            $location_id = '';
            $not_in_array = array();
            if (geodir_is_page('detail') || geodir_is_page('preview') || geodir_is_page('add-listing')) {
                if (isset($post->post_type) && $post->post_type == $hood_post_type && isset($post->post_location_id)) {
                    $not_in_array[] = $post->ID;
                    $location_id = $post->post_location_id;
                }
            } elseif (in_array($geodir_post_type, $all_postypes) && $geodir_post_type == $hood_post_type) {
                if (isset($_SESSION['gd_city']) && $_SESSION['gd_city'] != '') {
                    $location_id = $wpdb->get_var($wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug = %s", array($_SESSION['gd_city'])));
                } else {
                    $default_location = geodir_get_default_location();
                    $location_id = $default_location->location_id;
                }
            }
            $gd_neighbourhoods = geodir_get_neighbourhoods($location_id);
            if ($gd_neighbourhoods) {
                ?>
			
			<div class="geodir_locations geodir_location_listing">
						<div class="locatin_list_heading clearfix">
							<h3><?php 
                _e(ucfirst($title), GEODIRLOCATION_TEXTDOMAIN);
                ?>
</h3>
						</div>
						
						<?php 
                $hood_slug_arr = array();
                if (!empty($gd_neighbourhoods)) {
                    foreach ($gd_neighbourhoods as $hoodslug) {
                        $hood_slug_arr[] = $hoodslug->hood_slug;
                    }
                }
                $query_args = array('posts_per_page' => $post_number, 'is_geodir_loop' => true, 'post__not_in' => $not_in_array, 'gd_neighbourhood' => $hood_slug_arr, 'gd_location' => $add_location_filter ? true : false, 'post_type' => $hood_post_type, 'order_by' => $list_sort, 'excerpt_length' => $character_count);
                if ($hood_category != 0 || $hood_category != '') {
                    $category_taxonomy = geodir_get_taxonomies($hood_post_type);
                    $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $hood_category);
                    $query_args['tax_query'] = array($tax_query);
                }
                global $gridview_columns;
                query_posts($query_args);
                if (strstr($layout, 'gridview')) {
                    $listing_view_exp = explode('_', $layout);
                    $gridview_columns = $layout;
                    $layout = $listing_view_exp[0];
                }
                $template = apply_filters("geodir_template_part-listing-listview", geodir_plugin_path() . '/geodirectory-templates/listing-listview.php');
                include $template;
                wp_reset_query();
                ?>
				
						 
					</div>
			
			<?php 
            }
            echo $after_widget;
        }
开发者ID:poweronio,项目名称:mbsite,代码行数:86,代码来源:geodir_location_widgets.php

示例5: dt_geodir_dummy_content_generator

function dt_geodir_dummy_content_generator($post_infos = array())
{
    global $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2;
    if (empty($post_infos)) {
        return;
    }
    foreach ($post_infos as $post_info) {
        $default_location = geodir_get_default_location();
        if ($city_bound_lat1 > $city_bound_lat2) {
            $dummy_post_latitude = geodir_random_float(geodir_random_float($city_bound_lat1, $city_bound_lat2), geodir_random_float($city_bound_lat2, $city_bound_lat1));
        } else {
            $dummy_post_latitude = geodir_random_float(geodir_random_float($city_bound_lat2, $city_bound_lat1), geodir_random_float($city_bound_lat1, $city_bound_lat2));
        }
        if ($city_bound_lng1 > $city_bound_lng2) {
            $dummy_post_longitude = geodir_random_float(geodir_random_float($city_bound_lng1, $city_bound_lng2), geodir_random_float($city_bound_lng2, $city_bound_lng1));
        } else {
            $dummy_post_longitude = geodir_random_float(geodir_random_float($city_bound_lng2, $city_bound_lng1), geodir_random_float($city_bound_lng1, $city_bound_lng2));
        }
        $postal_code = '';
        $address = '';
        $post_address = geodir_get_address_by_lat_lan($dummy_post_latitude, $dummy_post_longitude);
        if (!empty($post_address)) {
            foreach ($post_address as $add_key => $add_value) {
                if ($add_value->types[0] == 'postal_code') {
                    $postal_code = $add_value->long_name;
                }
                if ($add_value->types[0] == 'street_number') {
                    if ($address != '') {
                        $address .= ',' . $add_value->long_name;
                    } else {
                        $address .= $add_value->long_name;
                    }
                }
                if ($add_value->types[0] == 'route') {
                    if ($address != '') {
                        $address .= ',' . $add_value->long_name;
                    } else {
                        $address .= $add_value->long_name;
                    }
                }
                if ($add_value->types[0] == 'neighborhood') {
                    if ($address != '') {
                        $address .= ',' . $add_value->long_name;
                    } else {
                        $address .= $add_value->long_name;
                    }
                }
                if ($add_value->types[0] == 'sublocality') {
                    if ($address != '') {
                        $address .= ',' . $add_value->long_name;
                    } else {
                        $address .= $add_value->long_name;
                    }
                }
            }
            $post_info['post_address'] = $address;
            $post_info['post_city'] = $default_location->city;
            $post_info['post_region'] = $default_location->region;
            $post_info['post_country'] = $default_location->country;
            $post_info['post_zip'] = $postal_code;
            $post_info['post_latitude'] = $dummy_post_latitude;
            $post_info['post_longitude'] = $dummy_post_longitude;
        }
        geodir_save_listing($post_info, true);
    }
}
开发者ID:mistergiri,项目名称:directory-starter,代码行数:66,代码来源:dummy.php

示例6: geodir_sc_listing_map

/**
 * The geodirectory listing map shortcode.
 *
 * This implements the functionality of the shortcode for displaying listing map.
 *
 * @since 1.0.0
 * @since 1.5.2 Added TERRAIN for $maptype attribute.
 * @package GeoDirectory
 * @global object $post The current post object.
 * @param array $atts {
 *     Attributes of the shortcode.
 *
 *     @type string $width           Map width in pixels. Default 294.
 *     @type string $height          Map height in pixels. Default 370.
 *     @type string $maptype         Map type. Default ROADMAP. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN.
 *     @type string $zoom            The zoom level of the map. Between 1-19. Default 13.
 *     @type string $autozoom        True if the map should autozoom, false if not.
 *     @type bool   $sticky          True if should be sticky, false if not
 *     @type string $showall         Show all listings on map? (not just page list). Default 0.
 *     @type string $child_collapse  True if the map should collapse the categories, false if not.
 *     @type string $scrollwheel     True to allow scroll wheel to scroll map or false if not.
 *     @type bool   $marker_cluster  Enable marker cluster? Default: false.
 *
 * }
 * @return string Map HTML.
 */
function geodir_sc_listing_map($atts)
{
    ob_start();
    add_action('wp_head', 'init_listing_map_script');
    // Initialize the map object and marker array
    add_action('the_post', 'create_list_jsondata');
    // Add marker in json array
    add_action('wp_footer', 'show_listing_widget_map');
    // Show map for listings with markers
    $defaults = array('width' => '294', 'height' => '370', 'zoom' => '13', 'autozoom' => '', 'sticky' => '', 'showall' => '0', 'scrollwheel' => '0', 'maptype' => 'ROADMAP', 'child_collapse' => 0, 'marker_cluster' => false);
    $params = shortcode_atts($defaults, $atts);
    $params = gdsc_validate_map_args($params);
    $map_args = array('map_canvas_name' => 'gd_listing_map', 'width' => $params['width'], 'height' => $params['height'], 'zoom' => $params['zoom'], 'autozoom' => $params['autozoom'], 'sticky' => $params['sticky'], 'showall' => $params['showall'], 'scrollwheel' => $params['scrollwheel'], 'child_collapse' => 0, 'enable_cat_filters' => false, 'enable_text_search' => false, 'enable_post_type_filters' => false, 'enable_location_filters' => false, 'enable_jason_on_load' => true);
    if (is_single()) {
        global $post;
        $map_default_lat = $address_latitude = $post->post_latitude;
        $map_default_lng = $address_longitude = $post->post_longitude;
        $mapview = $post->post_mapview;
        $map_args['zoom'] = $post->post_mapzoom;
        $map_args['map_class_name'] = 'geodir-map-listing-page-single';
    } else {
        $default_location = geodir_get_default_location();
        $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
        $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
        $map_args['map_class_name'] = 'geodir-map-listing-page';
    }
    if (empty($mapview)) {
        $mapview = 'ROADMAP';
    }
    // Set default map options
    $map_args['ajax_url'] = geodir_get_ajax_url();
    $map_args['latitude'] = $map_default_lat;
    $map_args['longitude'] = $map_default_lng;
    $map_args['streetViewControl'] = true;
    $map_args['maptype'] = $mapview;
    $map_args['showPreview'] = '0';
    $map_args['maxZoom'] = 21;
    $map_args['bubble_size'] = 'small';
    // Add marker cluster
    if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) {
        $map_args['enable_marker_cluster'] = true;
    } else {
        $map_args['enable_marker_cluster'] = false;
    }
    geodir_draw_map($map_args);
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
开发者ID:bangjojo,项目名称:wp,代码行数:75,代码来源:geodirectory_shortcodes.php

示例7: geodir_admin_option_form


//.........这里部分代码省略.........
            ?>
            <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 
开发者ID:kkoppenhaver,项目名称:geodirectory,代码行数:67,代码来源:admin_template_tags.php

示例8: geodir_sc_popular_in_neighbourhood

/**
 *
 * @global object $wpdb WordPress Database object.
 *
 * @param $atts
 * @return string
 */
function geodir_sc_popular_in_neighbourhood($atts)
{
    ob_start();
    $defaults = array('post_type' => 'gd_place', 'category' => '0', 'list_sort' => 'latest', 'post_number' => 5, 'layout' => 'gridview_onehalf', 'character_count' => 20, 'add_location_filter' => 1);
    $params = shortcode_atts($defaults, $atts);
    /**
     * Being validating $params
     */
    // Check we have a valid post_type
    if (!gdsc_is_post_type_valid($params['post_type'])) {
        $params['post_type'] = 'gd_place';
    }
    // Manage the entered categories
    if (0 != $params['category'] || '' != $params['category']) {
        $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']);
    }
    // Validate our sorting choice
    $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']);
    // Post_number needs to be a positive integer
    $params['post_number'] = absint($params['post_number']);
    if (0 == $params['post_number']) {
        $params['post_number'] = 1;
    }
    // Validate our layout choice
    // Outside of the norm, I added some more simple terms to match the existing
    // So now I just run the switch to set it properly.
    $params['layout'] = gdsc_validate_layout_choice($params['layout']);
    // Validate character_count
    $params['character_count'] = absint($params['character_count']);
    if (20 > $params['character_count']) {
        $params['character_count'] = 20;
    }
    /**
     * End validation
     */
    global $wpdb, $post, $geodir_post_type;
    if ($geodir_post_type == '') {
        $geodir_post_type = 'gd_place';
    }
    $all_postypes = geodir_get_posttypes();
    $location_id = '';
    $not_in_array = array();
    if (geodir_is_page('detail') || geodir_is_page('preview') || geodir_is_page('add-listing')) {
        if (isset($post->post_type) && $post->post_type == $params['post_type'] && isset($post->post_location_id)) {
            $not_in_array[] = $post->ID;
            $location_id = $post->post_location_id;
        }
    } elseif (in_array($geodir_post_type, $all_postypes) && $geodir_post_type == $params['post_type']) {
        if (isset($_SESSION['gd_city']) && $_SESSION['gd_city'] != '') {
            $location_id = $wpdb->get_var($wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug = %s", array($_SESSION['gd_city'])));
        } else {
            $default_location = geodir_get_default_location();
            $location_id = $default_location->location_id;
        }
    }
    $gd_neighbourhoods = geodir_get_neighbourhoods($location_id);
    if ($gd_neighbourhoods) {
        ?>

		<div class="geodir_locations geodir_location_listing">
			<?php 
        $hood_slug_arr = array();
        if (!empty($gd_neighbourhoods)) {
            foreach ($gd_neighbourhoods as $hoodslug) {
                $hood_slug_arr[] = $hoodslug->hood_slug;
            }
        }
        $query_args = array('posts_per_page' => $params['post_number'], 'is_geodir_loop' => true, 'post__not_in' => $not_in_array, 'gd_neighbourhood' => $hood_slug_arr, 'gd_location' => $params['add_location_filter'] ? true : false, 'post_type' => $params['post_type'], 'order_by' => $params['list_sort'], 'excerpt_length' => $params['character_count']);
        if ($params['category'] != 0 || $params['category'] != '') {
            $category_taxonomy = geodir_get_taxonomies($params['post_type']);
            $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $params['category']);
            $query_args['tax_query'] = array($tax_query);
        }
        global $gridview_columns;
        query_posts($query_args);
        if (strstr($params['layout'], 'gridview')) {
            $listing_view_exp = explode('_', $params['layout']);
            $gridview_columns = $params['layout'];
            $layout = $listing_view_exp[0];
        }
        $template = apply_filters("geodir_template_part-listing-listview", geodir_plugin_path() . '/geodirectory-templates/listing-listview.php');
        include $template;
        wp_reset_query();
        ?>

		</div>

	<?php 
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
开发者ID:poweronio,项目名称:mbsite,代码行数:100,代码来源:geodir_location_shortcodes.php

示例9: geodir_get_location_array

/**
 * Get location array using arguments.
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 *
 * @global object $wpdb WordPress Database object.
 *
 * @param null|array $args {
 *    Attributes of args.
 *
 *    @type string $what What do you want to query. Possible values: city, region, country. Default: 'city'.
 *    @type string $city_val City value.
 *    @type string $region_val Region value.
 *    @type string $country_val Country value.
 *    @type string $country_non_restricted Non restricted countries.
 *    @type string $region_non_restricted Non restricted regions.
 *    @type string $city_non_restricted Non restricted cities.
 *    @type bool $filter_by_non_restricted Filter by non restricted?.
 *    @type string $compare_operator Comparison operator.
 *    @type string $country_column_name Country column name.
 *    @type string $region_column_name Region column name.
 *    @type string $city_column_name City column name.
 *    @type bool $location_link_part Location link part.
 *    @type string $order_by Order by value.
 *    @type string $no_of_records No of records to return.
 *    @type string $spage Current page number.
 *    @type array $format {
 *        Attributes of format.
 *
 *        @type string $type Type. Default: 'list'.
 *        @type string $container_wrapper Container wrapper. Default: 'ul'.
 *        @type string $container_wrapper_attr Container wrapper attr.
 *        @type string $item_wrapper Item wrapper. Default: 'li'.
 *        @type string $item_wrapper_attr Item wrapper attr.
 *
 *    }
 *
 * }
 * @param bool $switcher Todo: describe this part.
 * @return array|mixed|string
 */
function geodir_get_location_array($args = null, $switcher = false)
{
    global $wpdb;
    $defaults = array('what' => 'city', 'city_val' => '', 'region_val' => '', 'country_val' => '', 'country_non_restricted' => '', 'region_non_restricted' => '', 'city_non_restricted' => '', 'filter_by_non_restricted' => true, 'compare_operator' => 'like', 'country_column_name' => 'country', 'region_column_name' => 'region', 'city_column_name' => 'city', 'location_link_part' => true, 'order_by' => 'asc', 'no_of_records' => '', 'spage' => '', 'format' => array('type' => 'list', 'container_wrapper' => 'ul', 'container_wrapper_attr' => '', 'item_wrapper' => 'li', 'item_wrapper_attr' => ''));
    $location_args = wp_parse_args($args, $defaults);
    $search_query = '';
    $location_link_column = '';
    $location_default = geodir_get_default_location();
    if ($location_args['filter_by_non_restricted']) {
        // Non restricted countries
        if ($location_args['country_non_restricted'] == '') {
            if (get_option('geodir_enable_country') == 'default') {
                $country_non_retsricted = isset($location_default->country) ? $location_default->country : '';
                $location_args['country_non_restricted'] = $country_non_retsricted;
            } else {
                if (get_option('geodir_enable_country') == 'selected') {
                    $country_non_retsricted = get_option('geodir_selected_countries');
                    if (!empty($country_non_retsricted) && is_array($country_non_retsricted)) {
                        $country_non_retsricted = implode(',', $country_non_retsricted);
                    }
                    $location_args['country_non_restricted'] = $country_non_retsricted;
                }
            }
            $location_args['country_non_restricted'] = geodir_parse_location_list($location_args['country_non_restricted']);
        }
        //Non restricted Regions
        if ($location_args['region_non_restricted'] == '') {
            if (get_option('geodir_enable_region') == 'default') {
                $regoin_non_restricted = isset($location_default->region) ? $location_default->region : '';
                $location_args['region_non_restricted'] = $regoin_non_restricted;
            } else {
                if (get_option('geodir_enable_region') == 'selected') {
                    $regoin_non_restricted = get_option('geodir_selected_regions');
                    if (!empty($regoin_non_restricted) && is_array($regoin_non_restricted)) {
                        $regoin_non_restricted = implode(',', $regoin_non_restricted);
                    }
                    $location_args['region_non_restricted'] = $regoin_non_restricted;
                }
            }
            $location_args['region_non_restricted'] = geodir_parse_location_list($location_args['region_non_restricted']);
        }
        //Non restricted cities
        if ($location_args['city_non_restricted'] == '') {
            if (get_option('geodir_enable_city') == 'default') {
                $city_non_retsricted = isset($location_default->city) ? $location_default->city : '';
                $location_args['city_non_restricted'] = $city_non_retsricted;
            } else {
                if (get_option('geodir_enable_city') == 'selected') {
                    $city_non_restricted = get_option('geodir_selected_cities');
                    if (!empty($city_non_restricted) && is_array($city_non_restricted)) {
                        $city_non_restricted = implode(',', $city_non_restricted);
                    }
                    $location_args['city_non_restricted'] = $city_non_restricted;
                }
            }
            $location_args['city_non_restricted'] = geodir_parse_location_list($location_args['city_non_restricted']);
        }
    }
//.........这里部分代码省略.........
开发者ID:poweronio,项目名称:mbsite,代码行数:101,代码来源:geodir_location_functions.php

示例10: geodir_set_location_var_in_session_in_core

/**
 * Add the location variables in session.
 *
 * @since 1.0.0
 *
 * @param object $wp The WordPress object.
 */
function geodir_set_location_var_in_session_in_core($wp)
{
    //$wp->geodir_query_vars = $wp->query_vars ;
    // this code will determine when a user wants to switch location
    // Query Vars will have page_id parameter
    // check if query var has page_id and that page id is location page
    geodir_set_is_geodir_page($wp);
    if (!get_option('geodir_set_as_home')) {
        if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
            if ('page' == get_option('show_on_front')) {
                $wp->query_vars['page_id'] = get_option('page_on_front');
            }
        }
    }
    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
        $gd_country = '';
        $gd_region = '';
        $gd_city = '';
        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') {
            $gd_country = urldecode($wp->query_vars['gd_country']);
        }
        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') {
            $gd_region = urldecode($wp->query_vars['gd_region']);
        }
        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') {
            $gd_city = urldecode($wp->query_vars['gd_city']);
        }
        if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
            $default_location = geodir_get_default_location();
            if (get_option('geodir_add_location_url')) {
                if (get_option('geodir_show_location_url') != 'all') {
                    if ($gd_region == '') {
                        if (isset($_SESSION['gd_region'])) {
                            $gd_region = $_SESSION['gd_region'];
                        } else {
                            $gd_region = $default_location->region_slug;
                        }
                    }
                    if ($gd_city == '') {
                        if (isset($_SESSION['gd_city'])) {
                            $gd_city = $_SESSION['gd_city'];
                        } else {
                            $gd_city = $default_location->city_slug;
                        }
                        $base_location_link = geodir_get_location_link('base');
                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
                        exit;
                    }
                }
            }
            $args = array('what' => 'city', 'city_val' => $gd_city, 'region_val' => $gd_region, 'country_val' => $gd_country, 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => '');
            $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
            if (!empty($location_array)) {
                $_SESSION['gd_multi_location'] = 1;
                $_SESSION['gd_country'] = $gd_country;
                $_SESSION['gd_region'] = $gd_region;
                $_SESSION['gd_city'] = $gd_city;
                $wp->query_vars['gd_country'] = $gd_country;
                $wp->query_vars['gd_region'] = $gd_region;
                $wp->query_vars['gd_city'] = $gd_city;
            } else {
                unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']);
            }
        } else {
            unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']);
        }
    } else {
        if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
            if (!is_admin()) {
                $requested_post_type = $wp->query_vars['post_type'];
                // check if this post type is geodirectory post types
                $post_type_array = geodir_get_posttypes();
                if (in_array($requested_post_type, $post_type_array)) {
                    // now u can apply geodirectory related manipulation.
                }
            }
        } else {
            // check if a geodirectory taxonomy is set
            $gd_country = '';
            $gd_region = '';
            $gd_city = '';
            $is_geodir_taxonomy = false;
            $is_geodir_taxonomy_term = false;
            // the last term is real geodirectory taxonomy term or not
            $is_geodir_location_found = false;
            $geodir_taxonomy = '';
            $geodir_post_type = '';
            $geodir_term = '';
            $geodir_set_location_session = true;
            $geodir_taxonomis = geodir_get_taxonomies('', true);
            foreach ($geodir_taxonomis as $taxonomy) {
                if (array_key_exists($taxonomy, $wp->query_vars)) {
                    $is_geodir_taxonomy = true;
//.........这里部分代码省略.........
开发者ID:jefferose,项目名称:geodirectory,代码行数:101,代码来源:custom_taxonomy_hooks_actions.php

示例11: widget

 /**
  * Front-end display content for listing page map widget.
  *
  * @since 1.0.0
  * @since 1.5.1 Declare function public.
  *
  * @global object $post The current post object.
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     if (geodir_is_page('listing') || geodir_is_page('author') || geodir_is_page('search') || geodir_is_page('detail')) {
         extract($args, EXTR_SKIP);
         /** This action is documented in geodirectory_shortcodes.php */
         $width = empty($instance['width']) ? '294' : apply_filters('widget_width', $instance['width']);
         /** This action is documented in geodirectory_shortcodes.php */
         $height = empty($instance['heigh']) ? '370' : apply_filters('widget_heigh', $instance['heigh']);
         /** This action is documented in geodirectory_shortcodes.php */
         $maptype = empty($instance['maptype']) ? 'ROADMAP' : apply_filters('widget_maptype', $instance['maptype']);
         /** This action is documented in geodirectory_shortcodes.php */
         $zoom = empty($instance['zoom']) ? '13' : apply_filters('widget_zoom', $instance['zoom']);
         /** This action is documented in geodirectory_shortcodes.php */
         $autozoom = empty($instance['autozoom']) ? '' : apply_filters('widget_autozoom', $instance['autozoom']);
         /**
          * Filter the listing map value widget_sticky, to set if the map should be sticky or not (scroll with page).
          *
          * @since 1.0.0
          * @param bool $sticky True if should be sticky, false if not
          */
         $sticky = empty($instance['sticky']) ? '' : apply_filters('widget_sticky', $instance['sticky']);
         /** This action is documented in geodirectory_shortcodes.php */
         $scrollwheel = empty($instance['scrollwheel']) ? '0' : apply_filters('widget_scrollwheel', $instance['scrollwheel']);
         $showall = empty($instance['showall']) ? '0' : apply_filters('widget_showall', $instance['showall']);
         /**
          * Filter the listing map should to be displayed or not.
          *
          * @since 1.4.6
          *
          * @param bool $display true if map should be displayed, false if not.
          */
         $show_map = apply_filters('geodir_show_map_listing', $display = true);
         if (!$show_map) {
             return;
         }
         $map_args = array();
         $map_args['map_canvas_name'] = str_replace('-', '_', $args['widget_id']);
         $map_args['width'] = $width;
         $map_args['height'] = $height;
         $map_args['scrollwheel'] = $scrollwheel;
         $map_args['showall'] = $showall;
         $map_args['child_collapse'] = '0';
         $map_args['sticky'] = $sticky;
         $map_args['enable_cat_filters'] = false;
         $map_args['enable_text_search'] = false;
         $map_args['enable_post_type_filters'] = false;
         $map_args['enable_location_filters'] = false;
         $map_args['enable_jason_on_load'] = true;
         if (is_single()) {
             global $post;
             $map_default_lat = $address_latitude = $post->post_latitude;
             $map_default_lng = $address_longitude = $post->post_longitude;
             $mapview = $post->post_mapview;
             $mapzoom = $post->post_mapzoom;
             $map_args['map_class_name'] = 'geodir-map-listing-page-single';
         } else {
             $default_location = geodir_get_default_location();
             $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
             $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
             $map_args['map_class_name'] = 'geodir-map-listing-page';
             $mapview = $maptype;
         }
         if (empty($mapview)) {
             $mapview = 'ROADMAP';
         }
         if (empty($mapzoom)) {
             $mapzoom = $zoom;
         }
         // Set default map options
         $map_args['ajax_url'] = geodir_get_ajax_url();
         $map_args['latitude'] = $map_default_lat;
         $map_args['longitude'] = $map_default_lng;
         $map_args['zoom'] = $zoom;
         //$map_args['scrollwheel'] = true;
         $map_args['scrollwheel'] = $scrollwheel;
         $map_args['showall'] = $showall;
         $map_args['streetViewControl'] = true;
         $map_args['maptype'] = $mapview;
         $map_args['showPreview'] = '0';
         $map_args['maxZoom'] = 21;
         $map_args['autozoom'] = $autozoom;
         $map_args['bubble_size'] = 'small';
         echo $before_widget;
         geodir_draw_map($map_args);
         echo $after_widget;
     }
 }
开发者ID:jefferose,项目名称:geodirectory,代码行数:98,代码来源:listing_map_widget.php

示例12: geodir_get_custom_fields_html


//.........这里部分代码省略.........
                echo '<small>( ' . $admin_desc . ' )</small>';
            }
            ?>
            </h5><?php 
        } elseif ($type == 'address') {
            $prefix = $name . '_';
            $site_title != '' ? $address_title = $site_title : ($address_title = ucwords($prefix . ' address'));
            $extra_fields['zip_lable'] != '' ? $zip_title = $extra_fields['zip_lable'] : ($zip_title = ucwords($prefix . ' zip/post code '));
            $extra_fields['map_lable'] != '' ? $map_title = $extra_fields['map_lable'] : ($map_title = ucwords('set address on map'));
            $extra_fields['mapview_lable'] != '' ? $mapview_title = $extra_fields['mapview_lable'] : ($mapview_title = ucwords($prefix . ' mapview'));
            $address = '';
            $zip = '';
            $mapview = '';
            $mapzoom = '';
            $lat = '';
            $lng = '';
            if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && isset($_SESSION['listing'])) {
                $post = unserialize($_SESSION['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'] : '';
            } elseif (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
开发者ID:bangjojo,项目名称:wp,代码行数:67,代码来源:custom_fields_functions.php

示例13: geodir_ajax_import_export


//.........这里部分代码省略.........
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    // WPML
                                    if ($is_wpml) {
                                        if ($column == 'language') {
                                            $language = strtolower(trim($row[$c]));
                                        } else {
                                            if ($column == 'original_post_id') {
                                                $original_post_id = (int) $row[$c];
                                            }
                                        }
                                    }
                                    // WPML
                                    $c++;
                                }
                                // WPML
                                if ($is_wpml && $language != '') {
                                    $sitepress->switch_lang($language, true);
                                }
                                // WPML
                                $gd_post['IMAGE'] = $post_images;
                                $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
                                $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
                                $valid = true;
                                if ($post_title == '' || !in_array($post_type, $post_types)) {
                                    $invalid++;
                                    $valid = false;
                                }
                                $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
                                if ($location_allowed) {
                                    $location_result = geodir_get_default_location();
                                    if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
                                        $invalid_addr++;
                                        $valid = false;
                                    } else {
                                        if (!empty($location_result) && $location_result->location_id == 0) {
                                            if (strtolower($post_city) != strtolower($location_result->city) || strtolower($post_region) != strtolower($location_result->region) || strtolower($post_country) != strtolower($location_result->country)) {
                                                $invalid_addr++;
                                                $valid = false;
                                            } else {
                                                if (!function_exists('geodir_location_plugin_activated')) {
                                                    $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']';
                                                    // Set the default location when location manager not activated.
                                                }
                                            }
                                        }
                                    }
                                }
                                if (!$valid) {
                                    continue;
                                }
                                $cat_taxonomy = $post_type . 'category';
                                $tags_taxonomy = $post_type . '_tags';
                                $post_category = array();
                                if (!empty($post_category_arr)) {
                                    foreach ($post_category_arr as $value) {
                                        $category_name = wp_kses_normalize_entities(trim($value));
                                        if ($category_name != '') {
                                            $term_category = array();
                                            if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
                                                $term_category = $term;
                                            } else {
                                                if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
开发者ID:jefferose,项目名称:geodirectory,代码行数:67,代码来源:admin_functions.php

示例14: geodir_add_sharelocation_scripts

/**
 * Prints location related javascript.
 *
 * @since 1.0.0
 * @package GeoDirectory
 */
function geodir_add_sharelocation_scripts()
{
    $default_search_for_text = SEARCH_FOR_TEXT;
    if (get_option('geodir_search_field_default_text')) {
        $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
    }
    $default_near_text = NEAR_TEXT;
    if (get_option('geodir_near_field_default_text')) {
        $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
    }
    ?>


    <script type="text/javascript">
        var default_location = '<?php 
    if ($search_location = geodir_get_default_location()) {
        echo $search_location->city;
    }
    ?>
';
        var latlng;
        var Sgeocoder;
        var address;
        var dist = 0;
        var Sgeocoder = new google.maps.Geocoder();

		function geodir_setup_submit_search() {
			jQuery('.geodir_submit_search').click(function() {
				var s = ' ';
				var $form = jQuery(this).closest('form');
				
				if (jQuery("#sdist input[type='radio']:checked").length != 0) dist = jQuery("#sdist input[type='radio']:checked").val();
				if (jQuery('.search_text', $form).val() == '' || jQuery('.search_text', $form).val() == '<?php 
    echo $default_search_for_text;
    ?>
') jQuery('.search_text', $form).val(s);
				
				// Disable location based search for disabled location post type.
				if (jQuery('.search_by_post', $form).val() != '' && typeof gd_cpt_no_location == 'function') {
					if (gd_cpt_no_location(jQuery('.search_by_post', $form).val())) {
						jQuery('.snear', $form).remove();
						jQuery('.sgeo_lat', $form).remove();
						jQuery('.sgeo_lon', $form).remove();
						jQuery('select[name="sort_by"]', $form).remove();
						jQuery($form).submit();
						return;
					}
				}
				
				if (dist > 0 || (jQuery('select[name="sort_by"]').val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest') || (jQuery(".snear", $form).val() != '' && jQuery(".snear", $form).val() != '<?php 
    echo $default_near_text;
    ?>
')) {
					geodir_setsearch($form);
				} else {
					jQuery(".snear", $form).val('');
					jQuery($form).submit();
				}
			});
		}

        jQuery(document).ready(function() {
			/*
			jQuery('#sort_by').change(function() {
				jQuery('.geodir_submit_search:first').click();
			});
			*/
			
			geodir_setup_submit_search();
		});
        
		function geodir_setsearch($form) {
			if ((dist > 0 || (jQuery('select[name="sort_by"]', $form).val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest')) && (jQuery(".snear", $form).val() == '' || jQuery(".snear", $form).val() == '<?php 
    echo $default_near_text;
    ?>
')) jQuery(".snear", $form).val(default_location);
			geocodeAddress($form);
		}

        function updateSearchPosition(latLng, $form) {
            jQuery('.sgeo_lat').val(latLng.lat());
            jQuery('.sgeo_lon').val(latLng.lng());
            jQuery($form).submit(); // submit form after insering the lat long positions
        }

        function geocodeAddress($form) {
            Sgeocoder = new google.maps.Geocoder(); // Call the geocode function

            if (jQuery('.snear', $form).val() == '' || ( jQuery('.sgeo_lat').val() != '' && jQuery('.sgeo_lon').val() != ''  ) || jQuery('.snear', $form).val().match("^<?php 
    _e('In:', 'geodirectory');
    ?>
")) {
                if (jQuery('.snear', $form).val().match("^<?php 
    _e('In:', 'geodirectory');
//.........这里部分代码省略.........
开发者ID:kkoppenhaver,项目名称:geodirectory,代码行数:101,代码来源:geodirectory_template_tags.php

示例15: geodir_location_form_submit

/**
 * Handles location form submitted data.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wpdb WordPress Database object.
 * @global string $plugin_prefix Geodirectory plugin table prefix.
 */
function geodir_location_form_submit()
{
    global $wpdb, $plugin_prefix;
    if (isset($_REQUEST['add_location'])) {
        $location_info = array('city' => $_REQUEST['city'], 'region' => $_REQUEST['region'], 'country' => $_REQUEST['country'], 'geo_lat' => $_REQUEST['latitude'], 'geo_lng' => $_REQUEST['longitude'], 'is_default' => $_REQUEST['is_default'], 'update_city' => $_REQUEST['update_city']);
        $old_location = geodir_get_default_location();
        $locationid = geodir_add_new_location($location_info);
        $default_location = geodir_get_location($locationid);
        //UPDATE AND DELETE LISTING
        $posttype = geodir_get_posttypes();
        if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
            foreach ($posttype as $posttypeobj) {
                /* do not update latitude and longitude otrherwise all listings will be spotted on one point on map
                                if ($old_location->city_latitude != $_REQUEST['latitude'] || $old_location->city_longitude != $_REQUEST['longitude']) {
                
                                    $del_post_sql = $wpdb->get_results(
                                        $wpdb->prepare(
                                            "SELECT post_id from ".$plugin_prefix.$posttypeobj."_detail WHERE post_location_id = %d AND (post_city != %s OR post_region != %s)",
                                            array($locationid,$_REQUEST['city'],$_REQUEST['region'])
                                        )
                                    );
                                    $sql = $wpdb->prepare(
                                            "SELECT post_id from ".$plugin_prefix.$posttypeobj."_detail WHERE post_location_id = %d AND (post_city != %s OR post_region != %s)",
                                            array($locationid,$_REQUEST['city'],$_REQUEST['region'])
                                        );
                                    if (!empty($del_post_sql)) {
                                        foreach ($del_post_sql as $del_post_info) {
                                            $postid = (int)$del_post_info->post_id;
                                            //wp_delete_post($postid); // update post location instead of delete post
                                            $sql = $wpdb->prepare(
                                                "UPDATE ".$plugin_prefix.$posttypeobj."_detail SET post_latitude=%s, post_longitude=%s WHERE post_location_id=%d AND post_id=%d",
                                                array( $_REQUEST['latitude'], $_REQUEST['longitude'], $locationid, $postid )
                                            );
                                            $wpdb->query($sql);
                                        }
                                    }
                                }
                                */
                $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']';
                // set all overall post location
                $sql = $wpdb->prepare("UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s\r\n\t\t\t\t\t\tWHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)", array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations));
                $wpdb->query($sql);
            }
        }
    }
}
开发者ID:kkoppenhaver,项目名称:geodirectory,代码行数:54,代码来源:location_functions.php


注:本文中的geodir_get_default_location函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。