diff --git a/assets/css/frontend/widget-batch5.css b/assets/css/frontend/widget-batch5.css index fcf64247..027d6884 100644 --- a/assets/css/frontend/widget-batch5.css +++ b/assets/css/frontend/widget-batch5.css @@ -2217,3 +2217,82 @@ a.main-color > .icon-cover-card:hover, width: 100vw; max-width: 100vw; } + +/* ===== Batch19-21: categories tree, hot meta, paid mini, main renderer, lang ===== */ + +.aksrt-cat-list.has-thumb .aksrt-cat-list__link, +.aksrt-cat-list.is-tree .aksrt-cat-list__link { + display: flex; + align-items: center; + gap: 10px; + text-decoration: none; + color: inherit; +} +.aksrt-cat-list__thumb { + width: 32px; + height: 32px; + border-radius: 8px; + overflow: hidden; + flex: 0 0 auto; + background: var(--surface-2, #f3f4f6); + display: inline-flex; + align-items: center; + justify-content: center; + color: #999; +} +.aksrt-cat-list__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; } +.aksrt-cat-list__text { min-width: 0; flex: 1; display: flex; flex-direction: column; } +.aksrt-cat-list__name { font-weight: 600; } +.aksrt-cat-list__desc { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.aksrt-cat-list__children { + list-style: none; + margin: 6px 0 0 18px; + padding: 0; + border-left: 2px solid var(--color-line, #e5e7eb); + padding-left: 10px; +} +.aksrt-cat-list .count { + margin-left: auto; + font-size: 12px; + color: var(--muted-2-color, #999); + background: var(--surface-2, #f3f4f6); + border-radius: 999px; + padding: 1px 8px; +} + +.aksrt-paid-posts__item.is-mini { + position: relative; + margin-bottom: 10px; +} +.aksrt-paid-posts__item.is-mini .aksrt-paid-posts__price.badge { + position: absolute; + top: 6px; + right: 6px; + z-index: 2; + background: rgba(239, 68, 68, .92); + color: #fff; + font-size: 11px; + padding: 2px 8px; + border-radius: 999px; +} + +.aksrt-lang-switch-widget.hide-name .aksrt-lang-switch__toggle span, +.aksrt-lang-switch-widget.hide-name .aksrt-lang-switch__item { + font-size: 0; +} +.aksrt-lang-switch-widget.hide-current .aksrt-lang-switch__item.is-active, +.aksrt-lang-switch-widget.hide-current .aksrt-lang-switch__flag.is-active { + display: none; +} +.aksrt-lang-switch-widget.style-inline .aksrt-lang-switch--flags { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.aksrt-forum-widget__item.is-top .aksrt-forum-widget__rank { + background: var(--theme-color, #f04494); + color: #fff; +} +.tag-cloud.aksrt-tag-cloud a { transition: transform .15s ease; } +.tag-cloud.aksrt-tag-cloud a:hover { transform: translateY(-1px); } diff --git a/src/AKSRT/Widgets/CategoriesWidget.php b/src/AKSRT/Widgets/CategoriesWidget.php index 5e412231..62e79ec8 100644 --- a/src/AKSRT/Widgets/CategoriesWidget.php +++ b/src/AKSRT/Widgets/CategoriesWidget.php @@ -1,6 +1,6 @@ esc_html__('以列表形式展示文章分类', 'aksrt'), 'customize_selective_refresh' => true, + 'classname' => 'widget_aksrt_categories', ] ); } @@ -37,6 +38,9 @@ class CategoriesWidget extends \WP_Widget { return array_values(array_unique($ids)); } + /** + * @param array $instance + */ public static function render_html(array $instance): string { $count = max(1, min(50, (int) ($instance['count'] ?? 8))); $orderby = sanitize_key((string) ($instance['orderby'] ?? 'count')); @@ -48,12 +52,14 @@ class CategoriesWidget extends \WP_Widget { $hierarchical = !empty($instance['hierarchical']); $parent = max(0, (int) ($instance['parent'] ?? 0)); $show_count = !isset($instance['show_count']) || !empty($instance['show_count']); + $show_desc = !empty($instance['show_desc']); + $show_thumb = !empty($instance['show_thumb']); $exclude = self::parse_ids_static((string) ($instance['exclude'] ?? '')); $include = self::parse_ids_static((string) ($instance['include'] ?? '')); $term_args = [ 'taxonomy' => 'category', - 'number' => $count, + 'number' => $hierarchical ? 0 : $count, 'orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, @@ -61,6 +67,8 @@ class CategoriesWidget extends \WP_Widget { ]; if ($parent > 0) { $term_args['parent'] = $parent; + } elseif ($hierarchical) { + $term_args['parent'] = 0; } if ($include) { $term_args['include'] = $include; @@ -79,19 +87,88 @@ class CategoriesWidget extends \WP_Widget { } ob_start(); - echo '