diff --git a/assets/css/frontend/widgets/part-2.css b/assets/css/frontend/widgets/part-2.css index 14337910..9cc4840d 100644 --- a/assets/css/frontend/widgets/part-2.css +++ b/assets/css/frontend/widgets/part-2.css @@ -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; +} diff --git a/assets/img/null.svg b/assets/img/null.svg new file mode 100644 index 00000000..d6dd55b1 --- /dev/null +++ b/assets/img/null.svg @@ -0,0 +1,9 @@ + diff --git a/inc/bootstrap.php b/inc/bootstrap.php index e5573087..2b383295 100644 --- a/inc/bootstrap.php +++ b/inc/bootstrap.php @@ -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'; diff --git a/inc/classes/class-aksrt-widgets-batch1.php b/inc/classes/class-aksrt-widgets-batch1.php index 22e558c8..50e6d6f4 100644 --- a/inc/classes/class-aksrt-widgets-batch1.php +++ b/inc/classes/class-aksrt-widgets-batch1.php @@ -192,7 +192,7 @@ class AKSRT_Recent_Comments_Widget extends WP_Widget { -

+ ' . esc_html__('暂无评论', 'aksrt') . '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> -

+ ' . esc_html__('暂无友情链接', 'aksrt') . '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> '; wp_reset_postdata(); } else { - echo '

' . esc_html__('暂无热门文章', 'aksrt') . '

'; + echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无热门文章', 'aksrt')) : '

' . esc_html__('暂无热门文章', 'aksrt') . '

'; } echo $args['after_widget']; @@ -360,7 +360,7 @@ class AKSRT_Tab_Posts_Widget extends WP_Widget { -

+ ' . esc_html__('暂无文章', 'aksrt') . '

'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> diff --git a/inc/classes/widgets/class-aksrt-home-widgets.php b/inc/classes/widgets/class-aksrt-home-widgets.php index aaf55950..78a9e722 100644 --- a/inc/classes/widgets/class-aksrt-home-widgets.php +++ b/inc/classes/widgets/class-aksrt-home-widgets.php @@ -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 '

' . esc_html__('暂无内容', 'aksrt') . '

'; + echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无内容', 'aksrt')) : '

' . esc_html__('暂无内容', 'aksrt') . '

'; wp_reset_postdata(); return; } @@ -464,7 +464,7 @@ class AKSRT_Category_Tabs_Widget extends WP_Widget { echo '
'; if (empty($tabs)) { - echo '

' . esc_html__('暂无可用分类', 'aksrt') . '

'; + echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无可用分类', 'aksrt')) : '

' . esc_html__('暂无可用分类', 'aksrt') . '

'; echo '
'; 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 '

' . esc_html__('暂无推荐分类', 'aksrt') . '

'; + echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无推荐分类', 'aksrt')) : '

' . esc_html__('暂无推荐分类', 'aksrt') . '

'; echo ''; echo $args['after_widget']; return; diff --git a/inc/helpers/aksrt-comments.php b/inc/helpers/aksrt-comments.php index de3de7eb..cb94a64c 100644 --- a/inc/helpers/aksrt-comments.php +++ b/inc/helpers/aksrt-comments.php @@ -571,12 +571,18 @@ if (!function_exists('aksrt_comments_render_empty')) : * @param array $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 '

' . esc_html__('成为第一个评论者吧', 'aksrt') . '

'; + return; + } ?>
-

+

' . esc_html((string) $text) . '

' + : ''; + 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 '
' + . '' + . $caption + . '
'; + } +} + +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); + } +} diff --git a/inc/helpers/aksrt-single-render.php b/inc/helpers/aksrt-single-render.php index 2b5b04b7..5996da6b 100644 --- a/inc/helpers/aksrt-single-render.php +++ b/inc/helpers/aksrt-single-render.php @@ -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' : ''); + ?> +
+
+
+
+
+ +
+
+ "> - + + + + + +