示例#1
0
    function display($post)
    {
        $post_format = et_get_post_format($post->ID);
        if (!$post_format) {
            $post_format = '0';
        }
        ?>
		<div id="post-formats-select">
		<input type="radio" name="et_post_format" class="post-format" id="et-post-format-0" value="0" <?php 
        checked($post_format, '0');
        ?>
 /> <label for="et-post-format-0" class="post-format-icon post-format-standard"><?php 
        echo esc_html(et_get_post_format_string('standard'));
        ?>
</label>
		<?php 
        foreach (et_get_theme_post_format_slugs() as $format) {
            ?>
		<br /><input type="radio" name="et_post_format" class="post-format" id="et-post-format-<?php 
            echo esc_attr($format);
            ?>
" value="<?php 
            echo esc_attr($format);
            ?>
" <?php 
            checked($post_format, $format);
            ?>
 /> <label for="et-post-format-<?php 
            echo esc_attr($format);
            ?>
" class="post-format-icon post-format-<?php 
            echo esc_attr($format);
            ?>
"><?php 
            echo esc_html(et_get_post_format_string($format));
            ?>
</label>
		<?php 
        }
        ?>
<br />
	</div>
	<?php 
    }
示例#2
0
$type = strtolower(et_get_option('archive_list_style', 'standard'));
?>
<div class="posts-blog-feed-module <?php 
echo esc_attr($type);
?>
 post-module et_pb_extra_module module">
	<div class="paginated_page" <?php 
echo 'masonry' == $type ? 'data-columns' : '';
?>
>
	<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        $post_format = et_get_post_format();
        $post_format_class = !empty($post_format) ? 'et-format-' . $post_format : '';
        ?>
				<article id="post-<?php 
        the_ID();
        ?>
" <?php 
        post_class('hentry ' . $post_format_class);
        ?>
>
					<div class="header">
						<?php 
        $thumb_args = array('size' => 'extra-image-medium', 'img_after' => '<span class="et_pb_extra_overlay"></span>');
        require locate_template('post-top-content.php');
        ?>
					</div>
示例#3
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();
        }
    }
示例#4
0
function et_extra_get_post_thumb($args = array())
{
    $default_args = array('post_id' => 0, 'size' => '', 'height' => 50, 'width' => 50, 'title' => '', 'link_wrapped' => true, 'permalink' => '', 'a_class' => array(), 'img_class' => array(), 'img_style' => '', 'img_after' => '', 'post_format_thumb_fallback' => false, 'fallback' => '', 'thumb_src' => '', 'return' => 'img');
    $args = wp_parse_args($args, $default_args);
    $post_id = $args['post_id'] ? $args['post_id'] : get_the_ID();
    $permalink = !empty($args['permalink']) ? $args['permalink'] : get_the_permalink($post_id);
    $title = !empty($args['title']) ? $args['title'] : get_the_title($post_id);
    $width = (int) apply_filters('et_extra_post_thumbnail_width', $args['width']);
    $height = (int) apply_filters('et_extra_post_thumbnail_height', $args['height']);
    $size = !empty($args['size']) ? $args['size'] : array($width, $height);
    $thumb_src = $args['thumb_src'];
    $img_style = $args['img_style'];
    $thumbnail_id = get_post_thumbnail_id($post_id);
    if (!$thumbnail_id && !$args['thumb_src']) {
        if ($args['post_format_thumb_fallback']) {
            $post_format = et_get_post_format();
            if (in_array($post_format, array('video', 'quote', 'link', 'audio', 'map', 'text'))) {
                $thumb_src = et_get_post_format_thumb($post_format, 'thumb');
            } else {
                $thumb_src = et_get_post_format_thumb('text', 'thumb');
            }
        } else {
            if (!empty($args['fallback'])) {
                return $args['fallback'];
            } else {
                $thumb_src = et_get_post_format_thumb('text', 'icon');
            }
        }
    }
    if ($thumbnail_id) {
        list($thumb_src, $thumb_width, $thumb_height) = wp_get_attachment_image_src($thumbnail_id, $size);
    }
    if ('thumb_src' === $args['return']) {
        return $thumb_src;
    }
    $image_output = sprintf('<img src="%1$s" alt="%2$s"%3$s %4$s/>%5$s', esc_attr($thumb_src), esc_attr($title), !empty($args['img_class']) ? sprintf(' class="%s"', esc_attr(implode(' ', $args['img_class']))) : '', !empty($img_style) ? sprintf(' style="%s"', esc_attr($img_style)) : '', $args['img_after']);
    if ($args['link_wrapped']) {
        $image_output = sprintf('<a href="%1$s" title="%2$s"%3$s%5$s>
				%4$s
			</a>', esc_attr($permalink), esc_attr($title), !empty($args['a_class']) ? sprintf(' class="%s"', esc_attr(implode(' ', $args['a_class']))) : '', $image_output, !empty($img_style) ? sprintf(' style="%s"', esc_attr($img_style)) : '');
    }
    return $image_output;
}
示例#5
0
function et_has_format_content($post_id = 0)
{
    if (empty($post_id)) {
        $post_id = get_the_ID();
    }
    if ('post' === get_post_type($post_id)) {
        switch (et_get_post_format($post_id)) {
            case 'video':
                $meta_key = '_video_format_urls';
                break;
            case 'audio':
                $meta_key = '_audio_format_file_url';
                break;
            case 'quote':
                $meta_key = '_quote_format_quote';
                break;
            case 'gallery':
                $meta_key = '_gallery_format_attachment_ids';
                break;
            case 'link':
                $meta_key = '_link_format_link_url';
                break;
            case 'map':
                $meta_key = '_map_format_lat';
                break;
            default:
                $meta_key = '';
                break;
        }
        if (!empty($meta_key)) {
            $has_format_content_setting = get_post_meta($post_id, $meta_key, true);
        } else {
            $has_format_content_setting = has_post_thumbnail();
        }
        $has_format_content = $has_format_content_setting ? true : false;
    } else {
        $has_format_content = false;
    }
    return apply_filters('et_has_format_content', $has_format_content, $post_id);
}