function widget($args, $instance)
 {
     global $comments, $comment;
     $cache = wp_cache_get('widget_recent_comments', 'widget');
     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;
     }
     extract($args, EXTR_SKIP);
     $output = '';
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = !empty($instance['number']) ? absint($instance['number']) : 5;
     if (!$number) {
         $number = 5;
     }
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     $output .= $before_widget;
     if ($title) {
         $output .= $before_title . $title . $after_title;
     }
     $output .= '<ul id="recentcomments" class="bw-sidebar-posts">';
     if ($comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             if (Bw::get_option('enable_lazy_image')) {
                 $bw_image = "<img class='lazy' data-src='" . get_avatar_url($comment->user_id) . "' src='" . Bw::empty_img() . "' alt='' >";
             } else {
                 $bw_image = "<img src='" . get_avatar_url($comment->user_id) . "' alt='' >";
             }
             $output .= '<li class="recentcomments">';
             $output .= '<div class="thumb"><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . $bw_image . '</a></div>';
             $output .= '<div class="cont"><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_comment_author_link() . '</a>';
             $output .= '<p>' . Bw::truncate($comment->comment_content, 7) . '</p></div>';
             $output .= '</li>';
         }
     }
     $output .= '</ul>';
     $output .= $after_widget;
     echo $output;
     $cache[$args['widget_id']] = $output;
     wp_cache_set('widget_recent_comments', $cache, 'widget');
 }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', BW_THEME) : $instance['title'], $instance, $this->id_base);
        if (empty($instance['number']) || !($number = absint($instance['number']))) {
            $number = 10;
        }
        $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true)));
        if ($r->have_posts()) {
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>
			<ul class="bw-sidebar-posts">
				<?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>
				
				<li class="<?php 
                if (!has_post_thumbnail()) {
                    echo 'auto';
                }
                ?>
">
					
					<?php 
                if (has_post_thumbnail()) {
                    ?>
					<div class="thumb">
						<a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
">
							
							<?php 
                    if (Bw::get_option('enable_lazy_image')) {
                        ?>
								<img class="lazy" data-src="<?php 
                        echo Bw::get_image_src('thumbnail');
                        ?>
" src="<?php 
                        echo Bw::empty_img();
                        ?>
" alt="" >
							<?php 
                    } else {
                        ?>
								<img src="<?php 
                        echo Bw::get_image_src('thumbnail');
                        ?>
" alt="" >
							<?php 
                    }
                    ?>
							
						</a>
					</div>
					<?php 
                }
                ?>
					
					<div class="cont <?php 
                if (!has_post_thumbnail()) {
                    echo ' no-thumb';
                }
                ?>
">
						<a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
">
							<?php 
                the_title();
                ?>
						</a>
						<p><?php 
                echo Bw::truncate(get_the_excerpt(), 6);
                ?>
</p>
					</div>
					
				</li>
				<?php 
            }
            ?>
			</ul>
			 
			<?php 
            echo $after_widget;
            wp_reset_postdata();
        }
    }
Пример #3
0
			<div class="article-date">
				<?php 
        $grid_date = get_the_date();
        ?>
				<?php 
        $grid_category = get_the_category_list(', ');
        ?>
				<?php 
        $grid_separator = (!empty($grid_date) and !empty($grid_category)) ? ' / ' : '';
        ?>
				<?php 
        echo "{$grid_date}{$grid_separator}{$grid_category}";
        ?>
			</div>
			<?php 
        echo Bw::truncate(get_the_excerpt(), 10);
        ?>
		</div>
	</article>
	<?php 
        $content_right .= ob_get_contents();
        ob_end_clean();
    }
    $c++;
}
wp_reset_postdata();
?>

<div class="papa-grid bw-over">
	
	<article class="part left-part">
    public function query_by_id($time, $instance)
    {
        global $wpdb;
        global $post;
        $limit = (int) $instance['max_posts'] > 0 && (int) $instance['max_posts'] <= 10 ? (int) $instance['max_posts'] : 5;
        //$categories = unserialize( $instance['category'] );
        //$joined_categories = is_array( $categories ) ? join( ',', $categories ) : null;
        if ($time !== 'bw-all-time' && $time > 0) {
            $joins = "\r\n\t\t\t\tLEFT JOIN {$wpdb->term_relationships} ON({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)\r\n\t\t\t\tLEFT JOIN {$wpdb->term_taxonomy} ON({$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id)\r\n\t\t\t\tLEFT JOIN {$wpdb->terms} ON({$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id)\r\n\t\t\t";
            $where = "\r\n\t\t\t\tAND {$wpdb->term_taxonomy}.taxonomy = 'category'\r\n\t\t\t\tAND {$wpdb->terms}.term_id  = '" . $time . "'\r\n\t\t\t";
        } else {
            $joins = '';
            $where = '';
        }
        $querystr = "\r\n\t\t\t\r\n\t\t\tSELECT *, CAST({$wpdb->posts}.post_date AS DATE) as bw_date\r\n\t\t\tFROM {$wpdb->posts}\r\n\t\t\tLEFT JOIN {$wpdb->postmeta} ON({$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)\r\n\t\t\t\t\r\n\t\t\t\t" . $joins . "\r\n\t\t\t\r\n\t\t\tWHERE {$wpdb->postmeta}.meta_key = 'post_views_count'\r\n\t\t\tAND {$wpdb->posts}.post_status = 'publish'\r\n\t\t\tAND {$wpdb->posts}.post_date < NOW()\r\n\t\t\tAND {$wpdb->posts}.post_type = 'post'\r\n\t\t\t\t\r\n\t\t\t\t" . $where . "\r\n\t\t\t\r\n\t\t\tORDER BY bw_date desc, {$wpdb->postmeta}.meta_value+0 desc\r\n\t\t\t\r\n\t\t\tLIMIT " . $limit . "\r\n\t\t\t\r\n\t\t";
        $pageposts = $wpdb->get_results($querystr, object);
        $c = 1;
        echo '<ul class="bw-sidebar-posts ' . trim($time) . '">';
        foreach ($pageposts as $post) {
            setup_postdata($post);
            ?>
<li>
				
				<!--div class="position">
					<?php 
            echo sprintf("%02d", $c);
            ?>
				</div-->
				
				<?php 
            if (has_post_thumbnail()) {
                ?>
				<div class="thumb">
					<a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
">
						
						<?php 
                if (Bw::get_option('enable_lazy_image')) {
                    ?>
							<img class="lazy" data-src="<?php 
                    echo Bw::get_image_src('thumbnail');
                    ?>
" src="<?php 
                    echo Bw::empty_img();
                    ?>
" alt="" >
						<?php 
                } else {
                    ?>
							<img src="<?php 
                    echo Bw::get_image_src('thumbnail');
                    ?>
" alt="" >
						<?php 
                }
                ?>
						
					</a>
				</div>
				<?php 
            }
            ?>
				
				<div class="cont <?php 
            if (!has_post_thumbnail()) {
                echo ' no-thumb';
            }
            ?>
">
					<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
">
						<?php 
            the_title();
            ?>
					</a>
					<p><?php 
            echo Bw::truncate(get_the_excerpt(), 7);
            ?>
</p>
				</div>
				
			</li><?php 
            $c++;
        }
        wp_reset_postdata();
        echo '</ul>';
    }
Пример #5
0
    $author_id = get_the_author_meta('ID');
    ?>
	<div class="post-author">
		<div class="thumb">
			<?php 
    echo get_avatar($author_id, 120);
    ?>
 
		</div>
		<div class="cont">
			<h4><?php 
    the_author_posts_link();
    ?>
</h4>
			<p><?php 
    echo Bw::truncate(get_the_author_meta('description'));
    ?>
</p>
			
			<ul class="author-list">
			<?php 
    $author_list = array('url', 'facebook', 'twitter', 'google_plus');
    foreach ($author_list as $author_item) {
        if (get_the_author_meta($author_item, $author_id)) {
            echo '<li><a href="' . get_the_author_meta($author_item, $author_id) . '" target="_blank">' . __(Bw::humanize($author_item == 'url' ? 'Website' : $author_item), BW_THEME) . '</a></li>';
        }
    }
    ?>
			</ul>
			
		</div>