function vl_featured_post_image()
{
    $post_video = get_the_post_video_url($post_id);
    // $post_video = https://vimeo.com/example
    if (strpos($post_video, 'vimeo.com') !== FALSE) {
        $x = explode('/', $post_video);
        // $x = ['https:', 'vimeo.com', 'example']
        $video_id = array_pop($x);
        // $video_id = 'example'
        $player_url = '//player.vimeo.com/video/' . $video_id . '?autoplay=1&color=FFF';
        // $player_url = '//player.vimeo.com/video/example'
    }
    echo '<div class="entry">';
    echo '<a class="video-thumbnail" href="';
    echo $player_url;
    echo '" data-featherlight="iframe">';
    echo '<div class="entry-thumbnail">';
    the_post_thumbnail('large');
    //you can use medium, large or a custom size
    echo '<div class="play-button"></div>';
    echo '</div>';
    echo '</a>';
    // echo get_the_post_video( $post_id );
    // echo '<iframe class="lightbox" src="' . get_the_post_video_url( $post_id ) . '" id="';
    // echo get_the_ID();
    // echo '" style="border:none;" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>';
    // echo '</div>';
}
示例#2
0
 /**
  * Callback function of the metabox; generates the HTML content.
  *
  * @since 1.0.0
  */
 public function metabox_content()
 {
     wp_nonce_field(FVP_NAME . FVP_VERSION, 'fvp_nonce');
     // Get current post's id.
     $post_id = isset($_GET['post']) ? $_GET['post'] : $GLOBALS['post']->ID;
     $options = get_option('fvp-settings');
     $meta = get_post_meta($post_id, '_fvp_video', true);
     $has_post_video = has_post_video($post_id);
     $content = '';
     // Current featured video.
     $content .= sprintf('<div class="fvp-current-video"%s>%s</div>', FVP_HTML::inline_styles(array('height: 0px' => !$has_post_video), true, true), get_the_post_video($post_id, array(256, 144)));
     // Input box containing the featured video URL input.
     $full = $has_post_video ? get_the_post_video_url($post_id) : '';
     // Media gallery wrapper.
     $content .= sprintf('<div class="fvp-input-wrapper" data-target=".fvp-video" data-title="%1$s" data-button="%1$s">', esc_attr__('Set Featured Video', 'featured-video-plus'));
     // Video input.
     $content .= sprintf('<textarea class="fvp-video" name="fvp_video" type="text" placeholder="%s">%s</textarea>', esc_attr__('Video URL', 'featured-video-plus'), $full);
     // Media gallery button.
     $content .= sprintf('<a href="#" class="fvp-video-choose">' . '<span class="fvp-media-icon"%s></span>' . '</a>', FVP_HTML::inline_styles(array('background-image' => sprintf('url(%s/wp-admin/images/media-button.png)', get_bloginfo('wpurl'))), true, true));
     // Close media gallery wrapper.
     $content .= '</div>';
     // 'Current theme does not support Featured Images' warning.
     if (!current_theme_supports('post-thumbnails') && 'manual' !== $options['mode']) {
         $content .= '<p class="fvp-warning description">';
         $content .= sprintf('<span style="font-weight: bold;">%s</span>&nbsp;', esc_html__('The current theme does not support Featured Images', 'featured-video-plus'));
         $content .= sprintf(esc_html__('To display Featured Videos you need to use the %1$sShortcode%2$s or %1$sPHP functions%2$s. To hide this notice deactivate %3$sReplace Featured Images%4$s in the %5$sMedia Settings%6$s.', 'featured-video-plus'), '<code>', '</code>', '&quot;<em>', '</em>&quot;', '<a href="' . esc_attr(get_admin_url(null, '/options-media.php')) . '">', '</a>');
         '</p>';
     }
     echo "\n\n\n<!-- Featured Video Plus Metabox -->\n";
     echo $content;
     echo "<!-- Featured Video Plus Metabox End-->\n\n\n";
 }
function ft_featured_header()
{
    $featured_query_args = array('post_type' => 'post', 'meta_key' => '_is_ns_featured_post', 'meta_value' => 'yes');
    $featured = new WP_Query($featured_query_args);
    global $wp_query;
    $temp_query = $wp_query;
    $wp_query = NULL;
    $wp_query = $featured;
    if ($featured->have_posts()) {
        ?>

			<div class="featured-header widget-area">

			  <!-- the loop -->
			  <?php 
        while ($featured->have_posts()) {
            $featured->the_post();
            ?>
					<?php 
            $featured_video = get_the_post_video_url();
            $post_video = $featured_video;
            // $post_video = https://vimeo.com/example
            if (strpos($post_video, 'vimeo.com') !== FALSE) {
                $x = explode('/', $post_video);
                // $x = ['https:', 'vimeo.com', 'example']
                $video_id = array_pop($x);
                // $video_id = 'example'
                $player_url = '//player.vimeo.com/video/' . $video_id . '?autoplay=1&color=FFF';
                // $player_url = '//player.vimeo.com/video/example'
                // echo "Player URL: " . $player_url;
            }
            ?>
					<article <?php 
            post_class();
            ?>
>
						<a class="featured-header-link" data-featherlight="iframe" href="<?php 
            echo $player_url;
            ?>
">
							<div class="play-button"></div>
							<div class="img-wrap">
							<?php 
            echo get_the_post_thumbnail($post, 'large');
            ?>
							</div>
						</a>
						<div class="entry-content">
							<?php 
            the_content();
            ?>
						</div>
					</article>
			  <?php 
        }
        ?>
				<!-- end of the loop -->

			</div>

			<?php 
    } else {
        echo "no content";
    }
    // Reset postdata
    wp_reset_postdata();
    // Reset main query object
    $wp_query = NULL;
    $wp_query = $temp_query;
    // echo 'testingblah' . $featured_video;
    // echo get_metadata('page', 51, 'fvp_video', true);
}