优化加入我们录取进度查询表单样式
增加文章详情页文章筛选方式 用户点击文章标签时自动筛选出对应标签文章
This commit is contained in:
+123
-15
@@ -10,11 +10,14 @@ $is_itstudio_content_page = $is_itstudio_news_page || $is_itstudio_notice_page;
|
||||
<?php if ($is_itstudio_content_page) : ?>
|
||||
<?php
|
||||
$keyword = isset($_GET['q']) ? sanitize_text_field(wp_unslash($_GET['q'])) : '';
|
||||
$date_from = isset($_GET['date_from']) ? sanitize_text_field(wp_unslash($_GET['date_from'])) : '';
|
||||
$date_to = isset($_GET['date_to']) ? sanitize_text_field(wp_unslash($_GET['date_to'])) : '';
|
||||
$tag_slug = isset($_GET['tag']) ? sanitize_title(wp_unslash($_GET['tag'])) : '';
|
||||
$paged = max(1, (int) get_query_var('paged'), (int) get_query_var('page'));
|
||||
$active_post_type = $is_itstudio_news_page ? 'news' : 'announcement';
|
||||
$archive_url = $is_itstudio_news_page ? get_post_type_archive_link('news') : get_post_type_archive_link('announcement');
|
||||
if (!$archive_url) {
|
||||
$archive_url = $is_itstudio_news_page ? home_url('/news') : home_url('/announcements');
|
||||
$archive_url = $is_itstudio_news_page ? home_url('/news/') : home_url('/announcement/');
|
||||
}
|
||||
|
||||
$default_cover_url = get_template_directory_uri() . '/resources/it_logo_2024.svg';
|
||||
@@ -26,16 +29,74 @@ $empty_en = $is_itstudio_news_page ? 'No news found.' : 'No announcements found.
|
||||
$side_title_cn = $is_itstudio_news_page ? '要闻' : '重要公告';
|
||||
$side_title_en = $is_itstudio_news_page ? 'Top Stories' : 'Important Announcements';
|
||||
|
||||
$list_query = new WP_Query(array(
|
||||
$date_query = array();
|
||||
$date_from_valid = '';
|
||||
$date_to_valid = '';
|
||||
if ($date_from !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $date_from)) {
|
||||
$date_from_valid = $date_from . ' 00:00:00';
|
||||
}
|
||||
if ($date_to !== '' && preg_match('/^\d{4}-\d{2}-\d{2}$/', $date_to)) {
|
||||
$date_to_valid = $date_to . ' 23:59:59';
|
||||
}
|
||||
if ($date_from_valid !== '' || $date_to_valid !== '') {
|
||||
$range = array(
|
||||
'inclusive' => 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);
|
||||
<h1 class="news-archive-title" data-cn="<?php echo esc_attr($title_cn); ?>" data-en="<?php echo esc_attr($title_en); ?>"><?php echo esc_html($title_en); ?></h1>
|
||||
</header>
|
||||
|
||||
<div class="news-archive-tools news-archive-tools-single">
|
||||
<div class="news-archive-tools">
|
||||
<form class="news-archive-filter-form" method="get" action="<?php echo esc_url($archive_url); ?>">
|
||||
<?php if ($keyword !== '') : ?>
|
||||
<input type="hidden" name="q" value="<?php echo esc_attr($keyword); ?>">
|
||||
<?php endif; ?>
|
||||
<div class="news-archive-filter-fields">
|
||||
<label class="news-archive-filter-field">
|
||||
<span data-cn="发布时间起" data-en="From">发布时间起</span>
|
||||
<input type="date" name="date_from" value="<?php echo esc_attr($date_from); ?>">
|
||||
</label>
|
||||
<label class="news-archive-filter-field">
|
||||
<span data-cn="发布时间止" data-en="To">发布时间止</span>
|
||||
<input type="date" name="date_to" value="<?php echo esc_attr($date_to); ?>">
|
||||
</label>
|
||||
<label class="news-archive-filter-field news-archive-filter-tag">
|
||||
<span data-cn="标签" data-en="Tag">标签</span>
|
||||
<select name="tag">
|
||||
<option value="" data-cn="全部标签" data-en="All tags">全部标签</option>
|
||||
<?php foreach ($available_tags as $tag_option) : ?>
|
||||
<option value="<?php echo esc_attr($tag_option->slug); ?>" <?php selected($tag_slug, $tag_option->slug); ?>>
|
||||
<?php echo esc_html($tag_option->name); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<button type="submit" data-cn="筛选" data-en="Apply">筛选</button>
|
||||
</form>
|
||||
|
||||
<form class="news-archive-search" method="get" action="<?php echo esc_url($archive_url); ?>">
|
||||
<?php if ($date_from !== '') : ?>
|
||||
<input type="hidden" name="date_from" value="<?php echo esc_attr($date_from); ?>">
|
||||
<?php endif; ?>
|
||||
<?php if ($date_to !== '') : ?>
|
||||
<input type="hidden" name="date_to" value="<?php echo esc_attr($date_to); ?>">
|
||||
<?php endif; ?>
|
||||
<?php if ($tag_slug !== '') : ?>
|
||||
<input type="hidden" name="tag" value="<?php echo esc_attr($tag_slug); ?>">
|
||||
<?php endif; ?>
|
||||
<input
|
||||
type="search"
|
||||
name="q"
|
||||
value="<?php echo esc_attr($keyword); ?>"
|
||||
placeholder="<?php esc_attr_e('Search posts...', 'itstudio'); ?>"
|
||||
aria-label="<?php esc_attr_e('Search posts', 'itstudio'); ?>"
|
||||
data-cn-placeholder="搜索文章..."
|
||||
data-en-placeholder="Search posts..."
|
||||
data-cn-aria-label="搜索文章"
|
||||
data-en-aria-label="Search posts"
|
||||
placeholder="<?php esc_attr_e('Search title or author...', 'itstudio'); ?>"
|
||||
aria-label="<?php esc_attr_e('Search title or author', 'itstudio'); ?>"
|
||||
data-cn-placeholder="搜索文章或发布者..."
|
||||
data-en-placeholder="Search title or author..."
|
||||
data-cn-aria-label="搜索文章或发布者"
|
||||
data-en-aria-label="Search title or author"
|
||||
>
|
||||
<button type="submit" data-cn="搜索" data-en="Search">Search</button>
|
||||
<button type="submit" data-cn="搜索" data-en="Search">搜索</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="news-archive-layout">
|
||||
<section class="news-main-column">
|
||||
<?php if ($list_query->have_posts()) : ?>
|
||||
@@ -138,8 +235,15 @@ $featured_ids = array_slice(array_values(array_unique($featured_ids)), 0, 4);
|
||||
<span class="news-story-tag-label" data-cn="标签" data-en="Tags">Tags</span>
|
||||
<?php if (!empty($tags) && !is_wp_error($tags)) : ?>
|
||||
<?php foreach (array_slice($tags, 0, 5) as $tag) : ?>
|
||||
<?php $tag_link = get_term_link($tag); ?>
|
||||
<?php if (!is_wp_error($tag_link)) : ?>
|
||||
<?php
|
||||
$tag_link = function_exists('itstudio_get_archive_tag_filter_url')
|
||||
? itstudio_get_archive_tag_filter_url($tag, $active_post_type)
|
||||
: '';
|
||||
if ($tag_link === '') {
|
||||
$tag_link = get_term_link($tag);
|
||||
}
|
||||
?>
|
||||
<?php if (!is_wp_error($tag_link) && !empty($tag_link)) : ?>
|
||||
<a class="news-story-tag" href="<?php echo esc_url($tag_link); ?>">#<?php echo esc_html($tag->name); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
@@ -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);
|
||||
<?php endif; ?>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
|
||||
|
||||
+84
-8
@@ -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 {
|
||||
|
||||
+126
-18
@@ -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%
|
||||
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 16px 30px -24px rgba(120, 140, 165, 0.35);
|
||||
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"],
|
||||
|
||||
+109
-4
@@ -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;
|
||||
}
|
||||
|
||||
+3
-4
@@ -312,14 +312,13 @@ if ($is_post_request && function_exists('itstudio_join_detect_form_submission_st
|
||||
<form method="get" class="join-progress-query-form">
|
||||
<div class="join-progress-query-grid">
|
||||
<label class="join-progress-query-field">
|
||||
<span data-cn="姓名 / QQ / 邮箱 / 学号" data-en="Name / QQ / Email / Student ID">姓名 / QQ / 邮箱 / 学号</span>
|
||||
<input
|
||||
type="text"
|
||||
name="join_query_identity"
|
||||
value="<?php echo esc_attr((string) ($progress_lookup['identity'] ?? '')); ?>"
|
||||
data-cn-placeholder="请输入中文姓名 / QQ / 邮箱 / 10~12位学号"
|
||||
data-en-placeholder="Enter Name / QQ / Email / Student ID (10-12 digits)"
|
||||
placeholder="请输入中文姓名 / QQ / 邮箱 / 10~12位学号"
|
||||
data-cn-placeholder="请输入中文姓名 / QQ / 邮箱 / 学号"
|
||||
data-en-placeholder="Enter Name / QQ / Email / Student ID"
|
||||
placeholder="请输入中文姓名 / QQ / 邮箱 / 学号"
|
||||
>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
+9
-2
@@ -60,8 +60,15 @@
|
||||
?>
|
||||
<footer class="single-article-tags">
|
||||
<?php foreach (array_slice($tags, 0, 8) as $tag) : ?>
|
||||
<?php $tag_link = get_term_link($tag); ?>
|
||||
<?php if (!is_wp_error($tag_link)) : ?>
|
||||
<?php
|
||||
$tag_link = function_exists('itstudio_get_archive_tag_filter_url')
|
||||
? itstudio_get_archive_tag_filter_url($tag, $post_type)
|
||||
: '';
|
||||
if ($tag_link === '') {
|
||||
$tag_link = get_term_link($tag);
|
||||
}
|
||||
?>
|
||||
<?php if (!is_wp_error($tag_link) && !empty($tag_link)) : ?>
|
||||
<a class="single-article-tag" href="<?php echo esc_url($tag_link); ?>">#<?php echo esc_html($tag->name); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user