function widget($args, $instance) { extract($args); $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $count = $instance['count']; global $wp; $params = $wp->query_vars['xt_param']; $page_no = $params['page']; $page_size = $count; $cid = $params['cid']; $s = $params['s']; $_params = array('post_type' => 'daogou', 'paged' => $page_no, 'posts_per_page' => $page_size, 's' => $s); if (!empty($cid)) { $_params['tax_query'] = array(array("taxonomy" => "daogou_category", "field" => "id", "terms" => $cid)); } query_posts($_params); echo $before_widget; echo '<div class="hd"><h4 class="xt-bd-l" ' . (!empty($title) ? '' : ' style="display:none;"') . '><span>' . $title . '</span></h4></div><div class="bd">'; _xt_widget_blog_daogou($layout); echo '</div>'; echo $after_widget; echo '<div id="X_Pagination-Bottom" class="clearfix">'; echo '<div class="pagination xt-pagination-links" style="padding:0;margin:0 auto;">'; global $wp_query; $big = 100; // need an unlikely integer echo paginate_links(array('base' => xt_get_daogou_search_url(array_merge($params, array('page' => '%#%'))), 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages, 'type' => 'list')); echo '</div></div>'; }
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)); echo $before_widget; echo '<div class="xt-custom-bd clearfix">'; if (!empty($cids)) { foreach ($cids as $cid) { echo '<div class="xt-block">'; echo '<h4><a class="text-gray" href="' . xt_get_daogou_search_url(array('cid' => $cid['cid'])) . '" target="_blank">' . $cid['title'] . '</a></h4>'; $_params = array('post_type' => 'daogou', 'posts_per_page' => 9); 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; $a = ''; $list = array(array('', ''), array('', '', ''), array('', '', ''), array('', '', '')); $_isA = false; $_tags = array(); while (have_posts()) { the_post(); $_permalink = get_permalink(); $_title = get_the_title(); $_excerpt = wp_trim_words($_title, 7, ''); if (!$_isA && has_post_thumbnail()) { $post_thumbnail_id = get_post_thumbnail_id(get_the_ID()); $image = wp_get_attachment_image_src($post_thumbnail_id, 'post-thumbnail', false); list($src, $width, $height) = $image; $a = '<a class="xt-first" href="' . $_permalink . '" target="_blank"><img src="' . $src . '" alt="' . $_title . '"><span class="xt-text xt-bg-l">' . $_excerpt . '</span></a>'; $_isA = true; } else { switch ($_post_count) { case 0: $list[0][0] = '<a href="' . $_permalink . '" target="_blank" title="' . $_title . '">' . wp_trim_words($_title, 8, '') . '</a>'; break; case 1: $list[0][1] = '<a href="' . $_permalink . '" target="_blank" title="' . $_title . '">' . wp_trim_words($_title, 8, '') . '</a>'; break; case 2: $list[1][0] = _xt_widget_taobaoguide_tag($_tags); $list[1][1] = '<a class="text-gray" href="' . $_permalink . '" target="_blank" title="' . $_title . '">' . $_excerpt . '</a>'; break; case 3: if (empty($list[1][0])) { $list[1][0] = _xt_widget_taobaoguide_tag($_tags); } $list[1][2] = '<a class="text-gray" href="' . $_permalink . '" target="_blank" title="' . $_title . '">' . $_excerpt . '</a>'; break; case 4: $list[2][0] = _xt_widget_taobaoguide_tag($_tags); $list[2][1] = '<a class="text-gray" href="' . $_permalink . '" target="_blank" title="' . $_title . '">' . $_excerpt . '</a>'; break; case 5: if (empty($list[2][0])) { $list[2][0] = _xt_widget_taobaoguide_tag($_tags); } $list[2][2] = '<a class="text-gray" href="' . $_permalink . '" target="_blank" title="' . $_title . '">' . $_excerpt . '</a>'; break; case 6: $list[3][0] = _xt_widget_taobaoguide_tag($_tags); $list[3][1] = '<a class="text-gray" href="' . $_permalink . '" target="_blank" title="' . $_title . '">' . $_excerpt . '</a>'; break; case 7: if (empty($list[3][0])) { $list[3][0] = _xt_widget_taobaoguide_tag($_tags); } $list[3][2] = '<a class="text-gray" href="' . $_permalink . '" target="_blank" title="' . $_title . '">' . $_excerpt . '</a>'; break; case 8: $a = '<a class="xt-first" href="' . $_permalink . '" target="_blank"><img alt="' . $_title . '"><span class="xt-text xt-bg-l">' . $_excerpt . '</span></a>'; break; } $_post_count++; } } echo $a; echo '<ul class="unstyled">'; foreach ($list as $li) { echo '<li>' . implode('', $li) . '</li>'; } if (!empty($_tags)) { $rands = array_rand($_tags, 4); echo '<li>'; $_count = 0; foreach ($rands as $rand) { $tag = $_tags[$rand]; $class = ' class="text-gray" '; if ($_count == 1) { $class = ' '; } echo '<span>[<a' . $class . 'href="' . get_tag_link($tag) . '" target="_blank" title="' . $tag->name . '">' . wp_trim_words($tag->name, 3, '') . '</a>]</span>'; $_count++; } echo '</li>'; } echo '</ul>'; echo '</div>'; } } echo '</div>'; echo $after_widget; }
function xt_design_pages() { global $xt_design_syspages; if (empty($xt_design_syspages)) { $xt_design_syspages = array('home' => array('id' => 'home', 'title' => '首页', 'preview' => home_url()), 'error404' => array('id' => 'error404', 'title' => '404错误页面', 'preview' => home_url('404')), 'shares' => array('id' => 'shares', 'title' => '分享列表页', 'preview' => xt_get_shares_search_url(), 'layouts_edit' => 0), 'share' => array('id' => 'share', 'title' => '分享详情页', 'preview' => xt_site_url('id-' . 'SHAREID')), 'albums' => array('id' => 'albums', 'title' => '专辑列表页', 'preview' => xt_get_albums_search_url(), 'layouts_edit' => 0), 'album' => array('id' => 'album', 'title' => '专辑详情页', 'preview' => xt_site_url('aid-' . 'ALBUMID'), 'layouts_edit' => 0), 'users' => array('id' => 'users', 'title' => '会员列表页', 'preview' => ''), 'user' => array('id' => 'user', 'title' => '会员详情页', 'preview' => xt_site_url('uid-USERID'), 'layouts_edit' => 0, 'widgets_edit' => 0), 'taobaos' => array('id' => 'taobaos', 'title' => '淘宝搜索页', 'preview' => xt_get_taobao_search_url(), 'layouts_edit' => 0), 'taobao' => array('id' => 'taobao', 'title' => '淘宝商品详情页', 'preview' => xt_site_url('taobao-NUMIID'), 'layouts_edit' => 0), 'shops' => array('id' => 'shops', 'title' => '淘宝店铺搜索页', 'preview' => xt_get_shop_search_url(), 'layouts_edit' => 0), 'paipais' => array('id' => 'paipais', 'title' => '拍拍搜索页', 'preview' => xt_get_paipai_search_url(), 'layouts_edit' => 0), 'bijias' => array('id' => 'bijias', 'title' => '全网搜索页', 'preview' => xt_get_bijia_search_url(), 'layouts_edit' => 0), 'tuans' => array('id' => 'tuans', 'title' => '团购搜索页', 'preview' => xt_get_tuan_search_url(), 'layouts_edit' => 0), 'temais' => array('id' => 'temais', 'title' => '淘宝特卖搜索页', 'preview' => xt_get_temai_search_url(), 'layouts_edit' => 0), 'coupons' => array('id' => 'coupons', 'title' => '淘宝折扣搜索页', 'preview' => xt_get_coupon_search_url(), 'layouts_edit' => 0), 'daogous' => array('id' => 'daogous', 'title' => '导购文章搜索页', 'preview' => xt_get_daogou_search_url(), 'layouts_edit' => 0), 'daogou' => array('id' => 'daogou', 'title' => '导购文章详情页', 'preview' => '', 'layouts_edit' => 0), 'helps' => array('id' => 'helps', 'title' => '帮助文章列表页', 'preview' => xt_get_help_search_url(), 'layouts_edit' => 0), 'help' => array('id' => 'help', 'title' => '帮助详情页', 'preview' => '', 'layouts_edit' => 0), 'brands' => array('id' => 'brands', 'title' => '天猫品牌街', 'preview' => xt_site_url('brands'), 'layouts_edit' => 0), 'stars' => array('id' => 'stars', 'title' => '明星店', 'preview' => xt_site_url('stars'), 'layouts_edit' => 0), 'activities' => array('id' => 'activities', 'title' => '特卖活动', 'preview' => xt_site_url('activities'), 'layouts_edit' => 0), 'taoquan' => array('id' => 'taoquan', 'title' => '淘宝优惠券', 'preview' => xt_site_url('taoquan'), 'layouts_edit' => 0), 'malls' => array('id' => 'malls', 'title' => '商城', 'preview' => xt_site_url('malls'), 'layouts_edit' => 0), 'invite' => array('id' => 'invite', 'title' => '邀请页', 'preview' => xt_site_url('invite-USERID'), 'layouts_edit' => 0)); } return $xt_design_syspages; }