From 9be0018a1ec8a1f952e8bb020657ba719e0340db Mon Sep 17 00:00:00 2001 From: Yaosanqi137 Date: Sat, 7 Mar 2026 15:39:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=A0=E5=85=A5=E6=88=91?= =?UTF-8?q?=E4=BB=AC=E5=BD=95=E5=8F=96=E8=BF=9B=E5=BA=A6=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加文章详情页文章筛选方式 用户点击文章标签时自动筛选出对应标签文章 --- archive.php | 138 ++++++++++++++++++++++++++++++++---- assets/css/content.css | 92 +++++++++++++++++++++--- assets/css/join-page.css | 148 +++++++++++++++++++++++++++++++++------ functions.php | 113 ++++++++++++++++++++++++++++-- page-join.php | 7 +- single.php | 11 ++- 6 files changed, 456 insertions(+), 53 deletions(-) diff --git a/archive.php b/archive.php index 9babd18..8712de3 100644 --- a/archive.php +++ b/archive.php @@ -10,11 +10,14 @@ $is_itstudio_content_page = $is_itstudio_news_page || $is_itstudio_notice_page; true, + 'column' => 'post_date', + ); + if ($date_from_valid !== '') { + $range['after'] = $date_from_valid; + } + if ($date_to_valid !== '') { + $range['before'] = $date_to_valid; + } + $date_query[] = $range; +} + +if ($tag_slug !== '') { + $resolved_tag = get_term_by('slug', $tag_slug, 'post_tag'); + if (!($resolved_tag instanceof WP_Term)) { + $tag_slug = ''; + } +} + +$available_tags = get_terms(array( + 'taxonomy' => 'post_tag', + 'hide_empty' => true, + 'orderby' => 'name', + 'order' => 'ASC', +)); +if (is_wp_error($available_tags)) { + $available_tags = array(); +} + +$list_query_args = array( 'post_type' => $active_post_type, 'post_status' => 'publish', 'posts_per_page' => 10, 'paged' => $paged, - 's' => $keyword, 'ignore_sticky_posts' => true, 'orderby' => 'date', 'order' => 'DESC', -)); + 'suppress_filters' => false, +); +if ($keyword !== '') { + $list_query_args['itstudio_archive_extend_search'] = true; + $list_query_args['itstudio_archive_keyword'] = $keyword; +} +if (!empty($date_query)) { + $list_query_args['date_query'] = $date_query; +} +if ($tag_slug !== '') { + $list_query_args['tax_query'] = array( + array( + 'taxonomy' => 'post_tag', + 'field' => 'slug', + 'terms' => array($tag_slug), + ), + ); +} + +$list_query = new WP_Query($list_query_args); $featured_query = new WP_Query(array( 'post_type' => $active_post_type, @@ -75,23 +136,59 @@ $featured_ids = array_slice(array_values(array_unique($featured_ids)), 0, 4);

-
+
+
+ + + +
+ + + +
+ +
+
-
have_posts()) : ?> @@ -138,8 +235,15 @@ $featured_ids = array_slice(array_values(array_unique($featured_ids)), 0, 4); - - + + @@ -175,6 +279,9 @@ $featured_ids = array_slice(array_values(array_unique($featured_ids)), 0, 4); 'add_args' => array_filter( array( 'q' => $keyword, + 'date_from' => $date_from, + 'date_to' => $date_to, + 'tag' => $tag_slug, ), static function ($value) { return $value !== ''; @@ -305,3 +412,4 @@ $featured_ids = array_slice(array_values(array_unique($featured_ids)), 0, 4); + diff --git a/assets/css/content.css b/assets/css/content.css index 5e985ac..031a887 100644 --- a/assets/css/content.css +++ b/assets/css/content.css @@ -637,21 +637,75 @@ .news-archive-tools { margin-top: 14px; display: grid; - grid-template-columns: 1fr minmax(240px, 320px); + grid-template-columns: minmax(0, 1fr) minmax(260px, 380px); gap: 12px; - align-items: center; + align-items: end; } -.news-archive-tools-single { - grid-template-columns: minmax(240px, 420px); - justify-content: end; - margin-left: auto; +.news-archive-filter-form { + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + gap: 8px; + align-items: end; +} + +.news-archive-filter-fields { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 8px; +} + +.news-archive-filter-field { + display: grid; + gap: 4px; +} + +.news-archive-filter-field span { + font-size: 0.72rem; + color: var(--text-secondary); + font-family: var(--font-mono); +} + +.news-archive-filter-form input[type="date"], +.news-archive-filter-form select { + width: 100%; + height: 36px; + border: 1px solid var(--border-default); + border-radius: var(--radius-sm); + background: transparent; + color: var(--text-primary); + padding: 0 11px; + font-size: 0.85rem; +} + +.news-archive-filter-form input[type="date"]:focus, +.news-archive-filter-form select:focus { + outline: none; + border-color: var(--color-primary); +} + +.news-archive-filter-form button { + height: 36px; + padding: 0 12px; + border: 1px solid var(--border-default); + border-radius: var(--radius-sm); + background: transparent; + color: var(--text-primary); + font-size: 0.86rem; + font-weight: 600; + cursor: pointer; +} + +.news-archive-filter-form button:hover { + border-color: var(--color-primary); + color: var(--color-primary); } .news-archive-search { display: grid; grid-template-columns: 1fr auto; gap: 8px; + align-self: end; } .news-archive-search input[type="search"] { @@ -687,6 +741,24 @@ color: var(--color-primary); } +html:not([data-theme="dark"]) .news-archive-filter-form input[type="date"], +html:not([data-theme="dark"]) .news-archive-filter-form select { + color-scheme: light; +} + +[data-theme="dark"] .news-archive-filter-form input[type="date"], +[data-theme="dark"] .news-archive-filter-form select { + background: color-mix(in srgb, var(--bg-card) 92%, #000 8%); + color: var(--text-primary); + color-scheme: dark; +} + +[data-theme="dark"] .news-archive-filter-form select option, +[data-theme="dark"] .news-archive-filter-form select optgroup { + background-color: #0f1724; + color: var(--text-primary); +} + .news-archive-layout { margin-top: 22px; display: grid; @@ -1005,9 +1077,13 @@ grid-template-columns: 1fr; } - .news-archive-tools-single { + .news-archive-filter-form { + grid-template-columns: 1fr; + align-items: stretch; + } + + .news-archive-filter-fields { grid-template-columns: 1fr; - margin-left: 0; } .news-archive-search { diff --git a/assets/css/join-page.css b/assets/css/join-page.css index ef93e1d..4bb1695 100644 --- a/assets/css/join-page.css +++ b/assets/css/join-page.css @@ -660,15 +660,72 @@ } .join-form-card { - border: 1px solid color-mix(in srgb, var(--border-default) 86%, transparent); - border-radius: 14px; - background: linear-gradient( - 145deg, - color-mix(in srgb, var(--bg-card) 82%, #1b2430 18%) 0%, - color-mix(in srgb, var(--bg-card) 94%, transparent) 100% - ); + position: relative; + overflow: hidden; + border: 1px solid color-mix(in srgb, var(--color-primary) 28%, var(--border-default) 72%); + border-radius: 6px; + background: + linear-gradient( + 118deg, + color-mix(in srgb, var(--color-primary) 12%, transparent) 0%, + transparent 36% + ), + radial-gradient( + 120% 80% at 100% 0%, + color-mix(in srgb, var(--color-primary) 14%, transparent) 0%, + transparent 52% + ), + linear-gradient( + 180deg, + color-mix(in srgb, var(--bg-card) 84%, #0f1a2b 16%) 0%, + color-mix(in srgb, var(--bg-card) 95%, transparent) 100% + ); padding: 18px; - box-shadow: 0 16px 30px -24px color-mix(in srgb, #000000 65%, transparent); + box-shadow: + 0 22px 40px -32px color-mix(in srgb, #000000 78%, transparent), + inset 0 1px 0 color-mix(in srgb, #9bc9ff 18%, transparent), + inset 0 -1px 0 color-mix(in srgb, #0a101a 70%, transparent); +} + +.join-form-card::before { + content: ""; + position: absolute; + inset: 0; + pointer-events: none; + background: + repeating-linear-gradient( + 0deg, + color-mix(in srgb, var(--color-primary) 8%, transparent) 0 1px, + transparent 1px 13px + ), + repeating-linear-gradient( + 90deg, + color-mix(in srgb, var(--color-primary) 7%, transparent) 0 1px, + transparent 1px 18px + ); + opacity: 0.26; +} + +.join-form-card::after { + content: ""; + position: absolute; + inset: 10px; + pointer-events: none; + background: + linear-gradient(90deg, color-mix(in srgb, var(--color-primary) 72%, transparent), transparent) + top left / 88px 1px no-repeat, + linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 72%, transparent), transparent) + top left / 1px 44px no-repeat, + linear-gradient(270deg, color-mix(in srgb, var(--color-primary) 48%, transparent), transparent) + bottom right / 66px 1px no-repeat, + linear-gradient(0deg, color-mix(in srgb, var(--color-primary) 48%, transparent), transparent) + bottom right / 1px 30px no-repeat; + opacity: 0.65; +} + +.join-form-card > * { + position: relative; + z-index: 1; } .join-form-card + .join-panel-title { @@ -712,18 +769,55 @@ .join-progress-query-field input { width: 100%; - border: 1px solid color-mix(in srgb, var(--border-default) 86%, transparent); - border-radius: 10px; - background: color-mix(in srgb, var(--bg-card) 90%, transparent); - color: var(--text-primary); + appearance: none; + -webkit-appearance: none; + border: 1px solid color-mix(in srgb, var(--border-default) 86%, transparent) !important; + border-radius: 8px; + background: color-mix(in srgb, var(--bg-card) 90%, transparent) !important; + color: var(--text-primary) !important; padding: 9px 10px; line-height: 1.3; + transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background-color var(--duration-fast); +} + +.join-progress-query-field input::placeholder { + color: color-mix(in srgb, var(--text-secondary) 78%, var(--text-primary) 22%); + opacity: 1; +} + +.join-progress-query-field input:hover { + border-color: color-mix(in srgb, var(--color-primary) 42%, var(--border-default) 58%) !important; } .join-progress-query-field input:focus { outline: none; - border-color: color-mix(in srgb, var(--color-primary) 55%, var(--border-default) 45%); - box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 16%, transparent); + border-color: color-mix(in srgb, var(--color-primary) 55%, var(--border-default) 45%) !important; + background: color-mix(in srgb, var(--bg-card) 90%, transparent) !important; + color: var(--text-primary) !important; + box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 16%, transparent) !important; +} + +.join-progress-query-field input:-webkit-autofill, +.join-progress-query-field input:-webkit-autofill:hover, +.join-progress-query-field input:-webkit-autofill:focus, +.join-progress-query-field input:autofill { + -webkit-text-fill-color: var(--text-primary) !important; + -webkit-box-shadow: 0 0 0 1000px color-mix(in srgb, var(--bg-card) 90%, transparent) inset !important; + box-shadow: 0 0 0 1000px color-mix(in srgb, var(--bg-card) 90%, transparent) inset !important; + background: color-mix(in srgb, var(--bg-card) 90%, transparent) !important; + border: 1px solid color-mix(in srgb, var(--border-default) 86%, transparent) !important; + caret-color: var(--text-primary) !important; + transition: background-color 9999s ease-out 0s !important; +} + +[data-theme="dark"] .join-progress-query-form, +[data-theme="dark"] .join-progress-query-field input { + color-scheme: dark; +} + +[data-theme="light"] .join-progress-query-form, +[data-theme="light"] .join-progress-query-field input { + color-scheme: light; } .join-progress-query-actions { @@ -1060,12 +1154,26 @@ } [data-theme="light"] .join-form-card { - background: linear-gradient( - 145deg, - color-mix(in srgb, #ffffff 94%, #e8f2ff 6%) 0%, - color-mix(in srgb, #ffffff 98%, #e8f2ff 2%) 100% - ); - box-shadow: 0 16px 30px -24px rgba(120, 140, 165, 0.35); + border-color: color-mix(in srgb, #8bbcff 52%, var(--border-default) 48%); + background: + linear-gradient( + 118deg, + color-mix(in srgb, #d9eaff 42%, transparent) 0%, + transparent 40% + ), + radial-gradient( + 140% 90% at 100% 0%, + color-mix(in srgb, #dbe9ff 48%, transparent) 0%, + transparent 54% + ), + linear-gradient( + 180deg, + color-mix(in srgb, #ffffff 94%, #edf5ff 6%) 0%, + color-mix(in srgb, #ffffff 98%, #edf5ff 2%) 100% + ); + box-shadow: + 0 18px 34px -26px rgba(92, 126, 172, 0.34), + inset 0 1px 0 rgba(255, 255, 255, 0.7); } [data-theme="light"] .join-form-content .frm_style_formidable-style.with_frm_style input[type="text"], diff --git a/functions.php b/functions.php index f59c4cc..576085d 100644 --- a/functions.php +++ b/functions.php @@ -1252,6 +1252,111 @@ function itstudio_get_post_excerpt_chars($post_id, $limit = 200) { return wp_html_excerpt($excerpt, $limit, '...'); } +function itstudio_get_archive_url_by_post_type($post_type) { + $post_type = sanitize_key((string) $post_type); + if ($post_type === '') { + return home_url('/'); + } + + $archive_url = get_post_type_archive_link($post_type); + if ($archive_url) { + return $archive_url; + } + + if ($post_type === 'news') { + return home_url('/news/'); + } + + if ($post_type === 'announcement') { + return home_url('/announcement/'); + } + + return home_url('/'); +} + +function itstudio_get_archive_tag_filter_url($term, $post_type) { + $term_obj = null; + if ($term instanceof WP_Term) { + $term_obj = $term; + } else { + $term_obj = get_term($term, 'post_tag'); + } + + if (!($term_obj instanceof WP_Term) || is_wp_error($term_obj)) { + return ''; + } + + $post_type = sanitize_key((string) $post_type); + if (!in_array($post_type, array('news', 'announcement'), true)) { + return ''; + } + + $archive_url = itstudio_get_archive_url_by_post_type($post_type); + return add_query_arg( + array( + 'tag' => $term_obj->slug, + ), + $archive_url + ); +} + +function itstudio_archive_extended_search_enabled($query) { + if (!($query instanceof WP_Query)) { + return false; + } + + if (!$query->get('itstudio_archive_extend_search')) { + return false; + } + + $keyword = trim((string) $query->get('itstudio_archive_keyword')); + return $keyword !== ''; +} + +function itstudio_archive_extended_search_join($join, $query) { + if (!itstudio_archive_extended_search_enabled($query)) { + return $join; + } + + global $wpdb; + if (strpos($join, $wpdb->users) !== false) { + return $join; + } + + return $join . " LEFT JOIN {$wpdb->users} ON ({$wpdb->posts}.post_author = {$wpdb->users}.ID) "; +} +add_filter('posts_join', 'itstudio_archive_extended_search_join', 10, 2); + +function itstudio_archive_extended_search_where($where, $query) { + if (!itstudio_archive_extended_search_enabled($query)) { + return $where; + } + + global $wpdb; + $keyword = trim((string) $query->get('itstudio_archive_keyword')); + $like = '%' . $wpdb->esc_like($keyword) . '%'; + + $search_sql = $wpdb->prepare( + " AND ( + {$wpdb->posts}.post_title LIKE %s + OR {$wpdb->posts}.post_excerpt LIKE %s + OR {$wpdb->posts}.post_content LIKE %s + OR {$wpdb->users}.display_name LIKE %s + OR {$wpdb->users}.user_login LIKE %s + OR {$wpdb->users}.user_nicename LIKE %s + )", + $like, + $like, + $like, + $like, + $like, + $like + ); + + return $where . $search_sql; +} +add_filter('posts_where', 'itstudio_archive_extended_search_where', 10, 2); + function itstudio_is_probably_bot_request() { $user_agent = strtolower(trim((string) ($_SERVER['HTTP_USER_AGENT'] ?? ''))); if ($user_agent === '') { @@ -2607,15 +2712,15 @@ function itstudio_join_resolve_progress_lookup($runtime = array(), $request_sour } if (!$has_input_value) { - $response['message_cn'] = '请输入姓名(中文)/ QQ / 邮箱 / 学号(10~12位数字)。'; - $response['message_en'] = 'Please enter Name (Chinese) / QQ / Email / Student ID (10-12 digits).'; + $response['message_cn'] = '请输入姓名(中文)/ QQ / 邮箱 / 学号。'; + $response['message_en'] = 'Please enter Name (Chinese) / QQ / Email / Student ID.'; $response['tone'] = 'warning'; return $response; } if (!$has_query_value) { - $response['message_cn'] = '无法识别输入内容,请输入姓名(中文)/ QQ / 邮箱 / 学号(10~12位数字)。'; - $response['message_en'] = 'Input cannot be recognized. Please enter Name (Chinese) / QQ / Email / Student ID (10-12 digits).'; + $response['message_cn'] = '无法识别输入内容,请输入姓名(中文)/ QQ / 邮箱 / 学号。'; + $response['message_en'] = 'Input cannot be recognized. Please enter Name (Chinese) / QQ / Email / Student ID.'; $response['tone'] = 'warning'; return $response; } diff --git a/page-join.php b/page-join.php index 9a1c0d4..3d8a636 100644 --- a/page-join.php +++ b/page-join.php @@ -312,14 +312,13 @@ if ($is_post_request && function_exists('itstudio_join_detect_form_submission_st
diff --git a/single.php b/single.php index aac63fd..73c902c 100644 --- a/single.php +++ b/single.php @@ -60,8 +60,15 @@ ?>