feat(single): align author bar follow and reward actions with the site flows
- guests get the sign-in trigger instead of a redirect to the login page, for both follow and wallet reward controls - follow requests swap the label for an inline loader and block a second submit; the followed state uses the .actived hook - follower counts sync through data-follow-count on the user homepage (the previous selector matched nothing) and only for the viewed profile - reward button uses the secondary action colour; the reward template is only rendered for signed-in visitors - drop the unused author-hero aria-disabled rule and stale wording in the touched comments Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8ad5ef9aff
commit
d40906b4a3
13 files changed
+148
-56
No files matched your search
@@ -25,6 +25,17 @@ if (!function_exists('jio_get_rewards_button')) {
|
||||
$settings = \Jio\Settings\Settings::get_post_page_settings();
|
||||
$label = (string) ($settings['rewards_btn_text'] ?? __('赞赏', 'jio'));
|
||||
$icon = function_exists('jio_icon_markup') ? jio_icon_markup('jiosvg-money') : '';
|
||||
|
||||
// 站内余额赞赏必须登录;游客点按钮直接拉起登录弹窗,不在提交后才报错。
|
||||
if (!is_user_logged_in()) {
|
||||
return sprintf(
|
||||
'<a href="javascript:;" class="%1$s signin-loader">%2$s<text>%3$s</text></a>',
|
||||
esc_attr($class),
|
||||
$icon, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- fixed sprite markup.
|
||||
esc_html($label)
|
||||
);
|
||||
}
|
||||
|
||||
$template_id = 'jio-reward-template-' . $user_id . '-' . $post_id;
|
||||
return sprintf(
|
||||
'<button type="button" class="%1$s jio-reward-open" data-jio-reward-open data-template-id="%2$s" data-user-id="%3$d" data-post-id="%4$d">%5$s<text>%6$s</text></button>',
|
||||
@@ -42,7 +53,7 @@ if (!function_exists('jio_render_rewards_template_for_user')) {
|
||||
function jio_render_rewards_template_for_user(int $user_id, int $post_id = 0): void {
|
||||
static $done = [];
|
||||
$key = $user_id . ':' . $post_id;
|
||||
if ($user_id <= 0 || isset($done[$key]) || !jio_rewards_enabled()) {
|
||||
if ($user_id <= 0 || isset($done[$key]) || !jio_rewards_enabled() || !is_user_logged_in()) {
|
||||
return;
|
||||
}
|
||||
$done[$key] = true;
|
||||
|
||||
Reference in new issue
Block a user