function widget($args, $instance) { extract($args); $title_new = apply_filters('widget_title_new', $instance['title_new']); $title_popular = apply_filters('widget_title_popular', $instance['title_popular']); //表示数を取得 $entry_count = apply_filters('widget_entry_count', $instance['entry_count']); //表示タイプ $entry_type = apply_filters('widget_entry_type', $instance['entry_type']); //固定ページを含める $is_pages_include = apply_filters('widget_is_pages_include', $instance['is_pages_include']); $is_views_visible = apply_filters('widget_is_views_visible', $instance['is_views_visible']); $range = apply_filters('range', $instance['range']); $range_visible = apply_filters('range_visible', $instance['range_visible']); $is_ranking_visible = apply_filters('is_ranking_visible', $instance['is_ranking_visible']); //表示数をグローバル変数に格納 //後で使用するテンプレートファイルへの受け渡し //表示数が設定されていない時は5にする global $g_entry_count; if (!$entry_count) { $entry_count = 5; } $g_entry_count = $entry_count; //表示タイプのデフォルト設定 global $g_entry_type; if (!$entry_type) { $entry_type = 'default'; } $g_entry_type = $entry_type; //固定ページを含めるかのデフォルト設定 global $g_is_pages_include; $g_is_pages_include = $is_pages_include; //ページビュー表示に格納 global $g_is_views_visible; $g_is_views_visible = $is_views_visible; global $g_range; $g_range = $range ? $range : 'all'; global $g_widget_item; $g_widget_item = 'SimplicityWidgetItem'; ?> <?php if (is_home()) { //トップリストの場合 ?> <div id="popular-entries" class="widget widget_new_popular"> <h4><?php if ($title_popular) { echo $title_popular; } else { echo '人気記事'; } ?> </h4> <?php if ($is_ranking_visible) { //ランキングの表示 echo get_popular_posts_ranking_style('.widget_new_popular'); } ?> <?php if (is_wpp_enable()) { //Wordpress Popular Postsを有効にしてあるか ?> <?php //PV順 if ($entry_type == 'default') { get_template_part('popular-posts-entries'); //デフォルト } else { get_template_part('popular-posts-entries-large'); //大きなサムネイル } ?> <?php if ($range_visible) { echo get_range_tag($range); } ?> <?php } else { //Wordpress Popular Postsがインストールされていない ?> <?php //コメント順 if ($entry_type == 'default') { get_template_part('popular-entries'); //デフォルト } else { get_template_part('popular-entries-large'); //大きなサムネイル } ?> <?php } ?> </div> <?php } else { //メインページ以外 ?> <div id="new-entries" class="widget widget_new_popular"> <h4><?php if ($title_new) { echo $title_new; } else { echo '新着記事'; } ?> </h4> <?php //新着記事 if ($entry_type == 'default') { get_template_part('new-entries'); //デフォルト } else { get_template_part('new-entries-large'); //大きなサムネイル } ?> </div><!-- /#new-entries --> <?php } ?> <?php }
<div class="search-form"> <?php get_search_form(); ?> </div> <?php if (is_home()) { //メインページの場合 ?> <div id="popular-entries"> <h4>人気エントリー</h4> <?php if (function_exists('wpp_get_mostpopular') && is_wpp_enable()) { //Wordpress Popular Postsを ?> <?php get_template_part('popular-posts-entries'); //PV順 ?> <?php } else { //Wordpress Popular Postsがインストールされていない ?> <?php get_template_part('popular-entries'); //コメント順 ?> <?php
foreach ($categories as $category) { array_push($category_IDs, $category->cat_ID); } $now_id = implode(",", $category_IDs); } elseif (is_category()) { //カテゴリページではトップカテゴリーのみ取得 $categories = get_the_category(); $cat_now = $categories[0]; $now_id = $cat_now->cat_ID; } } //デバッグ用 //echo 'IDs:'.$now_id.'<br />'; //echo 'RANGE:'.$g_range; //Wordpress Popular Postsがインストールされているとき if (is_wpp_enable()) { $args = ' limit=' . $g_entry_count . '& range=' . $g_range . '& order_by=views& thumbnail_width=75& thumbnail_height=75& cat="' . $now_id . '"& wpp_start=""& wpp_end=""& post_start="<div class="popular-post"><ul>"& post_end="</ul></div>"&' . $post_type . 'stats_comments=0& stats_views=' . ($g_is_views_visible ? 1 : 0) . ''; wpp_get_mostpopular($args); } ?>