feat(widgets): user-card guest OAuth social login bar

Match zibll widget_ui_user guest shell with social provider buttons
under login/register CTAs.
This commit is contained in:
2026-07-19 01:25:57 +08:00
parent 05200ce781
commit 53d85c6ebd
2 changed files with 31 additions and 2 deletions
+15
View File
@@ -512,3 +512,18 @@
color: var(--muted-2-color, #999);
font-size: 12px;
}
.aksrt-user-card__oauth {
margin-top: 14px;
padding-top: 12px;
border-top: 1px dashed var(--color-line, #e5e7eb);
}
.aksrt-user-card__oauth .social-login-divider {
font-size: 12px;
color: var(--muted-2-color, #999);
margin-bottom: 8px;
}
.aksrt-user-card__oauth .social-login-item,
.aksrt-user-card__oauth a {
margin: 0 4px;
}
+16 -2
View File
@@ -137,6 +137,16 @@ class WidgetUserCard extends \WP_Widget {
? get_avatar_url(0, ['size' => 144, 'force_default' => true])
: includes_url('images/blank.gif');
$oauth_html = '';
if (class_exists('\AKSRT\Auth\OAuth')) {
$oauth = \AKSRT\Auth\OAuth::get_instance();
if (method_exists($oauth, 'render_social_buttons')) {
$oauth_html = (string) $oauth->render_social_buttons(__('社交账号登录', 'aksrt'));
} elseif (method_exists($oauth, 'get_login_buttons')) {
$oauth_html = (string) $oauth->get_login_buttons();
}
}
echo '<div class="aksrt-user-card user-card zib-widget widget is-guest">';
if ($show_cover) {
echo '<div class="aksrt-user-card__cover user-cover graphic is-empty"></div>';
@@ -147,9 +157,13 @@ class WidgetUserCard extends \WP_Widget {
echo '<div class="aksrt-user-card__actions">';
echo '<a class="aksrt-user-card__btn aksrt-user-card__btn--primary signin-loader" href="' . esc_url($login) . '">' . esc_html__('登录', 'aksrt') . '</a>';
if ($register) {
echo '<a class="aksrt-user-card__btn aksrt-user-card__btn--ghost" href="' . esc_url($register) . '">' . esc_html__('注册', 'aksrt') . '</a>';
echo '<a class="aksrt-user-card__btn aksrt-user-card__btn--ghost signup-loader" href="' . esc_url($register) . '">' . esc_html__('注册', 'aksrt') . '</a>';
}
echo '</div></div></div>';
echo '</div>';
if ($oauth_html !== '') {
echo '<div class="aksrt-user-card__oauth social_loginbar">' . $oauth_html . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo '</div></div>';
}
public function form($instance): void {