Ejemplo n.º 1
0
function tin_user_profile_widget()
{
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $li_output = '';
        $li_output .= '<li style="line-height:36px;clear: both;">' . tin_get_avatar($current_user->ID, '36', tin_get_avatar_type($current_user->ID), false) . sprintf(__('登录者 <a href="%1$s">%2$s</a>', 'tinection'), get_edit_profile_url($current_user->ID), $current_user->display_name) . '<a href="' . wp_logout_url(tin_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="' . tin_get_user_url('profile') . '#pass">' . __('【重要】请添加正确的邮箱以保证账户安全', 'tinection') . '</a></li>';
        }
        $shorcut_links[] = array('title' => __('个人主页', 'tinection'), 'url' => get_author_posts_url($current_user->ID));
        if (current_user_can('manage_options')) {
            $shorcut_links[] = array('title' => __('管理后台', 'tinection'), 'url' => admin_url());
        }
        $can_post_cat = ot_get_option('tin_can_post_cat');
        if (count($can_post_cat)) {
            $shorcut_links[] = array('title' => __('文章投稿', 'tinection'), 'url' => add_query_arg('action', 'new', tin_get_user_url('post')));
        }
        $shorcut_html = '<li class="active">';
        foreach ($shorcut_links as $shorcut) {
            $shorcut_html .= '<a href="' . $shorcut['url'] . '">' . $shorcut['title'] . ' &raquo;</a>';
        }
        $shorcut_html .= '</li>';
        $credit = intval(get_user_meta($current_user->ID, 'tin_credit', true));
        $credit_void = intval(get_user_meta($current_user->ID, 'tin_credit_void', true));
        $unread_count = intval(get_tin_message($current_user->ID, 'count', "( msg_type='unread' OR msg_type='unrepm' )"));
        $collects = get_user_meta($current_user->ID, 'tin_collect', true) ? get_user_meta($current_user->ID, 'tin_collect', true) : 0;
        $collects_array = explode(',', $collects);
        $collects_count = $collects != 0 ? count($collects_array) : 0;
        $info_array = array(array('title' => __('文章', 'tinection'), 'url' => tin_get_user_url('post'), 'count' => count_user_posts($current_user->ID)), array('title' => __('评论', 'tinection'), 'url' => tin_get_user_url('comment'), 'count' => get_comments(array('status' => '1', 'user_id' => $current_user->ID, 'count' => true))), array('title' => __('收藏', 'tinection'), 'url' => tin_get_user_url('collect'), 'count' => intval($collects_count)));
        if ($unread_count) {
            $info_array[] = array('title' => __('未读', 'tinection'), 'url' => tin_get_user_url('message'), 'count' => $unread_count);
        }
        $info_array[] = array('title' => __('积分', 'tinection'), 'url' => tin_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 .= tin_whether_signed($current_user->ID);
        $info_html .= '</li>';
        $friend_html = '
	<li>
		<div class="input-group">
			<span class="input-group-addon">' . __('本页推广链接', 'tinection') . '</span>
			<input class="tin_aff_url form-control" type="text" class="form-control" value="' . add_query_arg('aff', $current_user->ID, tin_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>' . __('本地帐号', 'tinection') . '</a></span>';
        if (ot_get_option('tin_open_qq') == 'on') {
            $html .= '<span class="other-sign"><a class="qqlogin btn" href="' . home_url('/?connect=qq&action=login&redirect=' . urlencode(tin_get_redirect_uri())) . '"><i class="fa fa-qq"></i><span>' . __('QQ 登 录', 'tinection') . '</span></a></span>';
        }
        if (ot_get_option('tin_open_weibo') == 'on') {
            $html .= '<span class="other-sign"><a class="weibologin btn" href="' . home_url('/?connect=weibo&action=login&redirect=' . urlencode(tin_get_redirect_uri())) . '"><i class="fa fa-weibo"></i><span>' . __('微博登录', 'tinection') . '</span></a></span>';
        }
        $html .= '</li>';
        return $html;
    }
}
Ejemplo n.º 2
0
function tin_force_ssl()
{
    $url = tin_get_current_page_url();
    if ($_SERVER['REQUEST_SCHEME'] == 'http' && ot_get_option('ssl_site') == 'on') {
        wp_redirect(set_url_scheme($url, 'https'));
        exit;
    }
}
Ejemplo n.º 3
0
                $message = __('扩展资料已更新', 'tinection');
            }
        }
        if ($update == 'pass') {
            $data = array();
            $data['ID'] = $user_id;
            $data['user_email'] = sanitize_text_field($_POST['email']);
            if (!empty($_POST['pass1']) && !empty($_POST['pass2']) && $_POST['pass1'] === $_POST['pass2']) {
                $data['user_pass'] = sanitize_text_field($_POST['pass1']);
            }
            $user_id = wp_update_user($data);
            if (!is_wp_error($user_id)) {
                $message = __('安全信息已更新', 'tinection');
            }
        }
        $message .= ' <a href="' . tin_get_current_page_url() . '">' . __('点击刷新', 'tinection') . '</a>';
        $user_info = get_userdata($curauth->ID);
    }
}
//~ 个人资料end
//~ 投稿start
if (isset($_GET['action']) && in_array($_GET['action'], array('new', 'edit')) && $oneself) {
    if (isset($_GET['id']) && is_numeric($_GET['id']) && get_post($_GET['id']) && intval(get_post($_GET['id'])->post_author) === get_current_user_id()) {
        $action = 'edit';
        $the_post = get_post($_GET['id']);
        $post_title = $the_post->post_title;
        $post_content = $the_post->post_content;
        foreach (get_the_category($_GET['id']) as $category) {
            $post_cat[] = $category->term_id;
        }
    } else {
Ejemplo n.º 4
0
 function tin_open_logout($type = 'qq')
 {
     $redirect = get_edit_profile_url();
     if ($type === 'qq') {
         $type = 'qq';
         $name = ' <img src="' . get_bloginfo('template_url') . '/images/qq_32x32.png" > QQ ';
     } elseif ($type === 'weibo') {
         $type = 'weibo';
         $name = ' <img src="' . get_bloginfo('template_url') . '/images/weibo_32x32.png" > 微博 ';
     } else {
         $type = 'weixin';
         $name = ' <img src="' . get_bloginfo('template_url') . '/images/weixin_32x32.png" > 微信 ';
     }
     if (isset($_GET['wpnonce']) && wp_verify_nonce(trim($_GET['wpnonce']), $type . '_logout')) {
         $user_ID = get_current_user_id();
         if ($type === 'weibo') {
             $token = get_user_meta($user_ID, 'tin_weibo_access_token', true);
             $info = wp_remote_retrieve_body(wp_remote_get('https://api.weibo.com/oauth2/revokeoauth2?access_token=' . $token));
         }
         delete_user_meta($user_ID, 'tin_' . $type . '_openid');
         delete_user_meta($user_ID, 'tin_' . $type . '_access_token');
         header('Location:' . $redirect);
         exit;
     } else {
         wp_die(sprintf(__('你正在试图解除%1$s绑定,确定这样做吗?<a href="%2$s">点击继续</a> <p>不知道这是哪里?<a href="%3$s">点击返回</a></p>', 'tin'), $name, add_query_arg('wpnonce', wp_create_nonce($type . '_logout'), tin_get_current_page_url()), $redirect), __('解除账号绑定', 'tinection'));
     }
 }
Ejemplo n.º 5
0
                $message = __('扩展资料已更新', 'xiapistudio');
            }
        }
        if ($update == 'pass') {
            $data = array();
            $data['ID'] = $user_id;
            $data['user_email'] = sanitize_text_field($_POST['email']);
            if (!empty($_POST['pass1']) && !empty($_POST['pass2']) && $_POST['pass1'] === $_POST['pass2']) {
                $data['user_pass'] = sanitize_text_field($_POST['pass1']);
            }
            $user_id = wp_update_user($data);
            if (!is_wp_error($user_id)) {
                $message = __('安全信息已更新', 'xiapistudio');
            }
        }
        $message .= ' <a href="' . tin_get_current_page_url() . '">' . __('点击刷新', 'xiapistudio') . '</a>';
        $user_info = get_userdata($curauth->ID);
    }
}
//~ 个人资料end
//~ 投稿start
if (isset($_GET['action']) && in_array($_GET['action'], array('new', 'edit')) && $oneself) {
    if (isset($_GET['id']) && is_numeric($_GET['id']) && get_post($_GET['id']) && intval(get_post($_GET['id'])->post_author) === get_current_user_id()) {
        $action = 'edit';
        $the_post = get_post($_GET['id']);
        $post_title = $the_post->post_title;
        $post_content = $the_post->post_content;
        foreach (get_the_category($_GET['id']) as $category) {
            $post_cat[] = $category->term_id;
        }
    } else {