/** * Frontend Shortcode Handler * * @param array $atts array of attributes * @param string $content text within enclosing form of shortcode element * @param string $shortcodename the shortcode found, when == callback name * @return string $output returns the modified html string */ function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "") { global $wp_embed; extract(shortcode_atts(array('src' => '', 'autoplay' => '', 'format' => '', 'height' => '9', 'width' => '16'), $atts)); $custom_class = !empty($meta['custom_class']) ? $meta['custom_class'] : ""; $style = ""; $html = ""; $file_extension = substr($src, strrpos($src, '.') + 1); if (in_array($file_extension, array('ogv', 'webm', 'mp4'))) { $output = avia_html5_video_embed($src); $html = "avia-video-html5"; } else { $output = $wp_embed->run_shortcode("[embed]" . trim($src) . "[/embed]"); } if ($format == 'custom') { $height = intval($height); $width = intval($width); $ratio = 100 / $width * $height; $style = "style='padding-bottom:{$ratio}%;'"; } if ($output) { $output = "<div {$style} class='avia-video avia-video-{$format} {$html} {$custom_class}'>{$output}</div>"; } return $output; }
static function set_video_slide($video_url, $service = false, $meta = false) { $video = ""; if (empty($service)) { $service = self::which_video_service($video_url); } $uid = 'player_' . get_the_ID() . '_' . mt_rand() . '_' . mt_rand(); $controls = empty($meta['video_controls']) ? 1 : 0; $loop = empty($meta['video_loop']) ? 0 : 1; switch ($service) { case "html5": $video = "<div class='av-click-overlay'></div>" . avia_html5_video_embed($video_url); break; case "iframe": $video = $video_url; break; case "youtube": $explode_at = strpos($video_url, 'youtu.be/') !== false ? "/" : "v="; $video_url = explode($explode_at, trim($video_url)); $video_url = end($video_url); $video_id = $video_url; //if parameters are appended make sure to create the correct video id if (strpos($video_url, '?') !== false || strpos($video_url, '?') !== false) { preg_match('!(.+)[&?]!', $video_url, $video_id); $video_id = isset($video_id[1]) ? $video_id[1] : $video_id[0]; } $video_data = apply_filters('avf_youtube_video_data', array('autoplay' => 0, 'videoid' => $video_id, 'hd' => 1, 'rel' => 0, 'wmode' => 'opaque', 'playlist' => $uid, 'loop' => 0, 'version' => 3, 'autohide' => 1, 'color' => 'white', 'controls' => $controls, 'showinfo' => 0)); $data = AviaHelper::create_data_string($video_data); $video = "<div class='av-click-overlay'></div><div class='mejs-mediaelement'><div height='1600' width='900' class='av_youtube_frame' id='{$uid}' {$data}></div></div>"; break; case "vimeo": $color = ltrim(avia_get_option('colorset-main_color-primary'), '#'); $autopause = empty($meta['video_section_bg']) ? 1 : 0; //pause if another vimeo video plays? $video_url = explode('/', trim($video_url)); $video_url = end($video_url); $video_url = add_query_arg(array('portrait' => 0, 'byline' => 0, 'title' => 0, 'badge' => 0, 'loop' => $loop, 'autopause' => $autopause, 'api' => 1, 'rel' => 0, 'player_id' => $uid, 'color' => $color), 'http://player.vimeo.com/video/' . $video_url); $video_url = apply_filters('avf_vimeo_video_url', $video_url); $video = "<div class='av-click-overlay'></div><div class='mejs-mediaelement'><iframe src='{$video_url}' height='1600' width='900' frameborder='' class='av_vimeo_frame' id='{$uid}'></iframe></div>"; break; } return $video; }
/** * Fetches a url based on values set in the backend * @param array $option_array array that at least needs to contain the linking method and depending on that, the appropriate 2nd id value * @param string $keyprefix option set key that must be in front of every element key * @param string $inside if inside is passed it will be wrapped inside <a> tags with the href set to the previously returned link url * @param string $post_id if the function is called outside of the loop we might want to retrieve the permalink of a different post with this id * @return string url (with image inside <a> tag if the image string was passed) */ function avia_get_link($option_array, $keyprefix, $inside = false, $post_id = false, $attr = "") { if (empty($option_array[$keyprefix . 'link'])) { $option_array[$keyprefix . 'link'] = ""; } //check which value the link array has (possible are empty, lightbox, page, post, cat, url) and create the according link switch ($option_array[$keyprefix . 'link']) { case "lightbox": $url = avia_image_by_id($option_array[$keyprefix . 'image'], array('width' => 8000, 'height' => 8000), 'url'); break; case "cat": $url = get_category_link($option_array[$keyprefix . 'link_cat']); break; case "page": $url = get_page_link($option_array[$keyprefix . 'link_page']); break; case "self": if (!is_singular() || $post_id != avia_get_the_ID() || !isset($option_array[$keyprefix . 'image'])) { $url = get_permalink($post_id); } else { $url = avia_image_by_id($option_array[$keyprefix . 'image'], array('width' => 8000, 'height' => 8000), 'url'); } break; case "url": $url = $option_array[$keyprefix . 'link_url']; break; case "video": $video_url = $option_array[$keyprefix . 'link_video']; if (avia_backend_is_file($video_url, 'html5video')) { $output = avia_html5_video_embed($video_url); $class = "html5video"; } else { global $wp_embed; $output = $wp_embed->run_shortcode("[embed]" . $video_url . "[/embed]"); $class = "embeded_video"; } $output = "<div class='slideshow_video {$class}'>" . $output . "</div>"; return $inside . $output; break; default: $url = $inside; break; } if (!$inside || $url == $inside) { return $url; } else { return "<a {$attr} href='" . $url . "'>" . $inside . "</a>"; } }
/** * Frontend Shortcode Handler * * @param array $atts array of attributes * @param string $content text within enclosing form of shortcode element * @param string $shortcodename the shortcode found, when == callback name * @return string $output returns the modified html string */ function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "") { extract(shortcode_atts(array('src' => '', 'src_1' => '', 'src_2' => '', 'autoplay' => '', 'format' => '', 'height' => '9', 'width' => '16'), $atts, $this->config['shortcode'])); $custom_class = !empty($meta['custom_class']) ? $meta['custom_class'] : ''; $style = ''; $html = ''; if (current_theme_supports('avia_template_builder_custom_html5_video_urls')) { $sources = array(); if (!empty($src)) { $sources['src'] = array('url' => $src, 'extension' => substr($src, strrpos($src, '.') + 1)); } if (!empty($src_1)) { $sources['src_1'] = array('url' => $src_1, 'extension' => substr($src_1, strrpos($src_1, '.') + 1)); } if (!empty($src_2)) { $sources['src_2'] = array('url' => $src_2, 'extension' => substr($src_2, strrpos($src_2, '.') + 1)); } $html5 = false; if (!empty($sources)) { foreach ($sources as $source) { if (in_array($source['extension'], array('ogv', 'webm', 'mp4'))) { $html5 = true; } else { $video = $source['url']; $html5 = false; break; } } } if ($html5 && !empty($sources)) { $video = ''; foreach ($sources as $source) { $video .= $source['extension'] . '="' . $source['url'] . '" '; } $output = do_shortcode('[video ' . $video . ']'); $html = "avia-video-html5"; } else { if (!empty($video)) { global $wp_embed; $output = $wp_embed->run_shortcode("[embed]" . trim($src) . "[/embed]"); } } } else { $file_extension = substr($src, strrpos($src, '.') + 1); if (in_array($file_extension, array('ogv', 'webm', 'mp4'))) { $output = avia_html5_video_embed($src); $html = "avia-video-html5"; } else { global $wp_embed; $output = $wp_embed->run_shortcode("[embed]" . trim($src) . "[/embed]"); } } if ($format == 'custom') { $height = intval($height); $width = intval($width); $ratio = 100 / $width * $height; $style = "style='padding-bottom:{$ratio}%;'"; } if (!empty($output)) { $markup = avia_markup_helper(array('context' => 'video', 'echo' => false, 'custom_markup' => $meta['custom_markup'])); $output = "<div {$style} class='avia-video avia-video-{$format} {$html} {$custom_class}' {$markup}>{$output}</div>"; } return $output; }
function slideshow() { global $avia_config; $counter = 1; $set_size = $output = $extraid = ""; $this->slider_size_calc(); // calc $this->slideshowSize if (strpos($this->type, 'piecemaker') !== false) { $extraid = "id='slideshow_" . $this->type . $this->post_id . "'"; } if ($this->slidecount) { $output .= "<div {$extraid} class='" . $this->slideshow_class() . " slideshow_container'>"; $output .= "<ul class='slideshow' " . $this->slideshowSize . ">"; foreach ($this->slides as $slide) { //check if only video was linked if ($slide['slideshow_image'] == "") { if (!empty($this->slides[0]['slideshow_link']) && $this->slides[0]['slideshow_link'] == 'video') { if (!empty($this->slides[0]['slideshow_link_video']) && $this->slides[0]['slideshow_link_video'] != "http://") { $slide['slideshow_image'] = $this->slides[0]['slideshow_link_video']; } } } if ($slide['slideshow_image'] != "") { //check if we got an image or a video if (!empty($slide['slideshow_caption'])) { $slide['slideshow_caption'] = nl2br($slide['slideshow_caption']); } if (!is_numeric($slide['slideshow_image'])) { ### render a video ### $output .= "<li class='" . $this->slide_class($slide) . "featured featured_container" . $counter++ . "' >"; if (avia_backend_is_file($slide['slideshow_image'], 'html5video')) { $output .= avia_html5_video_embed($slide['slideshow_image']); } else { global $avia_config, $wp_embed; $vid_height = ""; if (isset($avia_config['imgSize'][$this->img_size]['height'])) { $vid_height = "height='" . $avia_config['imgSize'][$this->img_size]['height'] . "'"; } $output .= $wp_embed->run_shortcode("[embed {$vid_height} ]" . $slide['slideshow_image'] . "[/embed]"); } //check if the user has set either a title or a caption that we can display if ($this->showcaption && $this->type == 'aviacordion') { if (!empty($slide['slideshow_caption_title']) || !empty($slide['slideshow_caption']) || !empty($slideshow_options_show_controlls) && !empty($slides[1]['slideshow_image'])) { $output .= '<div class="slideshow_caption"><div class="inner_caption">'; if (!empty($slide['slideshow_caption_title'])) { $output .= '<h1>' . $slide['slideshow_caption_title'] . '</h1>'; } if (!empty($slide['slideshow_caption'])) { $output .= '<div class="featured_caption">' . do_shortcode($slide['slideshow_caption']) . '</div>'; } $output .= '</div></div>'; } } $output .= "</li>"; } else { ### render an image ### //get the image by passing the attachment id. $image_string = avia_image_by_id($slide['slideshow_image'], $this->img_size); //if we didnt get a valid image from the above function set it directly if (!$image_string) { $image_string = $slide['slideshow_image']; } //apply links to the image if thats what the user wanted if (empty($this->link_overwrite)) { $image = avia_get_link($slide, 'slideshow_', $image_string, $this->post_id); } else { $image = "<a href='" . $this->link_overwrite . "'>" . $image_string . "</a>"; } $output .= "<li class='" . $this->slide_class($slide) . "featured featured_container" . $counter++ . "' >"; $output .= $image; //check if the user has set either a title or a caption that we can display if ($this->showcaption) { if (!empty($slide['slideshow_caption_title']) || !empty($slide['slideshow_caption']) || !empty($slideshow_options_show_controlls) && !empty($slides[1]['slideshow_image'])) { $button = ""; $nextSlide = ''; if ($this->type == 'caption_slider' && !empty($slide['slideshow_button_title'])) { if ($slide['slideshow_button_link'] == 'nextSlide') { $nextSlide = 'nextSlide'; $button = "#"; } else { $button = avia_get_link($slide, 'slideshow_button_', false, $this->post_id); } if ($button) { $button = "<a class='avia-button caption-slideshow-button {$nextSlide}' href='{$button}' title='' >" . $slide['slideshow_button_title'] . "</a>"; } } $output .= '<div class="slideshow_caption"><div class="inner_caption">'; if (!empty($slide['slideshow_caption_title'])) { $output .= '<h1>' . $slide['slideshow_caption_title'] . '</h1>'; } if (!empty($slide['slideshow_caption'])) { $output .= '<div class="featured_caption">' . do_shortcode($slide['slideshow_caption']) . $button . '</div>'; } $output .= '</div></div>'; } } $output .= "</li>"; } } } $output .= "</ul>"; if ($this->show_thumbnails) { $output .= $this->slideshow_thumbs(); } $output .= '</div>'; if (strpos($this->type, 'piecemaker') !== false) { $output = "<div class='piecemaker' " . $this->slideshowSize . ">" . $output . "</div>"; } } return $output; }