Пример #1
0
/**
 * Main Template of Ucenter & Market WordPress Plugin
 *
 * @package   Ucenter & Market
 * @version   1.0
 * @date      2015.4.1
 * @author    Zhiyan <*****@*****.**>
 * @site      Zhiyanblog <www.zhiyanblog.com>
 * @copyright Copyright (c) 2015-2015, Zhiyan
 * @license   http://opensource.org/licenses/gpl-2.0.php GPL v2 or later
 * @link      http://www.zhiyanblog.com/wordpress-plugin-ucenter-and-market.html
**/
function um_loginbox()
{
    ?>
<div class="overlay-login"></div>
<div id="sign" class="um_sign">
    <div class="part loginPart">
    <form id="login" action="<?php 
    echo get_option('home');
    ?>
/wp-login.php" method="post" novalidate="novalidate">
        <?php 
    if (get_option('users_can_register') == 1) {
        ?>
<div id="register-active" class="switch"><i class="fa fa-toggle-on"></i>切换注册</div><?php 
    }
    ?>
        <h3>登录<p class="status"></p></h3>
        <p>
            <label class="icon" for="username"><i class="fa fa-user"></i></label>
            <input class="input-control" id="username" type="text" placeholder="请输入用户名" name="username" required="" aria-required="true">
        </p>
        <p>
            <label class="icon" for="password"><i class="fa fa-lock"></i></label>
            <input class="input-control" id="password" type="password" placeholder="请输入密码" name="password" required="" aria-required="true">
        </p>
        <p class="safe">
            <label class="remembermetext" for="rememberme"><input name="rememberme" type="checkbox" checked="checked" id="rememberme" class="rememberme" value="forever">记住我的登录</label>
            <a class="lost" href="<?php 
    echo get_option('home');
    ?>
/wp-login.php?action=lostpassword"><?php 
    _e('忘记密码 ?', 'tinection');
    ?>
</a>
        </p>
        <p>
            <input class="submit" type="submit" value="登录" name="submit">
        </p>
        <a class="close"><i class="fa fa-times"></i></a>
        <input type="hidden" id="security" name="security" value="<?php 
    echo wp_create_nonce('security_nonce');
    ?>
">
		<input type="hidden" name="_wp_http_referer" value="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
">
	</form>
    <?php 
    if (um_get_setting('um_open_qq') || um_get_setting('um_open_weibo')) {
        ?>
    <div class="other-sign">
      <p>您也可以使用第三方帐号快捷登录</p>
	  <?php 
        if (um_get_setting('um_open_qq')) {
            ?>
      <div><a class="qqlogin" href="<?php 
            echo home_url('/?connect=qq&action=login&redirect=' . urlencode(um_get_redirect_uri()));
            ?>
"><i class="fa fa-qq"></i><span><?php 
            _e('Q Q 登 录', 'tinection');
            ?>
</span></a></div>
	  <?php 
        }
        ?>
	  <?php 
        if (um_get_setting('um_open_weibo')) {
            ?>
	  <div><a class="weibologin" href="<?php 
            echo home_url('/?connect=weibo&action=login&redirect=' . urlencode(um_get_redirect_uri()));
            ?>
"><i class="fa fa-weibo"></i><span><?php 
            _e('微 博 登 录', 'tinection');
            ?>
</span></a></div>
	  <?php 
        }
        ?>
    </div>
	<?php 
    }
    ?>
    </div>
    <div class="part registerPart">
    <form id="register" action="<?php 
    bloginfo('url');
    ?>
/wp-login.php?action=register" method="post" novalidate="novalidate">
        <div id="login-active" class="switch"><i class="fa fa-toggle-off"></i>切换登录</div>
        <h3>注册<p class="status"></p></h3>    
        <p>
            <label class="icon" for="user_name"><i class="fa fa-user"></i></label>
            <input class="input-control" id="user_name" type="text" name="user_name" placeholder="输入英文用户名" required="" aria-required="true">
        </p>
        <p>
            <label class="icon" for="user_email"><i class="fa fa-envelope"></i></label>
            <input class="input-control" id="user_email" type="email" name="user_email" placeholder="输入常用邮箱" required="" aria-required="true">
        </p>
        <p>
            <label class="icon" for="user_pass"><i class="fa fa-lock"></i></label>
            <input class="input-control" id="user_pass" type="password" name="user_pass" placeholder="密码最小长度为6" required="" aria-required="true">
        </p>
        <p>
            <label class="icon" for="user_pass2"><i class="fa fa-retweet"></i></label>
            <input class="input-control" type="password" id="user_pass2" name="user_pass2" placeholder="再次输入密码" required="" aria-required="true">
        </p>
        <p id="captcha_inline">
            <input class="input-control inline" type="text" id="um_captcha" name="um_captcha" placeholder="输入验证码" required>
            <img src="<?php 
    echo UM_URI . '/static/img/captcha-clk.png';
    ?>
" class="captcha_img inline" title="点击刷新验证码">
            <input class="submit inline" type="submit" value="注册" name="submit">
        </p>
        <a class="close"><i class="fa fa-times"></i></a>  
        <input type="hidden" id="user_security" name="user_security" value="<?php 
    echo wp_create_nonce('user_security_nonce');
    ?>
"><input type="hidden" name="_wp_http_referer" value="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
"> 
    </form>
    </div>
</div>
<?php 
}
Пример #2
0
function um_user_manage_widget()
{
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $li_output = '';
        $li_output .= '<li style="line-height:36px;clear: both;">' . um_get_avatar($current_user->ID, '36', um_get_avatar_type($current_user->ID), false) . sprintf(__('登录者 <a href="%1$s">%2$s</a>', 'um'), get_edit_profile_url($current_user->ID), $current_user->display_name) . '<a href="' . wp_logout_url(um_get_current_page_url()) . '" title="' . esc_attr__('登出本帐号') . '">' . __('登出 &raquo;') . '</a></li>';
        if (!filter_var($current_user->user_email, FILTER_VALIDATE_EMAIL)) {
            $li_output .= '<li><a href="' . um_get_user_url('profile') . '#pass">' . __('【重要】请添加正确的邮箱以保证账户安全', 'um') . '</a></li>';
        }
        $shorcut_links[] = array('icon' => '<i class="fa fa-home"></i>', 'title' => __('个人主页', 'um'), 'url' => get_author_posts_url($current_user->ID));
        $shorcut_links[] = array('icon' => '<i class="fa fa-edit"></i>', 'title' => __('编辑资料', 'um'), 'url' => um_get_user_url('profile'));
        if (current_user_can('manage_options')) {
            $shorcut_links[] = array('icon' => '<i class="fa fa-dashboard"></i>', 'title' => __('管理后台', 'um'), 'url' => admin_url());
        }
        $can_post_cat = get_cat_ids();
        if (count($can_post_cat)) {
            $shorcut_links[] = array('icon' => '<i class="fa fa-send"></i>', 'title' => __('文章投稿', 'um'), 'url' => add_query_arg('action', 'new', um_get_user_url('post')));
        }
        $shorcut_links[] = array('icon' => '<i class="fa fa-shopping-cart"></i>', 'title' => __('我的订单', 'um'), 'url' => um_get_user_url('orders'), 'prefix' => '<br>');
        $shorcut_links[] = array('icon' => '<i class="fa fa-user-md"></i>', 'title' => __('会员信息', 'um'), 'url' => um_get_user_url('membership'), 'prefix' => '');
        $shorcut_links[] = array('icon' => '<i class="fa fa-money"></i>', 'title' => __('我的推广', 'um'), 'url' => um_get_user_url('affiliate'));
        if (current_user_can('manage_options')) {
            $shorcut_links[] = array('icon' => '<i class="fa fa-tasks"></i>', 'title' => __('订单管理', 'um'), 'url' => um_get_user_url('siteorders'));
        }
        if (current_user_can('manage_options')) {
            $shorcut_links[] = array('icon' => '<i class="fa fa-tags"></i>', 'title' => __('优惠码', 'um'), 'url' => um_get_user_url('coupon'));
        }
        $shorcut_html = '<li class="active">';
        foreach ($shorcut_links as $shorcut) {
            $shorcut_html .= isset($shorcut['prefix']) ? $shorcut['prefix'] : '';
            $shorcut_html .= '<a href="' . $shorcut['url'] . '">' . $shorcut['icon'] . $shorcut['title'] . '</a>';
        }
        $shorcut_html .= '</li>';
        $credit = intval(get_user_meta($current_user->ID, 'um_credit', true));
        $credit_void = intval(get_user_meta($current_user->ID, 'um_credit_void', true));
        $unread_count = intval(get_um_message($current_user->ID, 'count', "( msg_type='unread' OR msg_type='unrepm' )"));
        $collects = get_user_meta($current_user->ID, 'um_collect', true) ? get_user_meta($current_user->ID, 'um_collect', true) : 0;
        $collects_array = explode(',', $collects);
        $collects_count = $collects != 0 ? count($collects_array) : 0;
        $info_array = array(array('title' => __('文章', 'um'), 'url' => um_get_user_url('post'), 'count' => count_user_posts($current_user->ID)), array('title' => __('评论', 'um'), 'url' => um_get_user_url('comment'), 'count' => get_comments(array('status' => '1', 'user_id' => $current_user->ID, 'count' => true))), array('title' => __('收藏', 'um'), 'url' => um_get_user_url('collect'), 'count' => intval($collects_count)));
        if ($unread_count) {
            $info_array[] = array('title' => __('未读', 'um'), 'url' => um_get_user_url('message'), 'count' => $unread_count);
        }
        $info_array[] = array('title' => __('积分', 'um'), 'url' => um_get_user_url('credit'), 'count' => $credit);
        $info_html = '<li>';
        foreach ($info_array as $info) {
            $info_html .= $info['title'] . '<a href="' . $info['url'] . '"> ' . $info['count'] . '</a>';
        }
        $info_html .= um_whether_signed($current_user->ID);
        $info_html .= '</li>';
        $friend_html = '
	<li>
		<div class="input-group" style="width:100%;">
			<span class="input-group-addon">' . __('本页推广链接', 'um') . '</span>
			<input class="um_aff_url form-control" type="text" class="form-control" value="' . add_query_arg('aff', $current_user->ID, um_canonical_url()) . '">
		</div>
	</li>
	';
        return $li_output . $shorcut_html . $info_html . $friend_html;
    } else {
        $html = '<li><span class="local-account"><a data-sign="0" class="btn btn-primary user-login"><i class="fa fa-wordpress"></i>' . __('本地帐号', 'um') . '</a></span>';
        if (um_get_setting('um_open_qq')) {
            $html .= '<span class="other-sign"><a class="qqlogin btn" href="' . home_url('/?connect=qq&action=login&redirect=' . urlencode(um_get_redirect_uri())) . '"><i class="fa fa-qq"></i><span>' . __('QQ 登 录', 'um') . '</span></a></span>';
        }
        if (um_get_setting('um_open_weibo')) {
            $html .= '<span class="other-sign"><a class="weibologin btn" href="' . home_url('/?connect=weibo&action=login&redirect=' . urlencode(um_get_redirect_uri())) . '"><i class="fa fa-weibo"></i><span>' . __('微博登录', 'um') . '</span></a></span>';
        }
        $html .= '</li>';
        return $html;
    }
}
Пример #3
0
 function um_get_redirect_text()
 {
     $cookie_name = um_redirect_cookie_name();
     $redirect = isset($_COOKIE[$cookie_name]) ? urldecode($_COOKIE[$cookie_name]) : um_get_redirect_uri();
     return '<a href="' . $redirect . '">点击返回</a>';
 }