예제 #1
0
파일: theme-likes.php 프로젝트: phupx/genco
function checkHeaders()
{
    if (isset($_POST["likepost"])) {
        hb_like_this($_POST["likepost"], 'update');
    }
    //if
}
예제 #2
0
    function widget($args, $instance)
    {
        extract($args);
        global $wp_query;
        /* Our variables from the widget settings. */
        $title = apply_filters('widget_title', $instance['title']);
        $number = $instance['number'];
        $category = $instance['category'];
        /* Before widget (defined by themes). */
        echo $before_widget;
        /* Display the widget title if one was input (before and after defined by themes). */
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        if (!$number) {
            $number = -1;
        }
        $blog_posts = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $number, 'category__in' => $category, 'meta_key' => '_likes', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => true));
        if ($blog_posts->have_posts()) {
            ?>
		<ul class="most-liked-list">
			<?php 
            while ($blog_posts->have_posts()) {
                $blog_posts->the_post();
                $post_author = get_the_author_link();
                $post_date = get_the_date();
                $likes = hb_like_this(get_the_ID());
                ?>
				<li>
					<a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a>
					<span><?php 
                printf(__('By %1$s on %2$s', 'hbthemes'), $post_author, $post_date);
                ?>
</span>
					<span class="like-count"><i class="hb-moon-heart"></i></span>
					<a href="<?php 
                the_permalink();
                ?>
" class="like-count-num"><?php 
                echo number_format($likes);
                ?>
</a>
				</li>
			<?php 
            }
            ?>
		</ul>
		<?php 
        }
        echo $after_widget;
    }
예제 #3
0
 function widget($args, $instance)
 {
     extract($args);
     global $wp_query;
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', $instance['title']);
     $number = $instance['number'];
     $category = $instance['category'];
     $column_class = 'columns-3';
     /* Before widget (defined by themes). */
     echo $before_widget;
     /* Display the widget title if one was input (before and after defined by themes). */
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     if (!$number) {
         $number = -1;
     }
     $unique_id = "unique_id_" . rand(1, 50000);
     if ($category) {
         $portfolio_items = new WP_Query(array('post_type' => 'portfolio', 'meta_key' => '_likes', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'posts_per_page' => $number, 'tax_query' => array(array('taxonomy' => 'portfolio_categories', 'field' => 'id', 'terms' => $category))));
     } else {
         $portfolio_items = new WP_Query(array('post_type' => 'portfolio', 'meta_key' => '_likes', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'posts_per_page' => $number));
     }
     if (!$number) {
         $number = 1;
     }
     if ($number == 1) {
         $column_class = 'columns-1';
     }
     if ($number == 2) {
         $column_class = 'columns-2';
     }
     if ($number == 3 || $number == 6 || $number == 9 || $number == 15 || $number == 18) {
         $column_class = 'columns-3';
     }
     if ($number == 4 || $number == 8 || $number == 12 || $number == 16 || $number == 24) {
         $column_class = 'columns-4';
     }
     echo '<div class="hb-stream ' . $column_class . ' clearfix" id="' . $unique_id . '"><ul>';
     $counter = (int) $number;
     if ($portfolio_items->have_posts()) {
         while ($portfolio_items->have_posts()) {
             $portfolio_items->the_post();
             $perma = get_the_permalink();
             $custom_url = vp_metabox('portfolio_settings.hb_portfolio_custom_url');
             if ($custom_url) {
                 $perma = $custom_url;
             }
             $thumb = get_post_thumbnail_id();
             $image = hb_resize($thumb, '', 250, 250, true);
             $likes = hb_like_this(get_the_ID());
             if ($thumb) {
                 $counter--;
                 if ($counter >= 0) {
                     echo '<li><a href="' . $perma . '" title="' . get_the_title() . '" rel="tooltip">';
                     echo '<img src="' . $image['url'] . '" />';
                     echo '<span class="widget-like-count"><i class="hb-moon-heart"></i>' . number_format($likes) . '</span>';
                     echo '</a></li>';
                 }
             }
         }
     }
     wp_reset_query();
     echo '</ul></div>';
     echo $after_widget;
 }