From 97e19e990af1f32679935907a942006eb526d842 Mon Sep 17 00:00:00 2001 From: Yaosanqi137 Date: Sat, 7 Mar 2026 14:28:29 +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=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化加入我们页面的样式的同时,还更新了新闻日期的显示,使其精确到时分 同时在文章详情页,将文章的时间显示格式改成YYYY-MM-DD hh:mm --- archive.php | 4 +- assets/css/join-page.css | 253 +++++++++++++++++++++++++++++---------- assets/js/join-canvas.js | 230 +++++++++++++++++++++++++++++++++++ functions.php | 209 +++++++++++++++++++++++++++++--- index.php | 4 +- page-join.php | 227 +++++++++++++++++------------------ single.php | 2 +- 7 files changed, 723 insertions(+), 206 deletions(-) diff --git a/archive.php b/archive.php index e1dad4f..9babd18 100644 --- a/archive.php +++ b/archive.php @@ -118,7 +118,7 @@ $featured_ids = array_slice(array_values(array_unique($featured_ids)), 0, 4); @@ -215,7 +215,7 @@ $featured_ids = array_slice(array_values(array_unique($featured_ids)), 0, 4);
- + Views diff --git a/assets/css/join-page.css b/assets/css/join-page.css index 34cc7e9..ef93e1d 100644 --- a/assets/css/join-page.css +++ b/assets/css/join-page.css @@ -25,28 +25,45 @@ line-height: 1.5; } +.join-info-layout { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 22px; + align-items: start; +} + +.join-info-main, +.join-info-side { + min-width: 0; +} + +.join-panel-title { + margin: 0 0 12px; + font-size: clamp(1.35rem, 0.9vw + 1.1rem, 2.05rem); + line-height: 1.1; + color: var(--color-primary); + font-weight: 800; + letter-spacing: 0.01em; +} + .join-news-strip { - margin-bottom: 20px; - padding: 0 0 10px; + margin: 0; + padding: 0; } .join-news-strip-track { - display: flex; - gap: 14px; + display: grid; + gap: 0; } .join-news-item { - --join-news-cols: 5; - flex: 0 0 calc((100% - (var(--join-news-cols) - 1) * 14px) / var(--join-news-cols)); - width: calc((100% - (var(--join-news-cols) - 1) * 14px) / var(--join-news-cols)); - min-width: 0; - padding-right: 12px; - border-right: 1px solid color-mix(in srgb, var(--border-default) 82%, transparent); + padding: 12px 0; + border-bottom: 1px solid color-mix(in srgb, var(--border-default) 84%, transparent); } .join-news-item:last-child { - border-right: 0; - padding-right: 0; + border-bottom: 0; + padding-bottom: 0; } .join-news-item-title { @@ -66,17 +83,36 @@ color: var(--color-primary); } +.join-news-item-meta { + margin: 6px 0 0; + display: flex; + flex-wrap: wrap; + gap: 10px; + font-size: 0.76rem; + line-height: 1.45; + color: color-mix(in srgb, var(--text-secondary) 86%, var(--text-primary) 14%); +} + +.join-news-item-meta-author, +.join-news-item-meta-time { + display: inline-flex; + align-items: center; + gap: 5px; + white-space: nowrap; +} + .join-news-item-excerpt { - margin: 7px 0 0; + margin: 8px 0 0; color: var(--text-secondary); - font-size: 0.82rem; - line-height: 1.5; + font-size: 0.88rem; + line-height: 1.58; } .join-news-strip-empty { margin: 0; color: var(--text-secondary); font-size: 0.9rem; + line-height: 1.55; } .join-hero { @@ -88,7 +124,7 @@ .join-canvas-shell { position: relative; - height: clamp(280px, 31vw, 440px); + height: clamp(380px, 35vw, 600px); border-radius: 18px; overflow: hidden; background: color-mix(in srgb, var(--bg-card) 94%, transparent); @@ -623,16 +659,6 @@ overflow-wrap: anywhere; } -.join-forms-grid { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 16px; -} - -.join-forms-grid.is-single { - grid-template-columns: 1fr; -} - .join-form-card { border: 1px solid color-mix(in srgb, var(--border-default) 86%, transparent); border-radius: 14px; @@ -645,21 +671,14 @@ box-shadow: 0 16px 30px -24px color-mix(in srgb, #000000 65%, transparent); } -.join-form-card-full { - grid-column: 1 / -1; +.join-form-card + .join-panel-title { + margin-top: 16px; } -.join-form-head h2 { - margin: 0; - color: var(--text-primary); - font-size: 1.22rem; -} - -.join-form-head p { - margin: 6px 0 0; - color: color-mix(in srgb, var(--text-primary) 72%, var(--text-secondary) 28%); - font-size: 0.94rem; - line-height: 1.55; +.join-form-card-placeholder { + min-height: 132px; + display: flex; + align-items: center; } .join-form-content { @@ -677,7 +696,7 @@ .join-progress-query-grid { display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); + grid-template-columns: minmax(0, 1fr); gap: 10px; } @@ -748,6 +767,11 @@ background: color-mix(in srgb, #d89a1b 14%, var(--bg-card) 86%); } +.join-progress-query-feedback.is-info { + border-color: color-mix(in srgb, var(--color-primary) 52%, var(--border-default) 48%); + background: color-mix(in srgb, var(--color-primary) 14%, var(--bg-card) 86%); +} + .join-progress-query-feedback.is-error { border-color: color-mix(in srgb, #c34646 58%, var(--border-default) 42%); background: color-mix(in srgb, #c34646 14%, var(--bg-card) 86%); @@ -853,6 +877,126 @@ outline: none !important; } +.join-form-content .frm_style_formidable-style.with_frm_style .iti { + width: 100% !important; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti input[type="tel"] { + padding-right: 12px !important; + padding-left: calc(var(--iti-selected-country-arrow-padding, 64px) + 4px) !important; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__selected-country { + border-top-left-radius: 8px; + border-bottom-left-radius: 8px; +} + +.join-form-content .frm_style_formidable-style.with_frm_style input:-webkit-autofill, +.join-form-content .frm_style_formidable-style.with_frm_style input:-webkit-autofill:hover, +.join-form-content .frm_style_formidable-style.with_frm_style input:-webkit-autofill:focus, +.join-form-content .frm_style_formidable-style.with_frm_style textarea:-webkit-autofill, +.join-form-content .frm_style_formidable-style.with_frm_style textarea:-webkit-autofill:hover, +.join-form-content .frm_style_formidable-style.with_frm_style textarea:-webkit-autofill:focus, +.join-form-content .frm_style_formidable-style.with_frm_style select:-webkit-autofill, +.join-form-content .frm_style_formidable-style.with_frm_style select:-webkit-autofill:hover, +.join-form-content .frm_style_formidable-style.with_frm_style select:-webkit-autofill:focus { + -webkit-text-fill-color: color-mix(in srgb, var(--text-primary) 96%, #ffffff 4%) !important; + -webkit-box-shadow: 0 0 0 1000px color-mix(in srgb, var(--bg-body) 84%, #ffffff 16%) inset !important; + box-shadow: 0 0 0 1000px color-mix(in srgb, var(--bg-body) 84%, #ffffff 16%) inset !important; + caret-color: color-mix(in srgb, var(--text-primary) 96%, #ffffff 4%) !important; + transition: background-color 9999s ease-out 0s !important; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__dropdown-content { + background: color-mix(in srgb, var(--bg-card) 94%, var(--bg-body) 6%) !important; + border: 1px solid color-mix(in srgb, var(--border-default) 46%, var(--color-primary) 54%) !important; + color: color-mix(in srgb, var(--text-primary) 92%, #ffffff 8%) !important; + box-shadow: 0 18px 36px -22px color-mix(in srgb, #000000 68%, transparent); +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__search-input-wrapper { + margin: 6px 8px !important; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__search-input { + border: 1px solid color-mix(in srgb, var(--border-default) 38%, var(--color-primary) 62%) !important; + background: color-mix(in srgb, var(--bg-body) 84%, #ffffff 16%) !important; + color: color-mix(in srgb, var(--text-primary) 94%, #ffffff 6%) !important; + min-height: 40px !important; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__search-input::placeholder { + color: color-mix(in srgb, var(--text-secondary) 76%, var(--text-primary) 24%) !important; + opacity: 1; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__country-list { + background: transparent !important; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__country { + color: color-mix(in srgb, var(--text-primary) 90%, #ffffff 10%) !important; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__dial-code, +.join-form-content .frm_style_formidable-style.with_frm_style .iti__country-name { + color: color-mix(in srgb, var(--text-primary) 88%, var(--text-secondary) 12%) !important; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__country.iti__highlight, +.join-form-content .frm_style_formidable-style.with_frm_style .iti__country:hover { + background: color-mix(in srgb, var(--color-primary) 16%, var(--bg-card) 84%) !important; +} + +.join-form-content .frm_style_formidable-style.with_frm_style .iti__divider { + border-bottom-color: color-mix(in srgb, var(--border-default) 70%, transparent) !important; +} + +.frm_forms.with_frm_style .iti__dropdown-content { + background: color-mix(in srgb, var(--bg-card) 94%, var(--bg-body) 6%) !important; + border: 1px solid color-mix(in srgb, var(--border-default) 46%, var(--color-primary) 54%) !important; + color: color-mix(in srgb, var(--text-primary) 92%, #ffffff 8%) !important; + box-shadow: 0 18px 36px -22px color-mix(in srgb, #000000 68%, transparent); +} + +.frm_forms.with_frm_style .iti__search-input-wrapper { + margin: 6px 8px !important; +} + +.frm_forms.with_frm_style .iti__search-input { + border: 1px solid color-mix(in srgb, var(--border-default) 38%, var(--color-primary) 62%) !important; + background: color-mix(in srgb, var(--bg-body) 84%, #ffffff 16%) !important; + color: color-mix(in srgb, var(--text-primary) 94%, #ffffff 6%) !important; + min-height: 40px !important; +} + +.frm_forms.with_frm_style .iti__search-input::placeholder { + color: color-mix(in srgb, var(--text-secondary) 76%, var(--text-primary) 24%) !important; + opacity: 1; +} + +.frm_forms.with_frm_style .iti__country-list { + background: transparent !important; +} + +.frm_forms.with_frm_style .iti__country { + color: color-mix(in srgb, var(--text-primary) 90%, #ffffff 10%) !important; +} + +.frm_forms.with_frm_style .iti__dial-code, +.frm_forms.with_frm_style .iti__country-name { + color: color-mix(in srgb, var(--text-primary) 88%, var(--text-secondary) 12%) !important; +} + +.frm_forms.with_frm_style .iti__country.iti__highlight, +.frm_forms.with_frm_style .iti__country:hover { + background: color-mix(in srgb, var(--color-primary) 16%, var(--bg-card) 84%) !important; +} + +.frm_forms.with_frm_style .iti__divider { + border-bottom-color: color-mix(in srgb, var(--border-default) 70%, transparent) !important; +} + .join-form-content .frm_style_formidable-style.with_frm_style input[type="checkbox"], .join-form-content .frm_style_formidable-style.with_frm_style input[type="radio"] { accent-color: var(--color-primary); @@ -963,37 +1107,18 @@ padding: 30px 0 60px; } - .join-news-strip { - margin-bottom: 16px; - } - - .join-news-strip-track { - display: flex; - gap: 12px; - overflow-x: auto; - padding-bottom: 6px; - scrollbar-width: thin; + .join-info-layout { + grid-template-columns: 1fr; + gap: 20px; } .join-news-item { - flex: 0 0 220px; - padding-right: 0; - border-right: 0; - border-bottom: 1px solid color-mix(in srgb, var(--border-default) 82%, transparent); - padding-bottom: 8px; + padding: 10px 0; } .join-stage-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } - - .join-forms-grid { - grid-template-columns: 1fr; - } - - .join-form-card-full { - grid-column: auto; - } } @media (max-width: 640px) { @@ -1014,7 +1139,7 @@ } .join-canvas-shell { - height: 240px; + height: 272px; } .join-current-stage { diff --git a/assets/js/join-canvas.js b/assets/js/join-canvas.js index 3018b85..2ce7976 100644 --- a/assets/js/join-canvas.js +++ b/assets/js/join-canvas.js @@ -625,9 +625,239 @@ stopBoatAnimations(); }); + function resolveLanguage() { + const bootLang = typeof window.__ITSTUDIO_LANG__ === 'string' ? window.__ITSTUDIO_LANG__ : ''; + const htmlLang = document.documentElement.getAttribute('lang') || ''; + const lang = (bootLang || htmlLang || 'zh').toLowerCase(); + return lang.indexOf('en') === 0 ? 'en' : 'zh'; + } + + function pickLocaleText(cnText, enText) { + return resolveLanguage() === 'en' + ? (enText || cnText || '') + : (cnText || enText || ''); + } + + function getProgressLookupConfig() { + const config = joinData && typeof joinData.progressLookup === 'object' ? joinData.progressLookup : null; + if (!config) { + return null; + } + if (!config.ajaxUrl || !config.action || !config.nonce) { + return null; + } + return config; + } + + function ensureProgressFeedbackNode(formElement) { + const host = formElement.closest('.join-form-content') || formElement.parentElement; + if (!host) { + return null; + } + + let feedback = host.querySelector('.join-progress-query-feedback'); + if (!feedback) { + feedback = document.createElement('p'); + feedback.className = 'join-progress-query-feedback'; + feedback.hidden = true; + feedback.setAttribute('aria-live', 'polite'); + host.appendChild(feedback); + } + return feedback; + } + + function setProgressFeedback(feedback, tone, messageCn, messageEn) { + if (!feedback) { + return; + } + + const normalizedTone = ['success', 'warning', 'error', 'info'].indexOf(tone) >= 0 ? tone : 'info'; + feedback.classList.remove('is-success', 'is-warning', 'is-error', 'is-info'); + feedback.classList.add(`is-${normalizedTone}`); + feedback.dataset.cn = messageCn || ''; + feedback.dataset.en = messageEn || ''; + feedback.textContent = pickLocaleText(messageCn, messageEn); + feedback.hidden = !(feedback.textContent && feedback.textContent.trim() !== ''); + } + + function setupProgressLookupAjax() { + const formElement = document.querySelector('.join-progress-query-form'); + if (!formElement || typeof window.fetch !== 'function') { + return; + } + + const config = getProgressLookupConfig(); + if (!config) { + return; + } + + const identityInput = formElement.querySelector('input[name="join_query_identity"]'); + const submitButton = formElement.querySelector('button[type="submit"], input[type="submit"]'); + const feedback = ensureProgressFeedbackNode(formElement); + + formElement.addEventListener('submit', async (event) => { + event.preventDefault(); + + const identity = identityInput ? identityInput.value.trim() : ''; + const payload = new URLSearchParams(); + payload.set('action', config.action); + payload.set('nonce', config.nonce); + payload.set('join_progress_lookup', '1'); + payload.set('join_query_identity', identity); + + if (submitButton) { + submitButton.disabled = true; + submitButton.setAttribute('aria-busy', 'true'); + } + setProgressFeedback(feedback, 'info', '查询中,请稍候…', 'Checking, please wait...'); + + try { + const response = await window.fetch(config.ajaxUrl, { + method: 'POST', + credentials: 'same-origin', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + }, + body: payload.toString(), + }); + + const result = await response.json(); + if (!result || !result.success || !result.data) { + throw new Error('invalid_response'); + } + + const data = result.data; + setProgressFeedback( + feedback, + data.tone || 'info', + data.message_cn || '', + data.message_en || '' + ); + } catch (error) { + setProgressFeedback( + feedback, + 'error', + '查询失败,请稍后重试。', + 'Lookup failed. Please try again later.' + ); + } finally { + if (submitButton) { + submitButton.disabled = false; + submitButton.removeAttribute('aria-busy'); + } + } + }); + } + + function detectJoinSubmitIntentFromElement(element) { + if (!element) { + return ''; + } + + const name = (element.getAttribute('name') || '').toLowerCase(); + const value = String(element.value || element.textContent || '').toLowerCase(); + if (name.indexOf('draft') !== -1 || value.indexOf('draft') !== -1 || value.indexOf('草稿') !== -1) { + return 'draft'; + } + return 'submitted'; + } + + function ensureJoinSubmitNoticeNode() { + let notice = document.getElementById('joinSubmitNotice'); + if (notice) { + return notice; + } + + notice = document.querySelector('.join-submit-notice'); + if (notice) { + notice.id = 'joinSubmitNotice'; + return notice; + } + + const head = document.querySelector('.join-head'); + if (!head || !head.parentNode) { + return null; + } + + notice = document.createElement('p'); + notice.id = 'joinSubmitNotice'; + notice.className = 'join-submit-notice'; + notice.hidden = true; + head.parentNode.insertBefore(notice, head.nextSibling); + return notice; + } + + function showJoinSubmitNotice(intent) { + const notice = ensureJoinSubmitNoticeNode(); + if (!notice) { + return; + } + + const isDraft = intent === 'draft'; + const messageCn = isDraft ? '草稿已保存' : '你的报名表单已提交,感谢报名'; + const messageEn = isDraft ? 'Draft saved.' : 'Your registration form has been submitted. Thank you for applying.'; + notice.dataset.cn = messageCn; + notice.dataset.en = messageEn; + notice.textContent = pickLocaleText(messageCn, messageEn); + notice.hidden = false; + } + + function setupRegistrationSubmitNoticeBridge() { + const formElement = document.querySelector('.join-form-content .frm_forms form'); + if (!formElement) { + return; + } + + let submitIntent = 'submitted'; + formElement.addEventListener('click', (event) => { + const control = event.target.closest('button, input[type="submit"]'); + const nextIntent = detectJoinSubmitIntentFromElement(control); + if (nextIntent) { + submitIntent = nextIntent; + } + }); + + formElement.addEventListener('submit', (event) => { + const submitter = event.submitter || null; + const nextIntent = detectJoinSubmitIntentFromElement(submitter); + if (nextIntent) { + submitIntent = nextIntent; + } + }); + + const formHost = formElement.closest('.join-form-content') || formElement.parentElement; + if (!formHost) { + return; + } + + const updateSuccessMessage = () => { + const successNode = formHost.querySelector('.frm_message, .frm_success_style, .frm_success'); + if (!successNode) { + return; + } + + const lowerText = (successNode.textContent || '').toLowerCase(); + const resolvedIntent = (lowerText.indexOf('draft') !== -1 || lowerText.indexOf('草稿') !== -1) + ? 'draft' + : submitIntent; + + const messageCn = resolvedIntent === 'draft' ? '草稿已保存' : '你的报名表单已提交,感谢报名'; + const messageEn = resolvedIntent === 'draft' ? 'Draft saved.' : 'Your registration form has been submitted. Thank you for applying.'; + successNode.dataset.cn = messageCn; + successNode.dataset.en = messageEn; + successNode.textContent = pickLocaleText(messageCn, messageEn); + showJoinSubmitNotice(resolvedIntent); + }; + + const observer = new MutationObserver(updateSuccessMessage); + observer.observe(formHost, { childList: true, subtree: true }); + } + targetProgress = computeTargetProgress(); setupOverlayEntryAnimation(); renderStageMarks(); startWaves(); animateBoatToTarget(); + setupProgressLookupAjax(); + setupRegistrationSubmitNoticeBridge(); })(); diff --git a/functions.php b/functions.php index 1c9dd01..f59c4cc 100644 --- a/functions.php +++ b/functions.php @@ -152,6 +152,43 @@ function itstudio_enqueue_scripts() { } add_action('wp_enqueue_scripts', 'itstudio_enqueue_scripts'); +function itstudio_expand_news_notice_date_precision($the_date, $format, $post) { + $post_obj = $post instanceof WP_Post ? $post : get_post($post); + if (!($post_obj instanceof WP_Post)) { + return $the_date; + } + + if (!in_array((string) $post_obj->post_type, array('announcement', 'news'), true)) { + return $the_date; + } + + $format = (string) $format; + if ($format === '') { + $format = (string) get_option('date_format'); + } + + $lower = strtolower($format); + if (in_array($lower, array('c', 'r', 'u'), true)) { + return $the_date; + } + + // Already has time precision. + if (preg_match('/[HhGgis]/', $format)) { + return $the_date; + } + + $timestamp = function_exists('get_post_timestamp') + ? get_post_timestamp($post_obj, 'date') + : false; + if (!$timestamp) { + return $the_date; + } + + $format_with_time = rtrim($format) . ' H:i'; + return wp_date($format_with_time, (int) $timestamp, wp_timezone()); +} +add_filter('get_the_date', 'itstudio_expand_news_notice_date_precision', 10, 3); + function itstudio_register_sidebars() { register_sidebar(array( 'name' => __('Footer - Column 1', 'itstudio'), @@ -572,12 +609,20 @@ function itstudio_join_get_recruitment_feed_items($join_runtime = array(), $limi $excerpt = '...'; } + $author_id = (int) get_post_field('post_author', $post_id); + $author = trim((string) get_the_author_meta('display_name', $author_id)); + if ($author === '') { + $author = 'Unknown'; + } + $items[] = array( 'id' => $post_id, 'title' => $title, 'excerpt' => $excerpt, 'url' => $url, - 'date' => get_the_date('Y-m-d', $post_id), + 'date' => get_the_date('Y-m-d H:i', $post_id), + 'date_iso' => get_the_date('c', $post_id), + 'author' => $author, 'type' => get_post_type($post_id), ); } @@ -2293,6 +2338,55 @@ function itstudio_join_normalize_lookup_value($field, $value) { return strtolower($value); } +function itstudio_join_detect_progress_query_identity($raw_identity) { + $raw_identity = trim((string) $raw_identity); + $compacted = preg_replace('/\s+/u', '', $raw_identity); + + $detected = array( + 'raw' => $raw_identity, + 'field' => '', + 'value' => '', + ); + + if ($compacted === '') { + return $detected; + } + + $email = sanitize_email($compacted); + if ($email !== '' && is_email($email)) { + $detected['field'] = 'email'; + $detected['value'] = itstudio_join_normalize_lookup_value('email', $email); + return $detected; + } + + if (preg_match('/^\d+$/', $compacted)) { + $digits = $compacted; + $len = strlen($digits); + + if ($len >= 10 && $len <= 12) { + $detected['field'] = 'student_id'; + $detected['value'] = itstudio_join_normalize_lookup_value('student_id', $digits); + return $detected; + } + + if ($len >= 5 && $len <= 12) { + $detected['field'] = 'qq'; + $detected['value'] = itstudio_join_normalize_lookup_value('qq', $digits); + return $detected; + } + + return $detected; + } + + if (preg_match('/^[\x{4e00}-\x{9fff}·]{2,20}$/u', $compacted)) { + $detected['field'] = 'name'; + $detected['value'] = itstudio_join_normalize_lookup_value('name', $compacted); + return $detected; + } + + return $detected; +} + function itstudio_join_parse_result_records($raw) { $raw = str_replace(array("\r\n", "\r"), "\n", (string) $raw); if ($raw === '') { @@ -2462,30 +2556,43 @@ function itstudio_join_resolve_progress_lookup($runtime = array(), $request_sour $settings = isset($runtime['settings']) && is_array($runtime['settings']) ? $runtime['settings'] : itstudio_join_get_settings(); $request_source = is_array($request_source) ? $request_source : $_GET; + $raw_identity = isset($request_source['join_query_identity']) ? sanitize_text_field(wp_unslash((string) $request_source['join_query_identity'])) : ''; $raw_name = isset($request_source['join_query_name']) ? sanitize_text_field(wp_unslash((string) $request_source['join_query_name'])) : ''; $raw_qq = isset($request_source['join_query_qq']) ? sanitize_text_field(wp_unslash((string) $request_source['join_query_qq'])) : ''; $raw_email = isset($request_source['join_query_email']) ? sanitize_text_field(wp_unslash((string) $request_source['join_query_email'])) : ''; $raw_student_id = isset($request_source['join_query_student_id']) ? sanitize_text_field(wp_unslash((string) $request_source['join_query_student_id'])) : ''; - $query = array( - 'name' => itstudio_join_normalize_lookup_value('name', $raw_name), - 'qq' => itstudio_join_normalize_lookup_value('qq', $raw_qq), - 'email' => itstudio_join_normalize_lookup_value('email', $raw_email), - 'student_id' => itstudio_join_normalize_lookup_value('student_id', $raw_student_id), - ); - - $has_query_value = false; - foreach ($query as $value) { - if ($value !== '') { - $has_query_value = true; - break; + if (trim($raw_identity) === '') { + foreach (array($raw_name, $raw_qq, $raw_email, $raw_student_id) as $legacy_value) { + $legacy_value = trim((string) $legacy_value); + if ($legacy_value !== '') { + $raw_identity = $legacy_value; + break; + } } } - $submitted = isset($request_source['join_progress_lookup']) || $has_query_value; + $detected_identity = itstudio_join_detect_progress_query_identity($raw_identity); + + $query = array( + 'name' => '', + 'qq' => '', + 'email' => '', + 'student_id' => '', + ); + if ($detected_identity['field'] !== '') { + $query[$detected_identity['field']] = (string) $detected_identity['value']; + } + + $has_input_value = trim((string) $raw_identity) !== ''; + $has_query_value = $detected_identity['field'] !== ''; + + $submitted = isset($request_source['join_progress_lookup']) || $has_input_value; $response = array( 'submitted' => $submitted, 'has_query' => $has_query_value, + 'identity' => $raw_identity, + 'identity_field' => (string) ($detected_identity['field'] ?? ''), 'name' => $raw_name, 'qq' => $raw_qq, 'email' => $raw_email, @@ -2499,9 +2606,16 @@ function itstudio_join_resolve_progress_lookup($runtime = array(), $request_sour return $response; } + 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['tone'] = 'warning'; + return $response; + } + if (!$has_query_value) { - $response['message_cn'] = '请至少填写姓名、QQ、邮箱、学号中的一项。'; - $response['message_en'] = 'Please fill at least one item: name, QQ, email or student ID.'; + $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['tone'] = 'warning'; return $response; } @@ -3102,9 +3216,68 @@ function itstudio_join_get_frontend_payload() { 'endTs' => isset($stage['end_ts']) ? $stage['end_ts'] : null, ); }, (array) ($runtime['stages'] ?? array()))), + 'progressLookup' => array( + 'ajaxUrl' => admin_url('admin-ajax.php'), + 'action' => 'itstudio_join_progress_lookup', + 'nonce' => wp_create_nonce('itstudio_join_progress_lookup'), + ), ); } +function itstudio_join_ajax_progress_lookup() { + if (!check_ajax_referer('itstudio_join_progress_lookup', 'nonce', false)) { + wp_send_json_error( + array( + 'tone' => 'error', + 'message_cn' => '请求已过期,请刷新页面后重试。', + 'message_en' => 'Request expired. Please refresh the page and try again.', + ), + 403 + ); + } + + $runtime = itstudio_join_get_runtime_data(); + $request_source = $_POST; + if (!isset($request_source['join_progress_lookup'])) { + $request_source['join_progress_lookup'] = '1'; + } + + $lookup = itstudio_join_resolve_progress_lookup($runtime, $request_source); + $tone = trim((string) ($lookup['tone'] ?? 'info')); + if (!in_array($tone, array('success', 'warning', 'error', 'info'), true)) { + $tone = 'info'; + } + + wp_send_json_success( + array( + 'submitted' => !empty($lookup['submitted']), + 'has_query' => !empty($lookup['has_query']), + 'identity' => (string) ($lookup['identity'] ?? ''), + 'identity_field' => (string) ($lookup['identity_field'] ?? ''), + 'tone' => $tone, + 'message_cn' => (string) ($lookup['message_cn'] ?? ''), + 'message_en' => (string) ($lookup['message_en'] ?? ''), + ) + ); +} +add_action('wp_ajax_itstudio_join_progress_lookup', 'itstudio_join_ajax_progress_lookup'); +add_action('wp_ajax_nopriv_itstudio_join_progress_lookup', 'itstudio_join_ajax_progress_lookup'); + +function itstudio_join_force_formidable_ajax_submit($form) { + if (!itstudio_is_join_page_context() || !is_object($form)) { + return $form; + } + + if (!isset($form->options) || !is_array($form->options)) { + $form->options = array(); + } + + $form->options['ajax_submit'] = 1; + + return $form; +} +add_filter('frm_pre_display_form', 'itstudio_join_force_formidable_ajax_submit', 20); + function itstudio_join_enqueue_assets() { if (!itstudio_is_join_page_context()) { return; @@ -3114,7 +3287,7 @@ function itstudio_join_enqueue_assets() { 'itstudio-join-page', get_template_directory_uri() . '/assets/css/join-page.css', array('itstudio-content'), - '1.1.0' + '1.1.1' ); wp_enqueue_script( @@ -3129,7 +3302,7 @@ function itstudio_join_enqueue_assets() { 'itstudio-join-canvas', get_template_directory_uri() . '/assets/js/join-canvas.js', array('itstudio-animejs'), - '1.1.0', + '1.1.1', true ); diff --git a/index.php b/index.php index f38282e..4dd6f3d 100644 --- a/index.php +++ b/index.php @@ -175,7 +175,7 @@
- +

@@ -218,7 +218,7 @@
- +

diff --git a/page-join.php b/page-join.php index 8b04232..9a1c0d4 100644 --- a/page-join.php +++ b/page-join.php @@ -117,28 +117,6 @@ if ($is_post_request && function_exists('itstudio_join_detect_form_submission_st -
- -
- - -
-

- -

-

-
- -
- -

暂无可展示的招新新闻通告

- -
-
@@ -305,109 +283,120 @@ if ($is_post_request && function_exists('itstudio_join_detect_form_submission_st
- - 0) : ?> -
- -
-
-

报名表单

-

仅在报名阶段开放

-
-
- -

未检测到 Formidable Forms 插件 请先启用插件

- -

请在 设置 > 招新设置 中填写报名表单 Shortcode

- - - -
-
- +
+
+ +

报名表单

+
+
+ +

未检测到 Formidable Forms 插件,请先启用插件

+ +

请在 设置 > 招新设置 中填写报名表单 Shortcode

+ + + +
+
+ - -
-
-

录取进度查询

-

报名结束后至录取结果公布阶段可查询

-
-
-
-
- - - - -
-
- -
-
- - -

- -

- -
-
- + +

录取进度查询

+
+
+
+
+ +
+
+ +
+
+ + +

+ +

+ +
+
+ + + +
+
+

当前阶段暂无可操作表单

+
+
+ +
+ +
-