コード例 #1
0
 function widget($args, $instance)
 {
     $cache = wp_cache_get('widget_postviews_plus', '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;
     }
     $title = apply_filters('widget_title', esc_attr($instance['title']));
     $template = $instance['template'];
     $type = esc_attr($instance['type']);
     $mode = esc_attr($instance['mode']);
     $withbot = esc_attr($instance['withbot']);
     $thumbnail_width = intval($instance['thumbnail_width']);
     $thumbnail_height = intval($instance['thumbnail_height']);
     $limit = intval($instance['limit']);
     $chars = intval($instance['chars']);
     $cat_ids = $instance['cat_ids'];
     if (!is_array($cat_ids)) {
         $cat_ids = explode(',', $car_ids);
     }
     $tag_ids = explode(',', esc_attr($instance['tag_ids']));
     ob_start();
     echo $args['before_widget'];
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     echo '<ul>' . "\n";
     switch ($type) {
         case 'most_viewed':
             get_most_viewed($mode, $limit, $chars, true, $withbot, $template, $thumbnail_width, $thumbnail_height);
             break;
         case 'most_viewed_category':
             get_most_viewed_category($cat_ids, 'post', $limit, $chars, true, $withbot, $template, $thumbnail_width, $thumbnail_height);
             break;
         case 'most_viewed_tag':
             get_most_viewed_tag($tag_ids, 'post', $limit, $chars, true, $withbot, $template, $thumbnail_width, $thumbnail_height);
             break;
     }
     echo '</ul>' . "\n";
     echo $args['after_widget'];
     $cache[$args['widget_id']] = ob_get_flush();
     wp_cache_set('widget_postviews_plus', $cache, 'widget');
 }
コード例 #2
0
ファイル: wp-postviews.php プロジェクト: NickTaporuk/cd
 function widget($args, $instance)
 {
     $title = apply_filters('widget_title', esc_attr($instance['title']));
     $type = esc_attr($instance['type']);
     $mode = esc_attr($instance['mode']);
     $limit = intval($instance['limit']);
     $chars = intval($instance['chars']);
     $cat_ids = explode(',', esc_attr($instance['cat_ids']));
     echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title'];
     echo '<ul>' . "\n";
     switch ($type) {
         case 'least_viewed':
             get_least_viewed($mode, $limit, $chars);
             break;
         case 'most_viewed':
             get_most_viewed($mode, $limit, $chars);
             break;
         case 'most_viewed_category':
             get_most_viewed_category($cat_ids, $mode, $limit, $chars);
             break;
         case 'least_viewed_category':
             get_least_viewed_category($cat_ids, $mode, $limit, $chars);
             break;
     }
     echo '</ul>' . "\n";
     echo $args['after_widget'];
 }
コード例 #3
0
<footer class="footer grid-12">
                <div class="wrapper">
                    <div class="row links">
                        <div class="grid-3">
                            <span>MAIS VISITADOS</span>
                            <?php 
if (function_exists('get_most_viewed')) {
    ?>
                            <ul>
                                <li class="POSTS">
                                    <?php 
    get_most_viewed('post', 5);
    ?>
                                    </li>
                            </ul>
                            <?php 
}
?>
                        </div>
                        <div class="grid-4">
                            <span>REDES</span>
                            <ul>
                                <li>
                            <a href="#" title="Facebook" class='symbol facebook' icon='&#xe427;'>
                            </a>
                        </li>
                        <li>
                            <a href="#" title="Google+" class='symbol google' icon='&#xe439;'>
                            </a>
                        </li>
                        <li>
コード例 #4
0
?>
</h2>
					<div class="fb-like" data-href="http://kateskitchen.ru" data-width="100" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
                </div>
				<div id="most_viewed_post">
					<h2 class="title1"><?php 
echo get_post_meta(176, 'most_viewed_post', true);
?>
</h2></h2>
				<?php 
if (function_exists('get_most_viewed')) {
    ?>
					
				   <ul>
					  <?php 
    get_most_viewed('post', 1);
    ?>
				   </ul>
				<?php 
}
?>
				</div>
                <div>
                    <h2 class="title1"> <?php 
echo get_post_meta(176, 'last_comments', true);
?>
</h2>
                    <div id="recentcomments" class="dsq-widget">
						<script type="text/javascript" src="http://kateskitchenru.disqus.com/recent_comments_widget.js?num_items=5&hide_avatars=0&avatar_size=32&excerpt_length=200">
						</script>
					</div>
コード例 #5
0
ファイル: header.php プロジェクト: nomadcomanche/zdorov_shop
					<img src="<?php 
bloginfo('template_url');
?>
/images/headers/logo.png" alt="<?php 
bloginfo('name');
?>
"/>
				</a>
				</div>
				<div id="most_visited">
				<?php 
if (function_exists('get_most_viewed')) {
    ?>
						
						<?php 
    get_most_viewed();
    ?>
						
					<?php 
}
?>
				</div>
				<div id="call_back"><a href="javascript:void(0);">КОНСУЛЬТАЦИЯ ПСИХОЛОГА</a>
				</div>
				<div id="login_reg">
					<span class="loginout"><?php 
wp_loginout();
?>
<img src="<?php 
bloginfo('template_url');
?>
コード例 #6
0
ファイル: most-view.php プロジェクト: pslorus/WebsiteTinTuc
		<a href="<?php 
            echo esc_url($post->guid);
            ?>
"><p class="most-view-item"><?php 
            echo $post->post_title . " (" . $post->views . " lượt xem) ";
            ?>
<span class="badge" style="font-size:25px; border-radius:25px;"><?php 
            echo $count++;
            ?>
</span></p></a>
<?php 
        }
    }
    // nếu là trang category thì lấy đọc nhiều nhất ở riêng 1 chuyên mục
} elseif (is_category()) {
    if ($most_views = get_most_viewed()) {
        $count = 1;
        foreach ($most_views as $post) {
            ?>
		<a href="<?php 
            echo esc_url($post->guid);
            ?>
"><p class="most-view-item"><?php 
            echo $post->post_title . " (" . $post->views . " lượt xem) ";
            ?>
<span class="badge" style="font-size:25px; border-radius:25px;"><?php 
            echo $count++;
            ?>
</span></p></a>
<?php 
        }
コード例 #7
0
ファイル: functions.php プロジェクト: z-h-y/sydl
function test_action_do()
{
    if (isset($_POST['action'])) {
        $offset = $_POST['offset'];
        $category = $_POST['category'];
        switch ($_POST['action']) {
            case 'new_action':
                $posts = get_posts("category=" . $category . "&numberposts=10&offset=" . $offset);
                $json = array();
                $json['more'] = false;
                if ($posts) {
                    $json['more'] = true;
                    $json['title'] = array();
                    $json['link'] = array();
                    $json['thumbnail'] = array();
                    $json['views'] = array();
                    $json['type'] = array();
                    $json['play_link'] = array();
                    $json['id'] = array();
                    foreach ($posts as $post) {
                        if (in_category(18, $post)) {
                            $type = "街机游戏";
                        } else {
                            if (in_category(30, $post)) {
                                $type = "动作游戏";
                            } else {
                                if (in_category(23, $post)) {
                                    $type = "运动游戏";
                                } else {
                                    if (in_category(31, $post)) {
                                        $type = "射击游戏";
                                    } else {
                                        if (in_category(32, $post)) {
                                            $type = "棋牌游戏";
                                        } else {
                                            if (in_category(13, $post)) {
                                                $type = "益智游戏";
                                            } else {
                                                if (in_category(19, $post)) {
                                                    $type = "角色游戏";
                                                } else {
                                                    if (in_category(33, $post)) {
                                                        $type = "任玩小测试";
                                                    } else {
                                                        $type = "任玩小游戏";
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        $str = $post->post_content;
                        $start = '<a href="';
                        $end = substr($str, strlen($start) + strpos($str, $start));
                        $substr = substr($end, 0, (strlen($end) - strpos($end, '"')) * -1);
                        array_push($json['play_link'], $substr);
                        array_push($json['id'], $post->ID);
                        array_push($json['type'], $type);
                        array_push($json['title'], $post->post_title);
                        array_push($json['link'], get_permalink($post->ID));
                        array_push($json['views'], number_format(get_post_meta($post->ID, 'views', true)));
                        if (has_post_thumbnail($post->ID)) {
                            $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail');
                            array_push($json['thumbnail'], $large_image_url[0]);
                        } else {
                            array_push($json['thumbnail'], '');
                        }
                    }
                } else {
                    $json['more'] = false;
                }
                echo json_encode($json);
                unset($json);
                break;
            case 'hot_action':
                get_most_viewed('post', 9, $offset);
                break;
            case 'refresh_action':
                $posts = get_posts("category=16&numberposts=8&orderby=rand");
                if ($posts) {
                    foreach ($posts as $post) {
                        echo '<li class="h5-game-recommend"><a href="';
                        echo get_permalink($post->ID);
                        echo '" ><img src="';
                        if (has_post_thumbnail($post->ID)) {
                            $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail');
                            echo $large_image_url[0];
                        }
                        echo '" /><span class="game-name">';
                        echo $post->post_title;
                        echo '</span></a></li>';
                    }
                }
                break;
            case 'myfavorite_action':
                $arr = explode(",", $offset);
                $len = count($arr);
                for ($i = 0; $i < $len; $i++) {
                    $post = get_post($arr[$i]);
                    if ($post) {
                        echo '<div class="h5-game"><a href="' . get_permalink($post->ID) . '"  class="h5-game-content cf"><img class="h5-game-icon" src="';
                        if (has_post_thumbnail($post->ID)) {
                            $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail');
                            echo $large_image_url[0];
                        }
                        echo '" alt="' . $post->post_title . '" /><div class="h5-game-body"><h3 class="h5-game-name">' . $post->post_title . '</h3><span class="h5-game-kind">分类:';
                        if (in_category('18', $post)) {
                            $type = "街机游戏";
                        } else {
                            if (in_category('30', $post)) {
                                $type = "动作游戏";
                            } else {
                                if (in_category('23', $post)) {
                                    $type = "运动游戏";
                                } else {
                                    if (in_category('31', $post)) {
                                        $type = "射击游戏";
                                    } else {
                                        if (in_category('32', $post)) {
                                            $type = "棋牌游戏";
                                        } else {
                                            if (in_category('13', $post)) {
                                                $type = "益智游戏";
                                            } else {
                                                if (in_category('19', $post)) {
                                                    $type = "角色游戏";
                                                } else {
                                                    if (in_category('33', $post)) {
                                                        $type = "任玩小测试";
                                                    } else {
                                                        $type = "任玩小游戏";
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        echo $type . '</span><p class="h5-game-detail">';
                        if (function_exists('the_views')) {
                            echo "<span>" . get_post_meta($post->ID, 'views', true) . "</span> 人玩过";
                        }
                        echo '</p></div></a><a postid="' . $arr[$i] . '" class="delck ' . $category . '" href="javascript:void(0);">删除</a></div>';
                    }
                }
                break;
        }
        die;
    } else {
        return;
    }
}
コード例 #8
0
function render_most_popular_content($instance)
{
    /* This widget shows on ALL views except search */
    if (is_search()) {
        return '';
    }
    // first look in cache
    $output = get_transient("most-popular-content");
    $expire = 12 * 60 * 60;
    // cache in 12hrs ?
    if ($output === false) {
        // Not present in cache so load it
        $output = '';
        $limit = $instance['show'];
        $most_viewed_posts = get_most_viewed($limit);
        $most_commented_posts = get_most_commented($limit);
        $most_shared_posts = get_most_shared($limit);
        if ($most_viewed_posts || $most_commented_posts || $most_shared_posts) {
            $output .= '<ul class="tabs">';
            $output .= '<li><a href="#">Viewed</a></li>';
            $output .= '<li><a href="#">Commented</a></li>';
            $output .= '<li><a href="#">Shared</a></li>';
            $output .= '</ul>';
            $output .= '<div class="tabpanes">';
            foreach ($panes = array($most_viewed_posts, $most_commented_posts, $most_shared_posts) as $posts) {
                $output .= '<div class="tabpane">';
                if ($posts) {
                    $post_count = 0;
                    foreach ($posts as $post) {
                        $ssclass = $post_count == 0 ? 'first' : ($post_count == count($posts) - 1 ? 'last' : '');
                        $output .= "<dl class='{$ssclass}'>";
                        $output .= '<dt>';
                        // render post's categories
                        $post_categories = wp_get_post_categories($post['post_id']);
                        $cnt = 0;
                        foreach ($post_categories as $c) {
                            $cat = get_category($c);
                            $output .= '<a href="' . get_category_link($cat->cat_ID) . '">';
                            $output .= $cat->cat_name;
                            $output .= '</a>';
                            $cnt++;
                            if ($cnt != count($post_categories)) {
                                $output .= ', ';
                            }
                        }
                        $output .= '</dt>';
                        // display post's title with link
                        $post_title = $post['post_title'] ? $post['post_title'] : get_the_title($post['post_id']);
                        $output .= '<dd><a href="' . get_permalink($post['post_id']) . '">' . $post_title . '</a></dd>';
                        $output .= '</dl>';
                        $post_count++;
                    }
                }
                $output .= '</div>';
            }
            $output .= '</div>';
        }
        // save the output to cache
        if ($output) {
            set_transient("most-popular-content", $output, $expire);
        }
    }
    return $output;
}
コード例 #9
0
ファイル: index.php プロジェクト: Germey/xjdssyzx
?>
</h3>
			<ul>
                <?php 
article_list('hui_successful_case', 4, 134, 95, 95, 34);
?>
			</ul>
		</section>
		<section class="recommended-articles">
			<h3>推荐阅读</h3>
			<ul>
			<?php 
if (function_exists('get_most_viewed')) {
    ?>
                <?php 
    get_most_viewed('post', 9, 16);
    ?>
			<?php 
} else {
    ?>
				<?php 
    hui_most_commented_post(9, 16, 365, 'DESC');
    ?>
			<?php 
}
?>
			</ul>
		</section>
	</div>
	
	<div class="entry">
コード例 #10
0
ファイル: widgets.php プロジェクト: xuui/iLost
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Most Popular Articles', 'iLost') : $instance['title']);
     if (!($number = (int) $instance['number'])) {
         $number = 5;
     } elseif ($number < 1) {
         $number = 1;
     }
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     echo '<ul class="random">' . "\n";
     get_most_viewed('post', $number, 0, true, true);
     echo '</ul>' . "\n";
     echo $after_widget;
 }