diff --git a/assets/css/frontend/widget-batch5.css b/assets/css/frontend/widget-batch5.css index f068cf75..b8e2befd 100644 --- a/assets/css/frontend/widget-batch5.css +++ b/assets/css/frontend/widget-batch5.css @@ -527,3 +527,15 @@ .aksrt-user-card__oauth a { margin: 0 4px; } + +.aksrt-author-card__follow { + border: 0; + cursor: pointer; + margin-right: 6px; + background: #ef4444; + color: #fff !important; +} +.aksrt-author-card__follow.is-following { + background: var(--surface-2, #e5e7eb); + color: inherit !important; +} diff --git a/src/AKSRT/Widgets/WidgetAuthorCard.php b/src/AKSRT/Widgets/WidgetAuthorCard.php index 70c11018..9796f015 100644 --- a/src/AKSRT/Widgets/WidgetAuthorCard.php +++ b/src/AKSRT/Widgets/WidgetAuthorCard.php @@ -94,6 +94,13 @@ class WidgetAuthorCard extends \WP_Widget { echo '' . esc_html((string) $followers) . '' . esc_html__('粉丝', 'aksrt') . ''; echo ''; } + $cuid = get_current_user_id(); + $show_follow = !isset($instance['show_follow']) || !empty($instance['show_follow']); + if ($show_follow && $cuid > 0 && $cuid !== $author_id && class_exists('\AKSRT\User\Follow')) { + $following = \AKSRT\User\Follow::get_instance()->is_following($cuid, $author_id); + $label = $following ? __('已关注', 'aksrt') : __('关注', 'aksrt'); + echo ''; + } echo '' . esc_html__('查看主页', 'aksrt') . ''; echo '';