/
var
/
www
/
barefootlaw.org
/
wp-content
/
themes
/
barefoot
/
inc
/
vc
/
templates
/
Upload File
HOME
<?php if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } /** * Shortcode attributes * * @var $atts * @var $title * @var $link * @var $size * @var $el_class * @var $css * @var $css_animation * Shortcode class * @var $this WPBakeryShortCode_VC_Gmaps */ $title = $link = $size = $el_class = $css = $css_animation = $el_id = $markers = $center_latitude = $center_longitude = ''; $xs_vertical_offset = $xs_horizontal_offset = $sm_vertical_offset = $sm_horizontal_offset = $md_vertical_offset = $md_horizontal_offset = $lg_vertical_offset = $lg_horizontal_offset = 0; $output = ''; $atts = vc_map_get_attributes( $this->getShortcode(), $atts ); extract( $atts ); $embed_map = isset( $embed_map ) ? $embed_map : ''; $size = str_replace( array( 'px', ' ', ), array( '', '', ), $size ); if ( is_numeric( $size ) ) { $link = preg_replace( '/height="[0-9]*"/', 'height="' . $size . '"', $link ); } $class_to_filter = 'wpb_gmaps_widget wpb_content_element' . ( '' === $size ? ' vc_map_responsive' : '' ); $class_to_filter .= vc_shortcode_custom_css_class( $css, ' ' ) . $this->getExtraClass( $el_class ) . $this->getCSSAnimation( $css_animation ); $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts ); if ( $embed_map === 'yes' ) { $zoom = 14; // deprecated 4.0.2. In 4.6 was moved outside from shortcode_atts $type = 'm'; // deprecated 4.0.2 $bubble = ''; // deprecated 4.0.2 if ( '' === $link ) { return null; } $link = trim( vc_value_from_safe( $link ) ); $bubble = ( '' !== $bubble && '0' !== $bubble ) ? '&iwloc=near' : ''; ?> <div class="<?php echo esc_attr( $css_class ); ?>" id="<?php echo esc_attr( $el_id ); ?>"> <?php echo wpb_widget_title( array( 'title' => $title, 'extraclass' => 'wpb_map_heading', ) ); ?> <div class="wpb_wrapper"> <div class="wpb_map_wraper"> <?php if ( preg_match( '/^\<iframe/', $link ) ) { if ( $size === 'standard' ) { $link = preg_replace( '/height="[0-9]*"/', 'height="660"', $link ); } printf( '%s', $link ); } else { // TODO: refactor or remove outdated/deprecated attributes that is not mapped in gmaps. echo sprintf( '<%1$s width="100%" height="' . $size . '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' . $link . '&t=' . $type . '&z=' . $zoom . '&output=embed' . $bubble . '"></%1$s>', 'iframe' ); } ?> </div> </div> </div> <?php } elseif ( $embed_map === 'no' ) { $zoom = isset( $zoom ) && is_numeric( $zoom ) ? $zoom : 12; $full_screen = isset( $full_screen ) ? $full_screen : ''; $style = isset( $style ) ? $style : ''; $marker_position = isset( $marker_position ) ? $marker_position : false; $dom = new DOMDocument(); $root_map_wrapper = $dom->appendChild( $dom->createElement( 'div' ) ); $root_map_wrapper->setAttribute( 'class', esc_attr( $css_class ) ); if ( ! empty( $el_id ) ) { $root_map_wrapper->setAttribute( 'id', esc_attr( $el_id ) ); } if ( ! empty( $title ) ) { $h2 = $root_map_wrapper->appendChild( $dom->createElement( 'h2', esc_attr( $title ) ) ); $h2->setAttribute( 'class', esc_attr( 'wpb_heading wpb_map_heading' ) ); } $map_wrapper = $root_map_wrapper->appendChild( $dom->createElement( 'div' ) ); $map_wrapper->setAttribute( 'class', esc_attr( 'google-map map-wrap' ) ); if ( is_numeric( $size ) ) { $map_wrapper->setAttribute( 'style', "height:{$size}px;" ); } $map = $map_wrapper->appendChild( $dom->createElement( 'div' ) ); $map->setAttribute( 'class', esc_attr( 'google-map-container' ) ); if ( ! empty( $style ) && $style !== 'default' ) { $map->setAttribute( 'data-style-name', $style ); switch ( $style ) { case 'shades_gray' : $style = '[{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":16}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":17}]}]'; break; case 'ultra_light_labels' : $style = '[{"featureType":"water","elementType":"geometry","stylers":[{"color":"#e9e9e9"},{"lightness":17}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#ffffff"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#ffffff"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":16}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":21}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#dedede"},{"lightness":21}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#ffffff"},{"lightness":16}]},{"elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#333333"},{"lightness":40}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#f2f2f2"},{"lightness":19}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#fefefe"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#fefefe"},{"lightness":17},{"weight":1.2}]}]'; break; case 'pastel_tones' : $style = '[{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":60}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","stylers":[{"visibility":"on"},{"lightness":30}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#ef8c25"},{"lightness":40}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"visibility":"off"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#b6c54c"},{"lightness":40},{"saturation":-40}]},{}]'; break; } $map->setAttribute( 'data-style', $style ); } if ( ! empty( $marker_position ) ) { $lg_vertical_offset = (int)$lg_vertical_offset; $lg_horizontal_offset = $lg_horizontal_offset < 0 ? abs( $lg_horizontal_offset ) : - $lg_horizontal_offset; $md_vertical_offset = (int)$md_vertical_offset; $md_horizontal_offset = $md_horizontal_offset < 0 ? abs( $md_horizontal_offset ) : - $md_horizontal_offset; $sm_vertical_offset = (int)$sm_vertical_offset; $sm_horizontal_offset = $sm_horizontal_offset < 0 ? abs( $sm_horizontal_offset ) : - $sm_horizontal_offset; $xs_vertical_offset = (int)$xs_vertical_offset; $xs_horizontal_offset = $xs_horizontal_offset < 0 ? abs( $xs_horizontal_offset ) : - $xs_horizontal_offset; $positions = array( 'lg' => "{$lg_horizontal_offset},{$lg_vertical_offset}", 'md' => "{$md_horizontal_offset},{$md_vertical_offset}", 'sm' => "{$sm_horizontal_offset},{$sm_vertical_offset},", 'xs' => "{$xs_horizontal_offset},{$xs_vertical_offset}," ); $map->setAttribute( 'data-position', wp_json_encode( $positions ) ); } if ( $full_screen ) { $a = $map_wrapper->appendChild( $dom->createElement( 'a' ) ); $a->setAttribute( 'class', esc_attr( 'a-map google-map-expand' ) ); $a->setAttribute( 'href', esc_attr( '#' ) ); /*$a->setAttribute( 'data-toggle', esc_attr( 'modal' ) ); $a->setAttribute( 'data-backdrop', esc_attr( 'static' ) ); $a->setAttribute( 'data-keyboard', esc_attr( 'false' ) );*/ $a->setAttribute( 'title', __( 'Full Screen', 'covercase' ) ); $i = $a->appendChild( $dom->createElement( 'i' ) ); $i->setAttribute( 'class', esc_attr( 'si-arrows-frame' ) ); $i->setAttribute( 'aria-hidden', esc_attr( 'true' ) ); $close = $map_wrapper->appendChild( $dom->createElement( 'a' ) ); $close->setAttribute( 'class', esc_attr( 'google-map-hide map-close' ) ); $close->setAttribute( 'href', esc_attr( '#' ) ); $i = $close->appendChild( $dom->createElement( 'i' ) ); $i->setAttribute( 'class', esc_attr( 'cov-pm-close' ) ); $i->setAttribute( 'aria-hidden', esc_attr( 'true' ) ); } $markers = (array) vc_param_group_parse_atts( $markers ); $coordinates = array(); $marker_colors = array(); $marker_infobox = array(); $infobox_position = array(); $infobox_classes = array(); $infobox_containers = array(); $data_latitude = $data_longitude = ''; if ( ! empty( $markers ) ) { foreach ( $markers as $data ) { $infobox = isset( $data['infobox'] ) ? $data['infobox'] : 'false'; $infobox_img = isset( $data['infobox_img'] ) ? wp_get_attachment_url( $data['infobox_img'] ) : ''; $infobox_content = isset( $data['infobox_content'] ) ? $data['infobox_content'] : ''; $infobox_title = isset( $data['infobox_title'] ) ? $data['infobox_title'] : ''; $infobox_lg = isset( $data['infobox_lg'] ) ? 'lg_' . $data['infobox_lg'] : ''; $infobox_md = isset( $data['infobox_md'] ) ? 'md_' . $data['infobox_md'] : ''; $infobox_sm = isset( $data['infobox_sm'] ) ? 'sm_' . $data['infobox_sm'] : ''; $infobox_xs = isset( $data['infobox_xs'] ) ? 'xs_' . $data['infobox_xs'] : ''; $infobox_position[] = array( $infobox_lg, $infobox_md, $infobox_sm, $infobox_xs ); $marker_infobox[] = array( 'infobox' => $infobox, 'img' => $infobox_img, 'content' => $infobox_content, 'title' => $infobox_title ); $data_latitude = isset( $data['latitude'] ) ? $data['latitude'] : '51.513447'; $data_longitude = isset( $data['longitude'] ) ? $data['longitude'] : '-0.1159143'; $coordinates[] = $data_latitude . ',' . $data_longitude; $marker_colors[] = isset( $data['marker_color'] ) ? $data['marker_color'] : '#2884d7'; $infobox_show_lg = isset($data['infobox_show_lg']) ? 'lg_show_'.$data['infobox_show_lg'] : ''; $infobox_show_md = isset($data['infobox_show_md']) ? 'md_show_'.$data['infobox_show_md'] : ''; $infobox_show_sm = isset($data['infobox_show_sm']) ? 'sm_show_'.$data['infobox_show_sm'] : ''; $infobox_show_xs = isset($data['infobox_show_xs']) ? 'xs_show_'.$data['infobox_show_xs'] : ''; //$infobox_show = 'true' === $infobox_show ? '' : 'hide-infobox'; $infobox_classes[] = array( $infobox_show_lg, $infobox_show_md, $infobox_show_sm, $infobox_show_xs ); $infobox_container = isset($data['infobox_container']) ? $data['infobox_container'] : 'container'; $infobox_containers[] = array( $infobox_container ); } } $infobox_wrapper = $map_wrapper->appendChild( $dom->createElement( 'div' ) ); $infobox_wrapper->setAttribute( 'class', 'google-map-infobox-list' ); if(!empty($marker_infobox)) { $infobox_count = 0; foreach ($marker_infobox as $infobox_block) { $current_position = isset($infobox_position[$infobox_count]) ? $infobox_position[$infobox_count] : ''; $current_classes = isset($infobox_classes[$infobox_count]) ? $infobox_classes[$infobox_count] : ''; $current_container = isset($infobox_containers[$infobox_count]) ? $infobox_containers[$infobox_count] : ''; if(!empty($current_position) && is_array($current_position)){ $current_position = implode(' ', $current_position); } else { $current_position = ''; } if(!empty($current_classes) && is_array($current_classes)){ $current_classes = implode(' ', $current_classes); } else { $current_classes = ''; } if(!empty($current_container) && is_array($current_container)){ $current_container = implode(' ', $current_container); } else { $current_container = ''; } $infobox_count++; if('true' === $infobox_block['infobox']) { $infobox_div = $infobox_wrapper->appendChild( $dom->createElement( 'div' ) ); $infobox_div->setAttribute( 'class', $current_classes.' google-map-infobox '. $current_position ); $infobox_div->setAttribute( 'data-infobox-id', $infobox_count ); $infobox_container = $infobox_div->appendChild( $dom->createElement( 'div' ) ); $infobox_container->setAttribute('class',$current_container . ' google-map-container-wrap'); $infobox_wrap = $infobox_container->appendChild( $dom->createElement( 'div' ) ); $infobox_wrap->setAttribute( 'class', 'google-map-infobox-wrap '. $current_position ); $infobox_wrap_inner = $infobox_wrap->appendChild( $dom->createElement( 'div' ) ); $infobox_wrap_inner->setAttribute( 'class', 'google-map-infobox-wrap-inner' ); $infobox_body = $infobox_wrap_inner->appendChild( $dom->createElement( 'div' ) ); $infobox_body->setAttribute( 'class', 'google-map-infobox-body' ); $infobox_close = $infobox_body->appendChild( $dom->createElement( 'a' ) ); $infobox_close->setAttribute('class','google-map-infobox-close'); $infobox_close->setAttribute('href','#'); $infobox_close->setAttribute('title',__('Close','covercase')); $i = $infobox_close->appendChild( $dom->createElement( 'i' ) ); $i->setAttribute( 'class', esc_attr( 'cov-pm-close' ) ); $i->setAttribute( 'aria-hidden', esc_attr( 'true' ) ); $infobox_table = $infobox_body->appendChild( $dom->createElement( 'div' ) ); $infobox_table->setAttribute( 'class', 'google-map-infobox-table' ); $infobox_row = $infobox_table->appendChild( $dom->createElement( 'div' ) ); $infobox_row->setAttribute( 'class', 'google-map-infobox-row' ); if ( ! empty( $infobox_block['img'] ) ) { $infobox_cell1 = $infobox_row->appendChild( $dom->createElement( 'div' ) ); $infobox_cell1->setAttribute( 'class', 'google-map-infobox-cell1' ); $infobox_cell1->setAttribute( 'style', 'background-image:url('.esc_url($infobox_block['img']).');' ); } $infobox_cell2 = $infobox_row->appendChild( $dom->createElement( 'div' ) ); $infobox_cell2->setAttribute( 'class', 'google-map-infobox-cell2' ); if(!empty($infobox_block['title'])) { $infobox_title = $infobox_cell2->appendChild( $dom->createElement( 'div', $infobox_block['title'] ) ); $infobox_title->setAttribute( 'class', 'google-map-infobox-title' ); } if(!empty($infobox_block['content'])) { $infobox_p = $infobox_cell2->appendChild( $dom->createElement( 'div' ) ); $tmpDoc = new DOMDocument(); $content = preg_replace('/\x03/', '', $infobox_block['content']); $content = nl2br( $content ); $tmpDoc->loadHTML( $content ); foreach ( $tmpDoc->getElementsByTagName( 'body' )->item( 0 )->childNodes as $node ) { $node = $dom->importNode( $node, true ); $infobox_p->appendChild( $node ); } $infobox_p->setAttribute( 'class', 'google-map-infobox-content' ); } } } } $center_map = '51.513447,-0.1159143'; if ( $center_latitude && $center_longitude ) { $center_map = $center_latitude . ',' . $center_longitude; } elseif ($data_latitude && $data_longitude) { $center_map = $data_latitude . ',' . $data_longitude; } $coordinates = ! empty( $coordinates ) ? $coordinates : array( '51.513447,-0.1159143' ); $marker_colors = ! empty( $marker_colors ) ? $marker_colors : array( '#2884d7' ); $map->setAttribute( 'data-center', esc_attr( $center_map ) ); $map->setAttribute( 'data-markers', esc_attr( implode( ';', $coordinates ) ) ); $map->setAttribute( 'data-markers-color', esc_attr( implode( ',', $marker_colors ) ) ); $map->setAttribute( 'data-zoom', is_numeric( $zoom ) ? esc_attr( $zoom ) : '12' ); printf( '%s', $dom->saveHTML() ); } ?>