修复用户个人信息卡片
This commit is contained in:
@@ -22,23 +22,54 @@ final class UserRenderer {
|
||||
private static function user_card(array $i): string {
|
||||
$user_id = get_current_user_id();
|
||||
if ($user_id <= 0) {
|
||||
$login = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url();
|
||||
$register = function_exists('aksrt_get_register_url') ? aksrt_get_register_url() : wp_registration_url();
|
||||
$oauth_html = '';
|
||||
if (class_exists('AKSRT\\Auth\\OAuth')) {
|
||||
$oauth = \AKSRT\Auth\OAuth::get_instance();
|
||||
if (is_callable([$oauth, 'render_social_buttons'])) {
|
||||
$oauth_html = (string) $oauth->render_social_buttons(__('社交账号登录', 'aksrt'));
|
||||
} elseif (is_callable([$oauth, 'get_login_buttons'])) {
|
||||
$oauth_html = (string) $oauth->get_login_buttons();
|
||||
}
|
||||
}
|
||||
return '<div class="aksrt-user-card is-guest"><div class="aksrt-user-card__cover"></div><div class="aksrt-user-card__body">' . (function_exists('aksrt_get_avatar_html') ? aksrt_get_avatar_html(0, 88) : get_avatar(0, 88)) . '<h3>' . esc_html__('Hi,请登录', 'aksrt') . '</h3><p>' . esc_html__('登录后管理课程、会员、订单与创作内容。', 'aksrt') . '</p><div class="aksrt-user-card__actions"><a class="aksrt-widget-button is-primary signin-loader" href="' . esc_url($login) . '">' . esc_html__('登录', 'aksrt') . '</a><a class="aksrt-widget-button is-secondary signup-loader" href="' . esc_url($register) . '">' . esc_html__('注册', 'aksrt') . '</a></div>' . ($oauth_html !== '' ? '<div class="aksrt-user-card__oauth">' . $oauth_html . '</div>' : '') . '</div></div>';
|
||||
return self::guest_card($i);
|
||||
}
|
||||
$user = get_userdata($user_id);
|
||||
return $user instanceof \WP_User ? self::profile_card($user, $i, true) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 未登录卡片 — legacy parity zib_widget_ui_user(zibll inc/widgets/widget-user.php:29-43)
|
||||
* 与 zib_get_user_singin_page_box(zibll inc/functions/user/user.php:178-203)。
|
||||
*/
|
||||
private static function guest_card(array $i): string {
|
||||
$login = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url();
|
||||
$register = function_exists('aksrt_get_register_url') ? aksrt_get_register_url() : wp_registration_url();
|
||||
$title = trim((string) ($i['loged_title'] ?? ''));
|
||||
if ($title === '') {
|
||||
$title = __('Hi!请登录', 'aksrt');
|
||||
}
|
||||
|
||||
$cover = '';
|
||||
if (!empty($i['show_cover'])) {
|
||||
$cover = '<div class="user-cover graphic" style="padding-bottom:50%;"><img' . aksrt_get_lazy_attr('lazy_cover', get_theme_file_uri('assets/img/person_background.png'), 'lazyload fit-cover', aksrt_get_lazy_thumb('lg')) . ' alt=""></div>';
|
||||
}
|
||||
|
||||
$buttons = '<a class="signin-loader but jb-blue padding-lg" href="' . esc_url($login) . '"><i class="fa fa-fw fa-sign-in" aria-hidden="true"></i>' . esc_html__('登录', 'aksrt') . '</a>';
|
||||
if (get_option('users_can_register')) {
|
||||
$buttons .= '<a class="signup-loader but jb-yellow padding-lg ml10" href="' . esc_url($register) . '"><i class="fa fa-fw fa-user-plus" aria-hidden="true"></i>' . esc_html__('注册', 'aksrt') . '</a>';
|
||||
}
|
||||
|
||||
$oauth_html = '';
|
||||
if (class_exists('AKSRT\\Auth\\OAuth')) {
|
||||
$oauth = \AKSRT\Auth\OAuth::get_instance();
|
||||
if (is_callable([$oauth, 'render_social_buttons'])) {
|
||||
$oauth_html = (string) $oauth->render_social_buttons(__('社交账号登录', 'aksrt'));
|
||||
}
|
||||
}
|
||||
|
||||
$avatar = '<span class="avatar-img avatar-lg">' . aksrt_get_avatar_html(0, 80, ['class' => 'avatar fit-cover']) . '</span>';
|
||||
|
||||
return '<div class="user-card widget">' . $cover
|
||||
. '<div class="card-content mt10"><div class="user-content">'
|
||||
. '<div class="user-avatar">' . $avatar . '</div>'
|
||||
. '<div class="user-info mt10 text-center">'
|
||||
. '<p class="muted-color box-body em12">' . esc_html($title) . '</p>'
|
||||
. '<p class="box-body">' . $buttons . '</p>'
|
||||
. $oauth_html
|
||||
. '</div></div></div></div>';
|
||||
}
|
||||
|
||||
private static function author_card(array $i): string {
|
||||
$post = get_post();
|
||||
if (!$post instanceof \WP_Post) {
|
||||
|
||||
Reference in New Issue
Block a user