feat(widgets): author card follow button
Add data-aksrt-follow CTA on post author sidebar card for non-self users.
This commit is contained in:
@@ -527,3 +527,15 @@
|
|||||||
.aksrt-user-card__oauth a {
|
.aksrt-user-card__oauth a {
|
||||||
margin: 0 4px;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -94,6 +94,13 @@ class WidgetAuthorCard extends \WP_Widget {
|
|||||||
echo '<span><b>' . esc_html((string) $followers) . '</b>' . esc_html__('粉丝', 'aksrt') . '</span>';
|
echo '<span><b>' . esc_html((string) $followers) . '</b>' . esc_html__('粉丝', 'aksrt') . '</span>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
$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 '<button type="button" class="aksrt-author-card__btn aksrt-author-card__follow' . ($following ? ' is-following' : '') . '" data-aksrt-follow="' . (int) $author_id . '">' . esc_html($label) . '</button>';
|
||||||
|
}
|
||||||
echo '<a class="aksrt-author-card__btn" href="' . esc_url($home) . '">' . esc_html__('查看主页', 'aksrt') . '</a>';
|
echo '<a class="aksrt-author-card__btn" href="' . esc_url($home) . '">' . esc_html__('查看主页', 'aksrt') . '</a>';
|
||||||
echo '</div></div>';
|
echo '</div></div>';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user