fix(single): author card PM/reward and share dropdown fallback
Mirror bar PM/reward on author card and centralize #share-dropdown so tabbar share works when the actions row is absent.
This commit is contained in:
@@ -182,6 +182,40 @@ if (!function_exists('aksrt_single_render_box_header')) :
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_render_share_dropdown')) :
|
||||
/**
|
||||
* Shared #share-dropdown markup (actions row + tabbar fallback).
|
||||
*
|
||||
* @param array<string,mixed> $attrs Optional data-share-* overrides.
|
||||
*/
|
||||
function aksrt_render_share_dropdown(array $attrs = []): void {
|
||||
static $printed = false;
|
||||
if ($printed) {
|
||||
return;
|
||||
}
|
||||
$printed = true;
|
||||
$title = (string) ($attrs['title'] ?? get_the_title());
|
||||
$url = (string) ($attrs['url'] ?? (get_permalink() ?: ''));
|
||||
$image = (string) ($attrs['image'] ?? (get_the_post_thumbnail_url(null, 'large') ?: ''));
|
||||
?>
|
||||
<div class="share-dropdown" id="share-dropdown" aria-hidden="true"
|
||||
data-share-title="<?php echo esc_attr($title); ?>"
|
||||
data-share-url="<?php echo esc_url($url); ?>"
|
||||
<?php if ($image !== '') : ?>data-share-image="<?php echo esc_url($image); ?>"<?php endif; ?>>
|
||||
<div class="share-dropdown__grid">
|
||||
<button type="button" class="share-item" data-platform="qq"><i class="fab fa-qq"></i><span>QQ</span></button>
|
||||
<button type="button" class="share-item" data-platform="weibo"><i class="fab fa-weibo"></i><span>微博</span></button>
|
||||
<button type="button" class="share-item" data-platform="twitter"><i class="fab fa-x-twitter"></i><span>X</span></button>
|
||||
<button type="button" class="share-item" data-platform="wechat"><i class="fab fa-weixin"></i><span>微信</span></button>
|
||||
<button type="button" class="share-item" data-platform="copy"><i class="fas fa-link"></i><span><?php esc_html_e('复制链接', 'aksrt'); ?></span></button>
|
||||
<button type="button" class="share-item" data-platform="poster"><i class="fas fa-image"></i><span><?php esc_html_e('海报分享', 'aksrt'); ?></span></button>
|
||||
</div>
|
||||
<div id="share-qrcode-box" aria-hidden="true"><img id="share-qrcode-image" src="" alt="QR Code"></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_single_render_actions')) :
|
||||
/**
|
||||
* Like / reward / share / favorite row.
|
||||
@@ -228,18 +262,9 @@ if (!function_exists('aksrt_single_render_actions')) :
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($settings['share_enabled'])) : ?>
|
||||
<div class="share-dropdown" id="share-dropdown" aria-hidden="true">
|
||||
<div class="share-dropdown__grid">
|
||||
<button type="button" class="share-item" data-platform="qq"><i class="fab fa-qq"></i><span>QQ</span></button>
|
||||
<button type="button" class="share-item" data-platform="weibo"><i class="fab fa-weibo"></i><span>微博</span></button>
|
||||
<button type="button" class="share-item" data-platform="twitter"><i class="fab fa-x-twitter"></i><span>X</span></button>
|
||||
<button type="button" class="share-item" data-platform="wechat"><i class="fab fa-weixin"></i><span>微信</span></button>
|
||||
<button type="button" class="share-item" data-platform="copy"><i class="fas fa-link"></i><span><?php esc_html_e('复制链接', 'aksrt'); ?></span></button>
|
||||
<button type="button" class="share-item" data-platform="poster"><i class="fas fa-image"></i><span><?php esc_html_e('海报分享', 'aksrt'); ?></span></button>
|
||||
</div>
|
||||
<div id="share-qrcode-box" aria-hidden="true"><img id="share-qrcode-image" src="" alt="QR Code"></div>
|
||||
</div>
|
||||
<?php if (!empty($settings['share_enabled']) && function_exists('aksrt_render_share_dropdown')) : ?>
|
||||
<?php aksrt_render_share_dropdown();
|
||||
?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -323,6 +348,14 @@ if (!function_exists('aksrt_single_render_author_card')) :
|
||||
]);
|
||||
$is_self = is_user_logged_in() && get_current_user_id() === $author_id;
|
||||
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink());
|
||||
$aksrt_pm_on = class_exists('AKSRT_Settings') && !empty(AKSRT_Settings::private_message_settings()['enabled']);
|
||||
$aksrt_msg_url = function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '';
|
||||
$aksrt_post_settings = class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_post_page_settings')
|
||||
? AKSRT_Settings::get_post_page_settings()
|
||||
: [];
|
||||
$rewards_on = !empty($aksrt_post_settings['rewards_enabled'])
|
||||
|| !empty($aksrt_post_settings['post_rewards_enabled'])
|
||||
|| !empty($aksrt_post_settings['post_rewards_s']);
|
||||
?>
|
||||
<div class="user-card author zib-widget">
|
||||
<div class="card-content mt10 relative">
|
||||
@@ -350,6 +383,15 @@ if (!function_exists('aksrt_single_render_author_card')) :
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (!$is_self && is_user_logged_in() && $aksrt_pm_on && $aksrt_msg_url !== '') : ?>
|
||||
<a class="but pw-1em mr6 c-blue" href="<?php echo esc_url(add_query_arg('msg_type', 'conversation', $aksrt_msg_url)); ?>">
|
||||
<i class="fa fa-comment em09" aria-hidden="true"></i> <?php esc_html_e('私信', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php elseif (!$is_self && $rewards_on) : ?>
|
||||
<button type="button" class="but pw-1em mr6 c-yellow" data-aksrt-reward-open>
|
||||
<i class="fa fa-gift em09" aria-hidden="true"></i> <?php esc_html_e('赞赏', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<a class="but pw-1em mr6 jb-blue" href="<?php echo esc_url($author_url); ?>"><?php esc_html_e('个人主页', 'aksrt'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1387,6 +1387,14 @@ if (!function_exists('aksrt_render_footer_tabbar_single_extend')) :
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if ($share_on && function_exists('aksrt_render_share_dropdown')) {
|
||||
aksrt_render_share_dropdown([
|
||||
'title' => get_the_title($post_id),
|
||||
'url' => get_permalink($post_id) ?: '',
|
||||
'image' => get_the_post_thumbnail_url($post_id, 'large') ?: '',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($comments_open) :
|
||||
?>
|
||||
<a href="#comments"
|
||||
|
||||
Reference in New Issue
Block a user