diff --git a/assets/css/frontend/widget-batch5.css b/assets/css/frontend/widget-batch5.css index 63f5d4e2..9ea93067 100644 --- a/assets/css/frontend/widget-batch5.css +++ b/assets/css/frontend/widget-batch5.css @@ -227,3 +227,81 @@ overflow: hidden; text-overflow: ellipsis; } + + +/* Icon cover cards */ +.aksrt-icon-cover { + display: grid; + grid-template-columns: repeat(var(--aksrt-icc-pc, 2), minmax(0, 1fr)); + gap: 10px; + --aksrt-icc-icon: 25px; +} +@media (max-width: 575.98px) { + .aksrt-icon-cover { + grid-template-columns: repeat(var(--aksrt-icc-m, 1), minmax(0, 1fr)); + } +} +.aksrt-icon-cover__item { + display: flex; + align-items: center; + gap: 10px; + padding: 12px; + border-radius: 12px; + border: 1px solid var(--color-line, #e5e7eb); + background: var(--surface-1, #fff); + text-decoration: none; + color: inherit; +} +.aksrt-icon-cover__icon { + width: calc(var(--aksrt-icc-icon) + 18px); + height: calc(var(--aksrt-icc-icon) + 18px); + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + font-size: var(--aksrt-icc-icon); + color: var(--color-primary, #3b82f6); + background: var(--surface-2, #f3f4f6); + flex-shrink: 0; + overflow: hidden; +} +.aksrt-icon-cover.is-radius .aksrt-icon-cover__icon { border-radius: 10px; } +.aksrt-icon-cover__icon img { width: 70%; height: 70%; object-fit: contain; } +.aksrt-icon-cover__title { font-weight: 700; font-size: 14px; } +.aksrt-icon-cover__desc { font-size: 12px; color: var(--muted-2-color, #888); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + +/* Bookmark links */ +.aksrt-bookmark-links { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 10px; +} +.aksrt-bookmark-links.has-box { + padding: 10px; + border: 1px solid var(--color-line, #e5e7eb); + border-radius: 12px; +} +.aksrt-bookmark-links.style-simple { + grid-template-columns: 1fr; +} +.aksrt-bookmark-links__item { + display: flex; + align-items: center; + gap: 10px; + padding: 8px; + border-radius: 10px; + background: var(--surface-2, #f8fafc); + text-decoration: none; + color: inherit; + min-width: 0; +} +.aksrt-bookmark-links__img { + width: 36px; + height: 36px; + border-radius: 8px; + object-fit: cover; + flex-shrink: 0; +} +.aksrt-bookmark-links__text { min-width: 0; display: flex; flex-direction: column; } +.aksrt-bookmark-links__name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.aksrt-bookmark-links__desc { font-size: 11px; color: var(--muted-2-color, #999); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } diff --git a/inc/modules/widgets-register.php b/inc/modules/widgets-register.php index b0390149..19a5e2bb 100644 --- a/inc/modules/widgets-register.php +++ b/inc/modules/widgets-register.php @@ -76,6 +76,8 @@ function aksrt_register_widgets() { register_widget('\AKSRT\Widgets\WidgetTiltCases'); register_widget('\AKSRT\Widgets\WidgetMainPosts'); register_widget('\AKSRT\Widgets\WidgetTermAggregation'); + register_widget('\AKSRT\Widgets\WidgetIconCoverCards'); + register_widget('\AKSRT\Widgets\WidgetBookmarkLinks'); // Forum widgets diff --git a/src/AKSRT/Widgets/WidgetBookmarkLinks.php b/src/AKSRT/Widgets/WidgetBookmarkLinks.php new file mode 100644 index 00000000..e3d900e0 --- /dev/null +++ b/src/AKSRT/Widgets/WidgetBookmarkLinks.php @@ -0,0 +1,161 @@ + esc_html__('WordPress 链接(书签)列表,适合友链/导航。', 'aksrt'), + 'classname' => 'widget_aksrt_bookmark_links', + ] + ); + } + + public function widget($args, $instance): void { + $limit = max(0, min(100, (int) ($instance['links_limit'] ?? 12))); + $orderby = sanitize_key((string) ($instance['links_orderby'] ?? 'name')); + if (!in_array($orderby, ['name', 'updated', 'rating', 'rand', 'id'], true)) { + $orderby = 'name'; + } + $order = strtoupper((string) ($instance['links_order'] ?? 'ASC')) === 'DESC' ? 'DESC' : 'ASC'; + $type = sanitize_key((string) ($instance['type'] ?? 'card')); + if (!in_array($type, ['card', 'image', 'simple'], true)) { + $type = 'card'; + } + $go_link = !empty($instance['go_link']); + $blank = !isset($instance['blank']) || !empty($instance['blank']); + $nofollow = !empty($instance['nofollow']); + $show_box = !empty($instance['show_box']); + + $bm_args = [ + 'orderby' => $orderby === 'rand' ? 'rand' : $orderby, + 'order' => $order, + 'limit' => $limit > 0 ? $limit : -1, + ]; + $cats = trim((string) ($instance['links_cats'] ?? '')); + if ($cats !== '' && $cats !== 'all') { + $bm_args['category'] = $cats; + } + $bookmarks = get_bookmarks($bm_args); + if (!$bookmarks) { + return; + } + + echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + $title = apply_filters('widget_title', (string) ($instance['title'] ?? ''), $instance, $this->id_base); + if ($title !== '') { + echo $args['before_title'] . esc_html($title) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } + + $wrap = 'aksrt-bookmark-links style-' . $type . ($show_box ? ' has-box' : ''); + echo '
+ +
++ +
++ +
++ +
++ + +
+
+
+
+
+
+
+ +
++ +
++ + + +
+
+
+
+