<div class="portfolio-item"> <span><?php _e('URL:', 'onehost'); ?> </span> <?php echo get_post_meta(get_the_ID(), '_project_url', true); ?> </div> <div class="portfolio-item"> <span><?php _e('Category:', 'onehost'); ?> </span> <?php echo get_the_term_list(get_the_ID(), 'portfolio_category', '', ', ', ''); ?> </div> <?php $size = 'widget-thumb'; $image = onehost_get_image(array('size' => $size, 'format' => 'src', 'meta_key' => 'image', 'echo' => false)); ?> </div><!-- .entry-footer --> </div> <footer class="entry-footer portfolio-footer"> <?php onehost_post_nav(); ?> </footer> </article><!-- #post-## -->
/** * Testimonial shortcode * * @param array $atts * @param string $content * * @return string */ function testimonial($atts, $content) { $atts = shortcode_atts(array('style' => 'short', 'slider' => '', 'number' => 'all', 'single' => '', 'speed' => '700', 'navigation' => '', 'pagination' => '', 'class_name' => '', 'autoplay' => '', 'animation' => '', 'duration' => '', 'delay' => ''), $atts); $size = 'widget-thumb'; $item_class = ''; $data_animation = ''; $css_class = array(); $css_class[] = 'testimonial-list'; $id = ''; if ($atts['slider']) { $speed = intval($atts['speed']); $id = uniqid('testimonial-slider-'); $this->l10n['testimonial'][$id] = array('speed' => $speed, 'navigation' => $atts['navigation'] ? $atts['navigation'] : 'false', 'pagination' => $atts['pagination'] ? $atts['pagination'] : 'false', 'single' => $atts['single'] ? $atts['single'] : 'false', 'autoplay' => $atts['autoplay'] ? $atts['autoplay'] : 'false'); $id = 'id="' . $id . '"'; } else { if ($atts['style'] == 'full') { $size = 'testimonial-thumb'; $item_class = 'col-sm-6 col-md-6'; $css_class[] = 'row'; } elseif ($atts['style'] == 'medium') { $item_class = 'col-sm-4 col-md-4'; $css_class[] = 'row'; } } if ($atts['animation']) { $css_class[] = 'wow'; $css_class[] = esc_attr($atts['animation']); if ($atts['duration']) { $data_animation .= ' data-wow-duration="' . esc_attr($atts['duration']) . 'ms"'; } if ($atts['delay']) { $data_animation .= ' data-wow-delay="' . esc_attr($atts['delay']) . 'ms"'; } } $css_class[] = isset($atts['class_name']) ? esc_attr($atts['class_name']) : ''; $css_class[] = 'testimonial-' . esc_attr($atts['style']); $number = -1; if (strtolower($atts['number']) != 'all') { $number = intval($atts['number']); } $index = 0; $output = array(); $args = array('post_type' => 'testimonial', 'posts_per_page' => $number); $the_query = new WP_Query($args); while ($the_query->have_posts()) { $the_query->the_post(); $args = array('size' => $size, 'echo' => false, 'format' => 'src'); $image_src = onehost_get_image($args); $cats = wp_get_post_terms(get_the_ID(), 'testimonial_category'); $cat_name = $cats ? $cats[0]->name : ''; if (!$atts['slider']) { if ($atts['style'] == 'full') { if ($index % 2 == 0 && $index != 0) { $output[] = '<div class="clearfix"></div>'; } $index++; } elseif ($atts['style'] == 'medium') { if ($index % 3 == 0 && $index != 0) { $output[] = '<div class="clearfix"></div>'; } $index++; } } $output[] = sprintf('<div class="testi-item %s">', $item_class); $star = onehost_get_meta('star'); if ($star && $star != '0') { $output[] = '<div class="testi-star">'; $star = explode('.', $star); $num = intval($star[0]); if ($num) { if ($num > 0) { for ($i = 0; $i < $num; $i++) { $output[] = '<i class="fa fa-star fa-md"></i>'; } } } if (isset($star[1])) { $output[] = '<i class="fa fa-star-half-empty fa-md"></i>'; } else { $num = 5 - $num; if ($num > 0) { for ($i = 0; $i < $num; $i++) { $output[] = '<i class="fa fa-star-o fa-md"></i>'; } } } $output[] = '</div>'; } $output[] = sprintf('<div class="testi-desc">%s</div>', get_the_excerpt()); $output[] = sprintf('<div class="testi-author"><img src="%s" alt="%s" class="testi-pic"><div class="testi-company"><strong>%s</strong><span>, %s</span></div></div>', esc_url($image_src), the_title_attribute('echo=0'), get_the_title(), $cat_name); $output[] = '</div>'; } wp_reset_postdata(); return sprintf('<div %s class="%s" %s>%s</div>', $id, implode(' ', $css_class), $data_animation, implode('', $output)); }
/** * 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 . $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 = onehost_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()), esc_attr(the_title_attribute('echo=0')), esc_url($src), esc_attr(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 onehost_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") . ' ' . get_the_time("M") . ' ' . get_the_time("Y") . '</time>'; } if ($instance['comments']) { $comments_count = wp_count_comments(get_the_ID()); echo '<span class="post-comments">' . sprintf(__('%s Comments', 'onehost'), intval($comments_count->total_comments)) . '</span>'; } if ($instance['readmore']) { echo '<a class="read-more" href="' . get_the_permalink() . '" title="' . get_the_title() . '" rel="bookmark">' . $instance['more_text'] . '</a>'; } ?> </div> </article> <?php } wp_reset_postdata(); echo $after_widget; }
/** * Show entry thumbnail base on its format * * @since 1.0 */ function onehost_entry_thumbnail($size = 'blog-thumb') { $html = ''; $css_class = ''; if ('full-content' == onehost_get_layout()) { $size = 'blog-full-thumb'; } $size = apply_filters('onehost_post_format_thumbnail_size', $size); switch (get_post_format()) { case 'image': $image = onehost_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>', get_permalink(), the_title_attribute('echo=0'), $image); break; case 'gallery': $images = onehost_get_meta('images', "type=image&size={$size}"); if (empty($images)) { break; } $gallery = array(); foreach ($images as $image) { $gallery[] = '<div class="entry-item">' . '<img src="' . $image['url'] . '" alt="' . the_title_attribute('echo=0') . '">' . '</div>'; } $html .= '<div class="flexslider entry-image"><div class="slides">' . implode('', $gallery) . '</div></div>'; break; case 'audio': $thumb = get_the_post_thumbnail(get_the_ID(), $size); if (!empty($thumb)) { $html .= '<a class="entry-image" href="' . get_permalink() . '">' . $thumb . '</a>'; } $audio = onehost_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': if (!empty($thumb)) { $html .= '<a class="entry-image" href="' . get_permalink() . '">' . $thumb . '</a>'; } $video = onehost_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'] = onehost_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="' . get_permalink() . '">' . $thumb . '</a>'; } $link = onehost_get_meta('url'); $text = onehost_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 = onehost_get_meta('quote'); $author = onehost_get_meta('quote_author'); $author_url = onehost_get_meta('author_url'); if (!$quote) { break; } $html .= sprintf('<blockquote>%s<cite>%s</cite></blockquote>', esc_html($quote), empty($author_url) ? $author : "<a href='{$author_url}'> - {$author}</a>"); break; default: $thumb = onehost_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>"; } }
/** * 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 = onehost_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>', get_permalink(), the_title_attribute('echo=0'), $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', 'onehost'), 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(get_option('date_format')) . '</time>'; } if ($instance['popular_comments']) { echo '<span class="post-comments">' . sprintf(__('%s Comments', 'onehost'), 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', 'onehost'), $comment->comment_author, __('on', 'onehost'), 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; }