/** * DEFINE shortcode content * * @param type $atts * @param type $content */ public function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $inner_content = WR_Pb_Helper_Shortcode::remove_autop($content); $custom_style = WR_Pb_Utils_Placeholder::get_placeholder('custom_style'); return "{$heading}<!--heading-->{$icon}<!--icon--><div id='pane{index}' class='tab-pane {active} {fade_effect}' {$custom_style}>\n\t\t\t{$inner_content}\n\t\t\t\t</div><!--seperate-->"; }
/** * DEFINE shortcode content * * @param type $atts * @param type $content */ public function element_shortcode_full($atts = null, $content = null) { extract(shortcode_atts($this->config['params'], $atts)); // tag1,tag2 => tag1 tag2 , to filter $tag = str_replace(' ', '_', $tag); $tag = str_replace(',', ' ', $tag); $inner_content = WR_Pb_Helper_Shortcode::remove_autop($content); WR_Pb_Helper_Functions::heading_icon($heading, $icon); return "\n\t\t\t<div class='panel panel-default' data-tag='{$tag}'>\n\t\t\t\t<div class='panel-heading'>\n\t\t\t\t\t<h4 class='panel-title'>\n\t\t\t\t\t\t<a data-toggle='collapse' href='#collapse{index}'>\n\t\t\t\t\t\t\t<i class='{$icon}'></i>{$heading}\n\t\t\t\t\t\t\t<i class='wr-icon-accordion'></i>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</h4>\n\t\t\t\t</div>\n\t\t\t\t<div id='collapse{index}' class='panel-collapse collapse {show_hide}'>\n\t\t\t\t <div class='panel-body'>\n\t\t\t\t {$inner_content}\n\t\t\t\t </div>\n\t\t\t\t</div>\n\t\t\t</div><!--seperate-->"; }
/** * DEFINE shortcode content * * @param type $atts * @param type $content */ public function element_shortcode_full($atts = null, $content = null) { extract(shortcode_atts($this->config['params'], $atts)); $rowstyle = !$rowstyle || strtolower($rowstyle) == 'default' ? '' : $rowstyle; if (in_array($tagname, array('tr_start', 'tr_end'))) { return "{$tagname}<!--seperate-->"; } $width_type = $width_type == 'percentage' ? '%' : $width_type; $width = !empty($width_value) ? "width='{$width_value}{$width_type}'" : ''; $empty = empty($content) ? '<!--empty-->' : ''; return "<CELL_WRAPPER class='{$rowstyle}' rowspan='{$rowspan}' colspan='{$colspan}' {$width}>" . WR_Pb_Helper_Shortcode::remove_autop($content) . "</CELL_WRAPPER>{$empty}<!--seperate-->"; }
/** * DEFINE shortcode content * * @param type $atts * @param type $content */ public function element_shortcode_full($atts = null, $content = null) { extract(shortcode_atts($this->config['params'], $atts)); $content_class = !empty($image_file) ? 'carousel-caption' : 'carousel-content'; $img = !empty($image_file) ? "<img width='{WIDTH}' height='{HEIGHT}' src='{$image_file}' alt='{$alt}' style='height : {HEIGHT}px;'>" : ''; // remove image shortcode in content $content = WR_Pb_Helper_Shortcode::remove_wr_shortcodes($content, 'wr_image'); $inner_content = WR_Pb_Helper_Shortcode::remove_autop($content); WR_Pb_Helper_Functions::heading_icon($heading, $icon, true); $heading = trim($heading); $inner_content = trim($inner_content); if (empty($heading) && empty($inner_content)) { $html_content = ""; } else { $html_content = "<div class='{$content_class}'>"; $html_content .= !empty($heading) ? "<h4><i class='{$icon}'></i>{$heading}</h4>" : ''; $html_content .= !empty($inner_content) ? "<p>{$inner_content}</p>" : ''; $html_content .= "</div>"; } return "<div class='{active} item'>{$img}{$html_content}</div><!--seperate-->"; }
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ public function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $random_id = WR_Pb_Utils_Common::random_string(); $testimonial_id = "testimonial_{$random_id}"; $styles = "style='width:100%'"; $image_container_style = $author_image_style != 'no-styling' ? "{$author_image_style}" : ''; $content_elements = array_filter(explode('__#__', $content_elements)); $testimonial_indicators = array(); $testimonial_indicators[] = '<ol class="carousel-indicators">'; $sub_shortcode = do_shortcode($content); $testimonial_content = array(); $items = explode('<!--seperate-->', $sub_shortcode); $items = array_filter($items); $count_items = count($items); foreach ($items as $idx => $item) { $item = unserialize($item); if ($idx % $items_per_slide == 0) { $active = $idx == 0 ? 'active' : ''; $testimonial_content[] = "<div class='item row {$active}'>"; $active_li = $idx == 0 ? "class='active'" : ''; $testimonial_indicators[] = "<li {$active_li}></li>"; } $divide = $count_items > $items_per_slide ? $items_per_slide : $count_items; $colmd = 'col-md-' . 12 / $divide; $colsm = 'col-sm-' . 12 / $divide; $item_html = "<div class='wr-testimonial-item {$colmd} {$colsm}'>"; $testimonial_info = array(); if (in_array('content', $content_elements)) { $item_content = WR_Pb_Helper_Shortcode::remove_autop($item['testimonial_content']); $item_content = WR_Pb_Utils_Common::trim_content($item_content, $content_count, $content_type); $testimonial_info['content'] = "<div class='wr-testimonial-box top'><div class='arrow'></div><div class='wr-testimonial-content'><p>" . $item_content . '</p></div></div>'; } if (isset($item['image_file']) && !empty($item['image_file'])) { $data = getimagesize($item['image_file']); $width = $data[0]; $height = $data[1]; $img = "<div class='wr-testimonial-avatar'><img width='{$width}' height='{$height}' class='{$image_container_style}' src='{$item['image_file']}' /></div>"; } else { $img = ''; } $testimonial_info['image'] = in_array('image', $content_elements) ? $img : ''; // Process company field if (isset($item['company']) && $item['company'] != '') { $company_link = "<a href='{$item['web_url']}'>{$item['company']}</a>"; } else { $company_link = "<a href='{$item['web_url']}'>{$item['web_url']}</a>"; } if (!isset($item['web_url']) || empty($item['web_url'])) { $company_link = $item['company']; } // Process testimonial metadata $arr_style = array(); if (isset($item['name_height'])) { $arr_style[] = 'font-size: ' . $item['name_height'] . 'px'; } if (isset($item['name_color'])) { $arr_style[] = 'color: ' . $item['name_color']; } $style = $arr_style ? "style='" . implode(';', $arr_style) . "'" : ''; $name = isset($item['name']) && in_array('name', $content_elements) ? "<strong {$style} class='wr-testimonial-name'>{$item['name']}</strong>" : ''; $job_title = isset($item['job_title']) && in_array('job_title', $content_elements) ? "<span class='wr-testimonial-jobtitle'>{$item['job_title']}</span>" : ''; $country = isset($item['country']) && in_array('country', $content_elements) ? "<span class='wr-testimonial-country'>{$item['country']}</span>" : ''; if ($company_link) { $company = in_array('company', $content_elements) ? "<span class='wr-testimonial-link'>{$company_link}</span>" : ''; } $html_metadata = ''; if ($name != '' || $job_title != '' || $country != '' || $company != '') { $html_metadata .= '<div class="wr-testimonial-meta">'; $html_metadata .= $name . $job_title . $country . $company; $html_metadata .= '</div>'; } foreach ($content_elements as $element) { $item_html .= isset($testimonial_info[$element]) ? $testimonial_info[$element] : ''; } $item_html .= $html_metadata; $item_html .= '</div>'; $testimonial_content[] = $item_html; if (($idx + 1) % $items_per_slide == 0 || $idx + 1 == count($items)) { $testimonial_content[] = '</div>'; } } $testimonial_content = "<div class='carousel-inner'>" . implode('', $testimonial_content) . '</div>'; $testimonial_indicators[] = '</ol>'; $testimonial_indicators = implode('', $testimonial_indicators); $script = "<script type='text/javascript'>\n\t\t(function (\$){\n\t\t\t\$( document ).ready(function(){\n\t\t\t\tif( \$( '#{$testimonial_id}' ).length ){\n\t\t\t\t\t\$( '#{$testimonial_id} .carousel-indicators li' ).each(function (i) {\n\t\t\t\t\t\t\$(this).on('click', function () {\n\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel(i);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t} )( jQuery );\n\t\t</script>"; $slider_elements = explode('__#__', $slider_elements); if ($count_items <= $items_per_slide || !in_array('indicator', $slider_elements)) { $testimonial_indicators = ''; } $testimonial_navigator = $count_items > $items_per_slide && in_array('arrows', $slider_elements) ? "<a class='carousel-control left icon-arrow-left wr-arrow-left'></a><a class='carousel-control right icon-arrow-right wr-arrow-right'></a>" : ''; $html = "<div class='carousel slide wr-testimonial' {$styles} id='{$testimonial_id}'>{$testimonial_indicators} {$testimonial_content} {$testimonial_navigator}</div>"; return $this->element_wrapper($script . $html, $arr_params); }
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ public function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); $link = ''; $exclude_params = array('tag', 'text', 'preview'); $arr_styles = array(); if (strtolower($arr_params['font_face_type']) == 'google fonts' and $arr_params['font'] != 'inherit') { wp_enqueue_style('wr-google-fonts', "http://fonts.googleapis.com/css?family={$arr_params['font_face_value']}"); } if ($arr_params['font'] != 'inherit') { if ($arr_params['font_face_value']) { $arr_styles[] = 'font-family: ' . $arr_params['font_face_value']; } if ($arr_params['font_size_value']) { $arr_styles[] = 'font-size: ' . $arr_params['font_size_value'] . 'px'; } if ($arr_params['color']) { $arr_styles[] = 'color: ' . $arr_params['color']; } if ($arr_params['font_style'] == 'bold') { $arr_styles[] = 'font-weight: 700 !important'; } else { if ($arr_params['font_style'] == 'normal') { $arr_styles[] = 'font-weight: normal !important'; } else { $arr_styles[] = 'font-style: ' . $arr_params['font_style']; } } } $arr_icon_styles = array(); $arr_icon_class = array(); $arr_icon_class[] = ''; if ($arr_params['icon_position']) { $icon_position = strtolower($arr_params['icon_position']); $arr_icon_class[] = $icon_position != 'inherit' ? "wr-position-{$icon_position}" : ''; } if (strtolower($arr_params['icon_background_type']) != '') { $arr_icon_class[] = "wr-shape-{$arr_params['icon_background_type']}"; } if ($arr_params['icon_size_value']) { $arr_icon_class[] = "wr-icon-{$arr_params['icon_size_value']}"; } if ($arr_params['icon_background_color']) { $arr_icon_styles[] = 'background-color: ' . $arr_params['icon_background_color']; } if ($arr_params['icon_c_color']) { $arr_icon_styles[] = 'color: ' . $arr_params['icon_c_color']; } $html_elements = ''; $sub_shortcode = WR_Pb_Helper_Shortcode::remove_autop($content); $items = explode('<!--seperate-->', $sub_shortcode); // remove empty element $items = array_filter($items); $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open; foreach ($items as $idx => $item) { $open = $idx + 1 == $initial_open ? 'in' : ''; $items[$idx] = $item; } $sub_shortcode = implode('', $items); $sub_shortcode = implode('', $items); if (!empty($sub_shortcode)) { $parent_class = implode(' ', $arr_icon_class); $html_elements = "<ul class='wr-list-icons {$parent_class}'>"; $sub_htmls = do_shortcode($sub_shortcode); $sub_htmls = str_replace('wr-sub-icons', 'wr-icon-base', $sub_htmls); $sub_htmls = str_replace('wr-styles', implode(';', $arr_icon_styles), $sub_htmls); $sub_htmls = str_replace('wr-list-title', implode(';', $arr_styles), $sub_htmls); if ($arr_params['show_icon'] == 'no') { $pattern = '\\[(\\[?)(icon)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls); } else { $sub_htmls = str_replace('[icon]', '', $sub_htmls); $sub_htmls = str_replace('[/icon]', '', $sub_htmls); } if ($arr_params['show_heading'] == 'no') { $pattern = '\\[(\\[?)(heading)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $sub_htmls = preg_replace("/{$pattern}/s", '', $sub_htmls); } else { $sub_htmls = str_replace('[heading]', '', $sub_htmls); $sub_htmls = str_replace('[/heading]', '', $sub_htmls); } $html_elements .= $sub_htmls; $html_elements .= '</ul>'; } return $this->element_wrapper($link . $html_elements, $arr_params); }
/** * define shortcode structure of element */ function element_shortcode($atts = null, $content = null) { extract(shortcode_atts(array('span' => 'span12', 'hidden_on' => '', 'style' => ''), $atts)); $style = empty($style) ? '' : "style='{$style}'"; $span = intval(substr($span, 4)); $hidden_on = trim(str_replace('__#__', ' ', $hidden_on)); $class = "col-md-{$span} col-sm-{$span} col-xs-12 {$hidden_on}"; $content = WR_Pb_Helper_Shortcode::remove_autop($content); return '<div class="' . $class . '" ' . $style . '>' . $content . '</div>'; }
/** * define shortcode structure of element */ function element_shortcode($atts = null, $content = null) { $extra_class = $style = $custom_script = $extra_content = $data_attr = ''; $extra_id = !empty($atts['id_wrapper']) ? esc_attr($atts['id_wrapper']) : WR_Pb_Utils_Common::random_string(); if (isset($atts) && is_array($atts)) { $arr_styles = array(); switch ($atts['width']) { case 'full': $extra_class = 'wr_fullwidth'; // some overwrite css to enable row full width $script = "\$('body').addClass('wr-full-width');"; $custom_script = WR_Pb_Helper_Functions::script_box($script); $arr_styles[] = '-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;width: 100%;padding-left: 1000px;padding-right: 1000px;margin:0 -1000px;'; break; case 'boxed': ///$arr_styles[] = "width: 100%;"; break; } $background = ''; switch ($atts['background']) { case 'none': if ($atts['width'] == 'full') { $background = 'background: none;'; } break; case 'solid': $solid_color = $atts['solid_color_value']; $background = "background-color: {$solid_color};"; break; case 'gradient': $background = $atts['gradient_color_css']; break; case 'pattern': $pattern_img = $atts['pattern']; $background = "background-image:url(\"{$pattern_img}\");"; $background_repeat = self::background_repeat($atts['repeat']); if (!empty($background_repeat)) { $background .= "background-repeat:{$background_repeat};"; } break; case 'image': $image = $atts['image']; $image_position = $atts['position']; $background = "background-image:url(\"{$image}\");background-position:{$image_position};"; // Background repeat $background_repeat = self::background_repeat($atts['img_repeat']); if (!empty($background_repeat)) { $background .= "background-repeat:{$background_repeat};"; } break; case 'video': $url = $atts['video_url']; // Youtube video if (preg_match('/youtube\\.com/', $url)) { $extra_class .= ' wr_video_bg'; parse_str($url, $youtube_url); $data_attr = sprintf("data-property=\"{videoURL:'http://youtu.be/%s', containment:'%s', autoPlay:%s, mute:true, startAt:0, opacity:1, showControls:false}\"", reset($youtube_url), "#{$extra_id}", $atts['autoplay']); add_action('wp_footer', array(__CLASS__, 'enqueue_player_scripts')); add_action('wp_footer', array(__CLASS__, 'print_player_scripts')); } break; } $arr_styles[] = $background; // Paralax background if (isset($atts['paralax']) && $atts['paralax'] == 'yes') { $data_attr .= " data-stellar-background-ratio='-.3'"; } // Border if (isset($atts['border_width_value_']) && intval($atts['border_width_value_'])) { $border = array(); $border[] = $atts['border_width_value_'] . 'px'; $border[] = $atts['border_style']; $border[] = $atts['border_color']; $arr_styles[] = sprintf('border-top:%1$s; border-bottom:%1$s;', implode(' ', $border)); } // Padding $arr_styles[] = "padding-top:{$atts['div_padding_top']}px;"; $arr_styles[] = "padding-bottom:{$atts['div_padding_bottom']}px;"; if ($atts['width'] != 'full') { $arr_styles[] = "padding-left:{$atts['div_padding_left']}px;"; $arr_styles[] = "padding-right:{$atts['div_padding_right']}px;"; } $style = $arr_styles ? sprintf("style='%s'", implode('', $arr_styles)) : ''; } $extra_class .= !empty($atts['css_suffix']) ? ' ' . esc_attr($atts['css_suffix']) : ''; $content = WR_Pb_Helper_Shortcode::remove_autop($content); return $custom_script . sprintf("<div class='jsn-bootstrap3'><div id='%s' class='row %s' %s>%s</div></div>", $extra_id, ltrim($extra_class, ' '), $data_attr . ' ' . $style, balanceTags($extra_content . $content)); }
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ public function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); $html_element = ''; $sub_shortcode = WR_Pb_Helper_Shortcode::remove_autop($content, false); $items = explode('<!--seperate-->', $sub_shortcode); // remove empty element $items = array_filter($items); $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open; foreach ($items as $idx => $item) { $open = $idx + 1 == $initial_open ? 'in' : ''; $items[$idx] = $item; } $sub_shortcode = implode('', $items); $sub_htmls = $sub_shortcode; $arr_params['buttonbar_show_title'] = explode('__#__', $arr_params['buttonbar_show_title']); if (in_array('yes', $arr_params['buttonbar_show_title'])) { $sub_htmls = str_replace('[title]', '', $sub_htmls); $sub_htmls = str_replace('[/title]', '', $sub_htmls); } else { $pattern = '\\[(\\[?)(title)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $sub_htmls = preg_replace('/' . $pattern . '/s', '', $sub_htmls); } $arr_params['buttonbar_show_icon'] = explode('__#__', $arr_params['buttonbar_show_icon']); if (in_array('yes', $arr_params['buttonbar_show_icon'])) { $sub_htmls = str_replace('[icon]', '', $sub_htmls); $sub_htmls = str_replace('[/icon]', '', $sub_htmls); } else { $pattern = '\\[(\\[?)(icon)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $sub_htmls = preg_replace('/' . $pattern . '/s', '', $sub_htmls); } // button margin between $distance_between = isset($arr_params['distance_between']) ? intval($arr_params['distance_between']) : ''; $sub_htmls = str_replace('[style]', $distance_between ? "margin-right:{$distance_between}px" : '', $sub_htmls); if ($arr_params['buttonbar_group'] == 'yes__#__ ') { $html_element = "<div class='btn-group'>" . $sub_htmls . '</div>'; } else { $html_element = $sub_htmls; } $cls_alignment = ''; if (strtolower($arr_params['buttonbar_alignment']) != 'inherit') { if (strtolower($arr_params['buttonbar_alignment']) == 'left') { $cls_alignment = 'pull-left'; } if (strtolower($arr_params['buttonbar_alignment']) == 'right') { $cls_alignment = 'pull-right'; } if (strtolower($arr_params['buttonbar_alignment']) == 'center') { $cls_alignment = 'text-center'; } } $html_element = "<div class='btn-toolbar {$cls_alignment}'>{$html_element}</div>"; // Set button bar margin if (isset($arr_params['buttonbar_margin_top'])) { $arr_params['div_margin_top'] = $arr_params['buttonbar_margin_top']; } if (isset($arr_params['buttonbar_margin_left'])) { $arr_params['div_margin_left'] = $arr_params['buttonbar_margin_left']; } if (isset($arr_params['buttonbar_margin_right'])) { $arr_params['div_margin_right'] = $arr_params['buttonbar_margin_right']; } if (isset($arr_params['buttonbar_margin_bottom'])) { $arr_params['div_margin_bottom'] = $arr_params['buttonbar_margin_bottom']; } return $this->element_wrapper($html_element, $arr_params); }
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $random_id = WR_Pb_Utils_Common::random_string(); $script = $html_element = ''; if (!empty($content)) { $content = WR_Pb_Helper_Shortcode::remove_autop($content); } if (isset($enable_dropcap) && $enable_dropcap == 'yes') { if ($content) { $styles = array(); if ($dropcap_font_face_type == 'google fonts' and $dropcap_font_face_value != '') { $script .= WR_Pb_Helper_Functions::add_google_font_link_tag($dropcap_font_face_value); $styles[] = 'font-family:' . $dropcap_font_face_value; } elseif ($dropcap_font_face_type == 'standard fonts' and $dropcap_font_face_value) { $styles[] = 'font-family:' . $dropcap_font_face_value; } if (intval($dropcap_font_size) > 0) { $styles[] = 'font-size:' . intval($dropcap_font_size) . 'px'; $styles[] = 'line-height:' . intval($dropcap_font_size) . 'px'; } switch ($dropcap_font_style) { case 'bold': $styles[] = 'font-weight:700'; break; case 'italic': $styles[] = 'font-style:italic'; break; case 'normal': $styles[] = 'font-weight:normal'; break; } if (strpos($dropcap_font_color, '#') !== false) { $styles[] = 'color:' . $dropcap_font_color; } if (count($styles)) { $html_element .= '<style type="text/css">'; $html_element .= sprintf('%1$s .dropcap:first-letter, %1$s .dropcap p:first-letter { float:left;', "#{$random_id}"); $html_element .= implode(';', $styles); $html_element .= '}'; $html_element .= '</style>'; } $html_element .= "<div class='dropcap'>{$content}</div>"; } } else { $html_element .= $content; } $html = sprintf('<div class="wr_text" id="%s">', $random_id); $html .= $script; $html .= $html_element; $html .= '</div>'; // Process margins if (isset($arr_params['text_margin_top'])) { $arr_params['div_margin_top'] = $arr_params['text_margin_top']; } if (isset($arr_params['text_margin_bottom'])) { $arr_params['div_margin_bottom'] = $arr_params['text_margin_bottom']; } if (isset($arr_params['text_margin_right'])) { $arr_params['div_margin_right'] = $arr_params['text_margin_right']; } if (isset($arr_params['text_margin_left'])) { $arr_params['div_margin_left'] = $arr_params['text_margin_left']; } return $this->element_wrapper($html, $arr_params); }
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ public function element_shortcode_full($atts = null, $content = null) { $html_element = $container_class = $str_scripts = ''; $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $arrDefaultOptions = array('streetViewControl', 'zoomControl', 'panControl', 'mapTypeControl', 'scaleControl', 'overviewMapControl', 'scrollwheel'); if ($gmap_elements) { $arr_elements = array_filter(explode('__#__', $gmap_elements)); foreach ($arrDefaultOptions as $i => $item) { if (in_array($item, $arr_elements)) { $str_scripts .= $item . ': true,'; } else { $str_scripts .= $item . ': false,'; } } } $random_id = WR_Pb_Utils_Common::random_string(); $player_elements = ''; if ($gmap_alignment === 'right') { $player_elements .= '$( "#wr-gmap-' . $random_id . '" ).css( "float", "right" );'; $container_class .= 'clearafter '; } else { if ($gmap_alignment === 'center') { $player_elements .= '$( "#wr-gmap-' . $random_id . '" ).css( {"margin" : "0 auto", "display" : "block" } );'; } else { if ($gmap_alignment === 'left') { $player_elements .= '$( "#wr-gmap-' . $random_id . '" ).css( "float", "left" );'; $container_class .= 'clearafter '; } } } $html_element .= '<script type="text/javascript">(function ($) { $( document ).ready( function () { ' . $player_elements . ' var map_' . $random_id . ' = ""; var marker_locations_' . $random_id . ' = []; function get_latlong(obj) { var myLatlng = new google.maps.LatLng( obj.gmi_lat, obj.gmi_long); return myLatlng; } function get_infobox(obj) { var infowindow = ""; var contentString = "<div class=\\"wr-gmi-info\\" style=\\"width:250px\\" >"; contentString += "<div class=\\"wr-gmi-thumb\\">"; if ( obj.gmi_image != "" && obj.gmi_image != "http://" ) contentString += "<img src=\\"" + obj.gmi_image + "\\" />"; contentString += "</div>"; contentString += "<span class=\\"wr-gmi-title\\"><b>" + obj.gmi_title + "</b></span>"; if ( obj.gmi_desc_content ) contentString += "<p>" + obj.gmi_desc_content + "</p>"; if ( obj.gmi_url != "" && obj.gmi_url != "http://" ) contentString += "<a href=\\"" + obj.gmi_url + "\\" target=\\"_blank\\">more...></a>"; contentString += "</div>"; infowindow = new google.maps.InfoWindow({ content: contentString }); infowindow.setOptions({maxWidth:300}); return infowindow; } function markerAtPoint(latlng) { for (var i = 0; i < marker_locations_' . $random_id . '.length; ++i) { if (marker_locations_' . $random_id . '[i].equals(latlng)) return true; } return false; } function initialize_' . $random_id . '() { var gmap_zoom = parseInt("' . $gmap_zoom . '"); var gmap_lat = ""; var gmap_long = ""; var gmap_type = google.maps.MapTypeId.' . $gmap_type . '; var directionsService_' . $random_id . ' = new google.maps.DirectionsService(); var has_direction = false; var mapOptions_' . $random_id . ' = { zoom: gmap_zoom, center: new google.maps.LatLng(0,0), mapTypeId: gmap_type, ' . $str_scripts . ' }; map_' . $random_id . ' = new google.maps.Map(document.getElementById(\'wr-gmap-' . $random_id . '\'), mapOptions_' . $random_id . '); var rendererOptions_' . $random_id . ' = { map: map_' . $random_id . ', suppressMarkers: true } var directionsDisplay_' . $random_id . ' = new google.maps.DirectionsRenderer(rendererOptions_' . $random_id . '); directionsDisplay_' . $random_id . '.setMap(map_' . $random_id . '); // Check has directions $( "#wr-gmap-wrapper-' . $random_id . ' .wr-gmi-lat-long" ).each(function (index) { var obj = JSON.parse($(this).val()); if ( obj.gmi_lat != "" && obj.gmi_long != "" && obj.gmi_destination != "" ) { has_direction = true; } }); // Add markers if ( has_direction == false ) { $( "#wr-gmap-wrapper-' . $random_id . ' .wr-gmi-lat-long" ).each(function (index) { var obj = JSON.parse($(this).val()); if ( obj.gmi_lat != "" && obj.gmi_long != "" ) { var myLatlng = get_latlong(obj); var infowindow = get_infobox(obj); if ( map_' . $random_id . ' ) { var marker = new google.maps.Marker({ position: myLatlng, map: map_' . $random_id . ', title: obj.gmi_title }); marker_locations_' . $random_id . '.push(myLatlng); map_' . $random_id . '.setCenter(marker.getPosition()); google.maps.event.addListener(marker, \'click\', function() { infowindow.open(map_' . $random_id . ',marker); }); } } }); } else { $( "#wr-gmap-wrapper-' . $random_id . ' .wr-gmi-lat-long" ).each(function (i) { var obj = JSON.parse($(this).val()); $( "#wr-gmap-wrapper-' . $random_id . ' .wr-gmi-lat-long" ).each(function (j) { var sub_obj = JSON.parse($(this).val()); if ( sub_obj.gmi_title == obj.gmi_destination && sub_obj.gmi_lat != "" && sub_obj.gmi_long != "" ) { var start = get_latlong(obj); var end = get_latlong(sub_obj); var infowindow = get_infobox(obj); if ( map_' . $random_id . ' ) { var marker = new google.maps.Marker({ position: start, map: map_' . $random_id . ', title: obj.gmi_title }); marker_locations_' . $random_id . '.push(start); google.maps.event.addListener(marker, \'click\', function() { infowindow.open(map_' . $random_id . ',marker); }); } var sub_infowindow = get_infobox(sub_obj); if ( map_' . $random_id . ' ) { var sub_marker = new google.maps.Marker({ position: end, map: map_' . $random_id . ', title: sub_obj.gmi_title }); marker_locations_' . $random_id . '.push(end); google.maps.event.addListener(sub_marker, \'click\', function() { sub_infowindow.open(map_' . $random_id . ',sub_marker); }); } var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService_' . $random_id . '.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay_' . $random_id . '.setDirections(response); } }); } if ( markerAtPoint(new google.maps.LatLng( obj.gmi_lat, obj.gmi_long) ) == false ) { var myLatlng = get_latlong(obj); var infowindow = get_infobox(obj); if ( map_' . $random_id . ' ) { var marker = new google.maps.Marker({ position: myLatlng, map: map_' . $random_id . ', title: obj.gmi_title }); marker_locations_' . $random_id . '.push(myLatlng); map_' . $random_id . '.setCenter(marker.getPosition()); google.maps.event.addListener(marker, \'click\', function() { infowindow.open(map_' . $random_id . ',marker); }); } } }); }); } } google.maps.event.addDomListener(window, \'load\', initialize_' . $random_id . '); // Center map on resize google.maps.event.addDomListener(window, \'resize\', function() { var center = map_' . $random_id . '.getCenter(); google.maps.event.trigger(map_' . $random_id . ', \'resize\'); map_' . $random_id . '.setCenter(center); }); }); })(jQuery)</script>'; $class = 'wr-googlemap'; if ($gmap_container_style == 'img-thumbnail') { $class .= ' img-thumbnail'; } if ($gmap_margin_top) { $gmap_styles[] = "margin-top:{$gmap_margin_top}px !important"; } if ($gmap_margin_bottom) { $gmap_styles[] = "margin-bottom:{$gmap_margin_bottom}px !important"; } if ($gmap_margin_right) { $gmap_styles[] = "margin-right:{$gmap_margin_right}px !important"; } if ($gmap_margin_left) { $gmap_styles[] = "margin-left:{$gmap_margin_left}px !important"; } if ($gmap_dimension_height) { $gmap_styles[] = "height:{$gmap_dimension_height}px !important"; } if ($gmap_dimension_width) { $gmap_styles[] = "width:{$gmap_dimension_width}{$gmap_dimension_width_unit} !important"; } $styles = count($gmap_styles) ? ' style="' . implode(';', $gmap_styles) . '"' : ''; $html_element .= '<div id="wr-gmap-wrapper-' . $random_id . '">'; $html_element .= '<div id="wr-gmap-' . $random_id . '" ' . $styles . ' class="' . $class . '"></div>'; $sub_shortcode = WR_Pb_Helper_Shortcode::remove_autop($content); $items = explode('<!--seperate-->', $sub_shortcode); // remove empty element $items = array_filter($items); $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open; foreach ($items as $idx => $item) { $open = $idx + 1 == $initial_open ? 'in' : ''; $items[$idx] = $item; } $sub_htmls = do_shortcode($sub_shortcode); $html_element .= $sub_htmls; $html_element .= '</div>'; return $this->element_wrapper($html_element, $arr_params); }