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:
1 parent
de32c9ad35
commit
0298e6bba8
2 files changed
+62
-12
No files matched your search
@@ -182,6 +182,40 @@ if (!function_exists('aksrt_single_render_box_header')) :
|
|||||||
}
|
}
|
||||||
endif;
|
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')) :
|
if (!function_exists('aksrt_single_render_actions')) :
|
||||||
/**
|
/**
|
||||||
* Like / reward / share / favorite row.
|
* Like / reward / share / favorite row.
|
||||||
@@ -228,18 +262,9 @@ if (!function_exists('aksrt_single_render_actions')) :
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (!empty($settings['share_enabled'])) : ?>
|
<?php if (!empty($settings['share_enabled']) && function_exists('aksrt_render_share_dropdown')) : ?>
|
||||||
<div class="share-dropdown" id="share-dropdown" aria-hidden="true">
|
<?php aksrt_render_share_dropdown();
|
||||||
<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; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</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;
|
$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());
|
$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="user-card author zib-widget">
|
||||||
<div class="card-content mt10 relative">
|
<div class="card-content mt10 relative">
|
||||||
@@ -350,6 +383,15 @@ if (!function_exists('aksrt_single_render_author_card')) :
|
|||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?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>
|
<a class="but pw-1em mr6 jb-blue" href="<?php echo esc_url($author_url); ?>"><?php esc_html_e('个人主页', 'aksrt'); ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1387,6 +1387,14 @@ if (!function_exists('aksrt_render_footer_tabbar_single_extend')) :
|
|||||||
<?php
|
<?php
|
||||||
endif;
|
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) :
|
if ($comments_open) :
|
||||||
?>
|
?>
|
||||||
<a href="#comments"
|
<a href="#comments"
|
||||||
|
|||||||
Reference in new issue
Block a user