Example #1
0
 * 注释和代码同样重要~
 * @author 多梦 @email chihyu@aliyun.com 
 */
$general_setting = $GLOBALS['dmeng_general_setting'];
$header_profile_display = intval($general_setting['header_profile']);
$header_content = '';
$custom_header = dmeng_custom_header();
if ($custom_header) {
    $header_content = '<div class="container header-content"><div class="row">';
    $header_content .= '<div class="' . ($header_profile_display ? 'col-lg-8 col-md-7 col-sm-6 col-xs-12' : 'col-lg-12 col-md-12 col-sm-12 col-xs-12') . '">' . $custom_header . '</div>';
    if ($header_profile_display) {
        $profile_li = '';
        $current_user = wp_get_current_user();
        if ($current_user->exists()) {
            $author_url = get_edit_profile_url($current_user->ID);
            $avatar_url = dmeng_get_avatar($current_user->ID, '54', dmeng_get_avatar_type($current_user->ID), false);
            $profile_li .= '<li class="clearfix">' . sprintf(__('<a href="%1$s" class="name" title="%2$s">%2$s</a>,你好!', 'dmeng'), get_edit_profile_url($current_user->ID), $current_user->display_name) . '<a href="' . wp_logout_url(dmeng_get_current_page_url()) . '" title="' . esc_attr__('Log out of this account') . '" data-no-instant>' . __('Log out &raquo;') . '</a></li>';
            $unread_count = intval(get_dmeng_message($current_user->ID, 'count', "( msg_type='unread' OR msg_type='unrepm' )"));
            $unread_count = $unread_count ? sprintf(__('(%s)', 'dmeng'), $unread_count) : '';
            $profile_tabs = array('message' => __('消息', 'dmeng') . $unread_count);
            $profile_tabs_output = '';
            foreach ($profile_tabs as $tab_key => $tab_title) {
                $tab_attr_title = sprintf(__('查看我的%s', 'dmeng'), $tab_title);
                $profile_tabs_output .= sprintf('<a href="%1$s" title="%2$s">%3$s</a>', dmeng_get_user_url($tab_key), $tab_attr_title, $tab_title);
            }
            $profile_tabs_output .= sprintf('<a href="%1$s" title="%2$s">%3$s</a>', get_edit_profile_url($current_user->ID), '修改个人资料', '修改个人资料');
            $profile_li .= '<li class="tabs">' . $profile_tabs_output . '</li>';
        } else {
            $weekname = date('l', current_time('timestamp', 0));
            $weekarray = array('Monday' => __('星期一', 'dmeng'), 'Tuesday' => __('星期二', 'dmeng'), 'Wednesday' => __('星期三', 'dmeng'), 'Thursday' => __('星期四', 'dmeng'), 'Friday' => __('星期五', 'dmeng'), 'Saturday' => __('星期六', 'dmeng'), 'Sunday' => __('星期天', 'dmeng'));
            $profile_li .= '<li class="date">' . sprintf(__('今天是%1$s,%2$s', 'dmeng'), date(__(' Y 年 m 月 d 日', 'dmeng'), current_time('timestamp', 0)), $weekarray[$weekname]) . '</li>';
Example #2
0
                }
            }
            if ($pages > 1) {
                $item_html .= '<li class="tip">' . sprintf(__('第 %1$s 页,共 %2$s 页,每页显示 %3$s 条。', 'dmeng'), $paged, $pages, $number) . '</li>';
            }
        } else {
            $item_html = '<li class="tip">' . sprintf(__('私信功能需要<a href="%s">登录</a>才可使用!'), wp_login_url()) . '</li>';
        }
    }
    echo '<ul id="author-message">' . $item_html . '</ul>' . dmeng_pager($paged, $pages);
}
//~ 消息end
//~ 资料start
if ($get_tab == 'profile') {
    $avatar_type = array('default' => __('默认头像', 'dmeng'), 'qq' => __('腾讯QQ头像', 'dmeng'), 'weibo' => __('新浪微博头像', 'dmeng'));
    $author_profile = array(__('头像来源', 'dmeng') => $avatar_type[dmeng_get_avatar_type($user_info->ID)], __('用户名', 'dmeng') => $user_info->user_login, __('昵称', 'dmeng') => $user_info->display_name, __('站点', 'dmeng') => $user_info->user_url, __('个人说明', 'dmeng') => $user_info->description);
    $profile_output = '';
    foreach ($author_profile as $pro_name => $pro_content) {
        $profile_output .= '<tr><td class="title">' . $pro_name . '</td><td>' . $pro_content . '</td></tr>';
    }
    $days_num = round((strtotime(date('Y-m-d')) - strtotime($user_info->user_registered)) / 3600 / 24);
    echo '<ul id="author-message"><li class="tip">' . sprintf(__('%s来%s已经%s天了', 'dmeng'), $user_info->display_name, get_bloginfo('name'), $days_num > 1 ? $days_num : 1) . '</li></ul>' . '<table id="author-profile"><tbody>' . $profile_output . '</tbody></table>';
    if ($oneself) {
        ?>

<form id="info-form" class="form-horizontal" role="form" method="post">
	<input type="hidden" name="update" value="info">
	<input type="hidden" name="_wpnonce" value="<?php 
        echo wp_create_nonce('check-nonce');
        ?>
">