public function widget($args, $instance) { extract($args); $instance['title'] ? NULL : ($instance['title'] = ''); $title = apply_filters('widget_title', $instance['title']); $output = $before_widget . "\n"; if ($title) { $output .= $before_title . $title . $after_title; } ob_start(); /* Set tabs-nav order & output it /* ------------------------------------ */ $titles = array('recent' => $instance['title_latestpost'], 'popular' => $instance['title_hotpost'], 'comments' => $instance['title_comment']); $tabs = array(); $count = 0; $order = array('recent' => $instance['order_recent'], 'popular' => $instance['order_popular'], 'comments' => $instance['order_comments']); asort($order); foreach ($order as $key => $value) { if ($instance[$key . '_enable']) { $tabs[] = $key; $count++; } } if ($tabs && $count > 1) { $output .= $this->_create_tabs($titles, $tabs, $count); } ?> <?php if (ot_get_option('lazy_load_img') == 'on') { $lazy = 'class="box-hide" src="' . THEME_URI . '/images/image-pending.gif" data-original'; } else { $lazy = 'src'; } ?> <div class="tin-tabs-container"> <?php if ($instance['recent_enable']) { // Recent posts enabled? ?> <?php $recent = new WP_Query(); ?> <?php $recent->query('showposts=' . $instance["recent_num"] . '&cat=' . $instance["recent_cat_id"] . '&ignore_sticky_posts=1'); ?> <ul id="tab-recent" class="tin-tab group <?php if ($instance['recent_thumbs']) { echo 'thumbs-enabled'; } else { echo 'no-pic'; } ?> "> <?php while ($recent->have_posts()) { $recent->the_post(); ?> <?php $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); ?> <li> <?php if ($instance['recent_thumbs']) { // Thumbnails enabled? ?> <div class="tab-item-thumbnail"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <?php if (has_post_thumbnail()) { ?> <div class="thumb-img"> <img <?php echo $lazy; ?> ="<?php echo tin_thumb_source($large_image_url[0], 125, 78, false); ?> " alt="<?php the_title(); ?> " /> <span><?php the_article_icon(); ?> </span> </div> <?php } else { ?> <div class="thumb-img"> <img <?php echo $lazy; ?> ="<?php $img = catch_first_image(); echo tin_thumb_source($img, 125, 78, false); ?> " alt="<?php the_title(); ?> " /> <span><?php the_article_icon(); ?> </span> </div> <?php } ?> </a> </div> <?php } ?> <div class="tab-item-inner group"> <p class="tab-item-title"><a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "><?php the_title(); ?> </a></p> <?php if ($instance['tabs_date']) { ?> <span class="tab-item-date"><?php the_time('Y-m-j'); ?> </span><?php } ?> <?php if ($instance['tabs_category']) { ?> <span class="tab-item-category"><?php the_category(' / '); ?> </span><?php } ?> </div> </li> <?php } ?> </ul><!--/.tin-tab--> <?php } ?> <?php if ($instance['popular_enable']) { // Popular posts enabled? ?> <?php $popular = new WP_Query(array('post_type' => array('post'), 'showposts' => $instance['popular_num'], 'cat' => $instance['popular_cat_id'], 'ignore_sticky_posts' => true, 'orderby' => 'comment_count', 'order' => 'dsc', 'date_query' => array(array('after' => $instance['popular_time'])))); ?> <ul id="tab-popular" class="tin-tab group <?php if ($instance['popular_thumbs']) { echo 'thumbs-enabled'; } else { echo 'no-pic'; } ?> "> <?php while ($popular->have_posts()) { $popular->the_post(); ?> <?php $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); ?> <li> <?php if ($instance['popular_thumbs']) { // Thumbnails enabled? ?> <div class="tab-item-thumbnail"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <?php if (has_post_thumbnail()) { ?> <div class="thumb-img"> <img <?php echo $lazy; ?> ="<?php echo tin_thumb_source($large_image_url[0], 125, 78, false); ?> " alt="<?php the_title(); ?> " /> <span><?php the_article_icon(); ?> </span> </div> <?php } else { ?> <div class="thumb-img"> <img <?php echo $lazy; ?> ="<?php $img = catch_first_image(); echo tin_thumb_source($img, 125, 78, false); ?> " alt="<?php the_title(); ?> " /> <span><?php the_article_icon(); ?> </span> </div> <?php } ?> </a> </div> <?php } ?> <div class="tab-item-inner group"> <p class="tab-item-title"><a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "><?php the_title(); ?> </a></p> <?php if ($instance['tabs_date']) { ?> <span class="tab-item-date"><?php the_time('Y-m-j'); ?> </span><?php } ?> <?php if ($instance['tabs_category']) { ?> <span class="tab-item-category"><?php the_category(' / '); ?> </span><?php } ?> </div> </li> <?php } ?> </ul><!--/.tin-tab--> <?php } ?> <?php if ($instance['comments_enable']) { // Recent comments enabled? ?> <?php $args = array('number' => $instance["comments_num"], 'status' => 'approve', 'post_status' => 'publish'); if (isset($instance['comment_order']) && $instance['comment_order'] == 'vote') { $args['orderby'] = 'meta_value_num'; $args['meta_key'] = 'tin_comment_voteyes'; } $comments = get_comments($args); ?> <ul id="tab-comments" class="tin-tab group <?php if ($instance['comments_avatars']) { echo 'avatars-enabled'; } else { echo 'no-avatar'; } ?> "> <?php foreach ($comments as $comment) { ?> <li> <?php if ($instance['comments_avatars']) { // Avatars enabled? ?> <div class="tab-item-avatar"> <?php echo tin_get_avatar($comment->user_id, '96', tin_get_avatar_type($comment->user_id)); ?> </div> <?php } ?> <div class="tab-item-inner group"> <?php $comment_excerpt = preg_replace("'\\[private](.*?)\\[\\/private]'", '***该评论仅父级评论者及管理员可见***', get_comment_excerpt($comment->comment_ID)); $str = explode(' ', $comment_excerpt); $comment_excerpt = implode(' ', array_slice($str, 0, 11)); if (count($str) > 11 && substr($comment_excerpt, -1) != '.') { $comment_excerpt .= '...'; } ?> <div class="tab-item-comment"><span class="arrow-poptop"></span><a href="<?php echo esc_url(get_permalink($comment->comment_post_ID)); ?> "><i><?php echo $comment->comment_author; ?> </i><?php _e('说: ', 'xiapistudio'); echo $comment_excerpt; ?> </a><div class="tab-cmt-votes"><span class="cmt-vote"> <?php $c_name = 'tin_comment_vote_' . $comment->comment_ID; $cookie = isset($_COOKIE[$c_name]) ? $_COOKIE[$c_name] : ''; ?> <i class="fa fa-thumbs-o-up <?php if ($cookie == 1) { echo 'voted'; } ?> " title="<?php _e('顶', 'xiapistudio'); ?> " data="<?php echo $comment->comment_ID; ?> " data-type="1" data-num="<?php echo (int) get_comment_meta($comment->comment_ID, 'tin_comment_voteyes', true); ?> "><?php echo ' [' . (int) get_comment_meta($comment->comment_ID, 'tin_comment_voteyes', true) . ']'; ?> </i> <i class="fa fa-thumbs-o-down <?php if ($cookie == 2) { echo 'voted'; } ?> " title="<?php _e('踩', 'xiapistudio'); ?> " data="<?php echo $comment->comment_ID; ?> " data-type="2" data-num="<?php echo (int) get_comment_meta($comment->comment_ID, 'tin_comment_voteno', true); ?> "><?php echo ' [' . (int) get_comment_meta($comment->comment_ID, 'tin_comment_voteno', true) . ']'; ?> </i> </span></div></div> </div> </li> <?php } ?> </ul><!--/.tin-tab--> <?php } ?> </div> <?php $output .= ob_get_clean(); $output .= $after_widget . "\n"; echo $output; }
?> " title="<?php the_title(); ?> " class=""> <div class="thumb-img"> <img <?php echo $lazy; ?> ="<?php $imgsrc = catch_first_image(); echo tin_thumb_source($imgsrc, 175, 126, false); ?> "> <span><?php the_article_icon(); ?> </span> </div> </a> <?php } ?> </div> <div class="relpost-inner-text"> <a href="<?php the_permalink(); ?> " rel="bookmark" title='Permanent Link to "<?php the_title(); ?>
public function widget($args, $instance) { extract($args); $instance['title'] ? NULL : ($instance['title'] = ''); $title = apply_filters('widget_title', $instance['title']); $output = $before_widget . "\n"; if ($title) { $output .= $before_title . '<span>' . $title . '</span>' . $after_title; } ob_start(); ?> <?php $posts = new WP_Query(array('post_type' => array('post'), 'showposts' => $instance['posts_num'], 'cat' => $instance['posts_cat_id'], 'ignore_sticky_posts' => true, 'orderby' => $instance['posts_orderby'], 'order' => 'dsc', 'date_query' => array(array('after' => $instance['posts_time'])))); ?> <?php if (ot_get_option('lazy_load_img') == 'on') { $lazy = 'class="box-hide" src="' . THEME_URI . '/images/image-pending.gif" data-original'; } else { $lazy = 'src'; } ?> <ul class="tin-postsh group <?php if ($instance['posts_thumb']) { echo 'thumbs-enabled'; } ?> "> <?php while ($posts->have_posts()) { $posts->the_post(); ?> <?php $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); ?> <li> <?php if ($instance['posts_thumb']) { // Thumbnails enabled? ?> <div class="fancyimg"> <div class="post-item-thumbnail"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <?php if (has_post_thumbnail()) { ?> <img <?php echo $lazy; ?> ="<?php $imgsrc = $large_image_url[0]; echo tin_thumb_source($imgsrc, 188, 140, false); ?> " alt="<?php the_title(); ?> " /> <span><?php the_article_icon(); ?> </span> <?php } else { ?> <img <?php echo $lazy; ?> ="<?php $imgsrc = catch_first_image(); echo tin_thumb_source($imgsrc, 188, 140, false); ?> " alt="<?php the_title(); ?> " /> <span><?php the_article_icon(); ?> </span> <?php } ?> </a> </div> </div> <?php } ?> <div class="post-item-inner group"> <p class="post-item-title"><a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "><?php the_title(); ?> </a></p> </div> </li> <?php } ?> </ul> <?php $output .= ob_get_clean(); $output .= $after_widget . "\n"; echo $output; }