function new_build_i_world_map_exec($id, $overlay = false) { global $iwmparam_array; global $apiver; // i_world_map_defaults(); $simplemap = get_field('interactive_regions', $id); if ($simplemap == 'simple') { if (get_field('simple_interactive_regions', $id)) { $mapinput = ''; while (has_sub_field('simple_interactive_regions', $id)) { $regioncode = imap_place_replace(get_sub_field('region_code')); $tooltiptitle = imap_place_replace(get_sub_field('title')); $tooltipinfo = imap_place_replace(get_sub_field('tooltip')); $actionvalue = imap_place_replace(get_sub_field('action_value')); $colorcode = imap_place_replace(get_sub_field('color')); $mapinput .= $regioncode . ',' . $tooltiptitle . ',' . $tooltipinfo . ',' . $actionvalue . ',' . $colorcode . ';'; } // $input = htmlspecialchars($mapinput); $input = $mapinput; } } else { $input = get_field('advanced_data_editor', $id); // $input = htmlspecialchars($mapinput); } $styles = ''; $overrideh = false; // $placeholder = __("<div class='iwm_placeholder'><img width='32px' src='".plugins_url('imgs/placeholder.png', __FILE__)."'><br>".$mapdata['name']."</div>",'iw_maps'); //$input = str_replace(array("\r\n", "\r", "\n"), ' ', addslashes($mapdata['places'])); $usehtml = 1; $apiv = "1"; $apiv = $apiver; $bg_color = '#FFFFFF'; $ina_color = 'transparent'; $border_color = '#CCCCCC'; $border_stroke = 0; $act_color = '#438094'; $marker_size = 10; $width = ""; $height = ""; $aspect_ratio = 1; imap_include_responsive_js(); $tooltipt = 1; //none , selection , focus $diplaym = get_field('display_mode', $id); $interactive = "true"; $display_mode = $diplaym; $areashow = explode(",", get_field('region_to_display', $id)); $region = $areashow[0]; $resolution = $areashow[1]; $map_action = get_field('active_region_action', $id); $custom_action = ''; $projection = "mercator"; $beforediv = ""; $afterdiv = ""; if ($map_action != "none" || $map_action != 'null') { if ($map_action == 'i_map_action_content_below') { $afterdiv .= "<div id='imap" . $id . "message'></div>"; } if ($map_action == 'i_map_action_content_above') { $beforediv = "<div id='imap" . $id . "message'></div>"; } } $new_iwm_array = array("apiversion" => $apiv, "usehtml" => $usehtml, "id" => $id, "bgcolor" => $bg_color, "stroke" => $border_stroke, "bordercolor" => $border_color, "incolor" => $ina_color, "actcolor" => $act_color, "width" => $width, "height" => $height, "aspratio" => $aspect_ratio, "interactive" => $interactive, "tooltip" => $tooltipt, "region" => $region, "resolution" => $resolution, "markersize" => $marker_size, "displaymode" => $display_mode, "placestxt" => $input, "action" => $map_action, "custom_action" => '', "projection" => $projection); array_push($iwmparam_array, $new_iwm_array); i_world_map_scripts($iwmparam_array); $style = ''; if ($overlay == 'base') { $style .= "style='pointer-events:visible;' "; } $class = ''; $style .= "class='iwm_map_canvas"; if ($overlay == 'data') { $style .= " iwm_data"; } //closing class="" $style .= "'"; //if the size height is overrided with css, we need extra class if ($overrideh) { $beforediv .= '<div id="iwm_' . $id . '">'; $afterdiv = '</div>' . $afterdiv; } return $styles . $beforediv . "<div " . $style . "><div id='map_canvas_" . $id . "' class='i_world_map ' " . $style . ">" . $placeholder . "</div></div>" . $afterdiv; }
function build_i_world_map_exec($id, $type, $overlay = false, $atts) { global $wpdb; global $table_name_imap; global $iwmparam_array; global $apiver; $options = get_option('i-world-map-settings'); if ($options == false) { i_world_map_defaults(); $options = get_option('i-world-map-settings'); } $mapdata = $wpdb->get_row("SELECT * FROM {$table_name_imap} WHERE id = {$id}", ARRAY_A); $input = $mapdata['places']; $id = $mapdata['id']; //Check if custom css for this map exist $styles = ''; $overrideh = false; if ($mapdata['custom_css'] != '' && isset($options['default_responsive']) && $options['default_responsive'] == '1') { $css = array_filter(json_decode(stripslashes($mapdata['custom_css']), true), 'iwm_array_empty'); $inactivecolor = strtolower($mapdata['ina_color']); if (!empty($css)) { $styles = "<!-- Map Generated CSS --> \n <style>"; $styles .= "\n.iwm_map_canvas { overflow:hidden; }"; //set margin left if (isset($css['iwm_left']) && $css['iwm_left'] != '') { $styles .= "\n#map_canvas_" . $id . " { margin-left: " . $css['iwm_left'] . "%; }"; } //set margin top if (isset($css['iwm_top']) && $css['iwm_top'] != '') { $styles .= "\n#map_canvas_" . $id . " { margin-top: " . $css['iwm_top'] . "%; }"; } //set size % if (isset($css['iwm_size']) && $css['iwm_size'] != '' && $css['iwm_size'] != '100') { $styles .= "\n#map_canvas_" . $id . " { width: " . $css['iwm_size'] . "%; height: " . $css['iwm_size'] . "%; }"; } //set vertical override size if (isset($css['iwm_hsize']) && $css['iwm_hsize'] != '' && $css['iwm_hsize'] != '61.7') { $overrideh = true; $styles .= '#iwm_' . $id . ' .iwm_map_canvas:after { padding-top:' . $css['iwm_hsize'] . '%; }'; } //set hovercolor if (isset($css['hovercolor']) && $css['hovercolor'] != '') { if ($mapdata['use_defaults'] == 1) { $inactivecolor = strtolower($options['default_ina_color']); } //old simple way to implement hover //$styles .= '#map_canvas_'.$id.' path:not([fill^="'.$inactivecolor.'"]):hover { fill:'.$css['hovercolor'].'; }'; //new way to implement hover $styles .= "#map_canvas_" . $id . " path[stroke-width^='3'] + path { display:none; }"; $styles .= "#map_canvas_" . $id . " path[stroke-width^='3'] + path + path:not([fill^='" . $inactivecolor . "']) { display:none; }"; $styles .= "#map_canvas_" . $id . " path[stroke-width^='3'] { fill:" . $css['hovercolor'] . "; }"; $bw = 1; if (isset($css['bwidth']) && $css['bwidth'] != '') { $bw = $css['bwidth']; } $styles .= "#map_canvas_" . $id . " path:not([fill^='" . $inactivecolor . "']) + path[stroke-width^='3'] { stroke-width:" . $bw . "; stroke-opacity:0; stroke:" . $css['hovercolor'] . "; }"; //for circle and text $styles .= "#map_canvas_" . $id . " circle:hover { fill:" . $css['hovercolor'] . "; }"; $styles .= "#map_canvas_" . $id . " text:hover { fill:" . $css['hovercolor'] . "; }"; } //set cursor if (isset($css['showcursor']) && $css['showcursor'] == '1') { $styles .= '#map_canvas_' . $id . ' path:not([fill^="' . $inactivecolor . '"]):hover { cursor:pointer; }'; $styles .= '#map_canvas_' . $id . ' circle:hover { cursor:pointer; }'; $styles .= '#map_canvas_' . $id . ' text:hover { cursor:pointer; }'; } //set border/path colour if (isset($css['bcolor']) && $css['bcolor'] != '') { $styles .= '#map_canvas_' . $id . ' path { stroke:' . $css['bcolor'] . '; }'; } //set border/path width if (isset($css['bwidth']) && $css['bwidth'] != '') { $styles .= '#map_canvas_' . $id . ' path { stroke-width:' . $css['bwidth'] . '; }'; } //set border/path width for inactive regions if (isset($css['biwidth']) && $css['biwidth'] != '') { $styles .= '#map_canvas_' . $id . ' path[fill^="' . $inactivecolor . '"] { stroke-width:' . $css['biwidth'] . '; }'; $styles .= '#map_canvas_' . $id . ' path[fill^="' . $inactivecolor . '"]:hover { stroke-width:' . $css['biwidth'] . '; }'; $styles .= '#map_canvas_' . $id . ' path[fill^="none"] { stroke-width:' . $css['biwidth'] . '; stroke-opacity:0; }'; } //set background image if (isset($css['bgimage']) && $css['bgimage'] != '') { $mapdata['bg_color'] = 'transparent'; $options['default_bg_color'] = 'transparent'; $styles .= '#map_canvas_' . $id . ' { background-image: url("' . $css['bgimage'] . '"); }'; } //set background image repeat if (isset($css['bgrepeat']) && $css['bgrepeat'] != '') { if ($css['bgrepeat'] == '1') { $styles .= '#map_canvas_' . $id . ' { background-repeat:repeat; }'; } } if (!isset($css['bgrepeat'])) { $styles .= '#map_canvas_' . $id . ' { background-repeat:no-repeat; background-size: 100% 100%; }'; } //HTML Tooltips if (isset($css['tooltipfontfamily']) && $css['tooltipfontfamily'] != '') { $styles .= "\n#map_canvas_" . $id . " .google-visualization-tooltip * { font-family:'" . $css['tooltipfontfamily'] . "' !important; }"; } if (isset($css['tooltipfontsize']) && $css['tooltipfontsize'] != '') { $styles .= '#map_canvas_' . $id . ' .google-visualization-tooltip * { font-size:' . $css['tooltipfontsize'] . ' !important; }'; } if (isset($css['tooltipbg']) && $css['tooltipbg'] != '') { $styles .= '#map_canvas_' . $id . ' .google-visualization-tooltip { background:' . $css['tooltipbg'] . '; }'; } if (isset($css['tooltipminwidth']) && $css['tooltipminwidth'] != '') { $styles .= '#map_canvas_' . $id . ' .google-visualization-tooltip { width:' . $css['tooltipminwidth'] . '; }'; } if (isset($css['tooltiphidetitle']) && $css['tooltiphidetitle'] != '' && $css['tooltiphidetitle'] == 1) { $styles .= '#map_canvas_' . $id . ' .google-visualization-tooltip-item:first-child { display:none;}'; } if (isset($css['tooltipbordercolor']) && $css['tooltipbordercolor'] != '') { $styles .= '#map_canvas_' . $id . ' .google-visualization-tooltip { border-color:' . $css['tooltipbordercolor'] . '; }'; } if (isset($css['tooltipborderwidth']) && $css['tooltipborderwidth'] != '') { $styles .= '#map_canvas_' . $id . ' .google-visualization-tooltip { border-width:' . $css['tooltipborderwidth'] . '; }'; } if (isset($css['fontawesomeapply']) && $css['fontawesomeapply'] != '') { $styles .= '#map_canvas_' . $id . ' text { font-family:fontAwesome; }'; } if (isset($css['fontawesomeinclude']) && $css['fontawesomeinclude'] != '') { i_world_map_include_fontawesome(); } $styles .= '</style>'; } } /* Check if any of the entries is a group */ if (strpos($input, 'group:') !== false) { //if there's a group, we replicate the group entries $entries = explode(";", $input); $entries = array_slice($entries, 0, -1); $input = ''; foreach ($entries as $entry) { if (strpos($entry, 'group:') !== false) { $regentry = explode(',', $entry); $regioncode = $regentry[0]; $regioncode = str_replace('group:', '', $regioncode); $newcodes = explode('|', $regioncode); foreach ($newcodes as $new) { $entry = $new . ',' . $regentry[1] . ',' . $regentry[2] . ',' . $regentry[3] . ',' . $regentry[4]; $input .= $entry . ';'; } } else { $input .= $entry . ';'; } } } /* Conditional tag to populate the map automatically, if using categories as source */ if ($input == 'categories_count') { $input = ''; $args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0); $categories = get_categories($args); foreach ($categories as $category) { //model: Region Code, Tooltip Title, Tooltip info, Action Value (URL), Color Code; $input .= $category->name . ',' . $category->name . ',' . $category->description . $category->count . ',' . get_category_link($category->term_id) . ',' . $options['default_act_color'] . ';'; } } /* Conditional tag to populate the map automatically, if using CUSTOM POST TYPE as source */ if ($input == 'custom_post_type') { //EDIT HERE $cpt_id = 'iwm'; $region_code_meta = 'wpcf-regioncode'; //custom meta field name to fetch region code; $tooltip_meta = 'wpcf-tooltip'; //custom meta field name to fetch tooltip info; $color_meta = 'wpcf-color'; //cutom meta field name to fetch color codes //AVOID EDIT BELOW $input = ''; $args = array('post_type' => $cpt_id); $cpt = new WP_Query($args); // The Loop if ($cpt->have_posts()) { while ($cpt->have_posts()) { $cpt->the_post(); $regioncode = get_post_meta(get_the_ID(), $region_code_meta, true); $tooltiptitle = get_the_title(); $tooltipinfo = get_post_meta(get_the_ID(), $tooltip_meta, true); $actionvalue = do_shortcode(get_the_content()); $colorcode = get_post_meta(get_the_ID(), $color_meta, true); //to clean the content from commas (,) and semi-colons (;) $oreplace = array(",", ";"); $ofinal = array(",", ";"); $actionvalue = str_replace($oreplace, $ofinal, $actionvalue); //model: Region Code, Tooltip Title, Tooltip info, Action Value (URL), Color Code; $input .= $regioncode . ',' . $tooltiptitle . ',' . $tooltipinfo . ',' . $actionvalue . ',' . $colorcode . ';'; } } /* Restore original Post Data */ wp_reset_postdata(); } $placeholder = __("<div class='iwm_placeholder'><img width='32px' alt='" . $mapdata['name'] . " Placeholder' title='" . $mapdata['name'] . "' src='" . plugins_url('imgs/placeholder.png', __FILE__) . "'><br>" . $mapdata['name'] . "</div>", 'iw_maps'); //$input = str_replace(array("\r\n", "\r", "\n"), ' ', addslashes($mapdata['places'])); //add custom css function add_action('wp_footer', 'i_world_map_custom_css_js', 99); if ($options == false) { i_world_map_defaults(); $options = get_option('i-world-map-settings'); } $usehtml = array_key_exists('default_usehtml', $options) ? $options['default_usehtml'] : "0"; $apiv = "1"; if ($usehtml == 1) { $apiv = $apiver; } if ($mapdata['use_defaults'] == 1) { $bg_color = $options['default_bg_color']; $border_color = $options['default_border_color']; $border_stroke = $options['default_border_stroke']; $ina_color = $options['default_ina_color']; $act_color = $options['default_act_color']; $marker_size = $options['default_marker_size']; $width = $options['default_width']; $height = $options['default_height']; $aspect_ratio = $options['default_aspect_ratio']; } else { $bg_color = $mapdata['bg_color']; $border_color = $mapdata['border_color']; $border_stroke = $mapdata['border_stroke']; $ina_color = $mapdata['ina_color']; $act_color = $mapdata['act_color']; $marker_size = $mapdata['marker_size']; $width = $mapdata['width']; $height = $mapdata['height']; $aspect_ratio = $mapdata['aspect_ratio']; } if ($overlay == 'data') { $bg_color = 'transparent'; $ina_color = 'transparent'; } if (isset($options['default_responsive']) && $options['default_responsive'] == 1) { $width = ""; $height = ""; imap_include_responsive_js(); } $interactive = $mapdata['interactive']; $tooltipt = $mapdata['showtooltip']; $diplaym = $mapdata['display_mode']; if ($interactive == 0 || $overlay == 'data') { $interactive = "false"; } else { $interactive = "true"; } if ($tooltipt == 0) { $tooltipt = "none"; } else { if ($tooltipt == 2) { $tooltipt = "selection"; } else { $tooltipt = "focus"; } } $display_mode = $diplaym; $areashow = explode(",", $mapdata['region']); $region = $areashow[0]; $resolution = $areashow[1]; $map_action = $mapdata['map_action']; $custom_action = $mapdata['custom_action']; $projection = array_key_exists('map_projection', $options) ? $options['map_projection'] : "mercator"; $beforediv = ""; $afterdiv = ""; if (isset($atts['extras']) && $atts['extras'] == 'dropdown' && ($overlay == 'base' || $overlay == false)) { $afterdiv .= iwm_build_i_world_map_dropdown($atts); } if ($map_action != "none" || $map_action != 'null') { if ($map_action == 'i_map_action_content_below') { $afterdiv .= "<div id='imap" . $id . "message'></div>"; } if ($map_action == 'i_map_action_content_above') { $beforediv = "<div id='imap" . $id . "message'></div>"; } } $html = ''; if ($map_action == "i_map_action_custom") { $old_value = "ivalue_" . $id . "[selectedRegion]"; $new_action = str_replace($old_value, "value", $custom_action); $html = '<script type="text/javascript">'; $html .= 'function iwm_custom_action_' . $id . '(value) {'; $html .= $new_action; $html .= '}</script>'; } $new_iwm_array = array("apiversion" => $apiv, "usehtml" => $usehtml, "id" => $id, "bgcolor" => $bg_color, "stroke" => $border_stroke, "bordercolor" => $border_color, "incolor" => $ina_color, "actcolor" => $act_color, "width" => $width, "height" => $height, "aspratio" => $aspect_ratio, "interactive" => $interactive, "tooltip" => $tooltipt, "region" => $region, "resolution" => $resolution, "markersize" => $marker_size, "displaymode" => $display_mode, "placestxt" => $input, "action" => $map_action, "custom_action" => $custom_action, "projection" => $projection); array_push($iwmparam_array, $new_iwm_array); //if the theme loads content via ajax, we need to output some js variables in a different way $ajax_enabled = false; if (isset($options['ajax_enabled']) && $options['ajax_enabled'] == 1) { $ajax_enabled = true; } i_world_map_scripts($iwmparam_array); $style = ''; if ($overlay == 'base') { $style .= "style='pointer-events:visible;' "; } $class = ''; $style .= "class='iwm_map_canvas"; if ($overlay == 'data') { $style .= " iwm_data"; } //closing class="" $style .= "'"; //if the size height is overrided with css, we need extra class if ($overrideh) { $beforediv .= '<div id="iwm_' . $id . '">'; $afterdiv = '</div>' . $afterdiv; } if ($type == "shortcode") { return $html . $styles . $beforediv . "<div " . $style . "><div id='map_canvas_" . $id . "' class='i_world_map ' " . $style . ">" . $placeholder . "</div></div>" . $afterdiv; } if ($type == "php") { echo $html . $styles . $beforediv . "<div " . $style . "><div id='map_canvas_" . $id . "' class='i_world_map ' " . $style . ">" . $placeholder . "</div></div>" . $afterdiv; } if ($type == "nulloutput") { return; } }
function build_i_world_map_exec($id, $type) { global $wpdb; global $table_name_imap; global $iwmparam_array; global $apiver; $mapdata = $wpdb->get_row("SELECT * FROM {$table_name_imap} WHERE id = {$id}", ARRAY_A); $input = $mapdata['places']; //$input = str_replace(array("\r\n", "\r", "\n"), ' ', addslashes($mapdata['places'])); $options = get_option('i-world-map-settings'); if ($options == false) { i_world_map_defaults(); $options = get_option('i-world-map-settings'); } $usehtml = array_key_exists('default_usehtml', $options) ? $options['default_usehtml'] : "0"; $apiv = "1"; if ($usehtml == 1) { $apiv = $apiver; } if ($mapdata['use_defaults'] == 1) { $bg_color = $options['default_bg_color']; $border_color = $options['default_border_color']; $border_stroke = $options['default_border_stroke']; $ina_color = $options['default_ina_color']; $act_color = $options['default_act_color']; $marker_size = $options['default_marker_size']; $width = $options['default_width']; $height = $options['default_height']; $aspect_ratio = $options['default_aspect_ratio']; } else { $bg_color = $mapdata['bg_color']; $border_color = $mapdata['border_color']; $border_stroke = $mapdata['border_stroke']; $ina_color = $mapdata['ina_color']; $act_color = $mapdata['act_color']; $marker_size = $mapdata['marker_size']; $width = $mapdata['width']; $height = $mapdata['height']; $aspect_ratio = $mapdata['aspect_ratio']; } if (isset($options['default_responsive']) && $options['default_responsive'] == 1) { $width = ""; $height = ""; imap_include_responsive_js(); } $interactive = $mapdata['interactive']; $tooltipt = $mapdata['showtooltip']; $diplaym = $mapdata['display_mode']; if ($interactive == 0) { $interactive = "false"; } else { $interactive = "true"; } if ($tooltipt == 0) { $tooltipt = "none"; } else { $tooltipt = "focus"; } $display_mode = $diplaym; $areashow = explode(",", $mapdata['region']); $region = $areashow[0]; $resolution = $areashow[1]; $map_action = $mapdata['map_action']; $custom_action = $mapdata['custom_action']; $beforediv = ""; $afterdiv = ""; if ($map_action != "none" || $map_action != 'null') { if ($map_action == 'i_map_action_content_below') { $afterdiv = "<div id='imap" . $id . "message'></div>"; } if ($map_action == 'i_map_action_content_above') { $beforediv = "<div id='imap" . $id . "message'></div>"; } } if ($map_action == "i_map_action_custom") { $old_value = "ivalue_" . $id . "[selectedRegion]"; $new_action = str_replace($old_value, "value", $custom_action); $html = '<script type="text/javascript">'; $html .= 'function iwm_custom_action_' . $id . '(value) {'; $html .= $new_action; $html .= '}</script>'; echo $html; } $new_iwm_array = array("apiversion" => $apiv, "usehtml" => $usehtml, "id" => $id, "bgcolor" => $bg_color, "stroke" => $border_stroke, "bordercolor" => $border_color, "incolor" => $ina_color, "actcolor" => $act_color, "width" => $width, "height" => $height, "aspratio" => $aspect_ratio, "interactive" => $interactive, "tooltip" => $tooltipt, "region" => $region, "resolution" => $resolution, "markersize" => $marker_size, "displaymode" => $display_mode, "placestxt" => $input, "action" => $map_action, "custom_action" => $custom_action); array_push($iwmparam_array, $new_iwm_array); i_world_map_scripts($iwmparam_array); if ($type == "shortcode") { return $beforediv . "<div id='map_canvas'><div id='map_canvas_" . $id . "' class='i_world_map'></div></div>" . $afterdiv; } else { echo $beforediv . "<div id='map_canvas'><div id='map_canvas_" . $id . "' class='i_world_map'></div></div>" . $afterdiv; } }