function generate_video($link)
{
    $video = "";
    if (themeple_backend_is_file($link, 'html5video')) {
        $video = themeple_html5_video_embed($link);
    } else {
        if (strpos($link, '<iframe') !== false) {
            $video = $link;
        } else {
            global $wp_embed;
            $video = $wp_embed->run_shortcode("[embed]" . trim($link) . "[/embed]");
        }
    }
    if (strpos($video, '<a') === 0) {
        $video = '<iframe src="' . $link . '"></iframe>';
    }
    return $video;
}
 /**
  * themeple_slideshow::render_slideshow()
  * 
  * @return
  */
 function render_slideshow()
 {
     if (post_password_required($this->post_id)) {
         return false;
     }
     global $themeple_config;
     $output = "";
     $i = 0;
     $output .= $this->before_container_html;
     if ($this->slide_number) {
         $output .= '<div class="slideshow_container ' . $this->slide_container_class . ' slide_layout_' . $this->options['slideshow_layout'] . '" id="' . $this->slide_container_id . 'flex" ' . $this->additional_attr . '>';
         $output .= $this->custom_header_html;
         $output .= '    <ul class="' . $this->slide_ul_class . ' slide_' . $this->slide_type . '">';
         $output .= $this->before_elements;
         foreach ($this->slides as $slide) {
             $i++;
             $image = "";
             if (!empty($slide['slideshow_image'])) {
                 $m_d = array();
                 if (isset($this->media_img_data[$i])) {
                     $m_d = $this->media_img_data[$i];
                 }
                 $image_string = themeple_image_by_id($slide['slideshow_image'], $this->img_size, 'image', $m_d);
                 if (!$image_string) {
                     $image_string = $slide['slideshow_image'];
                 }
                 if (isset($slide['slideshow_link']) && $slide['slideshow_link'] != 'http://') {
                     $image = "<a href='" . $slide['slideshow_link'] . "'>" . $image_string . "</a>";
                 } else {
                     $image = $image_string;
                 }
             }
             $video = "";
             if (!empty($slide['slideshow_video'])) {
                 if (themeple_backend_is_file($slide['slideshow_video'], 'html5video')) {
                     $video = themeple_html5_video_embed($slide['slideshow_video']);
                 } else {
                     if (strpos($slide['slideshow_video'], '<iframe') !== false) {
                         $video = $slide['slideshow_video'];
                     } else {
                         global $wp_embed;
                         $video = $wp_embed->run_shortcode("[embed]" . trim($slide['slideshow_video']) . "[/embed]");
                     }
                 }
                 if (strpos($video, '<a') === 0) {
                     $video = '<iframe src="' . $slide['slideshow_video'] . '"></iframe>';
                 }
             }
             $output .= "\t\t<li class='" . $this->slide_element_class . " slide_element slide" . $i . " frame" . $i . "'>";
             if (!is_array($this->before_render_media)) {
                 $output .= $this->before_render_media;
             } else {
                 $output .= $this->before_render_media[$i];
             }
             $output .= $image . $video;
             $output .= $this->after_render_media;
             if (isset($slide['slideshow_description']) && strlen($slide['slideshow_description']) > 1) {
                 $output .= $this->after_render_media;
                 $output .= '<div class="captionss">';
                 $output .= '<p class="flex-caption" data-effect-in="fadeInLeft" data-effect-out="fadeOutRight"><span>' . $slide['slideshow_description'] . '</span></p>';
                 if (isset($slide['slideshow_description_2']) && strlen($slide['slideshow_description_2']) > 1) {
                     $output .= '<p class="flex-caption" data-effect-in="fadeInLeft" data-effect-out="fadeOutRight"><span>' . $slide['slideshow_description_2'] . '</span></p>';
                 }
                 $output .= '</div>';
             }
             $output .= "\t\t</li>";
         }
         $output .= $this->after_elements;
         $output .= "\t</ul>";
         $output .= $this->custom_footer_html;
         $output .= "</div>";
         $output .= $this->after_container_html;
     }
     return $output;
 }
 /**
  * VideoWidget::widget()
  * 
  * @param mixed $atts
  * @param mixed $instance
  * @return
  */
 function widget($atts, $instance)
 {
     extract($atts, EXTR_SKIP);
     echo $before_widget;
     $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
     $video = empty($instance['video']) ? '' : $instance['video'];
     $video_ = '<div class="visual"> ';
     if (themeple_backend_is_file($video, 'html5video')) {
         $video_ .= themeple_html5_video_embed($video);
     } else {
         if (strpos($video, '<iframe') !== false) {
             $video_ .= $video;
         } else {
             global $wp_embed;
             $video_ .= $wp_embed->run_shortcode("[embed]" . trim($video) . "[/embed]");
         }
     }
     if (strpos($video, '<a') === 0) {
         $video_ .= '<iframe width="width:220px" src="' . $video . '"></iframe>';
     }
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $video_ .= '</div>';
     echo $video_;
     echo $after_widget;
 }



                                            <?php 
            } elseif ($post_format == 'video') {
                ?>



                                               

                                                <?php 
                $video = "";
                if (themeple_backend_is_file(get_the_excerpt(), 'html5video')) {
                    $video = themeple_html5_video_embed(get_the_excerpt());
                } else {
                    if (strpos(get_the_excerpt(), '<iframe') !== false) {
                        $video = get_the_excerpt();
                    } else {
                        global $wp_embed;
                        $video = $wp_embed->run_shortcode("[embed]" . trim(get_the_excerpt()) . "[/embed]");
                    }
                }
                if (strpos($video, '<a') === 0) {
                    $video = '<iframe src="' . get_the_excerpt() . '"></iframe>';
                }
                echo $video;
                ?>
						  
							
 function headers($element)
 {
     extract($element['saved'][0]);
     $output = '<div class="span' . $dynamic_size . '">';
     if (!isset($dynamic_title)) {
         $dynamic_title = '';
     }
     if (!isset($dynamic_desc)) {
         $dynamic_desc = '';
     }
     if ($dynamic_shadow == 'yes') {
         $output .= '<div class="divider_shadow dynamic_el"><h5 class="block-title">' . $dynamic_title . '</h5><span class="block-desc">' . $dynamic_desc . '</span></div>';
     }
     $post = isset($dynamic_header_post) ? $dynamic_header_post : 0;
     if ($post != 0) {
         $query_post = array('p' => $post, 'posts_per_page' => 1, 'post_type' => 'header');
         $additional_loop = new WP_Query($query_post);
         $output .= '<div class="dynamic_element">';
         if ($additional_loop->have_posts()) {
             while ($additional_loop->have_posts()) {
                 $additional_loop->the_post();
                 $content = get_the_content();
                 $media_position = themeple_post_meta(get_the_ID(), 'media_position');
                 $video = themeple_post_meta(get_the_ID(), 'video_link');
                 $button_title = themeple_post_meta(get_the_ID(), 'button_title');
                 $button_link = themeple_post_meta(get_the_ID(), 'button_link');
                 $button_align = themeple_post_meta(get_the_ID(), 'button_align');
                 $list = themeple_post_meta(get_the_ID(), 'list_elements');
                 $visual = themeple_post_meta(get_the_ID(), 'media_box');
                 if ($visual == 'yes') {
                     $visual = 'visual';
                 } else {
                     $visual = '';
                 }
                 $featured = themeple_image_by_id(get_post_thumbnail_id(), 'header-thumb', 'url');
                 $output .= '<section class=" top_header_element">';
                 $output .= '<div class="row-fluid">';
                 if ($media_position == 'left') {
                     $output .= '<div class="span6"><div class="' . $visual . '"><div class="visual_image">';
                     if (empty($video) && !empty($featured)) {
                         $output .= '<img src="' . $featured . '" alt="" />';
                     } elseif (!empty($video) && empty($featured)) {
                         if (themeple_backend_is_file($video, 'html5video')) {
                             $video = themeple_html5_video_embed($slide['slideshow_video']);
                         } else {
                             if (strpos($video, '<iframe') !== false) {
                                 $video = $video;
                             } else {
                                 global $wp_embed;
                                 $video = $wp_embed->run_shortcode("[embed]" . trim($video) . "[/embed]");
                             }
                         }
                         if (strpos($video, '<a') === 0) {
                             $video = '<iframe src="' . $video . '"></iframe>';
                         }
                         $output .= $video;
                     }
                     $output .= '</div></div></div>';
                 }
                 $output .= '<div class="span6">';
                 $output .= '<h1>' . get_the_title() . '</h1>';
                 $output .= '<p>' . $content . '</p>';
                 $output .= '<div class="row-fluid">';
                 if (count($list) > 0) {
                     $output .= '<ul>';
                 }
                 foreach ($list as $li) {
                     $output .= '<li class="span6"><a href="' . $li['list_link'] . '">' . $li['list_title'] . '</a></li>';
                 }
                 if (count($list) > 0) {
                     $output .= '</ul>';
                 }
                 $output .= '</div>';
                 if (!empty($button_title)) {
                     $output .= '<div class="row-fluid"><a class="button_top_header ' . $button_align . '" href="' . $button_link . '">' . $button_title . '</a></div>';
                 }
                 $output .= '</div>';
                 if ($media_position == 'right') {
                     $output .= '<div class="span6"><div class="' . $visual . '"><div class="visual_image">';
                     if (empty($video) && !empty($featured)) {
                         $output .= '<img src="' . $featured . '" alt="" />';
                     } elseif (!empty($video) && empty($featured)) {
                         if (themeple_backend_is_file($video, 'html5video')) {
                             $video = themeple_html5_video_embed($slide['slideshow_video']);
                         } else {
                             if (strpos($video, '<iframe') !== false) {
                                 $video = $video;
                             } else {
                                 global $wp_embed;
                                 $video = $wp_embed->run_shortcode("[embed]" . trim($video) . "[/embed]");
                             }
                         }
                         if (strpos($video, '<a') === 0) {
                             $video = '<iframe src="' . $video . '"></iframe>';
                         }
                         $output .= $video;
                     }
                     $output .= '</div></div></div>';
                 }
                 $output .= '</div>';
                 $output .= '</section>';
             }
         }
         $output .= '</div>';
         $output .= '</div>';
         wp_reset_query();
     }
     return $output;
 }