fix(widgets): restore single-card reference UI for search and quote widgets

The 搜索框 and 一言 sidebar widgets fell into the generic renderer branch, so
they rendered a .jio-panel card wrapping a second bespoke card
(.jio-widget-search / .jio-widget-quote). In-article 一言 also used
divergent modifier classes and an extra hover rule.

- search: render through the shared jio_get_search_box() (legacy keyword,
  history and category pickers) inside one reference card, mirroring the
  reference widget's markup and title default 「搜索」
- quote: render the reference .yiyan-box card itself as the click root; the
  shell now emits only the reference widget-container/title wrapper
- article 一言: adopt the reference class lists for header, footer and the
  standalone after-article box; drop the invented yiyan--* modifiers and
  the duplicate hover/opacity rules
- client: fill .cn/.en in the reference order (first line .cn, second .en)
  and drop the stale window.JioYiyan bridge plus the dead qv-yiyan.php AJAX
  path in runtime main.js
- schema: replace the ad-hoc search_style radio with the reference switches
  (keywords, history, input category, more_cats) and default title
- assets: enqueue assets/js/yiyan.js through the quote widget's asset list

Tests: widget-system suite 820/821 (the one failure is the pre-existing
frontend-lifecycle theme-init stub); new search/quote card contracts pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-03 15:56:52 +08:00
1 parent 1549d5b25d
commit f80ca1e27d
19 files changed
+276 -182

No files matched your search

+5 -6
View File
@@ -249,7 +249,7 @@ if (!function_exists('jio_single_render_content_footer')) :
<?php if (!empty($settings['yiyan_footer'])) : ?>
<?php
jio_render_yiyan_block([
'class' => 'article-yiyan yiyan-box jio-yiyan yiyan--footer',
'class' => 'article-yiyan theme-box text-center radius8 main-shadow yiyan-box jio-yiyan',
]);
?>
<?php endif; ?>
@@ -604,7 +604,7 @@ if (!function_exists('jio_single_render_article')) :
<?php if (!empty($settings['yiyan_header'])) : ?>
<?php
jio_render_yiyan_block([
'class' => 'article-yiyan yiyan-box jio-yiyan yiyan--header theme-box text-center radius8 main-shadow',
'class' => 'article-yiyan theme-box text-center radius8 main-shadow yiyan-box jio-yiyan',
]);
?>
<?php endif; ?>
@@ -662,10 +662,9 @@ if (!function_exists('jio_single_render_after_box')) :
'class' => 'yiyan-box main-bg theme-box text-center box-body radius8 main-shadow jio-yiyan',
]);
}
if (!empty($settings['authordesc'])) {
jio_single_render_author_card($ctx);
}
if (!empty($settings['authordesc'])) {
jio_single_render_author_card($ctx);
}
jio_single_render_prevnext($ctx);
jio_single_render_related($ctx);
+2 -1
View File
@@ -60,6 +60,7 @@ if (!function_exists('jio_render_yiyan_block')) :
if (strpos($class, 'jio-yiyan') === false) {
$class = trim($class . ' jio-yiyan');
}
// 与参考结构一致:.yiyan 初始为空,由脚本写入 .cn(首行)与 .en(次行)。
$html = '<div class="' . esc_attr($class) . '"'
. ' data-jio-yiyan'
. ' data-endpoint="' . esc_url(admin_url('admin-ajax.php')) . '"'
@@ -68,7 +69,7 @@ if (!function_exists('jio_render_yiyan_block')) :
. ' role="button" tabindex="0"'
. ' aria-label="' . esc_attr__('点击切换一言', 'jio') . '"'
. ' aria-live="polite">'
. '<div class="yiyan"><div class="en"></div><div class="cn">' . esc_html__('加载中…', 'jio') . '</div></div>'
. '<div class="yiyan"></div>'
. '</div>';
return $html;
}
+26 -46
View File
@@ -300,63 +300,43 @@ if (!function_exists('jio_get_search_box')) :
// Popular keywords.
$keywords_html = '';
if (!empty($args['show_keywords'])) {
$show = true;
if (class_exists('\Jio\Settings\Settings') && method_exists('\Jio\Settings\Settings', 'hot_search_enabled')) {
$show = (bool) \Jio\Settings\Settings::hot_search_enabled();
}
if ($show) {
$keywords = function_exists('jio_get_search_hot_keywords') ? jio_get_search_hot_keywords() : [];
$limit = (int) $args['popular_limit'];
$keyword_link = jio_get_search_keywords_but(is_array($keywords) ? $keywords : [], 'popular', $limit);
if ($keyword_link !== '') {
$keywords_html = '<div class="search-keywords">'
. '<p class="muted-color"><span>' . esc_html((string) $args['keywords_title']) . '</span></p>'
. '<div>' . $keyword_link . '</div>'
. '</div>';
}
$keywords = function_exists('jio_get_search_hot_keywords') ? jio_get_search_hot_keywords() : [];
$limit = (int) $args['popular_limit'];
$keyword_link = jio_get_search_keywords_but(is_array($keywords) ? $keywords : [], 'popular', $limit);
if ($keyword_link !== '') {
$keywords_html = '<div class="search-keywords">'
. '<p class="muted-color"><span>' . esc_html((string) $args['keywords_title']) . '</span></p>'
. '<div>' . $keyword_link . '</div>'
. '</div>';
}
}
// History.
$history_html = '';
if (!empty($args['show_history'])) {
$show_h = true;
if (function_exists('jio_search_history_enabled')) {
$show_h = jio_search_history_enabled();
} elseif (class_exists('\Jio\Settings\Settings') && method_exists('\Jio\Settings\Settings', 'search_history_enabled')) {
$show_h = (bool) \Jio\Settings\Settings::search_history_enabled();
}
if ($show_h) {
$hist = jio_get_search_history_keywords();
$keyword_link = jio_get_search_keywords_but($hist, 'history');
if ($keyword_link !== '') {
$history_html = '<div class="search-keywords history-search">';
$history_html .= '<p class="muted-color"><span>' . esc_html__('历史搜索', 'jio') . '</span>';
$history_html .= '<a class="pull-right trash-history-search muted-3-color" href="javascript:;" data-cookie-path="'
. esc_attr(COOKIEPATH ?: '/') . '" data-cookie-domain="' . esc_attr(COOKIE_DOMAIN) . '" aria-label="'
. esc_attr__('清空历史', 'jio') . '"><i class="fa fas fa-trash-alt em12" aria-hidden="true"></i></a></p>';
$history_html .= '<div>' . $keyword_link . '</div></div>';
}
$hist = jio_get_search_history_keywords();
$keyword_link = jio_get_search_keywords_but($hist, 'history');
if ($keyword_link !== '') {
$history_html = '<div class="search-keywords history-search">';
$history_html .= '<p class="muted-color"><span>' . esc_html__('历史搜索', 'jio') . '</span>';
$history_html .= '<a class="pull-right trash-history-search muted-3-color" href="javascript:;" data-cookie-path="'
. esc_attr(COOKIEPATH ?: '/') . '" data-cookie-domain="' . esc_attr(COOKIE_DOMAIN) . '" aria-label="'
. esc_attr__('清空历史', 'jio') . '"><i class="fa fas fa-trash-alt em12" aria-hidden="true"></i></a></p>';
$history_html .= '<div>' . $keyword_link . '</div></div>';
}
}
// Hot posts (thumb swiper).
$posts_html = '';
if (!empty($args['show_posts'])) {
$show_p = true;
if (class_exists('\Jio\Settings\Settings') && method_exists('\Jio\Settings\Settings', 'search_posts_enabled')) {
$show_p = (bool) \Jio\Settings\Settings::search_posts_enabled();
}
if ($show_p && function_exists('jio_get_search_posts')) {
$slides = jio_get_search_posts(6, 'views', true);
if ($slides !== '') {
$posts_html = '<div class="padding-10 relates relates-thumb">';
$posts_html .= '<p class="muted-color">' . esc_html__('热门文章', 'jio') . '</p>';
$posts_html .= '<div class="swiper-container swiper-scroll">';
$posts_html .= '<div class="swiper-wrapper">' . $slides . '</div>';
$posts_html .= '<div class="swiper-button-prev"></div><div class="swiper-button-next"></div>';
$posts_html .= '</div></div>';
}
if (!empty($args['show_posts']) && function_exists('jio_get_search_posts')) {
$slides = jio_get_search_posts(6, 'views', true);
if ($slides !== '') {
$posts_html = '<div class="padding-10 relates relates-thumb">';
$posts_html .= '<p class="muted-color">' . esc_html__('热门文章', 'jio') . '</p>';
$posts_html .= '<div class="swiper-container swiper-scroll">';
$posts_html .= '<div class="swiper-wrapper">' . $slides . '</div>';
$posts_html .= '<div class="swiper-button-prev"></div><div class="swiper-button-next"></div>';
$posts_html .= '</div></div>';
}
}