示例#1
0
    function shortcode_video_preview($atts, $content = null, $shortcodename = '')
    {
        extract(shortcode_atts(array('title' => '', 'post_url' => '', 'date' => '', 'author' => '', 'lightbox' => 'no', 'custom_class' => ''), $atts));
        $output_title = '';
        $output_author = '';
        $output_date = '';
        $post_ID = url_to_postid($post_url);
        $get_post = get_post($post_ID);
        $get_user = get_userdata($get_post->post_author);
        $user_url = get_bloginfo('url') . '/author/' . $get_user->user_nicename;
        $video_embed_meta = get_post_meta($post_ID, 'tz_video_embed', true);
        if (empty($video_embed_meta)) {
            return '';
        }
        $video_url = parser_video_url($video_embed_meta);
        $video_url_popup = str_replace('src=', '', $video_url);
        $rand = rand();
        if (strpos($video_url, 'youtube') !== false) {
            $video_url_popup = str_replace('embed/', 'watch?v=', $video_url_popup);
        }
        $get_image_url = video_image($video_url);
        $img = '';
        if ($title == "yes") {
            $output_title = '<h4><a href="' . $post_url . '" title="' . $get_post->post_title . '">' . $get_post->post_title . '</a></h4>';
        }
        if ($author == "yes") {
            $output_author = '<span class="post_author">Posts by <a href="' . $user_url . '" title="Posts by ' . $get_user->user_nicename . '"  rel="author">' . $get_user->user_nicename . '</a></span>';
        }
        if ($date == "yes") {
            $output_date = '<span class="post_date"><time datetime="' . $get_post->post_date . '"> ' . get_the_date() . '</time></span>';
        }
        if ($get_image_url != false && $get_image_url != '') {
            if ($lightbox == 'yes') {
                $img = ' <script type="text/javascript">
					jQuery(document).ready(function() {
						jQuery(\'.popup-video-' . $rand . '\').magnificPopup({
							type: \'iframe\',
							mainClass: \'mfp-fade\',
							removalDelay: 160,
							preloader: false,
							fixedContentPos: false
						});
					});
				</script>';
                $img .= '<a class="popup-video-' . $rand . '" href="' . $video_url_popup . '" title="' . $get_image_url . '"><img src="' . $get_image_url . '" alt=""><span class="icon-play-circle hover"></span></a>';
            } else {
                $img = '<a class="preview_image"  href="' . $post_url . '" title="' . $get_image_url . '"><img src="' . $get_image_url . '" alt=""><span class="icon-play-circle hover"></span></a>';
            }
        }
        $output = '<figure class="featured-thumbnail thumbnail video_preview clearfix' . $custom_class . '"><div>' . $img . '<figcaption>' . $output_title . $output_author . $output_date . '</figcaption></div></figure>';
        $output = apply_filters('cherry_plugin_shortcode_output', $output, $atts, $shortcodename);
        return $output;
    }
 function shortcode_video_preview($atts, $content = null)
 {
     extract(shortcode_atts(array('title' => '', 'post_url' => '', 'date' => '', 'author' => '', 'custom_class' => ''), $atts));
     $output_title = '';
     $output_author = '';
     $output_date = '';
     $post_ID = url_to_postid($post_url);
     $get_post = get_post($post_ID);
     $get_user = get_userdata($get_post->post_author);
     $user_url = get_bloginfo('url') . '/author/' . $get_user->user_nicename;
     $video_url = parser_video_url(get_post_meta($post_ID, 'tz_video_embed', true));
     $get_image_url = video_image($video_url);
     $img = '';
     if ($title == "yes") {
         $output_title = '<h4><a href="' . $post_url . '" title="' . $get_post->post_title . '">' . $get_post->post_title . '</a></h4>';
     }
     if ($author == "yes") {
         $output_author = '<span class="post_author">Posts by <a href="' . $user_url . '" title="Posts by ' . $get_user->user_nicename . '"  rel="author">' . $get_user->user_nicename . '</a></span>';
     }
     if ($date == "yes") {
         $output_date = '<span class="post_date"><time datetime="' . $get_post->post_date . '"> ' . get_the_date() . '</time></span>';
     }
     if ($get_image_url != false && $get_image_url != '') {
         $img = '<a class="preview_image"  href="' . $post_url . '" title="' . $get_image_url . '"><img src="' . $get_image_url . '" alt=""><span class="icon-play-circle hover"></span></a>';
     }
     $output = '<figure class="featured-thumbnail thumbnail video_preview clearfix' . $custom_class . '"><div>' . $img . '<figcaption>' . $output_title . $output_author . $output_date . '</figcaption></div></figure>';
     return $output;
 }