예제 #1
0
function wpgmaps_tag_basic($atts)
{
    global $wpgmza_current_map_id;
    extract(shortcode_atts(array('id' => '1'), $atts));
    $ret_msg = "";
    global $short_code_active;
    $wpgmza_current_map_id = $atts['id'];
    $res = wpgmza_get_map_data($atts['id']);
    if (!isset($res)) {
        echo __("Error: The map ID", "wp-google-maps") . " (" . $wpgmza_current_map_id . ") " . __("does not exist", "wp-google-maps");
        return;
    }
    $short_code_active = true;
    //$wpgmza_data = get_option('WPGMZA');
    $map_align = $res->alignment;
    wpgmza_check_if_marker_file_exists($wpgmza_current_map_id);
    $map_width_type = stripslashes($res->map_width_type);
    $map_height_type = stripslashes($res->map_height_type);
    if (!isset($map_width_type)) {
        $map_width_type == "px";
    }
    if (!isset($map_height_type)) {
        $map_height_type == "px";
    }
    if ($map_width_type == "%" && intval($res->map_width) > 100) {
        $res->map_width = 100;
    }
    if ($map_height_type == "%" && intval($res->map_height) > 100) {
        $res->map_height = 100;
    }
    if (!$map_align || $map_align == "" || $map_align == "1") {
        $map_align = "float:left;";
    } else {
        if ($map_align == "2") {
            $map_align = "margin-left:auto !important; margin-right:auto; !important; align:center;";
        } else {
            if ($map_align == "3") {
                $map_align = "float:right;";
            } else {
                if ($map_align == "4") {
                    $map_align = "";
                }
            }
        }
    }
    $map_style = "style=\"display:block; overflow:auto; width:" . $res->map_width . "" . $map_width_type . "; height:" . $res->map_height . "" . $map_height_type . "; {$map_align}\"";
    $map_other_settings = maybe_unserialize($res->other_settings);
    $sl_data = "";
    if (isset($map_other_settings['store_locator_enabled']) && $map_other_settings['store_locator_enabled'] == 1) {
        $sl_data = wpgmaps_sl_user_output_basic($wpgmza_current_map_id);
    } else {
        $sl_data = "";
    }
    $ret_msg .= "\r\n            <style>\r\n            #wpgmza_map img { max-width:none !important; }\r\n            </style>\r\n            \r\n            {$sl_data}    \r\n            <div id=\"wpgmza_map\" {$map_style}>\r\n            </div>\r\n        ";
    $wpgmza_main_settings = get_option("WPGMZA_OTHER_SETTINGS");
    if (isset($wpgmza_main_settings['wpgmza_custom_css']) && $wpgmza_main_settings['wpgmza_custom_css'] != "") {
        $ret_msg = "\r\n            <!-- WP Google Maps Custom CSS -->\r\n            <style type=\"text/css\">" . $wpgmza_main_settings['wpgmza_custom_css'] . "</style>\r\n            " . $ret_msg;
    }
    return $ret_msg;
}
function wpgmaps_tag_pro($atts)
{
    global $wpgmza_current_map_id;
    global $wpgmza_current_map_cat_selection;
    global $wpgmza_current_map_shortcode_data;
    global $wpgmza_current_map_type;
    global $wpgmza_current_mashup;
    global $wpgmza_mashup_ids;
    global $wpgmza_mashup_all;
    $wpgmza_current_mashup = false;
    extract(shortcode_atts(array('id' => '1', 'mashup' => false, 'mashup_ids' => false, 'cat' => 'all', 'type' => 'default', 'parent_id' => false, 'lat' => false, 'lng' => false), $atts));
    /* first check if we are using custom fields to generate the map */
    if (isset($atts['lng']) && isset($atts['lat']) && isset($atts['parent_id']) && $atts['lat'] && $atts['lng']) {
        $atts['id'] = $atts['parent_id'];
        /* set the main ID as the specified parent id */
        $wpgmza_current_map_id = $atts['parent_id'];
        $wpgmza_current_map_shortcode_data[$wpgmza_current_map_id]['lat'] = $atts['lat'];
        $wpgmza_current_map_shortcode_data[$wpgmza_current_map_id]['lng'] = $atts['lng'];
        $wpgmza_current_map_shortcode_data[$wpgmza_current_map_id]['parent_id'] = $atts['parent_id'];
        $wpgmza_using_custom_meta = true;
    } else {
        $wpgmza_current_map_shortcode_data[$wpgmza_current_map_id]['lat'] = false;
        $wpgmza_current_map_shortcode_data[$wpgmza_current_map_id]['lng'] = false;
        $wpgmza_current_map_shortcode_data[$wpgmza_current_map_id]['parent_id'] = false;
        $wpgmza_using_custom_meta = false;
    }
    $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
    if (isset($atts['mashup'])) {
        $wpgmza_mashup = $atts['mashup'];
    }
    if (isset($atts['parent_id'])) {
        $wpgmza_mashup_parent_id = $atts['parent_id'];
    }
    if (isset($wpgmza_mashup_ids) && $wpgmza_mashup_ids == "ALL") {
    } else {
        if (isset($atts['mashup_ids'])) {
            $wpgmza_mashup_ids[$atts['id']] = explode(",", $atts['mashup_ids']);
        }
    }
    if (isset($wpgmza_mashup)) {
        $wpgmza_current_mashup = true;
    }
    if (isset($wpgmza_mashup)) {
        $wpgmza_current_map_id = $wpgmza_mashup_parent_id;
        $res = wpgmza_get_map_data($wpgmza_mashup_parent_id);
    } else {
        $wpgmza_current_map_id = $atts['id'];
        if (isset($wpgmza_settings['wpgmza_settings_marker_pull']) && $wpgmza_settings['wpgmza_settings_marker_pull'] == '0') {
        } else {
            /* only check if marker file exists if they are using the XML method */
            wpgmza_check_if_marker_file_exists($wpgmza_current_map_id);
        }
        $res = wpgmza_get_map_data($atts['id']);
    }
    if (!isset($atts['cat']) || $atts['cat'] == "all" || $atts['cat'] == "0") {
        $wpgmza_current_map_cat_selection[$wpgmza_current_map_id] = 'all';
    } else {
        $wpgmza_current_map_cat_selection[$wpgmza_current_map_id] = explode(",", $atts['cat']);
    }
    if (!isset($atts['type']) || $atts['type'] == "default" || $atts['type'] == "") {
        $wpgmza_current_map_type[$wpgmza_current_map_id] = '';
    } else {
        $wpgmza_current_map_type[$wpgmza_current_map_id] = $atts['type'];
    }
    $map_other_settings = maybe_unserialize($res->other_settings);
    $iw_output = "";
    /* handle new modern infowindow HTML output */
    if (isset($wpgmza_settings['wpgmza_iw_type']) && $wpgmza_settings['wpgmza_iw_type'] == '1' || isset($map_other_settings['wpgmza_iw_type']) && $map_other_settings['wpgmza_iw_type'] == "1") {
        if (isset($wpgmza_settings['wpgmza_settings_infowindow_link_text'])) {
            $wpgmza_settings_infowindow_link_text = $wpgmza_settings['wpgmza_settings_infowindow_link_text'];
        } else {
            $wpgmza_settings_infowindow_link_text = __("More details", "wp-google-maps");
        }
        $iw_output = "<div id='wpgmza_iw_holder_" . $wpgmza_current_map_id . "' style='display:none;'>";
        $iw_output .= "<div class='wpgmza_modern_infowindow_inner wpgmza_modern_infowindow_inner_" . $wpgmza_current_map_id . "'>";
        $iw_output .= "<div class='wpgmza_modern_infowindow_close'> x </div>";
        $iw_output .= "<div class='wpgmza_iw_image'>";
        $iw_output .= "<img src='' style='max-width:100% !important;' class='wpgmza_iw_marker_image' />";
        $iw_output .= "<div class='wpgmza_iw_title'>";
        $iw_output .= "<p class='wpgmza_iw_title_p'></p>";
        $iw_output .= "</div>";
        $iw_output .= "";
        $iw_output .= "</div>";
        $iw_output .= "<div class='wpgmza_iw_address'>";
        $iw_output .= "<p class='wpgmza_iw_address_p'></p>";
        $iw_output .= "</div>";
        $iw_output .= "<div class='wpgmza_iw_description'>";
        $iw_output .= "<p class='wpgmza_iw_description_p'></p>";
        $iw_output .= "</div>";
        $iw_output .= "<div class='wpgmza_iw_buttons'>";
        $iw_output .= "<a href='#' class='wpgmza_button wpgmza_left wpgmza_directions_button'>" . __("Directions", "wp-google-maps") . "</a>";
        $iw_output .= "<a href='#' class='wpgmza_button wpgmza_right wpgmza_more_info_button'>{$wpgmza_settings_infowindow_link_text}</a>";
        $iw_output .= "</div>";
        $iw_output .= "</div>";
        $iw_output .= "</div>";
    }
    if (isset($wpgmza_settings['wpgmza_settings_markerlist_category'])) {
        $hide_category_column = $wpgmza_settings['wpgmza_settings_markerlist_category'];
    }
    if (isset($wpgmza_settings['wpgmza_settings_markerlist_icon'])) {
        $hide_icon_column = $wpgmza_settings['wpgmza_settings_markerlist_icon'];
    }
    if (isset($wpgmza_settings['wpgmza_settings_markerlist_title'])) {
        $hide_title_column = $wpgmza_settings['wpgmza_settings_markerlist_title'];
    }
    if (isset($wpgmza_settings['wpgmza_settings_markerlist_address'])) {
        $hide_address_column = $wpgmza_settings['wpgmza_settings_markerlist_address'];
    }
    if (isset($wpgmza_settings['wpgmza_settings_markerlist_description'])) {
        $hide_description_column = $wpgmza_settings['wpgmza_settings_markerlist_description'];
    }
    if (isset($wpgmza_settings['wpgmza_settings_filterbycat_type'])) {
        $filterbycat_type = $wpgmza_settings['wpgmza_settings_filterbycat_type'];
    } else {
        $filterbycat_type = false;
    }
    if (!$filterbycat_type) {
        $filterbycat_type = 1;
    }
    $map_width_type = stripslashes($res->map_width_type);
    $map_height_type = stripslashes($res->map_height_type);
    if (!isset($map_width_type)) {
        $map_width_type = "px";
    }
    if (!isset($map_height_type)) {
        $map_height_type = "px";
    }
    if ($map_width_type == "%" && intval($res->map_width) > 100) {
        $res->map_width = 100;
    }
    if ($map_height_type == "%" && intval($res->map_height) > 100) {
        $res->map_height = 100;
    }
    $map_align = $res->alignment;
    if (!$map_align || $map_align == "" || $map_align == "1") {
        $map_align = "float:left;";
    } else {
        if ($map_align == "2") {
            $map_align = "margin-left:auto !important; margin-right:auto !important; align:center;";
        } else {
            if ($map_align == "3") {
                $map_align = "float:right;";
            } else {
                if ($map_align == "4") {
                    $map_align = "clear:both;";
                }
            }
        }
    }
    $map_style = "style=\"display:block; overflow:auto; width:" . $res->map_width . "" . $map_width_type . "; height:" . $res->map_height . "" . $map_height_type . "; {$map_align}\"";
    global $short_code_active;
    $short_code_active = true;
    wp_register_style('wpgmaps-style-pro', plugins_url('css/wpgmza_style_pro.css', __FILE__));
    wp_enqueue_style('wpgmaps-style-pro');
    global $wpgmza_short_code_array;
    $wpgmza_short_code_array[] = $wpgmza_current_map_id;
    $d_enabled = $res->directions_enabled;
    $filterbycat = $res->filterbycat;
    $map_width = $res->map_width;
    $map_width_type = $res->map_width_type;
    // for marker list
    $default_marker = $res->default_marker;
    if (isset($res->default_to)) {
        $default_to = $res->default_to;
    } else {
        $default_to = "";
    }
    $show_location = $res->show_user_location;
    if ($show_location == "1") {
        $use_location_from = "<span style=\"font-size:0.75em;\"><button id=\"wpgmza_use_my_location_from\" mid=\"" . $wpgmza_current_map_id . "\" title='" . __("Use my location", "wp-google-maps") . "' ><img src='" . plugins_url(plugin_basename(dirname(__FILE__))) . "/images/mylocation.png' title='" . __("Use my location", "wp-google-maps") . "' width='15' /></button></span>";
        $use_location_to = "<span style=\"font-size:0.75em;\"><button id=\"wpgmza_use_my_location_to\" mid=\"" . $wpgmza_current_map_id . "\" title='" . __("Use my location", "wp-google-maps") . "' ><img src='" . plugins_url(plugin_basename(dirname(__FILE__))) . "/images/mylocation.png' title='" . __("Use my location", "wp-google-maps") . "' width='15' /></button></span>";
    } else {
        $use_location_from = "";
        $use_location_to = "";
    }
    if ($default_marker) {
        $default_marker = "<img src='" . $default_marker . "' />";
    } else {
        $default_marker = "<img src='" . wpgmaps_get_plugin_url() . "/images/marker.png' />";
    }
    $dbox_width = $res->dbox_width;
    $dbox_option = $res->dbox;
    /* set the width of the directions box */
    if (isset($map_other_settings['wpgmza_dbox_width_type'])) {
        $wpgmza_dbox_width_type = $map_other_settings['wpgmza_dbox_width_type'];
    } else {
        $wpgmza_dbox_width_type = "px";
    }
    if ($dbox_option == "1") {
        $dbox_style = "display:none; width:" . $dbox_width . $wpgmza_dbox_width_type . "; clear:both;";
    } else {
        if ($dbox_option == "2") {
            $dbox_style = "float:left; width:" . $dbox_width . $wpgmza_dbox_width_type . "; padding-right:10px; display:block; overflow:auto;";
        } else {
            if ($dbox_option == "3") {
                $dbox_style = "float:right; width:" . $dbox_width . $wpgmza_dbox_width_type . "; padding-right:10px; display:block; overflow:auto;";
            } else {
                if ($dbox_option == "4") {
                    $dbox_style = "float:none; width:" . $dbox_width . $wpgmza_dbox_width_type . "; padding-bottom:10px; display:block; overflow:auto; clear:both;";
                } else {
                    if ($dbox_option == "5") {
                        $dbox_style = "float:none; width:" . $dbox_width . $wpgmza_dbox_width_type . "; padding-top:10px; display:block; overflow:auto; clear:both;";
                    } else {
                        $dbox_style = "display:none;";
                    }
                }
            }
        }
    }
    $wpgmza_marker_list_output = "";
    $wpgmza_marker_filter_output = "";
    // Filter by category
    if ($filterbycat == 1) {
        if ($filterbycat_type == "1") {
            $wpgmza_marker_filter_output .= "<p id='wpgmza_filter_" . $wpgmza_current_map_id . "' style='text-align:left; margin-bottom:0px;'>" . __("Filter by", "wp-google-maps") . "";
            $wpgmza_filter_dropdown = wpgmza_pro_return_category_select_list($wpgmza_current_map_id);
            $wpgmza_marker_filter_output .= "<select mid=\"" . $wpgmza_current_map_id . "\" name=\"wpgmza_filter_select\" id=\"wpgmza_filter_select\">";
            $wpgmza_marker_filter_output .= $wpgmza_filter_dropdown;
            $wpgmza_marker_filter_output .= "</select></p>";
        } else {
            if (intval($filterbycat_type) == 2) {
                $wpgmza_marker_filter_output .= "<p id='wpgmza_filter_" . $wpgmza_current_map_id . "' style='text-align:left; margin-bottom:0px;'>" . __("Filter by", "wp-google-maps") . "</p>";
                $wpgmza_marker_filter_output .= "<div style=\"display:block; width:100%; height:auto; margin-top:10px;\">";
                $wpgmza_marker_filter_output .= "<div class='wpgmza_filter_container' id='wpgmza_filter_container_" . $wpgmza_current_map_id . "'>";
                $wpgmza_marker_filter_output .= wpgmza_pro_return_category_checkbox_list($wpgmza_current_map_id, true, false);
                $wpgmza_marker_filter_output .= "</div>";
                $wpgmza_marker_filter_output .= "</div>";
            } else {
                $wpgmza_marker_filter_output .= "<p id='wpgmza_filter_" . $wpgmza_current_map_id . "' style='text-align:left; margin-bottom:0px;'>" . __("Filter by", "wp-google-maps") . "";
                $wpgmza_filter_dropdown = wpgmza_pro_return_category_select_list($wpgmza_current_map_id);
                $wpgmza_marker_filter_output .= "<select mid=\"" . $wpgmza_current_map_id . "\" name=\"wpgmza_filter_select\" id=\"wpgmza_filter_select\">";
                $wpgmza_marker_filter_output .= $wpgmza_filter_dropdown;
                $wpgmza_marker_filter_output .= "</select></p>";
            }
        }
    }
    $wpgmza_marker_datatables_output = "";
    if (isset($hide_category_column) && $hide_category_column == "yes") {
        $wpgmza_marker_datatables_output .= "<style>.wpgmza_table_category { display: none !important; }</style>";
    }
    if (isset($hide_icon_column) && $hide_icon_column == "yes") {
        $wpgmza_marker_datatables_output .= "<style>.wpgmza_table_marker { display: none; }</style>";
    }
    if (isset($hide_title_column) && $hide_title_column == "yes") {
        $wpgmza_marker_datatables_output .= "<style>.wpgmza_table_title { display: none; }</style>";
    }
    if (isset($hide_address_column) && $hide_address_column == "yes") {
        $wpgmza_marker_datatables_output .= "<style>.wpgmza_table_address { display: none; }</style>";
    }
    if (isset($hide_description_column) && $hide_description_column == "yes") {
        $wpgmza_marker_datatables_output .= "<style>.wpgmza_table_description { display: none; }</style>";
    }
    $sl_data = "";
    if (isset($map_other_settings['store_locator_enabled']) && $map_other_settings['store_locator_enabled'] == 1) {
        $sl_data = wpgmaps_sl_user_output_pro($wpgmza_current_map_id);
        $wpgmza_marker_filter_output = "";
    } else {
        $sl_data = "";
    }
    // GET LIST OF MARKERS
    if (isset($map_other_settings['list_markers_by']) && $map_other_settings['list_markers_by'] != "") {
        /* they are using the new listing options */
        if ($map_other_settings['list_markers_by'] == "3") {
            if ($wpgmza_current_mashup) {
                $wpgmc = new wpgmza();
                $wpgmza_marker_list_output .= $wpgmc->list_markers(false, 3, $wpgmza_mashup_parent_id, $wpgmza_current_map_cat_selection[$wpgmza_current_map_id], true, $wpgmza_mashup_ids[$atts['id']]);
            } else {
                $wpgmc = new wpgmza();
                $wpgmza_marker_list_output .= $wpgmc->list_markers(false, 3, $wpgmza_current_map_id, $wpgmza_current_map_cat_selection[$wpgmza_current_map_id]);
            }
        } else {
            if ($map_other_settings['list_markers_by'] == "1") {
                if ($wpgmza_current_mashup) {
                    $wpgmc = new wpgmza();
                    $wpgmza_marker_list_output .= $wpgmc->list_markers(false, 1, $wpgmza_mashup_parent_id, $wpgmza_current_map_cat_selection[$wpgmza_mashup_parent_id], true, $wpgmza_mashup_ids[$atts['id']], false, $res->order_markers_by, $res->order_markers_choice);
                } else {
                    $wpgmc = new wpgmza();
                    $wpgmza_marker_list_output .= $wpgmc->list_markers(false, 1, $wpgmza_current_map_id, $wpgmza_current_map_cat_selection[$wpgmza_current_map_id], false, false, false, $res->order_markers_by, $res->order_markers_choice);
                }
            } else {
                if ($map_other_settings['list_markers_by'] == "2") {
                    if ($wpgmza_current_mashup) {
                        $wpgmc = new wpgmza();
                        $wpgmza_marker_list_output .= $wpgmc->list_markers(false, 2, $wpgmza_mashup_parent_id, $wpgmza_current_map_cat_selection[$wpgmza_mashup_parent_id], true, $wpgmza_mashup_ids[$atts['id']]);
                    } else {
                        $wpgmc = new wpgmza();
                        $wpgmza_marker_list_output .= $wpgmc->list_markers(false, 2, $wpgmza_current_map_id, $wpgmza_current_map_cat_selection[$wpgmza_current_map_id]);
                    }
                } else {
                    if ($map_other_settings['list_markers_by'] == "4") {
                        if ($wpgmza_current_mashup) {
                            $wpgmc = new wpgmza();
                            $wpgmza_marker_list_output .= $wpgmc->list_markers(false, 4, $wpgmza_mashup_parent_id, $wpgmza_current_map_cat_selection[$wpgmza_mashup_parent_id], true, $wpgmza_mashup_ids[$atts['id']]);
                        } else {
                            $wpgmc = new wpgmza();
                            $wpgmza_marker_list_output .= $wpgmc->list_markers(false, 4, $wpgmza_current_map_id, $wpgmza_current_map_cat_selection[$wpgmza_current_map_id]);
                        }
                    }
                }
            }
        }
    } else {
        if ($res->listmarkers == 1 && $res->listmarkers_advanced == 1) {
            if ($wpgmza_current_mashup) {
                $wpgmza_marker_list_output .= wpgmza_return_marker_list($wpgmza_mashup_parent_id, false, $map_width . $map_width_type, $wpgmza_current_mashup, $wpgmza_mashup_ids[$atts['id']]);
            } else {
                $wpgmza_marker_list_output .= wpgmza_return_marker_list($wpgmza_current_map_id, false, $map_width . $map_width_type, false);
            }
        } else {
            if ($res->listmarkers == 1 && $res->listmarkers_advanced == 0) {
                global $wpdb;
                global $wpgmza_tblname;
                // marker sorting functionality
                if ($res->order_markers_by == 1) {
                    $order_by = "id";
                } else {
                    if ($res->order_markers_by == 2) {
                        $order_by = "title";
                    } else {
                        if ($res->order_markers_by == 3) {
                            $order_by = "address";
                        } else {
                            if ($res->order_markers_by == 4) {
                                $order_by = "description";
                            } else {
                                if ($res->order_markers_by == 5) {
                                    $order_by = "category";
                                } else {
                                    $order_by = "id";
                                }
                            }
                        }
                    }
                }
                if ($res->order_markers_choice == 1) {
                    $order_choice = "ASC";
                } else {
                    $order_choice = "DESC";
                }
                if ($wpgmza_current_mashup) {
                    $wpgmza_cnt = 0;
                    $sql_string1 = "";
                    if ($wpgmza_mashup_ids[$atts['id']][0] == "ALL") {
                        $wpgmza_sql1 = "SELECT * FROM {$wpgmza_tblname} ORDER BY `{$order_by}` {$order_choice}";
                    } else {
                        $wpgmza_id_cnt = count($wpgmza_mashup_ids[$atts['id']]);
                        foreach ($wpgmza_mashup_ids[$atts['id']] as $wpgmza_map_id) {
                            $wpgmza_cnt++;
                            if ($wpgmza_cnt == 1) {
                                $sql_string1 .= "`map_id` = '{$wpgmza_map_id}' ";
                            } elseif ($wpgmza_cnt > 1 && $wpgmza_cnt < $wpgmza_id_cnt) {
                                $sql_string1 .= "OR `map_id` = '{$wpgmza_map_id}' ";
                            } else {
                                $sql_string1 .= "OR `map_id` = '{$wpgmza_map_id}' ";
                            }
                        }
                        $wpgmza_sql1 = "SELECT * FROM {$wpgmza_tblname} WHERE {$sql_string1} ORDER BY `{$order_by}` {$order_choice}";
                    }
                } else {
                    $wpgmza_sql1 = "SELECT * FROM {$wpgmza_tblname} WHERE `map_id` = '{$wpgmza_current_map_id}' ORDER BY `{$order_by}` {$order_choice}";
                }
                $results = $wpdb->get_results($wpgmza_sql1);
                $wpgmza_marker_list_output .= "\r\n                    <div style='clear:both;'>\r\n                    <table id=\"wpgmza_marker_list\" class=\"wpgmza_marker_list_class\" cellspacing=\"0\" cellpadding=\"0\" style='width:" . $map_width . "" . $map_width_type . "'>\r\n                    <tbody>\r\n            ";
                $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
                if (isset($wpgmza_settings['wpgmza_settings_image_resizing']) && $wpgmza_settings['wpgmza_settings_image_resizing'] == 'yes') {
                    $wpgmza_image_resizing = true;
                } else {
                    $wpgmza_image_resizing = false;
                }
                if (isset($wpgmza_settings['wpgmza_settings_image_height'])) {
                    $wpgmza_image_height = $wpgmza_settings['wpgmza_settings_image_height'];
                } else {
                    $wpgmza_image_height = false;
                }
                if (isset($wpgmza_settings['wpgmza_settings_image_height'])) {
                    $wpgmza_image_height = $wpgmza_settings['wpgmza_settings_image_height'] . "px";
                } else {
                    $wpgmza_image_height = false;
                }
                if (isset($wpgmza_settings['wpgmza_settings_image_width'])) {
                    $wpgmza_image_width = $wpgmza_settings['wpgmza_settings_image_width'] . "px";
                } else {
                    $wpgmza_image_width = false;
                }
                if (!$wpgmza_image_height || !isset($wpgmza_image_height)) {
                    $wpgmza_image_height = "auto";
                }
                if (!$wpgmza_image_width || !isset($wpgmza_image_width)) {
                    $wpgmza_image_width = "auto";
                }
                $wmcnt = 0;
                foreach ($results as $result) {
                    $wmcnt++;
                    $img = $result->pic;
                    $wpgmaps_id = $result->id;
                    $link = $result->link;
                    $icon = $result->icon;
                    $wpgmaps_lat = $result->lat;
                    $wpgmaps_lng = $result->lng;
                    $wpgmaps_address = $result->address;
                    /* added in 5.52 - phasing out timthumb */
                    /* timthumb completely removed in 5.54 */
                    /*if ($wpgmza_use_timthumb == "" || !isset($wpgmza_use_timthumb)) {
                    		$pic = "<img src='".wpgmaps_get_plugin_url()."/timthumb.php?src=".$result->pic."&h=".$wpgmza_image_height."&w=".$wpgmza_image_width."&zc=1' />";
                                 } else {*/
                    if (!$img) {
                        $pic = "";
                    } else {
                        if ($wpgmza_image_resizing) {
                            $pic = "<img src='" . $result->pic . "' class='wpgmza_map_image' style=\"margin:5px; height:" . $wpgmza_image_height . "px; width:" . $wpgmza_image_width . ".px\" />";
                        } else {
                            $pic = "<img src='" . $result->pic . "' class='wpgmza_map_image' style=\"margin:5px;\" />";
                        }
                    }
                    /*}*/
                    if (!$icon) {
                        $icon = $default_marker;
                    } else {
                        $icon = "<img src='" . $result->icon . "' />";
                    }
                    if ($d_enabled == "1") {
                        $wpgmaps_dir_text = "<br /><a href=\"javascript:void(0);\" id=\"{$wpgmza_current_map_id}\" title=\"" . __("Get directions to", "wp-google-maps") . " " . $result->title . "\" class=\"wpgmza_gd\" wpgm_addr_field=\"" . $wpgmaps_address . "\" gps=\"{$wpgmaps_lat},{$wpgmaps_lng}\">" . __("Directions", "wp-google-maps") . "</a>";
                    } else {
                        $wpgmaps_dir_text = "";
                    }
                    if ($result->description) {
                        $wpgmaps_desc_text = "<br />" . $result->description . "";
                    } else {
                        $wpgmaps_desc_text = "";
                    }
                    if ($wmcnt % 2) {
                        $oddeven = "wpgmaps_odd";
                    } else {
                        $oddeven = "wpgmaps_even";
                    }
                    $wpgmza_marker_list_output .= "\r\n                    <tr id=\"wpgmza_marker_" . $result->id . "\" mid=\"" . $result->id . "\" mapid=\"" . $result->map_id . "\" class=\"wpgmaps_mlist_row {$oddeven}\">\r\n                        <td height=\"40\" class=\"wpgmaps_mlist_marker\">" . $icon . "</td>\r\n                        <td class=\"wpgmaps_mlist_pic\" style=\"width:" . ($wpgmza_image_width + 20) . "px;\">{$pic}</td>\r\n                        <td  valign=\"top\" align=\"left\" class=\"wpgmaps_mlist_info\">\r\n                            <strong><a href=\"javascript:openInfoWindow({$wpgmaps_id});\" id=\"wpgmaps_marker_{$wpgmaps_id}\" title=\"" . stripslashes($result->title) . "\">" . stripslashes($result->title) . "</a></strong>\r\n                            " . stripslashes($wpgmaps_desc_text) . "\r\n                            {$wpgmaps_dir_text}\r\n                        </td>\r\n\r\n                    </tr>";
                }
                $wpgmza_marker_list_output .= "</tbody></table></div>";
            } else {
                $wpgmza_marker_list_output = "";
            }
        }
    }
    $dbox_div = "\r\n        <div id=\"wpgmaps_directions_edit_" . $wpgmza_current_map_id . "\" style=\"{$dbox_style}\" class=\"wpgmaps_directions_outer_div\">\r\n            <h2>" . __("Get Directions", "wp-google-maps") . "</h2>\r\n            <div id=\"wpgmaps_directions_editbox_" . $wpgmza_current_map_id . "\">\r\n                <table>\r\n                    <tr>\r\n                        <td><label for=\"wpgmza_dir_type_" . $wpgmza_current_map_id . "\">" . __("For", "wp-google-maps") . "</label></td><td>\r\n                            <select id=\"wpgmza_dir_type_" . $wpgmza_current_map_id . "\" name=\"wpgmza_dir_type_" . $wpgmza_current_map_id . "\">\r\n                            <option value=\"DRIVING\" selected=\"selected\">" . __("Driving", "wp-google-maps") . "</option>\r\n                            <option value=\"WALKING\">" . __("Walking", "wp-google-maps") . "</option>\r\n                            <option value=\"BICYCLING\">" . __("Bicycling", "wp-google-maps") . "</option>\r\n                            </select>\r\n                            &nbsp;\r\n                            <a href=\"javascript:void(0);\" mapid=\"" . $wpgmza_current_map_id . "\" id=\"wpgmza_show_options_" . $wpgmza_current_map_id . "\" onclick=\"wpgmza_show_options(" . $wpgmza_current_map_id . ");\" style=\"font-size:10px;\">" . __("show options", "wp-google-maps") . "</a>\r\n                            <a href=\"javascript:void(0);\" mapid=\"" . $wpgmza_current_map_id . "\" id=\"wpgmza_hide_options_" . $wpgmza_current_map_id . "\" onclick=\"wpgmza_hide_options(" . $wpgmza_current_map_id . ");\" style=\"font-size:10px; display:none;\">" . __("hide options", "wp-google-maps") . "</a>\r\n                        <div style=\"display:none\" id=\"wpgmza_options_box_" . $wpgmza_current_map_id . "\">\r\n                            <input type=\"checkbox\" id=\"wpgmza_tolls_" . $wpgmza_current_map_id . "\" name=\"wpgmza_tolls_" . $wpgmza_current_map_id . "\" value=\"tolls\" /> <label for=\"wpgmza_tolls_" . $wpgmza_current_map_id . "\">" . __("Avoid Tolls", "wp-google-maps") . "</label><br />\r\n                            <input type=\"checkbox\" id=\"wpgmza_highways_" . $wpgmza_current_map_id . "\" name=\"wpgmza_highways_" . $wpgmza_current_map_id . "\" value=\"highways\" /> <label for=\"wpgmza_highways_" . $wpgmza_current_map_id . "\">" . __("Avoid Highways", "wp-google-maps") . "</label>\r\n                        </div>\r\n\r\n                        </td>\r\n                    </tr>\r\n                    <tr class='wpgmaps_from_row'><td class='wpgmaps_from_td1'><label for=\"wpgmza_input_from_" . $wpgmza_current_map_id . "\">" . __("From", "wp-google-maps") . "</label></td><td width='90%' class='wpgmaps_from_td2'><input type=\"text\" value=\"\" id=\"wpgmza_input_from_" . $wpgmza_current_map_id . "\" style='width:80%' /> {$use_location_from}</td></tr>\r\n                    <tr class='wpgmaps_to_row'><td class='wpgmaps_to_td1'><label for=\"wpgmza_input_to_" . $wpgmza_current_map_id . "\">" . __("To", "wp-google-maps") . "</td><td width='90%' class='wpgmaps_to_td2'><input type=\"text\" value=\"{$default_to}\" id=\"wpgmza_input_to_" . $wpgmza_current_map_id . "\" style='width:80%' /> {$use_location_to}</td></tr>\r\n                    <tr>\r\n\r\n                      <td>\r\n                        </td><td>\r\n                      <input onclick=\"javascript:void(0);\" class=\"wpgmaps_get_directions\" id=\"" . $wpgmza_current_map_id . "\" type=\"button\" value=\"" . __("Go", "wp-google-maps") . "\"/>\r\n                      </td>\r\n                    </tr>\r\n                </table>\r\n            </div>\r\n\r\n\r\n    ";
    if ($dbox_option == "5" || $dbox_option == "1" || !isset($dbox_option)) {
        if ($wpgmza_current_mashup) {
            $wpgmza_anchors = $wpgmza_mashup_ids[$atts['id']];
        } else {
            $wpgmza_anchors = $wpgmza_current_map_id;
        }
        $ret_msg = "\r\n            {$wpgmza_marker_datatables_output}\r\n            <style>\r\n            .wpgmza_map img { max-width:none !important; }\r\n            .wpgmza_widget { overflow: auto; }\r\n            </style>\r\n            " . wpgmaps_check_approval_string() . "\r\n            " . wpgmaps_return_marker_anchors($wpgmza_anchors) . "\r\n            {$wpgmza_marker_filter_output}\r\n            {$sl_data}\r\n            " . apply_filters("wpgooglemaps_filter_map_div_output", "<div class=\"wpgmza_map\" id=\"wpgmza_map_" . $wpgmza_current_map_id . "\" {$map_style}> </div>", $wpgmza_current_map_id) . "\r\n            {$wpgmza_marker_list_output}\r\n\r\n            <div style=\"display:block; width:100%;\">\r\n\r\n                {$dbox_div}\r\n                    <div id=\"wpgmaps_directions_notification_" . $wpgmza_current_map_id . "\" style=\"display:none;\">" . __("Fetching directions...", "wp-google-maps") . "...</div>\r\n                    <div id=\"wpgmaps_directions_reset_" . $wpgmza_current_map_id . "\" style=\"display:none;\">\r\n                        <a href='javascript:void(0)' onclick='wpgmza_reset_directions(" . $wpgmza_current_map_id . ");' id='wpgmaps_reset_directions' title='" . __("Reset directions", "wp-google-maps") . "'>" . __("Reset directions", "wp-google-maps") . "</a>\r\n                        <br /><a href='' id='wpgmaps_print_directions_" . $wpgmza_current_map_id . "' title='" . __("Print directions", "wp-google-maps") . "'>" . __("Print directions", "wp-google-maps") . "</a>\r\n                    </div>\r\n                    <div id=\"directions_panel_" . $wpgmza_current_map_id . "\"></div>\r\n                </div>\r\n            </div>\r\n\r\n        ";
    } else {
        if ($wpgmza_current_mashup) {
            $wpgmza_anchors = $wpgmza_mashup_ids[$atts['id']];
        } else {
            $wpgmza_anchors = $wpgmza_current_map_id;
        }
        $ret_msg = "\r\n            {$wpgmza_marker_datatables_output}\r\n            <style>\r\n            .wpgmza_map img { max-width:none !important; }\r\n            .wpgmza_widget { overflow: auto; }\r\n            </style>\r\n            \r\n            <div style=\"display:block; width:100%; overflow:auto;\">\r\n\r\n            \t{$dbox_div}\r\n                <div id=\"wpgmaps_directions_notification_" . $wpgmza_current_map_id . "\" style=\"display:none;\">" . __("Fetching directions...", "wp-google-maps") . "...</div>\r\n                <div id=\"wpgmaps_directions_reset_" . $wpgmza_current_map_id . "\" style=\"display:none;\">\r\n                    <a href='javascript:void(0)' onclick='wpgmza_reset_directions(" . $wpgmza_current_map_id . ");' id='wpgmaps_reset_directions' title='" . __("Reset directions", "wp-google-maps") . "'>" . __("Reset directions", "wp-google-maps") . "</a>\r\n                    <br /><a href='' id='wpgmaps_print_directions_" . $wpgmza_current_map_id . "' title='" . __("Print directions", "wp-google-maps") . "'>" . __("Print directions", "wp-google-maps") . "</a>\r\n                </div>\r\n                <div id=\"directions_panel_" . $wpgmza_current_map_id . "\"></div>\r\n            </div>\r\n                \r\n                \r\n\r\n                {$wpgmza_marker_filter_output}\r\n                {$sl_data}\r\n\r\n            " . wpgmaps_return_marker_anchors($wpgmza_anchors) . "\r\n            " . apply_filters("wpgooglemaps_filter_map_div_output", "<div class=\"wpgmza_map\" id=\"wpgmza_map_" . $wpgmza_current_map_id . "\" {$map_style}> </div>") . "   \r\n            \r\n                <div style='text-align:center; width:90%; border:1px solid #ccc; padding:10px;'>\r\n                    <h1>" . __("The map could not load.", "wp-google-maps") . "</h1><p>" . __("This is normally caused by a conflict with another plugin or a JavaScript error that is preventing our plugin's Javascript from executing. Please try disable all plugins one by one and see if this problem persists. If it persists, please contact nick@wpgmaps.com for support.", "wp-google-maps") . "</p>\r\n                    \r\n                </div>\r\n            </div>\r\n\r\n            {$wpgmza_marker_list_output}\r\n            </div>\r\n\r\n        ";
    }
    if (function_exists("wpgmza_register_ugm_version")) {
        $ugm_enabled = $res->ugm_enabled;
        if ($ugm_enabled == 1) {
            $ret_msg .= wpgmaps_ugm_user_form($wpgmza_current_map_id);
        }
    }
    if ($wpgmza_using_custom_meta) {
        /* we're using meta fields to generate the map, ignore default functionality */
        $ret_msg = "\r\n            <style>\r\n                .wpgmza_map img { max-width:none !important; }\r\n                .wpgmza_widget { overflow: auto; }\r\n            </style>\r\n            " . apply_filters("wpgooglemaps_filter_map_div_output", "<div class=\"wpgmza_map\" id=\"wpgmza_map_" . $wpgmza_current_map_id . "\" {$map_style}> </div>") . "\r\n\r\n            ";
    }
    $wpgmza_main_settings = get_option("WPGMZA_OTHER_SETTINGS");
    if (isset($wpgmza_main_settings['wpgmza_custom_css']) && $wpgmza_main_settings['wpgmza_custom_css'] != "") {
        $ret_msg = "\r\n            <!-- WP Google Maps Custom CSS -->\r\n            <style type=\"text/css\">" . $wpgmza_main_settings['wpgmza_custom_css'] . "</style>\r\n            " . $ret_msg;
    }
    /* modern infowindow output */
    /* $ret_msg = $ret_msg.$iw_output; deprecated in version 5.63 as the info window is now being created programatically with JS */
    $ret_msg = $ret_msg;
    return $ret_msg;
}
예제 #3
0
/**
 * Handle the WPGMZA shortcode
 * The shortcode attributes are identified and the relevant data is localized and the JS file enqueued
 * @param  array    $atts   array of shortcode attributes
 * @return void
 */
function wpgmaps_tag_basic($atts)
{
    global $wpgmza_current_map_id;
    global $wpgmza_version;
    global $short_code_active;
    global $wpgmza_override;
    extract(shortcode_atts(array('id' => '1'), $atts));
    $ret_msg = "";
    $wpgmza_current_map_id = $atts['id'];
    $res = wpgmza_get_map_data($atts['id']);
    if (!isset($res)) {
        echo __("Error: The map ID", "wp-google-maps") . " (" . $wpgmza_current_map_id . ") " . __("does not exist", "wp-google-maps");
        return;
    }
    $user_api_key = get_option('wpgmza_google_maps_api_key');
    if (!$user_api_key || $user_api_key == "") {
        $adminurl = admin_url('admin.php?page=wp-google-maps-menu-settings#tabs-4');
        $link = sprintf(__("In order for your map to display, please make sure you insert your Google Maps JavaScript API key in the <a href='%s' target='_BLANK'>Maps->Settings->Advanced tab</a>.", 'wp-google-maps'), $adminurl);
        echo "<div class='wpgmza_error' style='background-image:url(" . plugins_url('images/map-bg.jpg', __FILE__) . "); display:block; padding:15px; border:1px solid #eee; overflow:auto;'>";
        echo "<h3>" . __("WP Google Maps Error", "wp-google-maps") . "</h3>";
        echo "<p style='color:#333;'><strong>" . $link . "</strong></p>";
        echo "</div>";
        return;
    }
    if (!function_exists('wpgmaps_admin_styles_pro')) {
        wp_register_style('wpgmaps-style', plugins_url('css/wpgmza_style.css', __FILE__), array(), $wpgmza_version);
        wp_enqueue_style('wpgmaps-style');
    }
    if (isset($atts['zoom'])) {
        $zoom_override = $atts['zoom'];
        $wpgmza_override['zoom'] = $zoom_override;
    }
    $map_align = $res->alignment;
    $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
    if (isset($wpgmza_settings['wpgmza_settings_marker_pull']) && $wpgmza_settings['wpgmza_settings_marker_pull'] == '0') {
    } else {
        /* only check if marker file exists if they are using the XML method */
        wpgmza_check_if_marker_file_exists($wpgmza_current_map_id);
    }
    $map_width_type = stripslashes($res->map_width_type);
    $map_height_type = stripslashes($res->map_height_type);
    if (!isset($map_width_type)) {
        $map_width_type == "px";
    }
    if (!isset($map_height_type)) {
        $map_height_type == "px";
    }
    if ($map_width_type == "%" && intval($res->map_width) > 100) {
        $res->map_width = 100;
    }
    if ($map_height_type == "%" && intval($res->map_height) > 100) {
        $res->map_height = 100;
    }
    if (!$map_align || $map_align == "" || $map_align == "1") {
        $map_align = "float:left;";
    } else {
        if ($map_align == "2") {
            $map_align = "margin-left:auto !important; margin-right:auto; !important; align:center;";
        } else {
            if ($map_align == "3") {
                $map_align = "float:right;";
            } else {
                if ($map_align == "4") {
                    $map_align = "";
                }
            }
        }
    }
    $map_style = "style=\"display:block; overflow:auto; width:" . $res->map_width . "" . $map_width_type . "; height:" . $res->map_height . "" . $map_height_type . "; {$map_align}\"";
    $map_other_settings = maybe_unserialize($res->other_settings);
    $sl_data = "";
    if (isset($map_other_settings['store_locator_enabled']) && $map_other_settings['store_locator_enabled'] == 1) {
        $sl_data = wpgmaps_sl_user_output_basic($wpgmza_current_map_id);
    } else {
        $sl_data = "";
    }
    $ret_msg .= "\n            <style>\n            #wpgmza_map img { max-width:none !important; }\n            .wpgmza_widget { overflow: auto; }\n            </style>\n            \n            {$sl_data}    \n            <div id=\"wpgmza_map\" {$map_style}>\n            </div>\n        ";
    if (isset($wpgmza_main_settings['wpgmza_custom_css']) && $wpgmza_main_settings['wpgmza_custom_css'] != "") {
        $ret_msg = "\n            <!-- WP Google Maps Custom CSS -->\n            <style type=\"text/css\">" . $wpgmza_main_settings['wpgmza_custom_css'] . "</style>\n            " . $ret_msg;
    }
    $wpgmza_locale = get_locale();
    $wpgmza_suffix = ".com";
    /* Hebrew correction */
    if ($wpgmza_locale == "he_IL") {
        $wpgmza_locale = "iw";
    }
    /* Chinese integration */
    if ($wpgmza_locale == "zh_CN") {
        $wpgmza_suffix = ".cn";
    } else {
        $wpgmza_suffix = ".com";
    }
    $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
    /**
     * Only register the below scrips so that they are available on demand. 
     */
    if (isset($wpgmza_settings['wpgmza_settings_remove_api']) && $wpgmza_settings['wpgmza_settings_remove_api'] == "yes") {
        $wpgaps_core_dependancy = array();
    } else {
        if (isset($wpgmza_settings['wpgmza_api_version']) && $wpgmza_settings['wpgmza_api_version'] != "") {
            $api_version_string = "v=" . $wpgmza_settings['wpgmza_api_version'] . "&";
        } else {
            $api_version_string = "v=3.exp&";
        }
        $wpgmza_api_key = get_option('wpgmza_google_maps_api_key');
        if ($wpgmza_api_key) {
            wp_enqueue_script('wpgmza_api_call', '//maps.google' . $wpgmza_suffix . '/maps/api/js?' . $api_version_string . 'key=' . $wpgmza_api_key . '&language=' . $wpgmza_locale, array(), null);
        } else {
            wp_enqueue_script('wpgmza_api_call', '//maps.google' . $wpgmza_suffix . '/maps/api/js?' . $api_version_string . 'language=' . $wpgmza_locale, array(), null);
        }
        $wpgaps_core_dependancy = array('wpgmza_api_call');
    }
    wp_enqueue_script('wpgmaps_core', plugins_url('/js/wpgmaps.min.js', __FILE__), $wpgaps_core_dependancy, $wpgmza_version . 'b', false);
    $res = array();
    $res[0] = wpgmza_get_map_data($wpgmza_current_map_id);
    $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
    if (isset($wpgmza_settings['wpgmza_api_version'])) {
        $api_version = $wpgmza_settings['wpgmza_api_version'];
        if (isset($api_version) && $api_version != "") {
            $api_version_string = "v={$api_version}&";
        } else {
            $api_version_string = "v=3.exp&";
        }
    } else {
        $api_version_string = "v=3.exp&";
    }
    $map_other_settings = maybe_unserialize($res[0]->other_settings);
    $res[0]->other_settings = $map_other_settings;
    $res[0]->map_width_type = stripslashes($res[0]->map_width_type);
    if (isset($res[0]->other_settings['wpgmza_theme_data']) && $res[0]->other_settings['wpgmza_theme_data'] != '') {
        $res[0]->other_settings['wpgmza_theme_data'] = html_entity_decode(stripslashes($res[0]->other_settings['wpgmza_theme_data']));
    }
    $polygonoptions = array();
    $total_poly_array = wpgmza_b_return_polygon_id_array($wpgmza_current_map_id);
    if ($total_poly_array > 0) {
        foreach ($total_poly_array as $poly_id) {
            $polygonoptions[$poly_id] = wpgmza_b_return_poly_options($poly_id);
            $tmp_poly_array = wpgmza_b_return_polygon_array($poly_id);
            $poly_data_raw_array = array();
            foreach ($tmp_poly_array as $single_poly) {
                $poly_data_raw = str_replace(" ", "", $single_poly);
                $poly_data_raw = explode(",", $poly_data_raw);
                $lat = $poly_data_raw[0];
                $lng = $poly_data_raw[1];
                $poly_data_raw_array[] = $poly_data_raw;
            }
            $polygonoptions[$poly_id]->polydata = $poly_data_raw_array;
            $linecolor = $polygonoptions[$poly_id]->linecolor;
            $fillcolor = $polygonoptions[$poly_id]->fillcolor;
            $fillopacity = $polygonoptions[$poly_id]->opacity;
            if (!$linecolor) {
                $polygonoptions[$poly_id]->linecolor = "000000";
            }
            if (!$fillcolor) {
                $polygonoptions[$poly_id]->fillcolor = "66FF00";
            }
            if (!$fillopacity) {
                $polygonoptions[$poly_id]->opacity = "0.5";
            }
        }
    } else {
        $polygonoptions = array();
    }
    $polylineoptions = array();
    $total_poly_array = wpgmza_b_return_polyline_id_array($wpgmza_current_map_id);
    if ($total_poly_array > 0) {
        foreach ($total_poly_array as $poly_id) {
            $polylineoptions[$poly_id] = wpgmza_b_return_polyline_options($poly_id);
            $tmp_poly_array = wpgmza_b_return_polyline_array($poly_id);
            $poly_data_raw_array = array();
            foreach ($tmp_poly_array as $single_poly) {
                $poly_data_raw = str_replace(" ", "", $single_poly);
                $poly_data_raw = str_replace(")", "", $poly_data_raw);
                $poly_data_raw = str_replace("(", "", $poly_data_raw);
                $poly_data_raw = explode(",", $poly_data_raw);
                $lat = $poly_data_raw[0];
                $lng = $poly_data_raw[1];
                $poly_data_raw_array[] = $poly_data_raw;
            }
            $polylineoptions[$poly_id]->polydata = $poly_data_raw_array;
            if (isset($polylineoptions[$poly_id]->linecolor)) {
                $linecolor = $polylineoptions[$poly_id]->linecolor;
            } else {
                $linecolor = false;
            }
            if (isset($polylineoptions[$poly_id]->fillcolor)) {
                $fillcolor = $polylineoptions[$poly_id]->fillcolor;
            } else {
                $fillcolor = false;
            }
            if (isset($polylineoptions[$poly_id]->opacity)) {
                $fillopacity = $polylineoptions[$poly_id]->opacity;
            } else {
                $fillopacity = false;
            }
            if (!$linecolor) {
                $polylineoptions[$poly_id]->linecolor = "000000";
            }
            if (!$fillcolor) {
                $polylineoptions[$poly_id]->fillcolor = "66FF00";
            }
            if (!$fillopacity) {
                $polylineoptions[$poly_id]->opacity = "0.5";
            }
        }
    } else {
        $polylineoptions = array();
    }
    if (isset($wpgmza_settings['wpgmza_settings_marker_pull']) && $wpgmza_settings['wpgmza_settings_marker_pull'] == "0") {
        $markers = wpgmaps_return_markers($wpgmza_current_map_id);
    }
    do_action("wpgooglemaps_basic_hook_user_js_after_core");
    wp_localize_script('wpgmaps_core', 'wpgmaps_localize', $res);
    wp_localize_script('wpgmaps_core', 'wpgmaps_localize_polygon_settings', $polygonoptions);
    wp_localize_script('wpgmaps_core', 'wpgmaps_localize_polyline_settings', $polylineoptions);
    wp_localize_script('wpgmaps_core', 'wpgmaps_markerurl', wpgmaps_get_marker_url($wpgmza_current_map_id));
    if ($wpgmza_settings['wpgmza_settings_marker_pull'] == "0") {
        wp_localize_script('wpgmaps_core', 'wpgmaps_localize_marker_data', $markers);
    }
    $wpgmza_settings = apply_filters("wpgmza_basic_filter_localize_settings", $wpgmza_settings);
    wp_localize_script('wpgmaps_core', 'wpgmaps_localize_global_settings', $wpgmza_settings);
    wp_localize_script('wpgmaps_core', 'wpgmaps_lang_km_away', __("km away", "wp-google-maps"));
    wp_localize_script('wpgmaps_core', 'wpgmaps_lang_m_away', __("miles away", "wp-google-maps"));
    return $ret_msg;
}
예제 #4
0
function wpgmaps_tag_basic($atts)
{
    global $wpgmza_current_map_id;
    extract(shortcode_atts(array('id' => '1'), $atts));
    $ret_msg = "";
    global $short_code_active;
    $wpgmza_current_map_id = $atts['id'];
    $res = wpgmza_get_map_data($atts['id']);
    $short_code_active = true;
    //$wpgmza_data = get_option('WPGMZA');
    $map_align = $res->alignment;
    wpgmza_check_if_marker_file_exists($wpgmza_current_map_id);
    $map_width_type = stripslashes($res->map_width_type);
    $map_height_type = stripslashes($res->map_height_type);
    if (!isset($map_width_type)) {
        $map_width_type == "px";
    }
    if (!isset($map_height_type)) {
        $map_height_type == "px";
    }
    if ($map_width_type == "%" && intval($res->map_width) > 100) {
        $res->map_width = 100;
    }
    if ($map_height_type == "%" && intval($res->map_height) > 100) {
        $res->map_height = 100;
    }
    if (!$map_align || $map_align == "" || $map_align == "1") {
        $map_align = "float:left;";
    } else {
        if ($map_align == "2") {
            $map_align = "margin-left:auto !important; margin-right:auto; !important; align:center;";
        } else {
            if ($map_align == "3") {
                $map_align = "float:right;";
            } else {
                if ($map_align == "4") {
                    $map_align = "";
                }
            }
        }
    }
    $map_style = "style=\"display:block; overflow:auto; width:" . $res->map_width . "" . $map_width_type . "; height:" . $res->map_height . "" . $map_height_type . "; {$map_align}\"";
    $map_other_settings = maybe_unserialize($res->other_settings);
    $sl_data = "";
    if ($map_other_settings['store_locator_enabled'] == 1) {
        $sl_data = wpgmaps_sl_user_output_basic($wpgmza_current_map_id);
    } else {
        $sl_data = "";
    }
    $ret_msg .= "\n            <style>\n            #wpgmza_map img { max-width:none !important; }\n            </style>\n            \n            {$sl_data}    \n            <div id=\"wpgmza_map\" {$map_style}>\n                <div style='text-align:center; width:90%;'>\n                        <small><strong>" . __("The map could not load.", "wp-google-maps") . "</strong><br />" . __("This is normally caused by a conflict with another plugin or a JavaScript error that is preventing our plugin's Javascript from executing. Please try disable all plugins one by one and see if this problem persists. If it persists, please contact nick@wpgmaps.com for support.", "wp-google-maps") . "</small>\n                    \n                </div>\n            </div>\n        ";
    return $ret_msg;
}