Пример #1
0
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     global $xt;
     if ($xt->is_daogou) {
         $cats = get_the_terms(null, 'daogou_category');
         if (!$cats || is_wp_error($cats)) {
             $cats = array();
         }
         $cats = array_values($cats);
         foreach (array_keys($cats) as $key) {
             _make_cat_compat($cats[$key]);
         }
         $cids = array();
         if (!empty($cats)) {
             foreach ($cats as $cat) {
                 $cids[] = $cat->cat_ID;
             }
         }
         $cids = implode(',', $cids);
         $show = intval($instance['show']);
         $count = intval($instance['count']);
         $sortOrder = $instance['sortOrder'];
         $isDaogouList = $layout == 'span9' && $show == 2;
         if ($isDaogouList) {
             echo str_replace('xt-widget-blog', 'xt-widget-daogou', $before_widget);
         } else {
             echo $before_widget;
         }
         echo '<div class="hd"><h4 class="xt-bd-l" style="' . (empty($title) ? 'display:none' : '') . '"><span>' . $title . '</span></h4></div><div class="bd">';
         $_params = array('post_type' => 'daogou', 'posts_per_page' => $count, 'orderby' => $sortOrder);
         if (!empty($cids)) {
             $_params['tax_query'] = array(array("taxonomy" => "daogou_category", "field" => "id", "terms" => $cids));
         }
         query_posts($_params);
         if ($isDaogouList) {
             _xt_widget_blog_daogou($layout);
         } else {
             if ($show == 0) {
                 echo '<ul class="xt-bd-list unstyled clearfix">';
             } else {
                 echo '<ul class="media-list clearfix">';
             }
             $_post_count = 0;
             while (have_posts()) {
                 the_post();
                 _xt_widget_blog_li($show, $_post_count);
                 $_post_count++;
             }
             echo '</ul>';
         }
         echo '</div>';
         echo $after_widget;
     }
 }
Пример #2
0
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     $cids = isset($instance['cids']) ? $instance['cids'] : array(array('title' => '', 'cid' => -1), array('title' => '', 'cid' => -1), array('title' => '', 'cid' => -1));
     $show = intval($instance['show']);
     $count = intval($instance['count']);
     echo $before_widget;
     $_count = 0;
     echo '<div class="row-fluid">';
     $span = $layout == 'span12' ? 'span4' : ($layout == 'span9' ? 'span6' : 'span12');
     $_length = $layout == 'span12' ? 3 : ($layout == 'span9' ? 2 : 1);
     foreach ($cids as $cid) {
         echo '<div class="' . $span . '">';
         if (empty($cid['title'])) {
             $cid['title'] = '文章列表';
         }
         echo '<div class="hd"><h4 class="xt-bd-l" ' . (!empty($cid['title']) ? '' : 'style="display:none"') . '><a href="' . ($cid['cid'] > 0 ? get_category_link($cid) : '') . '" target="_blank">' . $cid['title'] . '</a></h4></div><div class="bd">';
         if ($show == 0) {
             echo '<ul class="xt-bd-list unstyled clearfix">';
         } else {
             echo '<ul class="media-list clearfix">';
         }
         $_params = array('post_type' => 'daogou', 'posts_per_page' => $count);
         if (!empty($cid['cid']) && $cid['cid'] > 0) {
             $_params['tax_query'] = array(array("taxonomy" => "daogou_category", "field" => "id", "terms" => $cid['cid']));
         }
         query_posts($_params);
         $_post_count = 0;
         while (have_posts()) {
             the_post();
             _xt_widget_blog_li($show, $_post_count);
             $_post_count++;
         }
         echo '</ul></div></div>';
         $_count++;
         if ($_count == $_length) {
             break;
         }
     }
     echo '</div>';
     echo $after_widget;
 }