feat(share): align social sharing runtime

This commit is contained in:
kate522 committed 2026-09-27 13:49:32 +08:00
1 parent 26ac8167f3
commit cf6c11852e
33 files changed
+802 -1919

No files matched your search

+2 -44
View File
@@ -178,40 +178,6 @@ 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="fa fab fa-qq"></i><span>QQ</span></button>
<button type="button" class="share-item" data-platform="weibo"><i class="fa fab fa-weibo"></i><span>微博</span></button>
<button type="button" class="share-item" data-platform="twitter"><i class="fa fab fa-twitter"></i><span>X</span></button>
<button type="button" class="share-item" data-platform="wechat"><i class="fa fab fa-weixin"></i><span>微信</span></button>
<button type="button" class="share-item" data-platform="copy"><i class="fa fas fa-link"></i><span><?php esc_html_e('复制链接', 'aksrt'); ?></span></button>
<button type="button" class="share-item" data-platform="poster"><i class="fa 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.
@@ -247,11 +213,8 @@ if (!function_exists('aksrt_single_render_actions')) :
}
?>
<?php if (!empty($settings['share_enabled'])) : ?>
<button type="button" class="action action-share" id="action-share-trigger" aria-haspopup="true" aria-expanded="false">
<i class="fa fas fa-share-alt" aria-hidden="true"></i>
<span class="action-btn__label"><?php esc_html_e('分享', 'aksrt'); ?></span>
</button>
<?php if (!empty($settings['share_enabled']) && function_exists('aksrt_get_post_share_btn')) : ?>
<?php echo aksrt_get_post_share_btn($post_id, 'action action-share'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php endif; ?>
<?php if (!empty($settings['favorite_enabled'])) : ?>
@@ -261,11 +224,6 @@ if (!function_exists('aksrt_single_render_actions')) :
</button>
<?php endif; ?>
</div>
<?php if (!empty($settings['share_enabled']) && function_exists('aksrt_render_share_dropdown')) : ?>
<?php aksrt_render_share_dropdown();
?>
<?php endif; ?>
</div>
<?php