Exemplo n.º 1
0
                    ?>
		</div><!-- .carousel-items -->
	</div><!-- .gallery-format.et-slider -->
	<?php 
                    echo $score_bar;
                    ?>
	<?php 
                }
            } else {
                if (et_has_post_format('video')) {
                    $video_urls = get_post_meta(get_the_ID(), '_video_format_urls', true);
                    if (!empty($video_urls)) {
                        ?>
	<div class="video-format">
		<?php 
                        $video_embed = extra_get_video_embed($video_urls);
                        if ($video_embed) {
                            echo $video_embed;
                            if (has_post_thumbnail()) {
                                $thumbnail_id = get_post_thumbnail_id();
                                $thumbnail_src = wp_get_attachment_image_src($thumbnail_id, extra_get_column_thumbnail_size());
                                if (isset($thumbnail_src[0])) {
                                    ?>
				<div class="video-overlay" style="background-image: url(<?php 
                                    echo esc_attr(esc_url($thumbnail_src[0]));
                                    ?>
);">
					<div class="video-overlay-hover">
						<a href="#" class="video-play-button"></a>
					</div>
				</div>
Exemplo n.º 2
0
    function widget($args, $instance)
    {
        $cache = array();
        if (!$this->is_preview()) {
            $cache = wp_cache_get('widget_recent_videos', 'extra');
        }
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = !empty($instance['title']) ? $instance['title'] : __('Recent Videos', 'extra');
        /** This filter is documented in wp-includes/default-widgets.php */
        $title = apply_filters('widget_title', $title, $instance, $this->id_base);
        $number = !empty($instance['number']) ? absint($instance['number']) : 5;
        if (!$number) {
            $number = 5;
        }
        $recent_video_posts = new WP_Query(apply_filters('widget_recent_videos_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'tax_query' => array(array('taxonomy' => ET_POST_FORMAT, 'field' => 'slug', 'terms' => ET_POST_FORMAT_PREFIX . 'video')))));
        if ($recent_video_posts->have_posts()) {
            ?>
		<?php 
            echo $before_widget;
            ?>
		<?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>
		<div class="widget_video_wrapper">
			<img src="<?php 
            echo esc_url(get_template_directory_uri());
            ?>
/images/pagination-loading.gif" alt="<?php 
            _e('Loading...', 'extra');
            ?>
" class="widget_video_loading">
		</div><!-- .widget_video_wrapper -->
		<div class="widget_content">
			<?php 
            while ($recent_video_posts->have_posts()) {
                $recent_video_posts->the_post();
                ?>
				<script type="text/template" class="widget-video-item widget-video-item-<?php 
                echo esc_attr(get_the_ID());
                ?>
">
					<?php 
                $video_urls = get_post_meta(get_the_ID(), '_video_format_urls', true);
                if (!empty($video_urls)) {
                    $video_embed = extra_get_video_embed($video_urls);
                    echo $video_embed;
                    // Display cover image
                    if (has_post_thumbnail() && $video_embed) {
                        $thumbnail_id = get_post_thumbnail_id();
                        $thumbnail_src = wp_get_attachment_image_src($thumbnail_id, extra_get_column_thumbnail_size());
                        if (isset($thumbnail_src[0])) {
                            ?>
							<div class="video-overlay" style="background-image: url(<?php 
                            esc_attr_e($thumbnail_src[0]);
                            ?>
);">
								<div class="video-overlay-hover">
									<a href="#" class="video-play-button"></a>
								</div>
							</div>
							<?php 
                        }
                    }
                }
                ?>
				</script><!-- .widget-video-item -->
			<?php 
            }
            ?>
			<script type="text/template" class="widget-video-item widget-video-item-empty">
				<h4 class="no-video-title"><?php 
            _e('No Video Found');
            ?>
</h4>
			</script>
		</div><!-- .widget_content -->
		<?php 
            $recent_video_posts->rewind_posts();
            ?>
		<ul class="widget_list">
		<?php 
            while ($recent_video_posts->have_posts()) {
                $recent_video_posts->the_post();
                ?>
			<li>
				<?php 
                $color = extra_get_post_category_color();
                $post_format = et_get_post_format();
                ?>
					<a href="<?php 
                the_permalink();
                ?>
" data-video-id="<?php 
                echo esc_attr(get_the_ID());
                ?>
" class="title"><?php 
                get_the_title() ? the_title() : the_ID();
                ?>
</a>
			</li>
		<?php 
            }
            ?>
		<?php 
            wp_reset_postdata();
            ?>
		</ul>
		<?php 
            echo $after_widget;
            ?>
		<?php 
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        if (!$this->is_preview()) {
            $cache[$args['widget_id']] = ob_get_flush();
            wp_cache_set('et_widget_recent_videos', $cache, 'extra');
        } else {
            ob_end_flush();
        }
    }