コード例 #1
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $lefts = $instance['left'];
        $rights = $instance['right'];
        $bgClass = '';
        if ($instance['color'] == 'black') {
            echo str_replace('clearfix', 'clearfix xt-widefat xt-black', $before_widget);
        } elseif ($instance['color'] == 'grey') {
            echo str_replace('clearfix', 'clearfix xt-widefat xt-grey', $before_widget);
        } else {
            $bgClass = ' xt-bg-l';
            echo str_replace('clearfix', 'clearfix xt-widefat xt-bg-l', $before_widget);
        }
        ?>
        <div class="clearfix xt-first">
            <ul class="pull-left unstyled">
                <?php 
        $isLeft = false;
        if (!empty($lefts)) {
            foreach ($lefts as $left) {
                if (!empty($left['title'])) {
                    $isLeft = true;
                    echo '<li><a href="' . ($left['link'] ? $left['link'] : 'javascript:;') . '">' . $left['title'] . '</a></li>';
                }
            }
        }
        ?>
            </ul>
            <ul class="pull-right unstyled">
                <?php 
        if (!empty($rights)) {
            if (isset($rights['login']) && $rights['login']) {
                $user = wp_get_current_user();
                if ($user->exists()) {
                    if (empty($user->display_name)) {
                        $user->display_name = $user->user_login;
                    }
                    global $wpdb;
                    $user_name = $wpdb->escape($user->display_name);
                    ?>
                            <li>欢迎您,<span><?php 
                    echo $user_name;
                    ?>
</span></li>
                            <li class="dropdown dropdown-hover">
                                <a href="<?php 
                    xt_the_user_url($user->ID);
                    ?>
" class="dropdown-toggle" data-toggle="dropdown">个人中心</a>
                                <ul class="dropdown-menu<?php 
                    echo $bgClass;
                    ?>
">
                                    <li><a href="<?php 
                    xt_the_user_url($user->ID);
                    ?>
#share" class="X_Menu-Share-A">我的分享</a></li>
                                    <li><a href="<?php 
                    xt_the_user_url($user->ID);
                    ?>
#like" class="X_Menu-Fav-A">我喜欢的</a></li>
                                    <li><a href="<?php 
                    xt_the_user_url($user->ID);
                    ?>
#album" class="X_Menu-Album-A">我的专辑</a></li>
                                    <li><a href="<?php 
                    echo xt_site_url('account#profile');
                    ?>
" class="X_Menu-Account-A">账号设置</a></li>
                                    <?php 
                    if (current_user_can('edit_pages')) {
                        ?>
                                        <li class="xt-last"><a href="<?php 
                        echo admin_url();
                        ?>
">管理中心</a></li>
                                    <?php 
                    }
                    ?>
                                    <li><a href="<?php 
                    echo wp_logout_url() . '&redirect_to=' . $_SERVER['REQUEST_URI'];
                    ?>
">退出登录</a></li>
                                </ul>
                            </li>
                            <?php 
                    if (xt_is_fanxian()) {
                        ?>
                                <li><a href="<?php 
                        echo xt_site_url('account');
                        ?>
">我的返现</a></li>
                            <?php 
                    }
                    ?>
                            <?php 
                } else {
                    echo '<li><a href="javascript:;" class="X_User-Login">登录</a></li>';
                    if (get_option('users_can_register')) {
                        echo '<li><a href="' . esc_url(site_url('wp-login.php?action=register&redirect_to=' . urlencode($_SERVER['REQUEST_URI']), 'login')) . '">注册</a></li>';
                    }
                    if (xt_is_fanxian()) {
                        echo '<li><a href="javascript:;" class="X_User-Need-Login">我的返现</a></li>';
                    }
                }
            }
            if (isset($rights['favorite']) && $rights['favorite']) {
                echo '<li><a href="javascript:;" class="X_User-addBrowserFavorite" data-title="' . esc_attr(get_bloginfo('name')) . '" data-url="' . esc_attr(home_url()) . '">加入收藏</a></li>';
            }
            if (isset($rights['follow']) && $rights['follow']) {
                $lis = array();
                if (!empty($rights['follow']['sina'])) {
                    $lis[] = '<li><a href="' . $rights['follow']['sina'] . '">新浪微博</a></li>';
                }
                if (!empty($rights['follow']['qq'])) {
                    $lis[] = '<li><a href="' . $rights['follow']['qq'] . '">腾讯微博</a></li>';
                }
                if (!empty($rights['follow']['qzone'])) {
                    $lis[] = '<li><a href="' . $rights['follow']['qzone'] . '">Q&nbsp;&nbsp;Q空间</a></li>';
                }
                if (!empty($rights['follow']['weixin'])) {
                    $lis[] = '<li><a href="' . $rights['follow']['weixin'] . '">微  信</a></li>';
                }
                if (!empty($lis)) {
                    ?>
                            <li class="dropdown dropdown-hover">
                                <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">关注我们</a>
                                <ul class="dropdown-menu<?php 
                    echo $bgClass;
                    ?>
">
                                    <?php 
                    echo implode('', $lis);
                    ?>
                                </ul>
                            </li>
                            <?php 
                }
            }
            if (isset($rights['help']) && $rights['help']) {
                echo '<li><a href="' . xt_get_help_search_url() . '">帮助</a></li>';
            }
        }
        ?>
            </ul>
        </div>
        <?php 
        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);
     if (empty($title)) {
         $title = '帮助中心';
     }
     global $xt, $xt_help_itemcat;
     if (isset($xt->is_helps) && $xt->is_helps) {
         $dataType = $instance['dataType'];
         $cids = $instance['cids'];
         $terms = array();
         if ($dataType == 'all') {
             $terms = get_terms('help_category', array('get' => 'all'));
         } else {
             if (!empty($cids)) {
                 $terms = get_terms('help_category', array('include' => $cids));
             }
         }
         if (!empty($terms)) {
             echo $before_widget;
             echo '<div class="hd"><h4 class="xt-bd-l" ' . (!empty($title) ? '' : 'style="display:none;"') . '><a href="' . xt_get_help_search_url() . '" class="text-gray">' . $title . '</a></h4></div>';
             echo '<div class="bd clearfix"><ul class="xt-bd-list unstyled">';
             foreach ($terms as $term) {
                 $active = '';
                 if (!empty($xt_help_itemcat)) {
                     if ($xt_help_itemcat->term_id == $term->term_id) {
                         $active = ' class="xt-bg-l active" ';
                     }
                 }
                 echo '<li' . $active . '><a href="' . xt_get_help_search_url(array('cid' => $term->term_id)) . '">' . $term->name . '</a></li>';
             }
             echo '</ul></div>';
             echo $after_widget;
         }
     }
 }
コード例 #3
0
ファイル: widgets.php プロジェクト: aspirin/wp-xintaoke
 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;
 }