feat(frontend): illustrated null states and author rewards fallback
Add aksrt_get_null / widget null helpers with null.svg, use them in sidebar widgets, comments empty, and related posts; when PM is off show post rewards entry on the single author bar.
This commit is contained in:
@@ -298,3 +298,15 @@
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
|
||||
|
||||
.aksrt-null--widget {
|
||||
padding: 12px 0 !important;
|
||||
}
|
||||
.aksrt-null--widget .aksrt-null__img {
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
}
|
||||
.aksrt-null .separator {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="280" height="200" viewBox="0 0 280 200" fill="none" aria-hidden="true">
|
||||
<rect width="280" height="200" fill="transparent"/>
|
||||
<ellipse cx="140" cy="168" rx="72" ry="10" fill="#E8E8E8" opacity=".55"/>
|
||||
<rect x="78" y="58" width="124" height="96" rx="14" fill="#F3F4F6" stroke="#D1D5DB" stroke-width="2"/>
|
||||
<path d="M98 92h84M98 110h62M98 128h48" stroke="#C4C9D1" stroke-width="6" stroke-linecap="round"/>
|
||||
<circle cx="188" cy="70" r="22" fill="#FFF7ED" stroke="#FDBA74" stroke-width="2"/>
|
||||
<path d="M188 60v12M182 72h12" stroke="#F59E0B" stroke-width="3" stroke-linecap="round"/>
|
||||
<path d="M104 48c8-14 28-18 40-8" stroke="#9CA3AF" stroke-width="3" stroke-linecap="round" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 746 B |
@@ -43,6 +43,7 @@ require_once AKSRT_DIR . '/inc/helpers/aksrt-resource.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-pay.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-coupon-order.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-credits.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-null.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/menu-decoration.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/class-aksrt-nav-walker.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-transactions.php';
|
||||
|
||||
@@ -192,7 +192,7 @@ class AKSRT_Recent_Comments_Widget extends WP_Widget {
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<p class="widget-empty"><?php esc_html_e('暂无评论', 'aksrt'); ?></p>
|
||||
<?php echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无评论', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无评论', 'aksrt') . '</p>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif;
|
||||
|
||||
echo $args['after_widget'];
|
||||
@@ -263,7 +263,7 @@ class AKSRT_Friend_Links_Widget extends WP_Widget {
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<p class="widget-empty"><?php esc_html_e('暂无友情链接', 'aksrt'); ?></p>
|
||||
<?php echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无友情链接', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无友情链接', 'aksrt') . '</p>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif;
|
||||
|
||||
echo $args['after_widget'];
|
||||
|
||||
@@ -107,7 +107,7 @@ class AKSRT_Hot_Posts_Widget extends WP_Widget {
|
||||
echo '</div>';
|
||||
wp_reset_postdata();
|
||||
} else {
|
||||
echo '<p class="widget-empty">' . esc_html__('暂无热门文章', 'aksrt') . '</p>';
|
||||
echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无热门文章', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无热门文章', 'aksrt') . '</p>';
|
||||
}
|
||||
|
||||
echo $args['after_widget'];
|
||||
@@ -360,7 +360,7 @@ class AKSRT_Tab_Posts_Widget extends WP_Widget {
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<p class="widget-empty"><?php esc_html_e('暂无文章', 'aksrt'); ?></p>
|
||||
<?php echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无文章', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无文章', 'aksrt') . '</p>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php wp_reset_postdata(); $first = false; endforeach; ?>
|
||||
|
||||
@@ -189,7 +189,7 @@ if (!function_exists('aksrt_home_widget_render_post_grid')) {
|
||||
*/
|
||||
function aksrt_home_widget_render_post_grid(WP_Query $query, string $layout = 'card', int $columns = 3, string $context = 'homepage'): void {
|
||||
if (!$query->have_posts()) {
|
||||
echo '<p class="widget-empty">' . esc_html__('暂无内容', 'aksrt') . '</p>';
|
||||
echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无内容', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无内容', 'aksrt') . '</p>';
|
||||
wp_reset_postdata();
|
||||
return;
|
||||
}
|
||||
@@ -464,7 +464,7 @@ class AKSRT_Category_Tabs_Widget extends WP_Widget {
|
||||
echo '<section class="aksrt-home-widget aksrt-home-widget--tabs widget-tab-posts">';
|
||||
|
||||
if (empty($tabs)) {
|
||||
echo '<p class="widget-empty">' . esc_html__('暂无可用分类', 'aksrt') . '</p>';
|
||||
echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无可用分类', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无可用分类', 'aksrt') . '</p>';
|
||||
echo '</section>';
|
||||
echo $args['after_widget'];
|
||||
return;
|
||||
@@ -649,7 +649,7 @@ class AKSRT_Category_Recommend_Widget extends WP_Widget {
|
||||
aksrt_home_widget_render_header($title);
|
||||
|
||||
if (empty($cards)) {
|
||||
echo '<p class="widget-empty">' . esc_html__('暂无推荐分类', 'aksrt') . '</p>';
|
||||
echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无推荐分类', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无推荐分类', 'aksrt') . '</p>';
|
||||
echo '</section>';
|
||||
echo $args['after_widget'];
|
||||
return;
|
||||
|
||||
@@ -571,12 +571,18 @@ if (!function_exists('aksrt_comments_render_empty')) :
|
||||
* @param array<string,mixed> $ctx Comments context.
|
||||
*/
|
||||
function aksrt_comments_render_empty(array $ctx): void {
|
||||
$text = (string) ($ctx['empty_text'] ?? __('暂无评论内容', 'aksrt'));
|
||||
if (function_exists('aksrt_get_null')) {
|
||||
echo aksrt_get_null($text, 40, 'null.svg', 'comment comment-null comments-empty', 220); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<p class="comments-empty__hint muted-3-color em09 text-center" style="margin-top:-20px;">' . esc_html__('成为第一个评论者吧', 'aksrt') . '</p>';
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="comments-empty post_ajax_loader">
|
||||
<div class="comments-empty__icon">
|
||||
<i class="far fa-comment-dots"></i>
|
||||
</div>
|
||||
<p class="comments-empty__text"><?php echo esc_html((string) $ctx['empty_text']); ?></p>
|
||||
<p class="comments-empty__text"><?php echo esc_html($text); ?></p>
|
||||
<p class="comments-empty__hint"><?php esc_html_e('成为第一个评论者吧', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Illustrated empty / null state helpers (Zibll zib_get_null parity).
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (!function_exists('aksrt_null_image_url')) {
|
||||
/**
|
||||
* Prefer theme null illustration; fall back to placeholder.
|
||||
*/
|
||||
function aksrt_null_image_url(string $file = 'null.svg'): string {
|
||||
$file = sanitize_file_name($file);
|
||||
if ($file === '') {
|
||||
$file = 'null.svg';
|
||||
}
|
||||
$candidates = [
|
||||
'/assets/img/' . $file,
|
||||
'/img/' . $file,
|
||||
'/assets/img/placeholder.svg',
|
||||
];
|
||||
foreach ($candidates as $rel) {
|
||||
$path = get_template_directory() . $rel;
|
||||
if (is_readable($path)) {
|
||||
return get_template_directory_uri() . $rel;
|
||||
}
|
||||
}
|
||||
return get_template_directory_uri() . '/assets/img/placeholder.svg';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_get_null')) {
|
||||
/**
|
||||
* Zibll-like empty illustration block.
|
||||
*
|
||||
* @param string|null $text Caption (null → 暂无内容).
|
||||
* @param int|string $margin Vertical padding / top margin.
|
||||
* @param string $img Image file under assets/img.
|
||||
* @param string $class Extra class on wrapper.
|
||||
* @param int $width Image max width.
|
||||
* @param int $height Optional fixed height.
|
||||
*/
|
||||
function aksrt_get_null($text = null, $margin = 60, string $img = 'null.svg', string $class = '', int $width = 280, int $height = 0): string {
|
||||
if (null === $text) {
|
||||
$text = __('暂无内容', 'aksrt');
|
||||
}
|
||||
$margin = is_numeric($margin) ? (string) $margin : '60';
|
||||
$caption = $text !== ''
|
||||
? '<p style="margin-top:' . esc_attr($margin) . 'px;" class="em09 muted-3-color separator">' . esc_html((string) $text) . '</p>'
|
||||
: '';
|
||||
if ($height > 0) {
|
||||
$style = $width > 0 ? 'max-width:' . (int) $width . 'px;' : '';
|
||||
$style .= 'height:' . (int) $height . 'px;';
|
||||
} else {
|
||||
$style = $width > 0 ? 'width:' . (int) $width . 'px;' : '';
|
||||
}
|
||||
$style .= 'opacity:.7;';
|
||||
$src = aksrt_null_image_url($img);
|
||||
return '<div class="text-center aksrt-null ' . esc_attr($class) . '" style="padding:' . esc_attr($margin) . 'px 0;">'
|
||||
. '<img class="no-imgbox aksrt-null__img" style="' . esc_attr($style) . '" src="' . esc_url($src) . '" alt="" loading="lazy" decoding="async">'
|
||||
. $caption
|
||||
. '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_get_widget_null')) {
|
||||
/**
|
||||
* Compact null for sidebar widgets.
|
||||
*/
|
||||
function aksrt_get_widget_null(string $text = '', int $margin = 24, int $width = 140): string {
|
||||
if ($text === '') {
|
||||
$text = __('暂无内容', 'aksrt');
|
||||
}
|
||||
return aksrt_get_null($text, $margin, 'null.svg', 'widget-empty aksrt-null--widget', $width);
|
||||
}
|
||||
}
|
||||
@@ -555,6 +555,17 @@ if (!function_exists('aksrt_single_render_related')) :
|
||||
$query = new WP_Query($args);
|
||||
if (!$query->have_posts()) {
|
||||
wp_reset_postdata();
|
||||
$empty_wrap = 'theme-box relates' . ($style === 'img' ? ' relates-thumb' : '');
|
||||
?>
|
||||
<div class="<?php echo esc_attr($empty_wrap); ?>">
|
||||
<div class="box-body notop">
|
||||
<div class="title-theme"><?php echo esc_html($title); ?></div>
|
||||
</div>
|
||||
<div class="zib-widget">
|
||||
<?php echo function_exists('aksrt_get_null') ? aksrt_get_null(__('暂无相关文章', 'aksrt'), 40, 'null.svg', 'related-null', 220) : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,10 +100,24 @@ if (class_exists('AKSRT_User_Home')) {
|
||||
<button type="button" class="px12-sm ml10 follow but c-red" data-aksrt-follow="<?php echo (int) $author_id; ?>">
|
||||
<i class="fa fa-heart em09" aria-hidden="true"></i> <?php esc_html_e('关注', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php if ($aksrt_pm_on && $aksrt_msg_url !== '') : ?>
|
||||
<?php if ($aksrt_pm_on && $aksrt_msg_url !== '') : ?>
|
||||
<a href="<?php echo esc_url(add_query_arg('msg_type', 'conversation', $aksrt_msg_url)); ?>" class="ml6 but c-blue px12-sm">
|
||||
<i class="fa fa-comment em09" aria-hidden="true"></i> <?php esc_html_e('私信', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
$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']);
|
||||
?>
|
||||
<?php if ($rewards_on) : ?>
|
||||
<button type="button" class="ml6 but c-yellow px12-sm" data-aksrt-reward-open>
|
||||
<i class="fa fa-gift em09" aria-hidden="true"></i> <?php esc_html_e('赞赏', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo esc_url($login_url); ?>" class="px12-sm ml10 follow but c-red">
|
||||
|
||||
Reference in New Issue
Block a user