/** * Posts carousel shortcode * * @param array $atts * @param string $content * * @return string */ function posts_carousel($atts, $content) { $atts = shortcode_atts(array('title' => '', 'total' => '12', 'categories' => '', 'order_by' => '', 'order' => '', 'excerpt_length' => '', 'hide_read_more' => '', 'read_more_text' => __('Read More', 'bigboom'), 'number' => '3', 'auto_play' => '', 'hide_navigation' => '', 'class_name' => ''), $atts); $output = array(); $number = intval($atts['number']); $number = $number ? $number : '4'; $id = uniqid('posts-carousel-'); $this->l10n['postsCarousel'][$id] = array('number' => $number, 'autoplay' => $atts['auto_play'] ? $atts['auto_play'] : 'false', 'navigation' => $atts['hide_navigation'] ? $atts['hide_navigation'] : 'true'); $query_args = array('orderby' => $atts['order_by'], 'order' => $atts['order'], 'posts_per_page' => $atts['total'], 'post_type' => 'post', 'ignore_sticky_posts' => true); if (!empty($atts['categories'])) { $query_args['category__in'] = $atts['categories']; } $query = new WP_Query($query_args); while ($query->have_posts()) { $query->the_post(); $src = bigboom_get_image(array('size' => 'blog-thumb-tiny', 'format' => 'src', 'echo' => false)); $class_thumb = 'no-thumb'; $article = array(); if ($src) { $class_thumb = ''; $article[] = sprintf('<a class="post-thumb" href="%s" title="%s"><img src="%s" alt="%s"></a>', esc_url(get_permalink()), the_title_attribute('echo=0'), esc_url($src), the_title_attribute('echo=0')); } $article[] = sprintf('<div class="post-text"><a class="post-title" href="%s" title="%s" rel="bookmark">%s</a>', esc_url(get_permalink()), the_title_attribute('echo=0'), get_the_title()); $article[] = bigboom_content_limit(get_the_excerpt(), intval($atts['excerpt_length']), '', false); if (!$atts['hide_read_more']) { $article[] = sprintf('<a class="read-more" href="%s" title="%s" rel="bookmark">%s<i class="fa fa-arrow-circle-right"></i></a>', esc_url(get_permalink()), the_title_attribute('echo=0'), $atts['read_more_text']); } $output[] = sprintf('<div class="bb-post %s">%s</div></div>', esc_attr($class_thumb), implode('', $article)); } wp_reset_postdata(); $heading = ''; if ($atts['title']) { $heading = sprintf('<h2 class="section-heading">%s</h2>', $atts['title']); } else { $atts['class_name'] .= ' no-title'; } if ($atts['hide_navigation']) { $atts['class_name'] .= ' no-owl-controls'; } return sprintf('<div id="%s" class="bb-posts-owl-carousel %s">%s<div class="bb-owl-list">%s</div></div>', esc_attr($id), esc_attr($atts['class_name']), $heading, implode('', $output)); }
/** * Show entry thumbnail base on its format * * @since 1.0 */ function bigboom_entry_thumbnail($size = 'blog-thumb') { $html = ''; $css_class = ''; if ('full-content' == bigboom_get_layout()) { $size = 'blog-large-thumb'; } $size = apply_filters('bigboom_post_format_thumbnail_size', $size); switch (get_post_format()) { case 'image': $image = bigboom_get_image(array('size' => $size, 'format' => 'src', 'meta_key' => 'image', 'echo' => false)); if (!$image) { break; } $html = sprintf('<a class="entry-image" href="%1$s" title="%2$s"><img src="%3$s" alt="%2$s"></a>', esc_url(get_permalink()), the_title_attribute('echo=0'), esc_url($image)); break; case 'gallery': $images = bigboom_get_meta('images', "type=image&size={$size}"); if (empty($images)) { break; } $gallery = array(); foreach ($images as $image) { $gallery[] = '<li>' . '<img src="' . esc_url($image['url']) . '" alt="' . the_title_attribute('echo=0') . '">' . '</li>'; } $html .= '<div class="flexslider entry-image"><ul class="slides">' . implode('', $gallery) . '</ul></div>'; break; case 'audio': $audio = bigboom_get_meta('audio'); if (!$audio) { break; } // If URL: show oEmbed HTML or jPlayer if (filter_var($audio, FILTER_VALIDATE_URL)) { // Try oEmbed first if ($oembed = @wp_oembed_get($audio)) { $html .= $oembed; } else { $html .= '<div class="audio-player">' . wp_audio_shortcode(array('src' => $audio)) . '</div>'; } } else { $html .= $audio; } break; case 'video': $video = bigboom_get_meta('video'); if (!$video) { break; } // If URL: show oEmbed HTML if (filter_var($video, FILTER_VALIDATE_URL)) { if ($oembed = @wp_oembed_get($video)) { $html .= $oembed; } else { $atts = array('src' => $video, 'width' => 848); if (has_post_thumbnail()) { $atts['poster'] = bigboom_get_image('format=src&echo=0&size=full'); } $html .= wp_video_shortcode($atts); } } else { $html .= $video; } break; case 'link': if (!empty($thumb)) { $html .= '<a class="entry-image" href="' . esc_url(get_permalink()) . '">' . $thumb . '</a>'; } $link = bigboom_get_meta('url'); $text = bigboom_get_meta('url_text'); if (!$link) { break; } $html .= sprintf('<a href="%s" class="link-block">%s</a>', esc_url($link), $text ? $text : $link); break; case 'quote': if (!empty($thumb)) { $html .= '<a class="entry-image" href="' . get_permalink() . '">' . $thumb . '</a>'; } $quote = bigboom_get_meta('quote'); $author = bigboom_get_meta('quote_author'); $author_url = bigboom_get_meta('author_url'); if (!$quote) { break; } $html .= sprintf('<blockquote>%s<cite>%s</cite></blockquote>', esc_html($quote), empty($author_url) ? $author : '<a href="' . esc_url($author_url) . '"> - ' . $author . '</a>'); break; default: $thumb = bigboom_get_image(array('size' => $size, 'meta_key' => 'image', 'echo' => false)); if (empty($thumb)) { break; } $html .= '<a class="entry-image" href="' . get_permalink() . '">' . $thumb . '</a>'; break; } if ($html = apply_filters(__FUNCTION__, $html, get_post_format())) { echo "<div class='entry-format'>{$html}</div>"; } }
/** * Display widget * * @param array $args Sidebar configuration * @param array $instance Widget settings * * @return void */ function widget($args, $instance) { $instance = wp_parse_args($instance, $this->defaults); extract($args); $query_args = array('posts_per_page' => $instance['limit'], 'post_type' => 'post', 'ignore_sticky_posts' => true); if (!empty($instance['cat']) && is_array($instance['cat'])) { $query_args['category__in'] = $instance['cat']; } $query = new WP_Query($query_args); if (!$query->have_posts()) { return; } echo $before_widget; if ($title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base)) { echo $before_title . esc_html($title) . $after_title; } $class = $instance['thumb'] ? '' : 'no-thumbnail'; $class .= $instance['thumb_left'] ? 'thumb-left' : ''; while ($query->have_posts()) { $query->the_post(); ?> <article class="recent-post <?php echo esc_attr($class); ?> "> <?php if ($instance['thumb']) { $src = bigboom_get_image(array('size' => $instance['thumb_size'], 'format' => 'src', 'echo' => false)); if ($src) { printf('<a class="widget-thumb" href="%s" title="%s"><img src="%s" alt="%s"></a>', esc_url(get_permalink()), the_title_attribute('echo=0'), esc_url($src), the_title_attribute('echo=0')); } } ?> <div class="post-text"> <a class="post-title" href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?> " rel="bookmark"><?php the_title(); ?> </a> <?php if ($instance['excerpt']) { echo bigboom_content_limit(get_the_excerpt(), intval($instance['limit']), ''); } if ($instance['date']) { echo '<time class="post-date" datetime="' . esc_attr(get_the_time('c')) . '">' . get_the_time("d F Y") . '</time>'; } if ($instance['comments']) { $comments_count = wp_count_comments(get_the_ID()); echo '<span class="post-comments">' . sprintf(__('%s Comments', 'bigboom'), intval($comments_count->total_comments)) . '</span>'; } if ($instance['readmore']) { echo '<a class="read-more" href="' . esc_url(get_permalink()) . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">' . $instance['more_text'] . '</a>'; } ?> </div> </article> <?php } wp_reset_postdata(); echo $after_widget; }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments * @param array $instance Saved values from database * * @return void */ function widget($args, $instance) { $instance = wp_parse_args($instance, $this->defaults); extract($args); echo $before_widget; echo '<div class="tabs">'; echo '<ul class="tabs-nav">'; if ($instance['popular_show']) { echo '<li><a href="#" class="active">' . $instance['popular_title'] . '</a></li>'; } if ($instance['recent_show']) { echo '<li><a href="#">' . $instance['recent_title'] . '</a></li>'; } if ($instance['comments_show']) { echo '<li><a href="#">' . $instance['comments_title'] . '</a></li>'; } echo '</ul>'; ?> <?php if ($instance['popular_show']) { ?> <?php $class = $instance['popular_thumb'] ? '' : 'no-thumbnail'; $class .= $instance['popular_thumb_left'] ? 'thumb-left' : ''; ?> <div class="tab-popular-posts tabs-panel active"> <?php $popular_posts = new WP_Query(array('posts_per_page' => $instance['popular_limit'], 'orderby' => 'comment_count', 'order' => 'DESC')); while ($popular_posts->have_posts()) { $popular_posts->the_post(); ?> <article class="popular-post <?php echo esc_attr($class); ?> "> <?php if ($instance['popular_thumb']) { $src = bigboom_get_image(array('size' => $instance['popular_thumb_size'], 'format' => 'src', 'echo' => false)); if ($src) { printf('<a class="widget-thumb" href="%s" title="%s"><img src="%s" alt="%s"></a>', esc_url(get_permalink()), the_title_attribute('echo=0'), esc_url($src), the_title_attribute('echo=0')); } } ?> <div class="post-text"> <a class="post-title" href="<?php the_permalink(); ?> " title="<?php printf(esc_attr__('Permalink to %s', 'bigboom'), the_title_attribute('echo=0')); ?> " rel="bookmark"><?php the_title(); ?> </a> <?php if ($instance['popular_date']) { echo '<time class="post-date" datetime="' . esc_attr(get_the_time('c')) . '">' . get_the_time('d F Y') . '</time>'; } if ($instance['popular_comments']) { echo '<span class="post-comments">' . sprintf(__('%s Comments', 'bigboom'), get_comments_number()) . '</span>'; } ?> </div> </article> <?php } wp_reset_postdata(); ?> </div> <?php } ?> <?php if ($instance['recent_show']) { ?> <?php $class_recent = $instance['recent_thumb_left'] ? 'thumb-left' : ''; ?> <div class="tab-recent-posts tabs-panel <?php echo esc_attr($class_recent); ?> "> <?php the_widget('TA_Recent_Posts_Widget', array('limit' => $instance['recent_limit'], 'thumb' => $instance['recent_thumb'], 'thumb_left' => $instance['recent_thumb_left'], 'thumb_size' => $instance['recent_thumb_size'], 'date' => $instance['recent_date'], 'comments' => $instance['recent_comments'], 'readmore' => 0), array('before_widget' => '', 'after_widget' => '')); ?> </div> <?php } ?> <?php if ($instance['comments_show']) { echo '<div class="tab-comments tabs-panel">'; $comments = get_comments(array('status' => 'approve', 'number' => $instance['comments_limit'])); foreach ($comments as $comment) { echo sprintf('<div class="comment"> <p class="comment-summary">%s <span class="author-comment">%s %s</span></p> <span class="post-comment">%s <a href="%s" title="%s">%s</a></span> </div>', wp_trim_words(strip_tags($comment->comment_content), 10), __('by', 'bigboom'), $comment->comment_author, __('on', 'bigboom'), get_comments_link($comment->comment_post_ID), get_the_title($comment->comment_post_ID), wp_trim_words(strip_tags(get_the_title($comment->comment_post_ID)), 7)); } echo '</div>'; } echo '</div>'; echo $after_widget; }