| @@ -15,8 +15,8 @@ discard block | ||
| 15 | 15 | */ | 
| 16 | 16 | function geodir_init_map_jason() | 
| 17 | 17 |  {
 | 
| 18 | - global $map_jason; | |
| 19 | - $map_jason = array(); | |
| 18 | + global $map_jason; | |
| 19 | + $map_jason = array(); | |
| 20 | 20 | } | 
| 21 | 21 | |
| 22 | 22 | /** | 
| @@ -28,8 +28,8 @@ discard block | ||
| 28 | 28 | */ | 
| 29 | 29 | function geodir_init_map_canvas_array() | 
| 30 | 30 |  {
 | 
| 31 | - global $map_canvas_arr; | |
| 32 | - $map_canvas_arr = array(); | |
| 31 | + global $map_canvas_arr; | |
| 32 | + $map_canvas_arr = array(); | |
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | 35 | |
| @@ -50,47 +50,47 @@ discard block | ||
| 50 | 50 | */ | 
| 51 | 51 | function create_marker_jason_of_posts($post) | 
| 52 | 52 |  {
 | 
| 53 | - global $wpdb, $map_jason, $add_post_in_marker_array, $geodir_cat_icons, $gd_marker_sizes; | |
| 53 | + global $wpdb, $map_jason, $add_post_in_marker_array, $geodir_cat_icons, $gd_marker_sizes; | |
| 54 | 54 | |
| 55 | -    if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') {
 | |
| 56 | -        $srcharr = array("'", "/", "-", '"', '\\');
 | |
| 57 | -        $replarr = array("′", "⁄", "–", "“", '');
 | |
| 55 | +	if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') {
 | |
| 56 | +		$srcharr = array("'", "/", "-", '"', '\\');
 | |
| 57 | +		$replarr = array("′", "⁄", "–", "“", '');
 | |
| 58 | 58 | |
| 59 | 59 | |
| 60 | - $geodir_cat_icons = geodir_get_term_icon(); | |
| 61 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$post->default_category]) ? $geodir_cat_icons[$post->default_category] : ''; | |
| 60 | + $geodir_cat_icons = geodir_get_term_icon(); | |
| 61 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$post->default_category]) ? $geodir_cat_icons[$post->default_category] : ''; | |
| 62 | 62 | |
| 63 | - $post_title = $post->post_title; | |
| 64 | - $title = str_replace($srcharr, $replarr, $post_title); | |
| 63 | + $post_title = $post->post_title; | |
| 64 | + $title = str_replace($srcharr, $replarr, $post_title); | |
| 65 | 65 | |
| 66 | -        if (is_ssl()) {
 | |
| 67 | -            $icon = str_replace("http:","https:",$icon );
 | |
| 68 | - } | |
| 66 | +		if (is_ssl()) {
 | |
| 67 | +			$icon = str_replace("http:","https:",$icon );
 | |
| 68 | + } | |
| 69 | 69 | |
| 70 | -        if ($icon != '') {
 | |
| 71 | - $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; | |
| 70 | +		if ($icon != '') {
 | |
| 71 | + $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; | |
| 72 | 72 | |
| 73 | -            if (isset($gd_marker_sizes[$icon])) {
 | |
| 74 | - $icon_size = $gd_marker_sizes[$icon]; | |
| 75 | -            } else {
 | |
| 76 | - $icon_size = geodir_get_marker_size($icon); | |
| 77 | - $gd_marker_sizes[$icon] = $icon_size; | |
| 78 | - } | |
| 79 | -        } else {
 | |
| 80 | -            $icon_size = array('w' => 36, 'h' => 45);
 | |
| 81 | - } | |
| 82 | - | |
| 83 | -        $post_json = '{"id":"' . $post->ID . '","t": "' . $title . '","lt": "' . $post->post_latitude . '","ln": "' . $post->post_longitude . '","mk_id":"' . $post->ID . '_' . $post->default_category . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"}';
 | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * Filter the json data when creating output for post json marker.. | |
| 87 | - * | |
| 88 | - * @since 1.5.7 | |
| 89 | - * @param string $post_json JSON representation of the post marker info. | |
| 90 | - * @param object $post The post object. | |
| 91 | - */ | |
| 92 | -        $map_jason[] = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post);
 | |
| 93 | - } | |
| 73 | +			if (isset($gd_marker_sizes[$icon])) {
 | |
| 74 | + $icon_size = $gd_marker_sizes[$icon]; | |
| 75 | +			} else {
 | |
| 76 | + $icon_size = geodir_get_marker_size($icon); | |
| 77 | + $gd_marker_sizes[$icon] = $icon_size; | |
| 78 | + } | |
| 79 | +		} else {
 | |
| 80 | +			$icon_size = array('w' => 36, 'h' => 45);
 | |
| 81 | + } | |
| 82 | + | |
| 83 | +		$post_json = '{"id":"' . $post->ID . '","t": "' . $title . '","lt": "' . $post->post_latitude . '","ln": "' . $post->post_longitude . '","mk_id":"' . $post->ID . '_' . $post->default_category . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"}';
 | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * Filter the json data when creating output for post json marker.. | |
| 87 | + * | |
| 88 | + * @since 1.5.7 | |
| 89 | + * @param string $post_json JSON representation of the post marker info. | |
| 90 | + * @param object $post The post object. | |
| 91 | + */ | |
| 92 | +		$map_jason[] = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post);
 | |
| 93 | + } | |
| 94 | 94 | } | 
| 95 | 95 | |
| 96 | 96 | /** | 
| @@ -103,59 +103,59 @@ discard block | ||
| 103 | 103 | */ | 
| 104 | 104 | function send_marker_jason_to_js() | 
| 105 | 105 |  {
 | 
| 106 | - global $map_jason, $map_canvas_arr; | |
| 107 | - | |
| 108 | -    if (is_array($map_canvas_arr) && !empty($map_canvas_arr)) {
 | |
| 109 | -        foreach ($map_canvas_arr as $canvas => $jason) {
 | |
| 110 | -            if (is_array($map_jason) && !empty($map_jason)) {
 | |
| 111 | - $canvas_jason = $canvas . "_jason"; | |
| 112 | - $map_canvas_arr[$canvas] = array_unique($map_jason); | |
| 113 | - unset($cat_content_info); | |
| 114 | -                $cat_content_info[] = implode(',', $map_canvas_arr[$canvas]);
 | |
| 115 | - $totalcount = count(array_unique($map_jason)); | |
| 116 | -                if (!empty($cat_content_info)) {
 | |
| 117 | -                    $json_content = substr(implode(',', $cat_content_info), 1);
 | |
| 118 | -                    $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016
 | |
| 119 | -                    $canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']';
 | |
| 120 | -                } else {
 | |
| 121 | -                    $canvas_jason = '[{"totalcount":"0"}]';
 | |
| 122 | - } | |
| 123 | - | |
| 124 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); | |
| 125 | - | |
| 126 | - /** | |
| 127 | - * Filter the send_marker_jason_to_js() function map canvas json args. | |
| 128 | - * | |
| 129 | - * You can use this filter to modify map canvas json args. | |
| 130 | - * | |
| 131 | - * @since 1.0.0 | |
| 132 | - * @package GeoDirectory | |
| 133 | - * @param string $canvas Map canvas array key. | |
| 134 | - * @param array $map_canvas_jason_args Map canvas args. | |
| 135 | - */ | |
| 136 | -                $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
 | |
| 137 | - | |
| 138 | -                wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
 | |
| 139 | -            } else {
 | |
| 140 | -                $canvas_jason = '[{"totalcount":"0"}]';
 | |
| 141 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); | |
| 142 | - | |
| 143 | - /** | |
| 144 | - * Filter the send_marker_jason_to_js() function map canvas json args. | |
| 145 | - * | |
| 146 | - * You can use this filter to modify map canvas json args. | |
| 147 | - * | |
| 148 | - * @since 1.0.0 | |
| 149 | - * @package GeoDirectory | |
| 150 | - * @param string $canvas Map canvas array key. | |
| 151 | - * @param array $map_canvas_jason_args Map canvas args. | |
| 152 | - */ | |
| 153 | -                $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
 | |
| 154 | -                wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
 | |
| 155 | - } | |
| 156 | - } | |
| 157 | - | |
| 158 | - } | |
| 106 | + global $map_jason, $map_canvas_arr; | |
| 107 | + | |
| 108 | +	if (is_array($map_canvas_arr) && !empty($map_canvas_arr)) {
 | |
| 109 | +		foreach ($map_canvas_arr as $canvas => $jason) {
 | |
| 110 | +			if (is_array($map_jason) && !empty($map_jason)) {
 | |
| 111 | + $canvas_jason = $canvas . "_jason"; | |
| 112 | + $map_canvas_arr[$canvas] = array_unique($map_jason); | |
| 113 | + unset($cat_content_info); | |
| 114 | +				$cat_content_info[] = implode(',', $map_canvas_arr[$canvas]);
 | |
| 115 | + $totalcount = count(array_unique($map_jason)); | |
| 116 | +				if (!empty($cat_content_info)) {
 | |
| 117 | +					$json_content = substr(implode(',', $cat_content_info), 1);
 | |
| 118 | +					$json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016
 | |
| 119 | +					$canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']';
 | |
| 120 | +				} else {
 | |
| 121 | +					$canvas_jason = '[{"totalcount":"0"}]';
 | |
| 122 | + } | |
| 123 | + | |
| 124 | + $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * Filter the send_marker_jason_to_js() function map canvas json args. | |
| 128 | + * | |
| 129 | + * You can use this filter to modify map canvas json args. | |
| 130 | + * | |
| 131 | + * @since 1.0.0 | |
| 132 | + * @package GeoDirectory | |
| 133 | + * @param string $canvas Map canvas array key. | |
| 134 | + * @param array $map_canvas_jason_args Map canvas args. | |
| 135 | + */ | |
| 136 | +				$map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
 | |
| 137 | + | |
| 138 | +				wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
 | |
| 139 | +			} else {
 | |
| 140 | +				$canvas_jason = '[{"totalcount":"0"}]';
 | |
| 141 | + $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * Filter the send_marker_jason_to_js() function map canvas json args. | |
| 145 | + * | |
| 146 | + * You can use this filter to modify map canvas json args. | |
| 147 | + * | |
| 148 | + * @since 1.0.0 | |
| 149 | + * @package GeoDirectory | |
| 150 | + * @param string $canvas Map canvas array key. | |
| 151 | + * @param array $map_canvas_jason_args Map canvas args. | |
| 152 | + */ | |
| 153 | +				$map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
 | |
| 154 | +				wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
 | |
| 155 | + } | |
| 156 | + } | |
| 157 | + | |
| 158 | + } | |
| 159 | 159 | } | 
| 160 | 160 | |
| 161 | 161 | /** | 
| @@ -174,92 +174,92 @@ discard block | ||
| 174 | 174 | */ | 
| 175 | 175 | function home_map_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = true, $pading = 0, $map_canvas_name = '', $child_collapse, $is_home_map = false) | 
| 176 | 176 |  {
 | 
| 177 | - global $cat_count, $geodir_cat_icons; | |
| 177 | + global $cat_count, $geodir_cat_icons; | |
| 178 | 178 | |
| 179 | -    $exclude_categories = get_option('geodir_exclude_cat_on_map');
 | |
| 180 | -    $exclude_categories_new = get_option('geodir_exclude_cat_on_map_upgrade');
 | |
| 179 | +	$exclude_categories = get_option('geodir_exclude_cat_on_map');
 | |
| 180 | +	$exclude_categories_new = get_option('geodir_exclude_cat_on_map_upgrade');
 | |
| 181 | 181 | |
| 182 | - // check if exclude categories saved before fix of categories identical names | |
| 183 | -    if ($exclude_categories_new) {
 | |
| 184 | - $gd_cat_taxonomy = isset($cat_taxonomy[0]) ? $cat_taxonomy[0] : ''; | |
| 185 | - $exclude_categories = !empty($exclude_categories[$gd_cat_taxonomy]) && is_array($exclude_categories[$gd_cat_taxonomy]) ? array_unique($exclude_categories[$gd_cat_taxonomy]) : array(); | |
| 186 | - } | |
| 182 | + // check if exclude categories saved before fix of categories identical names | |
| 183 | +	if ($exclude_categories_new) {
 | |
| 184 | + $gd_cat_taxonomy = isset($cat_taxonomy[0]) ? $cat_taxonomy[0] : ''; | |
| 185 | + $exclude_categories = !empty($exclude_categories[$gd_cat_taxonomy]) && is_array($exclude_categories[$gd_cat_taxonomy]) ? array_unique($exclude_categories[$gd_cat_taxonomy]) : array(); | |
| 186 | + } | |
| 187 | 187 | |
| 188 | -    $exclude_cat_str = implode(',', $exclude_categories);
 | |
| 188 | +	$exclude_cat_str = implode(',', $exclude_categories);
 | |
| 189 | 189 | |
| 190 | -    if ($exclude_cat_str == '') {
 | |
| 191 | - $exclude_cat_str = '0'; | |
| 192 | - } | |
| 190 | +	if ($exclude_cat_str == '') {
 | |
| 191 | + $exclude_cat_str = '0'; | |
| 192 | + } | |
| 193 | 193 | |
| 194 | -    $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'exclude' => $exclude_cat_str, 'hide_empty ' => $hide_empty));
 | |
| 194 | +	$cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'exclude' => $exclude_cat_str, 'hide_empty ' => $hide_empty));
 | |
| 195 | 195 | |
| 196 | -    if ($hide_empty) {
 | |
| 197 | - $cat_terms = geodir_filter_empty_terms($cat_terms); | |
| 198 | - } | |
| 196 | +	if ($hide_empty) {
 | |
| 197 | + $cat_terms = geodir_filter_empty_terms($cat_terms); | |
| 198 | + } | |
| 199 | 199 | |
| 200 | - $main_list_class = ''; | |
| 201 | - //If there are terms, start displaying | |
| 202 | -    if (count($cat_terms) > 0) {
 | |
| 203 | - //Displaying as a list | |
| 204 | - $p = $pading * 15; | |
| 205 | - $pading++; | |
| 200 | + $main_list_class = ''; | |
| 201 | + //If there are terms, start displaying | |
| 202 | +	if (count($cat_terms) > 0) {
 | |
| 203 | + //Displaying as a list | |
| 204 | + $p = $pading * 15; | |
| 205 | + $pading++; | |
| 206 | 206 | |
| 207 | -        if ($cat_parent == 0) {
 | |
| 208 | - $list_class = 'main_list'; | |
| 209 | - $display = ''; | |
| 210 | -        } else {
 | |
| 211 | - $list_class = 'sub_list'; | |
| 212 | - $display = !$child_collapse ? '' : 'display:none'; | |
| 213 | - } | |
| 207 | +		if ($cat_parent == 0) {
 | |
| 208 | + $list_class = 'main_list'; | |
| 209 | + $display = ''; | |
| 210 | +		} else {
 | |
| 211 | + $list_class = 'sub_list'; | |
| 212 | + $display = !$child_collapse ? '' : 'display:none'; | |
| 213 | + } | |
| 214 | 214 | |
| 215 | 215 | |
| 216 | - $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; | |
| 216 | + $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; | |
| 217 | 217 | |
| 218 | - $geodir_cat_icons = geodir_get_term_icon(); | |
| 218 | + $geodir_cat_icons = geodir_get_term_icon(); | |
| 219 | 219 | |
| 220 | -        $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') :  'gd_place';
 | |
| 221 | - $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : $geodir_default_map_search_pt; | |
| 222 | - foreach ($cat_terms as $cat_term): | |
| 220 | +		$geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') :  'gd_place';
 | |
| 221 | + $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : $geodir_default_map_search_pt; | |
| 222 | + foreach ($cat_terms as $cat_term): | |
| 223 | 223 | |
| 224 | 224 | |
| 225 | 225 | |
| 226 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$cat_term->term_id]) ? $geodir_cat_icons[$cat_term->term_id] : ''; | |
| 226 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$cat_term->term_id]) ? $geodir_cat_icons[$cat_term->term_id] : ''; | |
| 227 | 227 | |
| 228 | - if (!in_array($cat_term->term_id, $exclude_categories)): | |
| 229 | - //Secret sauce. Function calls itself to display child elements, if any | |
| 230 | - $checked = 'checked="checked"'; | |
| 228 | + if (!in_array($cat_term->term_id, $exclude_categories)): | |
| 229 | + //Secret sauce. Function calls itself to display child elements, if any | |
| 230 | + $checked = 'checked="checked"'; | |
| 231 | 231 | |
| 232 | - // Untick the category by default on home map | |
| 233 | -                if ($is_home_map && $geodir_home_map_untick = get_option('geodir_home_map_untick')) {
 | |
| 234 | -                    if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $cat_term->term_id, $geodir_home_map_untick)) {
 | |
| 235 | - $checked = ''; | |
| 236 | - } | |
| 237 | - } | |
| 232 | + // Untick the category by default on home map | |
| 233 | +				if ($is_home_map && $geodir_home_map_untick = get_option('geodir_home_map_untick')) {
 | |
| 234 | +					if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $cat_term->term_id, $geodir_home_map_untick)) {
 | |
| 235 | + $checked = ''; | |
| 236 | + } | |
| 237 | + } | |
| 238 | 238 | |
| 239 | - $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; | |
| 240 | - $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; | |
| 241 | - $term_check .= ' title="' . esc_attr(ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; | |
| 242 | - $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . ucfirst($cat_term->name) . '"/>'; | |
| 243 | - $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; | |
| 239 | + $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; | |
| 240 | + $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; | |
| 241 | + $term_check .= ' title="' . esc_attr(ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; | |
| 242 | + $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . ucfirst($cat_term->name) . '"/>'; | |
| 243 | + $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; | |
| 244 | 244 | |
| 245 | - endif; | |
| 245 | + endif; | |
| 246 | 246 | |
| 247 | 247 | |
| 248 | - // get sub category by recursion | |
| 249 | - $out .= home_map_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading, $map_canvas_name, $child_collapse, $is_home_map); | |
| 248 | + // get sub category by recursion | |
| 249 | + $out .= home_map_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading, $map_canvas_name, $child_collapse, $is_home_map); | |
| 250 | 250 | |
| 251 | - $out .= '</li>'; | |
| 251 | + $out .= '</li>'; | |
| 252 | 252 | |
| 253 | - endforeach; | |
| 253 | + endforeach; | |
| 254 | 254 | |
| 255 | - $out .= '</ul>'; | |
| 255 | + $out .= '</ul>'; | |
| 256 | 256 | |
| 257 | - return $out; | |
| 258 | -    } else {
 | |
| 259 | - if ($cat_parent == 0) | |
| 260 | -            return _e('No category', 'geodirectory');
 | |
| 261 | - } | |
| 262 | - return; | |
| 257 | + return $out; | |
| 258 | +	} else {
 | |
| 259 | + if ($cat_parent == 0) | |
| 260 | +			return _e('No category', 'geodirectory');
 | |
| 261 | + } | |
| 262 | + return; | |
| 263 | 263 | } | 
| 264 | 264 | |
| 265 | 265 | /** | 
| @@ -271,19 +271,19 @@ discard block | ||
| 271 | 271 | * @return string The map API provider name. | 
| 272 | 272 | */ | 
| 273 | 273 |  function geodir_map_name() {
 | 
| 274 | -    $geodir_map_name = get_option('geodir_load_map', 'google');
 | |
| 274 | +	$geodir_map_name = get_option('geodir_load_map', 'google');
 | |
| 275 | 275 | |
| 276 | -    if (!in_array($geodir_map_name, array('none', 'auto', 'google', 'osm'))) {
 | |
| 277 | - $geodir_map_name = 'auto'; | |
| 278 | - } | |
| 279 | - | |
| 280 | - /** | |
| 281 | - * Filter the map JS API provider name. | |
| 282 | - * | |
| 283 | - * @since 1.6.1 | |
| 284 | - * @param string $geodir_map_name The map API provider name. | |
| 285 | - */ | |
| 286 | -    return apply_filters('geodir_map_name', $geodir_map_name);
 | |
| 276 | +	if (!in_array($geodir_map_name, array('none', 'auto', 'google', 'osm'))) {
 | |
| 277 | + $geodir_map_name = 'auto'; | |
| 278 | + } | |
| 279 | + | |
| 280 | + /** | |
| 281 | + * Filter the map JS API provider name. | |
| 282 | + * | |
| 283 | + * @since 1.6.1 | |
| 284 | + * @param string $geodir_map_name The map API provider name. | |
| 285 | + */ | |
| 286 | +	return apply_filters('geodir_map_name', $geodir_map_name);
 | |
| 287 | 287 | } | 
| 288 | 288 | |
| 289 | 289 | /** | 
| @@ -299,48 +299,48 @@ discard block | ||
| 299 | 299 | * @return array The icon size. | 
| 300 | 300 | */ | 
| 301 | 301 |  function geodir_get_marker_size($icon, $default_size = array('w' => 36, 'h' => 45)) {
 | 
| 302 | - global $gd_marker_sizes; | |
| 302 | + global $gd_marker_sizes; | |
| 303 | 303 | |
| 304 | -    if (empty($gd_marker_sizes)) {
 | |
| 305 | - $gd_marker_sizes = array(); | |
| 306 | - } | |
| 304 | +	if (empty($gd_marker_sizes)) {
 | |
| 305 | + $gd_marker_sizes = array(); | |
| 306 | + } | |
| 307 | 307 | |
| 308 | -    if (!empty($gd_marker_sizes[$icon])) {
 | |
| 309 | - return $gd_marker_sizes[$icon]; | |
| 310 | - } | |
| 308 | +	if (!empty($gd_marker_sizes[$icon])) {
 | |
| 309 | + return $gd_marker_sizes[$icon]; | |
| 310 | + } | |
| 311 | 311 | |
| 312 | -    if (empty($icon)) {
 | |
| 313 | - $gd_marker_sizes[$icon] = $default_size; | |
| 312 | +	if (empty($icon)) {
 | |
| 313 | + $gd_marker_sizes[$icon] = $default_size; | |
| 314 | 314 | |
| 315 | - return $default_size; | |
| 316 | - } | |
| 315 | + return $default_size; | |
| 316 | + } | |
| 317 | 317 | |
| 318 | - $icon_url = $icon; | |
| 318 | + $icon_url = $icon; | |
| 319 | 319 | |
| 320 | - $uploads = wp_upload_dir(); // Array of key => value pairs | |
| 320 | + $uploads = wp_upload_dir(); // Array of key => value pairs | |
| 321 | 321 | |
| 322 | -    if (!path_is_absolute($icon)) {
 | |
| 323 | - $icon = str_replace($uploads['baseurl'], $uploads['basedir'], $icon); | |
| 324 | - } | |
| 322 | +	if (!path_is_absolute($icon)) {
 | |
| 323 | + $icon = str_replace($uploads['baseurl'], $uploads['basedir'], $icon); | |
| 324 | + } | |
| 325 | 325 | |
| 326 | -    if (!path_is_absolute($icon) && strpos($icon, WP_CONTENT_URL) !== false) {
 | |
| 327 | - $icon = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $icon); | |
| 328 | - } | |
| 326 | +	if (!path_is_absolute($icon) && strpos($icon, WP_CONTENT_URL) !== false) {
 | |
| 327 | + $icon = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $icon); | |
| 328 | + } | |
| 329 | 329 | |
| 330 | - $sizes = array(); | |
| 331 | -    if (is_file($icon) && file_exists($icon)) {
 | |
| 332 | - $size = getimagesize(trim($icon)); | |
| 330 | + $sizes = array(); | |
| 331 | +	if (is_file($icon) && file_exists($icon)) {
 | |
| 332 | + $size = getimagesize(trim($icon)); | |
| 333 | 333 | |
| 334 | -        if (!empty($size[0]) && !empty($size[1])) {
 | |
| 335 | -            $sizes = array('w' => $size[0], 'h' => $size[1]);
 | |
| 336 | - } | |
| 337 | - } | |
| 334 | +		if (!empty($size[0]) && !empty($size[1])) {
 | |
| 335 | +			$sizes = array('w' => $size[0], 'h' => $size[1]);
 | |
| 336 | + } | |
| 337 | + } | |
| 338 | 338 | |
| 339 | - $sizes = !empty($sizes) ? $sizes : $default_size; | |
| 339 | + $sizes = !empty($sizes) ? $sizes : $default_size; | |
| 340 | 340 | |
| 341 | - $gd_marker_sizes[$icon_url] = $sizes; | |
| 341 | + $gd_marker_sizes[$icon_url] = $sizes; | |
| 342 | 342 | |
| 343 | - return $sizes; | |
| 343 | + return $sizes; | |
| 344 | 344 | } | 
| 345 | 345 | |
| 346 | 346 |  add_action('wp_head', 'geodir_map_load_style', 10);
 | 
| @@ -352,7 +352,7 @@ discard block | ||
| 352 | 352 | * @package GeoDirectory | 
| 353 | 353 | */ | 
| 354 | 354 |  function geodir_map_load_style() {    
 | 
| 355 | -    if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) {
 | |
| 355 | +	if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) {
 | |
| 356 | 356 | ?> | 
| 357 | 357 | <script type="text/javascript"> | 
| 358 | 358 |  if (!(window.google && typeof google.maps !== 'undefined')) {
 | 
| @@ -360,7 +360,7 @@ discard block | ||
| 360 | 360 | } | 
| 361 | 361 | </script> | 
| 362 | 362 | <?php | 
| 363 | - } | |
| 363 | + } | |
| 364 | 364 | } | 
| 365 | 365 | |
| 366 | 366 |  add_action('wp_footer', 'geodir_map_load_script', 10);
 | 
| @@ -372,7 +372,7 @@ discard block | ||
| 372 | 372 | * @package GeoDirectory | 
| 373 | 373 | */ | 
| 374 | 374 |  function geodir_map_load_script() {
 | 
| 375 | -    if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) {
 | |
| 375 | +	if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) {
 | |
| 376 | 376 | ?> | 
| 377 | 377 | <script type="text/javascript"> | 
| 378 | 378 |  if (!(window.google && typeof google.maps !== 'undefined')) {
 | 
| @@ -381,5 +381,5 @@ discard block | ||
| 381 | 381 | } | 
| 382 | 382 | </script> | 
| 383 | 383 | <?php | 
| 384 | - } | |
| 384 | + } | |
| 385 | 385 | } | 
| 386 | 386 | \ No newline at end of file | 
| @@ -18,9 +18,9 @@ discard block | ||
| 18 | 18 | */ | 
| 19 | 19 | function init_listing_map_script() | 
| 20 | 20 |  {
 | 
| 21 | - global $list_map_json; | |
| 21 | + global $list_map_json; | |
| 22 | 22 | |
| 23 | - $list_map_json = array(); | |
| 23 | + $list_map_json = array(); | |
| 24 | 24 | |
| 25 | 25 | } | 
| 26 | 26 | |
| @@ -35,18 +35,18 @@ discard block | ||
| 35 | 35 | */ | 
| 36 | 36 | function create_list_jsondata($post) | 
| 37 | 37 |  {
 | 
| 38 | - global $wpdb, $list_map_json, $add_post_in_marker_array; | |
| 39 | - | |
| 40 | -    if ((is_main_query() || $add_post_in_marker_array) && isset($post->marker_json) && $post->marker_json != '') {
 | |
| 41 | - /** | |
| 42 | - * Filter the json data for search listing map. | |
| 43 | - * | |
| 44 | - * @since 1.5.7 | |
| 45 | - * @param string $post->marker_json JSON representation of the post marker info. | |
| 46 | - * @param object $post The post object. | |
| 47 | - */ | |
| 48 | -        $list_map_json[] = apply_filters('geodir_create_list_jsondata',$post->marker_json,$post);
 | |
| 49 | - } | |
| 38 | + global $wpdb, $list_map_json, $add_post_in_marker_array; | |
| 39 | + | |
| 40 | +	if ((is_main_query() || $add_post_in_marker_array) && isset($post->marker_json) && $post->marker_json != '') {
 | |
| 41 | + /** | |
| 42 | + * Filter the json data for search listing map. | |
| 43 | + * | |
| 44 | + * @since 1.5.7 | |
| 45 | + * @param string $post->marker_json JSON representation of the post marker info. | |
| 46 | + * @param object $post The post object. | |
| 47 | + */ | |
| 48 | +		$list_map_json[] = apply_filters('geodir_create_list_jsondata',$post->marker_json,$post);
 | |
| 49 | + } | |
| 50 | 50 | |
| 51 | 51 | } | 
| 52 | 52 | |
| @@ -59,28 +59,28 @@ discard block | ||
| 59 | 59 | */ | 
| 60 | 60 | function show_listing_widget_map() | 
| 61 | 61 |  {
 | 
| 62 | - global $list_map_json; | |
| 62 | + global $list_map_json; | |
| 63 | 63 | |
| 64 | -    if (!empty($list_map_json)) {
 | |
| 65 | - $list_map_json = array_unique($list_map_json); | |
| 66 | -        $cat_content_info[] = implode(',', $list_map_json);
 | |
| 67 | - } | |
| 64 | +	if (!empty($list_map_json)) {
 | |
| 65 | + $list_map_json = array_unique($list_map_json); | |
| 66 | +		$cat_content_info[] = implode(',', $list_map_json);
 | |
| 67 | + } | |
| 68 | 68 | |
| 69 | - $totalcount = count(array_unique($list_map_json)); | |
| 69 | + $totalcount = count(array_unique($list_map_json)); | |
| 70 | 70 | |
| 71 | 71 | |
| 72 | -    if (!empty($cat_content_info)) {
 | |
| 73 | -        $json_content = substr(implode(',', $cat_content_info), 1);
 | |
| 74 | -        $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016
 | |
| 75 | -        $list_json = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']';
 | |
| 76 | -    } else {
 | |
| 77 | -        $list_json = '[{"totalcount":"0"}]';
 | |
| 78 | - } | |
| 72 | +	if (!empty($cat_content_info)) {
 | |
| 73 | +		$json_content = substr(implode(',', $cat_content_info), 1);
 | |
| 74 | +		$json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016
 | |
| 75 | +		$list_json = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']';
 | |
| 76 | +	} else {
 | |
| 77 | +		$list_json = '[{"totalcount":"0"}]';
 | |
| 78 | + } | |
| 79 | 79 | |
| 80 | -    $listing_map_args = array('list_json' => $list_json);
 | |
| 80 | +	$listing_map_args = array('list_json' => $list_json);
 | |
| 81 | 81 | |
| 82 | - // Pass the json data in listing map script | |
| 83 | -    wp_localize_script('geodir-listing-map-widget', 'listing_map_args', $listing_map_args);
 | |
| 82 | + // Pass the json data in listing map script | |
| 83 | +	wp_localize_script('geodir-listing-map-widget', 'listing_map_args', $listing_map_args);
 | |
| 84 | 84 | |
| 85 | 85 | } | 
| 86 | 86 | |
| @@ -92,184 +92,184 @@ discard block | ||
| 92 | 92 | class geodir_map_listingpage extends WP_Widget | 
| 93 | 93 |  {
 | 
| 94 | 94 | |
| 95 | - /** | |
| 95 | + /** | |
| 96 | 96 | * Register the listing page map widget. | 
| 97 | 97 | * | 
| 98 | 98 | * @since 1.0.0 | 
| 99 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. | |
| 99 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. | |
| 100 | 100 | */ | 
| 101 | -    public function __construct() {
 | |
| 102 | -        $widget_ops = array('classname' => 'widget geodir-map-listing-page', 'description' => __('Google Map for Listing page. It will show you google map V3 for Listing page.', 'geodirectory'));
 | |
| 103 | - parent::__construct( | |
| 104 | - 'geodir_map_v3_listing_map', // Base ID | |
| 105 | -            __('GD > GMap - Listing page', 'geodirectory'), // Name
 | |
| 106 | - $widget_ops// Args | |
| 107 | - ); | |
| 101 | +	public function __construct() {
 | |
| 102 | +		$widget_ops = array('classname' => 'widget geodir-map-listing-page', 'description' => __('Google Map for Listing page. It will show you google map V3 for Listing page.', 'geodirectory'));
 | |
| 103 | + parent::__construct( | |
| 104 | + 'geodir_map_v3_listing_map', // Base ID | |
| 105 | +			__('GD > GMap - Listing page', 'geodirectory'), // Name
 | |
| 106 | + $widget_ops// Args | |
| 107 | + ); | |
| 108 | 108 | |
| 109 | -        add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array
 | |
| 109 | +		add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array
 | |
| 110 | 110 | |
| 111 | -        add_action('the_post', 'create_list_jsondata'); // Add marker in json array
 | |
| 111 | +		add_action('the_post', 'create_list_jsondata'); // Add marker in json array
 | |
| 112 | 112 | |
| 113 | -        add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers
 | |
| 114 | - } | |
| 113 | +		add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers
 | |
| 114 | + } | |
| 115 | 115 | |
| 116 | 116 | /** | 
| 117 | 117 | * Front-end display content for listing page map widget. | 
| 118 | 118 | * | 
| 119 | 119 | * @since 1.0.0 | 
| 120 | - * @since 1.5.1 Declare function public. | |
| 120 | + * @since 1.5.1 Declare function public. | |
| 121 | + * | |
| 122 | + * @global object $post The current post object. | |
| 121 | 123 | * | 
| 122 | - * @global object $post The current post object. | |
| 123 | - * | |
| 124 | 124 | * @param array $args Widget arguments. | 
| 125 | 125 | * @param array $instance Saved values from database. | 
| 126 | 126 | */ | 
| 127 | - public function widget($args, $instance) | |
| 128 | -    {
 | |
| 129 | - | |
| 130 | -        if (geodir_is_page('listing') || geodir_is_page('author') || geodir_is_page('search')
 | |
| 131 | -            || geodir_is_page('detail')
 | |
| 132 | - ) : | |
| 133 | - | |
| 134 | - extract($args, EXTR_SKIP); | |
| 135 | - /** This action is documented in geodirectory_shortcodes.php */ | |
| 136 | -            $width = empty($instance['width']) ? '294' : apply_filters('widget_width', $instance['width']);
 | |
| 137 | - /** This action is documented in geodirectory_shortcodes.php */ | |
| 138 | -            $height = empty($instance['heigh']) ? '370' : apply_filters('widget_heigh', $instance['heigh']);
 | |
| 139 | - /** This action is documented in geodirectory_shortcodes.php */ | |
| 140 | -            $maptype = empty($instance['maptype']) ? 'ROADMAP' : apply_filters('widget_maptype', $instance['maptype']);
 | |
| 141 | - /** This action is documented in geodirectory_shortcodes.php */ | |
| 142 | -            $zoom = empty($instance['zoom']) ? '13' : apply_filters('widget_zoom', $instance['zoom']);
 | |
| 143 | - /** This action is documented in geodirectory_shortcodes.php */ | |
| 144 | -            $autozoom = empty($instance['autozoom']) ? '' : apply_filters('widget_autozoom', $instance['autozoom']);
 | |
| 145 | - /** | |
| 146 | - * Filter the listing map value widget_sticky, to set if the map should be sticky or not (scroll with page). | |
| 147 | - * | |
| 148 | - * @since 1.0.0 | |
| 149 | - * @param bool $sticky True if should be sticky, false if not | |
| 150 | - */ | |
| 151 | -            $sticky = empty($instance['sticky']) ? '' : apply_filters('widget_sticky', $instance['sticky']);
 | |
| 152 | - /** This action is documented in geodirectory_shortcodes.php */ | |
| 153 | -            $scrollwheel = empty($instance['scrollwheel']) ? '0' : apply_filters('widget_scrollwheel', $instance['scrollwheel']);
 | |
| 154 | -            $showall = empty($instance['showall']) ? '0' : apply_filters('widget_showall', $instance['showall']);
 | |
| 127 | + public function widget($args, $instance) | |
| 128 | +	{
 | |
| 129 | + | |
| 130 | +		if (geodir_is_page('listing') || geodir_is_page('author') || geodir_is_page('search')
 | |
| 131 | +			|| geodir_is_page('detail')
 | |
| 132 | + ) : | |
| 133 | + | |
| 134 | + extract($args, EXTR_SKIP); | |
| 135 | + /** This action is documented in geodirectory_shortcodes.php */ | |
| 136 | +			$width = empty($instance['width']) ? '294' : apply_filters('widget_width', $instance['width']);
 | |
| 137 | + /** This action is documented in geodirectory_shortcodes.php */ | |
| 138 | +			$height = empty($instance['heigh']) ? '370' : apply_filters('widget_heigh', $instance['heigh']);
 | |
| 139 | + /** This action is documented in geodirectory_shortcodes.php */ | |
| 140 | +			$maptype = empty($instance['maptype']) ? 'ROADMAP' : apply_filters('widget_maptype', $instance['maptype']);
 | |
| 141 | + /** This action is documented in geodirectory_shortcodes.php */ | |
| 142 | +			$zoom = empty($instance['zoom']) ? '13' : apply_filters('widget_zoom', $instance['zoom']);
 | |
| 143 | + /** This action is documented in geodirectory_shortcodes.php */ | |
| 144 | +			$autozoom = empty($instance['autozoom']) ? '' : apply_filters('widget_autozoom', $instance['autozoom']);
 | |
| 145 | + /** | |
| 146 | + * Filter the listing map value widget_sticky, to set if the map should be sticky or not (scroll with page). | |
| 147 | + * | |
| 148 | + * @since 1.0.0 | |
| 149 | + * @param bool $sticky True if should be sticky, false if not | |
| 150 | + */ | |
| 151 | +			$sticky = empty($instance['sticky']) ? '' : apply_filters('widget_sticky', $instance['sticky']);
 | |
| 152 | + /** This action is documented in geodirectory_shortcodes.php */ | |
| 153 | +			$scrollwheel = empty($instance['scrollwheel']) ? '0' : apply_filters('widget_scrollwheel', $instance['scrollwheel']);
 | |
| 154 | +			$showall = empty($instance['showall']) ? '0' : apply_filters('widget_showall', $instance['showall']);
 | |
| 155 | 155 | |
| 156 | 156 | /** | 
| 157 | - * Filter the listing map should to be displayed or not. | |
| 158 | - * | |
| 159 | - * @since 1.4.6 | |
| 157 | + * Filter the listing map should to be displayed or not. | |
| 160 | 158 | * | 
| 161 | - * @param bool $display true if map should be displayed, false if not. | |
| 162 | - */ | |
| 159 | + * @since 1.4.6 | |
| 160 | + * | |
| 161 | + * @param bool $display true if map should be displayed, false if not. | |
| 162 | + */ | |
| 163 | 163 | $show_map = apply_filters( 'geodir_show_map_listing', $display = true ); | 
| 164 | 164 |  			if ( !$show_map ) {
 | 
| 165 | 165 | return; | 
| 166 | 166 | } | 
| 167 | 167 | |
| 168 | - $map_args = array(); | |
| 169 | -            $map_args['map_canvas_name'] = str_replace('-', '_', $args['widget_id']);
 | |
| 170 | - $map_args['width'] = $width; | |
| 171 | - $map_args['height'] = $height; | |
| 172 | - | |
| 173 | - $map_args['scrollwheel'] = $scrollwheel; | |
| 174 | - $map_args['showall'] = $showall; | |
| 175 | - $map_args['child_collapse'] = '0'; | |
| 176 | - $map_args['sticky'] = $sticky; | |
| 177 | - $map_args['enable_cat_filters'] = false; | |
| 178 | - $map_args['enable_text_search'] = false; | |
| 179 | - $map_args['enable_post_type_filters'] = false; | |
| 180 | - $map_args['enable_location_filters'] = false; | |
| 181 | - $map_args['enable_jason_on_load'] = true; | |
| 168 | + $map_args = array(); | |
| 169 | +			$map_args['map_canvas_name'] = str_replace('-', '_', $args['widget_id']);
 | |
| 170 | + $map_args['width'] = $width; | |
| 171 | + $map_args['height'] = $height; | |
| 172 | + | |
| 173 | + $map_args['scrollwheel'] = $scrollwheel; | |
| 174 | + $map_args['showall'] = $showall; | |
| 175 | + $map_args['child_collapse'] = '0'; | |
| 176 | + $map_args['sticky'] = $sticky; | |
| 177 | + $map_args['enable_cat_filters'] = false; | |
| 178 | + $map_args['enable_text_search'] = false; | |
| 179 | + $map_args['enable_post_type_filters'] = false; | |
| 180 | + $map_args['enable_location_filters'] = false; | |
| 181 | + $map_args['enable_jason_on_load'] = true; | |
| 182 | 182 | |
| 183 | -            if (is_single()) {
 | |
| 184 | - | |
| 185 | - global $post; | |
| 186 | - $map_default_lat = $address_latitude = $post->post_latitude; | |
| 187 | - $map_default_lng = $address_longitude = $post->post_longitude; | |
| 188 | - $mapview = $post->post_mapview; | |
| 189 | - $mapzoom = $post->post_mapzoom; | |
| 190 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; | |
| 191 | - | |
| 192 | -            } else {
 | |
| 193 | - $default_location = geodir_get_default_location(); | |
| 194 | - | |
| 195 | - $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; | |
| 196 | - $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; | |
| 197 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; | |
| 198 | - $mapview = $maptype; | |
| 199 | - } | |
| 200 | - | |
| 201 | - if (empty($mapzoom)) $mapzoom = $zoom; | |
| 202 | - | |
| 203 | - // Set default map options | |
| 204 | - $map_args['ajax_url'] = geodir_get_ajax_url(); | |
| 205 | - $map_args['latitude'] = $map_default_lat; | |
| 206 | - $map_args['longitude'] = $map_default_lng; | |
| 207 | - $map_args['zoom'] = $zoom; | |
| 208 | - //$map_args['scrollwheel'] = true; | |
| 209 | - $map_args['scrollwheel'] = $scrollwheel; | |
| 210 | - $map_args['showall'] = $showall; | |
| 211 | - $map_args['streetViewControl'] = true; | |
| 212 | - $map_args['maptype'] = $maptype; | |
| 213 | - $map_args['showPreview'] = '0'; | |
| 214 | - $map_args['maxZoom'] = 21; | |
| 215 | - $map_args['autozoom'] = $autozoom; | |
| 216 | - $map_args['bubble_size'] = 'small'; | |
| 217 | - | |
| 218 | - echo $before_widget; | |
| 219 | - geodir_draw_map($map_args); | |
| 220 | - echo $after_widget; | |
| 221 | - | |
| 222 | - endif; | |
| 223 | - } | |
| 183 | +			if (is_single()) {
 | |
| 184 | + | |
| 185 | + global $post; | |
| 186 | + $map_default_lat = $address_latitude = $post->post_latitude; | |
| 187 | + $map_default_lng = $address_longitude = $post->post_longitude; | |
| 188 | + $mapview = $post->post_mapview; | |
| 189 | + $mapzoom = $post->post_mapzoom; | |
| 190 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; | |
| 191 | + | |
| 192 | +			} else {
 | |
| 193 | + $default_location = geodir_get_default_location(); | |
| 194 | + | |
| 195 | + $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; | |
| 196 | + $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; | |
| 197 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; | |
| 198 | + $mapview = $maptype; | |
| 199 | + } | |
| 200 | + | |
| 201 | + if (empty($mapzoom)) $mapzoom = $zoom; | |
| 202 | + | |
| 203 | + // Set default map options | |
| 204 | + $map_args['ajax_url'] = geodir_get_ajax_url(); | |
| 205 | + $map_args['latitude'] = $map_default_lat; | |
| 206 | + $map_args['longitude'] = $map_default_lng; | |
| 207 | + $map_args['zoom'] = $zoom; | |
| 208 | + //$map_args['scrollwheel'] = true; | |
| 209 | + $map_args['scrollwheel'] = $scrollwheel; | |
| 210 | + $map_args['showall'] = $showall; | |
| 211 | + $map_args['streetViewControl'] = true; | |
| 212 | + $map_args['maptype'] = $maptype; | |
| 213 | + $map_args['showPreview'] = '0'; | |
| 214 | + $map_args['maxZoom'] = 21; | |
| 215 | + $map_args['autozoom'] = $autozoom; | |
| 216 | + $map_args['bubble_size'] = 'small'; | |
| 217 | + | |
| 218 | + echo $before_widget; | |
| 219 | + geodir_draw_map($map_args); | |
| 220 | + echo $after_widget; | |
| 221 | + | |
| 222 | + endif; | |
| 223 | + } | |
| 224 | 224 | |
| 225 | 225 | /** | 
| 226 | 226 | * Sanitize listing page map widget form values as they are saved. | 
| 227 | 227 | * | 
| 228 | 228 | * @since 1.0.0 | 
| 229 | - * @since 1.5.1 Declare function public. | |
| 229 | + * @since 1.5.1 Declare function public. | |
| 230 | 230 | * | 
| 231 | 231 | * @param array $new_instance Values just sent to be saved. | 
| 232 | 232 | * @param array $old_instance Previously saved values from database. | 
| 233 | 233 | * | 
| 234 | 234 | * @return array Updated safe values to be saved. | 
| 235 | 235 | */ | 
| 236 | - public function update($new_instance, $old_instance) | |
| 237 | -    {
 | |
| 238 | - //save the widget | |
| 239 | - $instance = $old_instance; | |
| 240 | - $instance['width'] = strip_tags($new_instance['width']); | |
| 241 | - $instance['heigh'] = ($new_instance['heigh']); | |
| 242 | - $instance['maptype'] = ($new_instance['maptype']); | |
| 243 | - $instance['zoom'] = ($new_instance['zoom']); | |
| 244 | - $instance['autozoom'] = isset($new_instance['autozoom']) ? $new_instance['autozoom'] : ''; | |
| 245 | - $instance['sticky'] = isset($new_instance['sticky']) ? $new_instance['sticky'] : ''; | |
| 246 | - $instance['scrollwheel'] = isset($new_instance['scrollwheel']) ? ($new_instance['scrollwheel']) : ''; | |
| 247 | - $instance['showall'] = isset($new_instance['showall']) ? ($new_instance['showall']) : ''; | |
| 248 | - | |
| 249 | - return $instance; | |
| 250 | - } | |
| 236 | + public function update($new_instance, $old_instance) | |
| 237 | +	{
 | |
| 238 | + //save the widget | |
| 239 | + $instance = $old_instance; | |
| 240 | + $instance['width'] = strip_tags($new_instance['width']); | |
| 241 | + $instance['heigh'] = ($new_instance['heigh']); | |
| 242 | + $instance['maptype'] = ($new_instance['maptype']); | |
| 243 | + $instance['zoom'] = ($new_instance['zoom']); | |
| 244 | + $instance['autozoom'] = isset($new_instance['autozoom']) ? $new_instance['autozoom'] : ''; | |
| 245 | + $instance['sticky'] = isset($new_instance['sticky']) ? $new_instance['sticky'] : ''; | |
| 246 | + $instance['scrollwheel'] = isset($new_instance['scrollwheel']) ? ($new_instance['scrollwheel']) : ''; | |
| 247 | + $instance['showall'] = isset($new_instance['showall']) ? ($new_instance['showall']) : ''; | |
| 248 | + | |
| 249 | + return $instance; | |
| 250 | + } | |
| 251 | 251 | |
| 252 | 252 | /** | 
| 253 | 253 | * Back-end listing page map widget settings form. | 
| 254 | 254 | * | 
| 255 | 255 | * @since 1.0.0 | 
| 256 | - * @since 1.5.1 Declare function public. | |
| 256 | + * @since 1.5.1 Declare function public. | |
| 257 | 257 | * | 
| 258 | 258 | * @param array $instance Previously saved values from database. | 
| 259 | 259 | */ | 
| 260 | - public function form($instance) | |
| 261 | -    {
 | |
| 262 | - //widgetform in backend | |
| 263 | -        $instance = wp_parse_args((array)$instance, array('width' => '', 'heigh' => '', 'maptype' => '', 'zoom' => '', 'autozoom' => '', 'sticky' => '', 'scrollwheel' => '0', 'showall' => '0'));
 | |
| 264 | - $width = strip_tags($instance['width']); | |
| 265 | - $heigh = strip_tags($instance['heigh']); | |
| 266 | - $maptype = strip_tags($instance['maptype']); | |
| 267 | - $zoom = strip_tags($instance['zoom']); | |
| 268 | - $autozoom = strip_tags($instance['autozoom']); | |
| 269 | - $sticky = strip_tags($instance['sticky']); | |
| 270 | - $scrollwheel = strip_tags($instance['scrollwheel']); | |
| 271 | - $showall = strip_tags($instance['showall']); | |
| 272 | - ?> | |
| 260 | + public function form($instance) | |
| 261 | +	{
 | |
| 262 | + //widgetform in backend | |
| 263 | +		$instance = wp_parse_args((array)$instance, array('width' => '', 'heigh' => '', 'maptype' => '', 'zoom' => '', 'autozoom' => '', 'sticky' => '', 'scrollwheel' => '0', 'showall' => '0'));
 | |
| 264 | + $width = strip_tags($instance['width']); | |
| 265 | + $heigh = strip_tags($instance['heigh']); | |
| 266 | + $maptype = strip_tags($instance['maptype']); | |
| 267 | + $zoom = strip_tags($instance['zoom']); | |
| 268 | + $autozoom = strip_tags($instance['autozoom']); | |
| 269 | + $sticky = strip_tags($instance['sticky']); | |
| 270 | + $scrollwheel = strip_tags($instance['scrollwheel']); | |
| 271 | + $showall = strip_tags($instance['showall']); | |
| 272 | + ?> | |
| 273 | 273 | <p> | 
| 274 | 274 | <label | 
| 275 | 275 |                  for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Map Width <small>(Default is : 294) you can use px or % here</small>', 'geodirectory'); ?>
 | 
| @@ -298,14 +298,14 @@ discard block | ||
| 298 | 298 |                          name="<?php echo $this->get_field_name('maptype'); ?>">
 | 
| 299 | 299 | |
| 300 | 300 |                      <option <?php if (isset($maptype) && $maptype == 'ROADMAP') {
 | 
| 301 | - echo 'selected="selected"'; | |
| 302 | -                    } ?> value="ROADMAP"><?php _e('Road Map', 'geodirectory'); ?></option>
 | |
| 301 | + echo 'selected="selected"'; | |
| 302 | +					} ?> value="ROADMAP"><?php _e('Road Map', 'geodirectory'); ?></option>
 | |
| 303 | 303 |                      <option <?php if (isset($maptype) && $maptype == 'SATELLITE') {
 | 
| 304 | - echo 'selected="selected"'; | |
| 305 | -                    } ?> value="SATELLITE"><?php _e('Satellite Map', 'geodirectory'); ?></option>
 | |
| 304 | + echo 'selected="selected"'; | |
| 305 | +					} ?> value="SATELLITE"><?php _e('Satellite Map', 'geodirectory'); ?></option>
 | |
| 306 | 306 |                      <option <?php if (isset($maptype) && $maptype == 'HYBRID') {
 | 
| 307 | - echo 'selected="selected"'; | |
| 308 | -                    } ?> value="HYBRID"><?php _e('Hybrid Map', 'geodirectory'); ?></option>
 | |
| 307 | + echo 'selected="selected"'; | |
| 308 | +					} ?> value="HYBRID"><?php _e('Hybrid Map', 'geodirectory'); ?></option>
 | |
| 309 | 309 | <option <?php selected($maptype, 'TERRAIN');?> | 
| 310 | 310 |  							value="TERRAIN"><?php _e('Terrain Map', 'geodirectory'); ?></option>
 | 
| 311 | 311 | </select> | 
| @@ -313,8 +313,8 @@ discard block | ||
| 313 | 313 | </p> | 
| 314 | 314 | |
| 315 | 315 | <?php | 
| 316 | - $map_zoom_level = geodir_map_zoom_level(); | |
| 317 | - ?> | |
| 316 | + $map_zoom_level = geodir_map_zoom_level(); | |
| 317 | + ?> | |
| 318 | 318 | |
| 319 | 319 | <p> | 
| 320 | 320 | <label | 
| @@ -324,14 +324,14 @@ discard block | ||
| 324 | 324 |                  <select class="widefat" id="<?php echo $this->get_field_id('zoom'); ?>"
 | 
| 325 | 325 |                          name="<?php echo $this->get_field_name('zoom'); ?>"> <?php
 | 
| 326 | 326 | |
| 327 | -                    foreach ($map_zoom_level as $level) {
 | |
| 328 | - $selected = ''; | |
| 329 | - if ($level == $zoom) | |
| 330 | - $selected = 'selected="selected"'; | |
| 327 | +					foreach ($map_zoom_level as $level) {
 | |
| 328 | + $selected = ''; | |
| 329 | + if ($level == $zoom) | |
| 330 | + $selected = 'selected="selected"'; | |
| 331 | 331 | |
| 332 | - echo '<option ' . $selected . ' value="' . $level . '">' . $level . '</option>'; | |
| 332 | + echo '<option ' . $selected . ' value="' . $level . '">' . $level . '</option>'; | |
| 333 | 333 | |
| 334 | - } ?> | |
| 334 | + } ?> | |
| 335 | 335 | |
| 336 | 336 | </select> | 
| 337 | 337 | |
| @@ -344,8 +344,8 @@ discard block | ||
| 344 | 344 | : | 
| 345 | 345 |                  <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('autozoom'); ?>"
 | 
| 346 | 346 |                         name="<?php echo $this->get_field_name('autozoom'); ?>"<?php if ($autozoom) {
 | 
| 347 | - echo 'checked="checked"'; | |
| 348 | - } ?> /></label> | |
| 347 | + echo 'checked="checked"'; | |
| 348 | + } ?> /></label> | |
| 349 | 349 | </p> | 
| 350 | 350 | |
| 351 | 351 | <p> | 
| @@ -354,8 +354,8 @@ discard block | ||
| 354 | 354 | : | 
| 355 | 355 |                  <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('sticky'); ?>"
 | 
| 356 | 356 |                         name="<?php echo $this->get_field_name('sticky'); ?>"<?php if ($sticky) {
 | 
| 357 | - echo 'checked="checked"'; | |
| 358 | - } ?> /> </label> | |
| 357 | + echo 'checked="checked"'; | |
| 358 | + } ?> /> </label> | |
| 359 | 359 | </p> | 
| 360 | 360 | |
| 361 | 361 | <p> | 
| @@ -375,7 +375,7 @@ discard block | ||
| 375 | 375 | </p> --> | 
| 376 | 376 | |
| 377 | 377 | <?php | 
| 378 | - } | |
| 378 | + } | |
| 379 | 379 | } // class geodir_map_listingpage | 
| 380 | 380 | |
| 381 | 381 |  register_widget('geodir_map_listingpage');
 |