diff --git a/src/AKSRT/Core/WidgetAjax.php b/src/AKSRT/Core/WidgetAjax.php index 8e60cbbf..d1daa471 100644 --- a/src/AKSRT/Core/WidgetAjax.php +++ b/src/AKSRT/Core/WidgetAjax.php @@ -129,15 +129,31 @@ class WidgetAjax { if (function_exists('aksrt_home_widget_render_post_grid')) { aksrt_home_widget_render_post_grid($query, $layout, $columns, $context); } elseif ($query->have_posts()) { - echo ''; + } else { + echo function_exists('aksrt_get_ajax_null') + ? aksrt_get_ajax_null(__('暂无文章', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + : '

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

'; } wp_reset_postdata(); - return new \WP_REST_Response(['success' => true, 'html' => (string) ob_get_clean()], 200); + $html = (string) ob_get_clean(); + if ($html === '') { + $html = function_exists('aksrt_get_ajax_null') + ? aksrt_get_ajax_null(__('暂无文章', 'aksrt')) + : '

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

'; + } + return new \WP_REST_Response(['success' => true, 'html' => $html], 200); } public function rest_hot_posts(\WP_REST_Request $request) {