导入 AKSRT 主题开发源码
This commit is contained in:
1 parent
9681dd3d48
commit
1268a55dd0
595 files changed
+127705
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户页面共享辅助函数
|
||||
*
|
||||
* 分页渲染和空状态卡片,供本人中心和公开主页共用。
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (!function_exists('aksrt_render_profile_pagination')) {
|
||||
/**
|
||||
* 渲染分页
|
||||
*
|
||||
* @param int $total_pages 总页数
|
||||
* @param int $current 当前页
|
||||
* @param string $param URL 参数名
|
||||
*/
|
||||
function aksrt_render_profile_pagination($total_pages, $current, $param) {
|
||||
if ($total_pages <= 1) {
|
||||
return;
|
||||
}
|
||||
$base = remove_query_arg($param);
|
||||
$base = add_query_arg($param, '%#%', $base);
|
||||
$links = paginate_links([
|
||||
'base' => $base,
|
||||
'format' => '',
|
||||
'current' => $current,
|
||||
'total' => $total_pages,
|
||||
'prev_text' => '<span aria-hidden="true">‹</span><span class="screen-reader-text">' . esc_html__('上一页', 'aksrt') . '</span>',
|
||||
'next_text' => '<span aria-hidden="true">›</span><span class="screen-reader-text">' . esc_html__('下一页', 'aksrt') . '</span>',
|
||||
'mid_size' => 1,
|
||||
'end_size' => 1,
|
||||
]);
|
||||
if ($links) {
|
||||
echo '<nav class="profile-pagination" aria-label="' . esc_attr__('分页', 'aksrt') . '">' . $links . '</nav>'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_render_profile_empty')) {
|
||||
/**
|
||||
* 渲染空状态卡片
|
||||
*/
|
||||
function aksrt_render_profile_empty($icon_svg, $title, $desc = '', $cta_url = '', $cta_label = '') {
|
||||
echo '<div class="profile-empty">';
|
||||
echo '<div class="profile-empty__icon" aria-hidden="true">' . $icon_svg . '</div>'; // phpcs:ignore
|
||||
echo '<h4 class="profile-empty__title">' . esc_html($title) . '</h4>';
|
||||
if ($desc) {
|
||||
echo '<p class="profile-empty__desc">' . esc_html($desc) . '</p>';
|
||||
}
|
||||
if ($cta_url && $cta_label) {
|
||||
echo '<a class="btn-primary btn-sm profile-empty__cta" href="' . esc_url($cta_url) . '">' . esc_html($cta_label) . '</a>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user