更新公告和新闻样式
This commit is contained in:
@@ -60,16 +60,36 @@ git clone https://github.com/itstudio-2002/ITStudioMainSite.git
|
||||
#### 2. 发布公告
|
||||
|
||||
主题内置了"公告通知"自定义文章类型:
|
||||
1. 进入 **公告 > 新建公告**
|
||||
1. 进入 **Announcement > 新建 Announcement**
|
||||
2. 填写标题和内容
|
||||
3. 发布即可在首页显示
|
||||
|
||||
#### 3. 技术博客
|
||||
#### 3. 发布新闻
|
||||
|
||||
使用 WordPress 默认的文章功能发布技术博客:
|
||||
1. 进入 **文章 > 写文章**
|
||||
2. 撰写博客内容
|
||||
3. 发布后会在首页博客栏显示
|
||||
主题内置了"社团新闻"自定义文章类型:
|
||||
1. 进入 **News > 新建 News**
|
||||
2. 填写标题和内容
|
||||
3. 发布即可在首页显示
|
||||
|
||||
#### 4. 新闻公告页权重字段(ACF)
|
||||
|
||||
新闻公告页右侧“高权重文章”读取 ACF 数值字段 `itstudio_weight`(数值越大,排序越靠前)。
|
||||
|
||||
适用范围:
|
||||
- 默认文章(`post`)
|
||||
- 公告(`announcement`)
|
||||
- 新闻(`news`)
|
||||
|
||||
设置步骤:
|
||||
1. 安装并启用插件 **Advanced Custom Fields (ACF)**。
|
||||
2. 主题会自动注册字段组“内容权重”,字段名为 `itstudio_weight`(显示名“权重”)。
|
||||
3. 编辑文章时在右侧填写“权重”数值(例如 `10`、`50`、`100`)。
|
||||
4. 更新或发布文章。
|
||||
|
||||
说明:
|
||||
- 当前仅读取 ACF 字段值,不再使用 Gutenberg 的“自定义字段”面板作为权重来源。
|
||||
- 未设置 `itstudio_weight` 的文章按 `0` 处理。
|
||||
- 当高权重文章不足 4 篇时,页面会自动用最新文章补足。
|
||||
|
||||
## 🎨 设计规范
|
||||
|
||||
@@ -144,7 +164,7 @@ MIT License - 详见 LICENSE 文件
|
||||
🎯 **使命**: 发现人才,培养人才,输送人才
|
||||
|
||||
🔗 **链接**:
|
||||
- GitHub: [github.com/itstudio-2002](https://github.com/itstudio-2002)
|
||||
- GitHub: [https://github.com/ITStudioOUC](https://github.com/ITStudioOUC)
|
||||
- Email: contact@itstudio.club
|
||||
|
||||
## 🤝 贡献
|
||||
|
||||
+242
-6
@@ -1,5 +1,240 @@
|
||||
<?php get_header(); ?>
|
||||
|
||||
<?php
|
||||
$itstudio_archive_mode = isset($GLOBALS['itstudio_archive_mode']) ? sanitize_key((string) $GLOBALS['itstudio_archive_mode']) : '';
|
||||
$is_itstudio_news_page = is_post_type_archive('news') || ($itstudio_archive_mode === 'news');
|
||||
$is_itstudio_notice_page = is_post_type_archive('announcement') || ($itstudio_archive_mode === 'announcement');
|
||||
$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'])) : '';
|
||||
$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');
|
||||
}
|
||||
|
||||
$default_cover_url = get_template_directory_uri() . '/resources/it_logo_2024.svg';
|
||||
$weight_meta_key = 'itstudio_weight';
|
||||
$title_cn = $is_itstudio_news_page ? '社团新闻' : '公告通知';
|
||||
$title_en = $is_itstudio_news_page ? 'Club News' : 'Announcements';
|
||||
$empty_cn = $is_itstudio_news_page ? '暂无新闻' : '暂无公告';
|
||||
$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(
|
||||
'post_type' => $active_post_type,
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 10,
|
||||
'paged' => $paged,
|
||||
's' => $keyword,
|
||||
'ignore_sticky_posts' => true,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
));
|
||||
|
||||
$featured_query = new WP_Query(array(
|
||||
'post_type' => $active_post_type,
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 4,
|
||||
'ignore_sticky_posts' => true,
|
||||
'meta_key' => $weight_meta_key,
|
||||
'orderby' => array(
|
||||
'meta_value_num' => 'DESC',
|
||||
'date' => 'DESC',
|
||||
),
|
||||
'order' => 'DESC',
|
||||
'no_found_rows' => true,
|
||||
));
|
||||
$featured_ids = array_map('intval', wp_list_pluck($featured_query->posts, 'ID'));
|
||||
wp_reset_postdata();
|
||||
|
||||
if (count($featured_ids) < 4) {
|
||||
$fill_query = new WP_Query(array(
|
||||
'post_type' => $active_post_type,
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 4 - count($featured_ids),
|
||||
'ignore_sticky_posts' => true,
|
||||
'post__not_in' => $featured_ids,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'no_found_rows' => true,
|
||||
));
|
||||
$featured_ids = array_merge($featured_ids, array_map('intval', wp_list_pluck($fill_query->posts, 'ID')));
|
||||
wp_reset_postdata();
|
||||
}
|
||||
$featured_ids = array_slice(array_values(array_unique($featured_ids)), 0, 4);
|
||||
?>
|
||||
<main class="site-main news-archive-page">
|
||||
<div class="container">
|
||||
<header class="news-archive-head">
|
||||
<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">
|
||||
<form class="news-archive-search" method="get" action="<?php echo esc_url($archive_url); ?>">
|
||||
<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"
|
||||
>
|
||||
<button type="submit" data-cn="搜索" data-en="Search">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="news-archive-layout">
|
||||
<section class="news-main-column">
|
||||
<?php if ($list_query->have_posts()) : ?>
|
||||
<div class="news-stream">
|
||||
<?php while ($list_query->have_posts()) : $list_query->the_post(); ?>
|
||||
<?php
|
||||
$post_id = get_the_ID();
|
||||
$excerpt = function_exists('itstudio_get_post_excerpt_chars')
|
||||
? itstudio_get_post_excerpt_chars($post_id, 200)
|
||||
: wp_html_excerpt(wp_strip_all_tags(get_the_excerpt() ?: get_the_content()), 200, '...');
|
||||
$views = function_exists('itstudio_get_post_views') ? (int) itstudio_get_post_views($post_id) : 0;
|
||||
$char_count = function_exists('itstudio_get_post_char_count') ? (int) itstudio_get_post_char_count($post_id) : (int) strlen(wp_strip_all_tags(get_the_content()));
|
||||
$tags = get_the_terms($post_id, 'post_tag');
|
||||
?>
|
||||
<article class="news-story">
|
||||
<div class="news-story-body">
|
||||
<h2 class="news-story-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
|
||||
|
||||
<div class="news-story-meta">
|
||||
<span class="news-story-meta-item">
|
||||
<span data-cn="浏览量" data-en="Views">Views</span>
|
||||
<strong><?php echo esc_html(number_format_i18n($views)); ?></strong>
|
||||
</span>
|
||||
<span class="news-story-meta-dot" aria-hidden="true">/</span>
|
||||
<time class="news-story-meta-item" datetime="<?php echo esc_attr(get_the_date('c')); ?>">
|
||||
<span data-cn="发表于" data-en="Published">Published</span>
|
||||
<?php echo esc_html(get_the_date('Y-m-d')); ?>
|
||||
</time>
|
||||
<span class="news-story-meta-dot" aria-hidden="true">/</span>
|
||||
<span class="news-story-meta-item">
|
||||
<span data-cn="发布者" data-en="Author">Author</span>
|
||||
<?php echo esc_html(get_the_author()); ?>
|
||||
</span>
|
||||
<span class="news-story-meta-dot" aria-hidden="true">/</span>
|
||||
<span class="news-story-meta-item">
|
||||
<span data-cn="字数" data-en="Words">Words</span>
|
||||
<strong><?php echo esc_html(number_format_i18n($char_count)); ?></strong>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p class="news-story-excerpt"><?php echo esc_html($excerpt); ?></p>
|
||||
|
||||
<div class="news-story-tags">
|
||||
<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)) : ?>
|
||||
<a class="news-story-tag" href="<?php echo esc_url($tag_link); ?>">#<?php echo esc_html($tag->name); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<span class="news-story-tag-empty" data-cn="无标签" data-en="No tags">No tags</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a class="news-story-cover" href="<?php the_permalink(); ?>" aria-label="<?php echo esc_attr(get_the_title()); ?>">
|
||||
<?php if (has_post_thumbnail()) : ?>
|
||||
<?php the_post_thumbnail('medium_large', array('loading' => 'lazy')); ?>
|
||||
<?php else : ?>
|
||||
<img class="news-story-cover-fallback" src="<?php echo esc_url($default_cover_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>" loading="lazy">
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</article>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
|
||||
<nav class="news-archive-pagination" aria-label="Pagination">
|
||||
<?php
|
||||
$pagination_base = esc_url_raw(add_query_arg('paged', '%#%', $archive_url));
|
||||
echo wp_kses_post(
|
||||
paginate_links(array(
|
||||
'base' => $pagination_base,
|
||||
'format' => '',
|
||||
'current' => $paged,
|
||||
'total' => max(1, (int) $list_query->max_num_pages),
|
||||
'mid_size' => 2,
|
||||
'prev_text' => '<span data-cn="上一页" data-en="Previous">Previous</span>',
|
||||
'next_text' => '<span data-cn="下一页" data-en="Next">Next</span>',
|
||||
'add_args' => array_filter(
|
||||
array(
|
||||
'q' => $keyword,
|
||||
),
|
||||
static function ($value) {
|
||||
return $value !== '';
|
||||
}
|
||||
),
|
||||
))
|
||||
);
|
||||
?>
|
||||
</nav>
|
||||
<?php else : ?>
|
||||
<p class="news-archive-empty" data-cn="<?php echo esc_attr($empty_cn); ?>" data-en="<?php echo esc_attr($empty_en); ?>"><?php echo esc_html($empty_en); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php wp_reset_postdata(); ?>
|
||||
</section>
|
||||
|
||||
<aside class="news-side-column">
|
||||
<section class="news-side-block">
|
||||
<h2 class="news-side-title" data-cn="<?php echo esc_attr($side_title_cn); ?>" data-en="<?php echo esc_attr($side_title_en); ?>"><?php echo esc_html($side_title_en); ?></h2>
|
||||
<ul class="news-side-list">
|
||||
<?php if (!empty($featured_ids)) : ?>
|
||||
<?php foreach ($featured_ids as $featured_id) : ?>
|
||||
<?php
|
||||
$featured_title = get_the_title($featured_id);
|
||||
$featured_link = get_permalink($featured_id);
|
||||
$featured_views = function_exists('itstudio_get_post_views') ? (int) itstudio_get_post_views($featured_id) : 0;
|
||||
$featured_cover = get_the_post_thumbnail_url($featured_id, 'thumbnail');
|
||||
?>
|
||||
<li class="news-side-item">
|
||||
<a class="news-side-cover" href="<?php echo esc_url($featured_link); ?>" aria-label="<?php echo esc_attr($featured_title); ?>">
|
||||
<?php if (!empty($featured_cover)) : ?>
|
||||
<img src="<?php echo esc_url($featured_cover); ?>" alt="<?php echo esc_attr($featured_title); ?>" loading="lazy">
|
||||
<?php else : ?>
|
||||
<img class="news-side-cover-fallback" src="<?php echo esc_url($default_cover_url); ?>" alt="<?php echo esc_attr($featured_title); ?>" loading="lazy">
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<div class="news-side-body">
|
||||
<h3 class="news-side-item-title">
|
||||
<a href="<?php echo esc_url($featured_link); ?>"><?php echo esc_html($featured_title); ?></a>
|
||||
</h3>
|
||||
<div class="news-side-meta">
|
||||
<time datetime="<?php echo esc_attr(get_the_date('c', $featured_id)); ?>"><?php echo esc_html(get_the_date('Y-m-d', $featured_id)); ?></time>
|
||||
<span class="news-side-meta-dot" aria-hidden="true">/</span>
|
||||
<span>
|
||||
<span data-cn="浏览" data-en="Views">Views</span>
|
||||
<?php echo esc_html(number_format_i18n($featured_views)); ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<li class="news-side-empty" data-cn="暂无文章" data-en="No posts found.">No posts found.</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</section>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<?php else : ?>
|
||||
<main class="site-main archive-page">
|
||||
<div class="container">
|
||||
<header class="archive-header">
|
||||
@@ -30,8 +265,8 @@
|
||||
</h2>
|
||||
|
||||
<div class="archive-meta">
|
||||
<time datetime="<?php echo get_the_date('c'); ?>">
|
||||
<?php echo get_the_date(); ?>
|
||||
<time datetime="<?php echo esc_attr(get_the_date('c')); ?>">
|
||||
<?php echo esc_html(get_the_date()); ?>
|
||||
</time>
|
||||
<?php if (get_post_type() === 'post') : ?>
|
||||
<span class="separator">|</span>
|
||||
@@ -46,7 +281,7 @@
|
||||
<?php endif; ?>
|
||||
|
||||
<a href="<?php the_permalink(); ?>" class="read-more">
|
||||
<?php _e('阅读更多', 'itstudio'); ?> →
|
||||
<?php esc_html_e('Read More', 'itstudio'); ?> ->
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
@@ -57,15 +292,16 @@
|
||||
<?php
|
||||
the_posts_pagination(array(
|
||||
'mid_size' => 2,
|
||||
'prev_text' => __('← 上一页', 'itstudio'),
|
||||
'next_text' => __('下一页 →', 'itstudio'),
|
||||
'prev_text' => __('Previous', 'itstudio'),
|
||||
'next_text' => __('Next', 'itstudio'),
|
||||
));
|
||||
?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<p><?php _e('暂无内容', 'itstudio'); ?></p>
|
||||
<p><?php esc_html_e('No posts found.', 'itstudio'); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
|
||||
@@ -543,3 +543,433 @@ ol.comment-list {
|
||||
.gh-file-content { padding: 20px; }
|
||||
.gh-pro-header .entry-title { font-size: 1.75rem; }
|
||||
}
|
||||
|
||||
/* News & Announcements Archive */
|
||||
.news-archive-page {
|
||||
padding: 36px 0 60px;
|
||||
}
|
||||
|
||||
.news-archive-head {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.news-archive-title {
|
||||
margin: 0;
|
||||
font-size: clamp(2.05rem, 1.2vw + 1.6rem, 2.9rem);
|
||||
line-height: 1.2;
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.news-archive-tools {
|
||||
margin-top: 14px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr minmax(240px, 320px);
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.news-archive-tools-single {
|
||||
grid-template-columns: minmax(240px, 420px);
|
||||
justify-content: end;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.news-archive-search {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.news-archive-search input[type="search"] {
|
||||
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.88rem;
|
||||
}
|
||||
|
||||
.news-archive-search input[type="search"]:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.news-archive-search 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-search button:hover {
|
||||
border-color: var(--color-primary);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.news-archive-layout {
|
||||
margin-top: 22px;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 320px;
|
||||
gap: 28px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.news-main-column {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.news-stream {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.news-story {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 232px;
|
||||
align-items: start;
|
||||
gap: 16px;
|
||||
padding: 16px 0;
|
||||
border-bottom: 1px solid var(--border-default);
|
||||
}
|
||||
|
||||
.news-story-cover {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 144px;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: var(--radius-sm);
|
||||
overflow: hidden;
|
||||
background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
|
||||
}
|
||||
|
||||
.news-story-cover img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.news-story-cover img.news-story-cover-fallback {
|
||||
width: 33.333%;
|
||||
height: auto;
|
||||
max-height: 33.333%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.news-story-body {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.news-story-title {
|
||||
margin: 0;
|
||||
font-size: clamp(1.32rem, 0.2vw + 1.24rem, 1.62rem);
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.news-story-title a {
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.news-story-title a:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.news-story-meta {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.8rem;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.news-story-meta-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.news-story-meta-item strong {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.news-story-meta-dot {
|
||||
color: var(--border-default);
|
||||
}
|
||||
|
||||
.news-story-excerpt {
|
||||
margin: 10px 0 0;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.66;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.news-story-tags {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.news-story-tag-label {
|
||||
font-size: 0.78rem;
|
||||
color: var(--text-secondary);
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.news-story-tag,
|
||||
.news-story-tag-empty {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 22px;
|
||||
padding: 0 8px;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 999px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-secondary);
|
||||
background: color-mix(in srgb, var(--bg-card) 88%, transparent);
|
||||
}
|
||||
|
||||
.news-story-tag {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.news-story-tag:hover {
|
||||
color: var(--color-primary);
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.news-side-column {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.news-side-block {
|
||||
margin-top: 16px;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 14px;
|
||||
background: color-mix(in srgb, var(--bg-card) 84%, transparent);
|
||||
}
|
||||
|
||||
.news-side-title {
|
||||
margin: 0;
|
||||
font-size: 1.06rem;
|
||||
color: var(--text-primary);
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.news-side-list {
|
||||
list-style: none;
|
||||
margin: 12px 0 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.news-side-item {
|
||||
display: grid;
|
||||
grid-template-columns: 88px minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid var(--border-default);
|
||||
}
|
||||
|
||||
.news-side-item:last-child {
|
||||
padding-bottom: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.news-side-cover {
|
||||
width: 88px;
|
||||
height: 64px;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: var(--radius-sm);
|
||||
overflow: hidden;
|
||||
background: var(--bg-surface);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.news-side-cover img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.news-side-cover img.news-side-cover-fallback {
|
||||
width: 33.333%;
|
||||
height: auto;
|
||||
max-height: 33.333%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.news-side-body {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.news-side-item-title {
|
||||
margin: 0;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.news-side-item-title a {
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.news-side-item-title a:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.news-side-meta {
|
||||
margin-top: 6px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.73rem;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.news-side-meta-dot {
|
||||
color: var(--border-default);
|
||||
}
|
||||
|
||||
.news-side-empty {
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
.news-archive-pagination {
|
||||
margin-top: 18px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.news-archive-pagination .page-numbers {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 34px;
|
||||
min-height: 34px;
|
||||
padding: 0 10px;
|
||||
margin: 0 4px;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-card);
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.88rem;
|
||||
}
|
||||
|
||||
.news-archive-pagination .page-numbers.current {
|
||||
color: var(--color-primary);
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.news-archive-empty {
|
||||
margin: 14px 0 0;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
@media (max-width: 1180px) {
|
||||
.news-archive-layout {
|
||||
grid-template-columns: minmax(0, 1fr) 292px;
|
||||
gap: 22px;
|
||||
}
|
||||
|
||||
.news-story {
|
||||
grid-template-columns: minmax(0, 1fr) 204px;
|
||||
}
|
||||
|
||||
.news-story-cover {
|
||||
height: 132px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.news-archive-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.news-side-block {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.news-side-column {
|
||||
order: -1;
|
||||
}
|
||||
|
||||
.news-main-column {
|
||||
order: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.news-archive-page {
|
||||
padding: 28px 0 50px;
|
||||
}
|
||||
|
||||
.news-archive-tools {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.news-archive-tools {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.news-archive-tools-single {
|
||||
grid-template-columns: 1fr;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.news-archive-search {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.news-story {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.news-story-cover {
|
||||
order: -1;
|
||||
height: 168px;
|
||||
}
|
||||
|
||||
.news-story-body {
|
||||
order: 1;
|
||||
}
|
||||
|
||||
.news-story-title {
|
||||
font-size: 1.08rem;
|
||||
}
|
||||
|
||||
.news-side-item {
|
||||
grid-template-columns: 82px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.news-side-cover {
|
||||
width: 82px;
|
||||
height: 58px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.news-story-cover {
|
||||
height: 168px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,19 +113,15 @@
|
||||
.services-provided h2,
|
||||
.landing-feed-head h2 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 1.15rem;
|
||||
color: var(--text-primary);
|
||||
font-size: clamp(1.35rem, 0.5vw + 1.2rem, 1.75rem);
|
||||
color: var(--color-primary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.services-provided h2::before,
|
||||
.landing-feed-head h2::before {
|
||||
content: "#";
|
||||
margin-right: 8px;
|
||||
color: var(--color-primary);
|
||||
font-family: var(--font-mono);
|
||||
font-weight: 700;
|
||||
content: none;
|
||||
}
|
||||
|
||||
.services-grid-box {
|
||||
|
||||
+51
-18
@@ -3,30 +3,63 @@ const body = document.body;
|
||||
|
||||
function getPreferredLang() {
|
||||
const savedLang = localStorage.getItem('language');
|
||||
if (savedLang) {
|
||||
if (savedLang === 'zh' || savedLang === 'en') {
|
||||
return savedLang;
|
||||
}
|
||||
return 'zh';
|
||||
}
|
||||
|
||||
function setLang(lang) {
|
||||
if (lang === 'en') {
|
||||
body.setAttribute('lang', 'en');
|
||||
if (langToggle) {
|
||||
langToggle.querySelector('.lang-text').textContent = '中';
|
||||
}
|
||||
} else {
|
||||
body.setAttribute('lang', 'zh');
|
||||
if (langToggle) {
|
||||
langToggle.querySelector('.lang-text').textContent = 'EN';
|
||||
function setElementTextByLang(element, lang) {
|
||||
const nextText = lang === 'en' ? element.getAttribute('data-en') : element.getAttribute('data-cn');
|
||||
if (!nextText) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') {
|
||||
const inputType = (element.getAttribute('type') || '').toLowerCase();
|
||||
if (inputType === 'submit' || inputType === 'button' || inputType === 'reset') {
|
||||
element.value = nextText;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理 Input 元素的值切换 (input[type=submit] cannot use CSS content replacement)
|
||||
const inputs = document.querySelectorAll('input[type="submit"][data-cn][data-en]');
|
||||
inputs.forEach(input => {
|
||||
input.value = lang === 'en' ? input.getAttribute('data-en') : input.getAttribute('data-cn');
|
||||
});
|
||||
element.textContent = nextText;
|
||||
}
|
||||
|
||||
function setElementPlaceholderByLang(element, lang) {
|
||||
const key = lang === 'en' ? 'data-en-placeholder' : 'data-cn-placeholder';
|
||||
const value = element.getAttribute(key);
|
||||
if (value) {
|
||||
element.setAttribute('placeholder', value);
|
||||
}
|
||||
}
|
||||
|
||||
function setElementAriaLabelByLang(element, lang) {
|
||||
const key = lang === 'en' ? 'data-en-aria-label' : 'data-cn-aria-label';
|
||||
const value = element.getAttribute(key);
|
||||
if (value) {
|
||||
element.setAttribute('aria-label', value);
|
||||
}
|
||||
}
|
||||
|
||||
function setLang(lang) {
|
||||
body.setAttribute('lang', lang);
|
||||
|
||||
if (langToggle) {
|
||||
const langText = langToggle.querySelector('.lang-text');
|
||||
if (langText) {
|
||||
langText.textContent = lang === 'en' ? '\u4e2d' : 'EN';
|
||||
}
|
||||
}
|
||||
|
||||
const textNodes = document.querySelectorAll('[data-cn][data-en]');
|
||||
textNodes.forEach((element) => setElementTextByLang(element, lang));
|
||||
|
||||
const placeholderNodes = document.querySelectorAll('[data-cn-placeholder][data-en-placeholder]');
|
||||
placeholderNodes.forEach((element) => setElementPlaceholderByLang(element, lang));
|
||||
|
||||
const ariaNodes = document.querySelectorAll('[data-cn-aria-label][data-en-aria-label]');
|
||||
ariaNodes.forEach((element) => setElementAriaLabelByLang(element, lang));
|
||||
|
||||
localStorage.setItem('language', lang);
|
||||
}
|
||||
@@ -37,7 +70,7 @@ setLang(initialLang);
|
||||
if (langToggle) {
|
||||
langToggle.addEventListener('click', () => {
|
||||
const currentLang = body.getAttribute('lang');
|
||||
const newLang = currentLang === 'en' ? 'zh' : 'en';
|
||||
setLang(newLang);
|
||||
const nextLang = currentLang === 'en' ? 'zh' : 'en';
|
||||
setLang(nextLang);
|
||||
});
|
||||
}
|
||||
|
||||
+245
-1
@@ -131,13 +131,97 @@ function itstudio_custom_post_types() {
|
||||
),
|
||||
'public' => true,
|
||||
'has_archive' => true,
|
||||
'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
|
||||
'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'),
|
||||
'taxonomies' => array('post_tag'),
|
||||
'menu_icon' => 'dashicons-megaphone',
|
||||
'show_in_rest' => true,
|
||||
));
|
||||
|
||||
register_post_type('news', array(
|
||||
'labels' => array(
|
||||
'name' => __('News', 'itstudio'),
|
||||
'singular_name' => __('News', 'itstudio'),
|
||||
),
|
||||
'public' => true,
|
||||
'has_archive' => 'news',
|
||||
'rewrite' => array(
|
||||
'slug' => 'news',
|
||||
'with_front' => false,
|
||||
),
|
||||
'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'),
|
||||
'taxonomies' => array('post_tag'),
|
||||
'menu_icon' => 'dashicons-media-document',
|
||||
'show_in_rest' => true,
|
||||
));
|
||||
|
||||
register_taxonomy_for_object_type('post_tag', 'announcement');
|
||||
register_taxonomy_for_object_type('post_tag', 'news');
|
||||
}
|
||||
add_action('init', 'itstudio_custom_post_types');
|
||||
|
||||
function itstudio_register_acf_fields() {
|
||||
if (!function_exists('acf_add_local_field_group')) {
|
||||
return;
|
||||
}
|
||||
|
||||
acf_add_local_field_group(array(
|
||||
'key' => 'group_itstudio_content_priority',
|
||||
'title' => '内容权重',
|
||||
'fields' => array(
|
||||
array(
|
||||
'key' => 'field_itstudio_weight',
|
||||
'label' => '权重',
|
||||
'name' => 'itstudio_weight',
|
||||
'type' => 'number',
|
||||
'instructions' => '数值越大,文章在侧栏排序越靠前。',
|
||||
'required' => 0,
|
||||
'default_value' => 0,
|
||||
'min' => 0,
|
||||
'step' => 1,
|
||||
),
|
||||
),
|
||||
'location' => array(
|
||||
array(
|
||||
array(
|
||||
'param' => 'post_type',
|
||||
'operator' => '==',
|
||||
'value' => 'post',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'param' => 'post_type',
|
||||
'operator' => '==',
|
||||
'value' => 'announcement',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'param' => 'post_type',
|
||||
'operator' => '==',
|
||||
'value' => 'news',
|
||||
),
|
||||
),
|
||||
),
|
||||
'position' => 'side',
|
||||
'style' => 'default',
|
||||
'active' => true,
|
||||
'show_in_rest' => 1,
|
||||
));
|
||||
}
|
||||
add_action('acf/init', 'itstudio_register_acf_fields');
|
||||
|
||||
function itstudio_archive_document_title($parts) {
|
||||
if (is_post_type_archive('announcement')) {
|
||||
$parts['title'] = html_entity_decode('公告通知', ENT_QUOTES, 'UTF-8');
|
||||
} elseif (is_post_type_archive('news')) {
|
||||
$parts['title'] = html_entity_decode('社团新闻', ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
return $parts;
|
||||
}
|
||||
add_filter('document_title_parts', 'itstudio_archive_document_title', 20);
|
||||
|
||||
// Fallback: render /about even if the page isn't created in WP admin.
|
||||
function itstudio_about_fallback() {
|
||||
if (!is_404()) {
|
||||
@@ -189,6 +273,59 @@ function itstudio_about_fallback() {
|
||||
}
|
||||
add_action('template_redirect', 'itstudio_about_fallback');
|
||||
|
||||
// Fallback: render /news via archive.php even if the page isn't created in WP admin.
|
||||
function itstudio_news_fallback() {
|
||||
if (!is_404()) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wp;
|
||||
$request = isset($wp->request) ? trim($wp->request, '/') : '';
|
||||
if ($request !== 'news') {
|
||||
return;
|
||||
}
|
||||
|
||||
$template = locate_template('archive.php');
|
||||
if ($template) {
|
||||
global $wp_query;
|
||||
if ($wp_query) {
|
||||
$wp_query->is_404 = false;
|
||||
$wp_query->is_page = true;
|
||||
$wp_query->is_singular = true;
|
||||
$virtual_post = new WP_Post((object) array(
|
||||
'ID' => 0,
|
||||
'post_type' => 'page',
|
||||
'post_parent' => 0,
|
||||
'post_title' => __('社团新闻', 'itstudio'),
|
||||
'post_status' => 'publish',
|
||||
'post_name' => 'news',
|
||||
'post_content' => '',
|
||||
));
|
||||
$wp_query->post = $virtual_post;
|
||||
$wp_query->posts = array($virtual_post);
|
||||
$wp_query->queried_object = $virtual_post;
|
||||
$wp_query->queried_object_id = 0;
|
||||
$wp_query->post_count = 1;
|
||||
$wp_query->found_posts = 1;
|
||||
$wp_query->max_num_pages = 1;
|
||||
global $post;
|
||||
$post = $virtual_post;
|
||||
setup_postdata($post);
|
||||
}
|
||||
add_filter('document_title_parts', function ($parts) {
|
||||
$parts['title'] = __('社团新闻', 'itstudio');
|
||||
return $parts;
|
||||
});
|
||||
$GLOBALS['itstudio_archive_mode'] = 'news';
|
||||
status_header(200);
|
||||
nocache_headers();
|
||||
include $template;
|
||||
unset($GLOBALS['itstudio_archive_mode']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
add_action('template_redirect', 'itstudio_news_fallback');
|
||||
|
||||
/**
|
||||
* GitHub 风格评论
|
||||
*/
|
||||
@@ -263,3 +400,110 @@ function itstudio_comment_callback($comment, $args, $depth) {
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
function itstudio_get_post_views($post_id) {
|
||||
$post_id = (int) $post_id;
|
||||
if ($post_id <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$meta_keys = array(
|
||||
'post_views_count',
|
||||
'itstudio_views',
|
||||
'views',
|
||||
'post_views',
|
||||
'view_count',
|
||||
'views_count',
|
||||
);
|
||||
|
||||
$max_views = 0;
|
||||
foreach ($meta_keys as $meta_key) {
|
||||
$raw = get_post_meta($post_id, $meta_key, true);
|
||||
if ($raw !== '' && is_numeric($raw)) {
|
||||
$max_views = max($max_views, (int) $raw);
|
||||
}
|
||||
}
|
||||
|
||||
return max(0, $max_views);
|
||||
}
|
||||
|
||||
function itstudio_get_post_weight($post_id, $field_name = 'itstudio_weight') {
|
||||
$post_id = (int) $post_id;
|
||||
if ($post_id <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!function_exists('get_field')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$raw = get_field($field_name, $post_id, false);
|
||||
if ($raw === '' || $raw === null || !is_numeric($raw)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) $raw;
|
||||
}
|
||||
|
||||
function itstudio_get_post_char_count($post_id) {
|
||||
$post_id = (int) $post_id;
|
||||
if ($post_id <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$content = (string) get_post_field('post_content', $post_id);
|
||||
$plain_text = trim(wp_strip_all_tags($content));
|
||||
if ($plain_text === '') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (function_exists('mb_strlen')) {
|
||||
return (int) mb_strlen($plain_text, 'UTF-8');
|
||||
}
|
||||
|
||||
return (int) strlen($plain_text);
|
||||
}
|
||||
|
||||
function itstudio_get_post_excerpt_chars($post_id, $limit = 200) {
|
||||
$post_id = (int) $post_id;
|
||||
$limit = max(1, (int) $limit);
|
||||
if ($post_id <= 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$excerpt = (string) get_post_field('post_excerpt', $post_id);
|
||||
if (trim($excerpt) === '') {
|
||||
$excerpt = (string) get_post_field('post_content', $post_id);
|
||||
}
|
||||
|
||||
$excerpt = trim(wp_strip_all_tags($excerpt));
|
||||
if ($excerpt === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return wp_html_excerpt($excerpt, $limit, '...');
|
||||
}
|
||||
|
||||
function itstudio_track_post_views() {
|
||||
if (is_admin() || wp_doing_ajax() || wp_doing_cron()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_singular(array('post', 'announcement', 'news')) || is_preview() || is_feed() || is_trackback() || is_embed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($_SERVER['REQUEST_METHOD']) || strtoupper((string) $_SERVER['REQUEST_METHOD']) !== 'GET') {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id = (int) get_queried_object_id();
|
||||
if ($post_id <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$views = itstudio_get_post_views($post_id) + 1;
|
||||
update_post_meta($post_id, 'post_views_count', $views);
|
||||
update_post_meta($post_id, 'itstudio_views', $views);
|
||||
}
|
||||
add_action('template_redirect', 'itstudio_track_post_views', 20);
|
||||
|
||||
+13
-7
@@ -60,7 +60,7 @@
|
||||
<path id="cls-3" data-name="cls-3" class="cls-3" d="M18,28L46,12V49L18,66V28Z"/>
|
||||
</g>
|
||||
<g class="text-group" transform="translate(165, 0)">
|
||||
<text y="38" class="text-cn" fill="currentColor">爱特工作室</text>
|
||||
<text y="38" class="text-cn" fill="currentColor">爱特工作室</text>
|
||||
<text y="56" class="text-en">IT Studio</text>
|
||||
</g>
|
||||
</svg>
|
||||
@@ -79,20 +79,26 @@
|
||||
if (!$announcement_nav_url) {
|
||||
$announcement_nav_url = home_url('/announcements');
|
||||
}
|
||||
$news_nav_url = get_post_type_archive_link('news');
|
||||
if (!$news_nav_url) {
|
||||
$news_nav_url = home_url('/news');
|
||||
}
|
||||
$posts_page_id = (int) get_option('page_for_posts');
|
||||
$blog_nav_url = $posts_page_id ? get_permalink($posts_page_id) : '';
|
||||
if (!$blog_nav_url) {
|
||||
$blog_nav_url = home_url('/blog');
|
||||
}
|
||||
$blog_nav_url = 'https://blog.itstudio.club';
|
||||
?>
|
||||
|
||||
<ul class="nav-menu">
|
||||
<li><a href="<?php echo esc_url(home_url('/')); ?>" data-cn="首页" data-en="Home"></a></li>
|
||||
<li><a href="<?php echo esc_url($announcement_nav_url); ?>" data-cn="公告通知" data-en="Events"></a></li>
|
||||
<li><a href="<?php echo esc_url($blog_nav_url); ?>" data-cn="技术博客" data-en="Blog"></a></li>
|
||||
<li><a href="<?php echo esc_url(home_url('/services')); ?>" data-cn="便民服务" data-en="Service"></a></li>
|
||||
<li><a href="<?php echo esc_url(home_url('/about')); ?>" data-cn="工作室介绍" data-en="Introduction"></a></li>
|
||||
<li><a href="<?php echo esc_url(home_url('/join')); ?>" data-cn="加入我们" data-en="Join"></a></li>
|
||||
<li><a href="<?php echo esc_url(home_url('/')); ?>" data-cn="首页" data-en="Home"></a></li>
|
||||
<li><a href="<?php echo esc_url($announcement_nav_url); ?>" data-cn="公告通知" data-en="Announcements"></a></li>
|
||||
<li><a href="<?php echo esc_url($news_nav_url); ?>" data-cn="社团新闻" data-en="News"></a></li>
|
||||
<li><a href="<?php echo esc_url($blog_nav_url); ?>" target="_blank" rel="noopener noreferrer" data-cn="技术博客" data-en="Blog"></a></li>
|
||||
<li><a href="<?php echo esc_url(home_url('/services')); ?>" data-cn="便民服务" data-en="Service"></a></li>
|
||||
<li><a href="<?php echo esc_url(home_url('/about')); ?>" data-cn="工作室介绍" data-en="Introduction"></a></li>
|
||||
<li><a href="<?php echo esc_url(home_url('/join')); ?>" data-cn="加入我们" data-en="Join"></a></li>
|
||||
</ul>
|
||||
|
||||
<div class="social-links">
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
if (!$announcement_archive_url) {
|
||||
$announcement_archive_url = home_url('/announcements');
|
||||
}
|
||||
$posts_page_id = (int) get_option('page_for_posts');
|
||||
$blog_archive_url = $posts_page_id ? get_permalink($posts_page_id) : '';
|
||||
if (!$blog_archive_url) {
|
||||
$blog_archive_url = home_url('/blog');
|
||||
$club_news_url = get_post_type_archive_link('news');
|
||||
if (!$club_news_url) {
|
||||
$club_news_url = home_url('/news');
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -17,9 +16,9 @@
|
||||
<canvas class="landing-hero-canvas" aria-hidden="true"></canvas>
|
||||
<div class="container">
|
||||
<div class="landing-hero-content">
|
||||
<h1 class="landing-hero-title" data-cn="爱特工作室" data-en="IT STUDIO"></h1>
|
||||
<p class="landing-hero-subtitle" data-cn="中国海洋大学信息技术与工程实践团队" data-en="Technology and Engineering Practice Team at OUC"></p>
|
||||
<a class="landing-hero-btn" href="<?php echo esc_url(home_url('/about')); ?>" data-cn="了解更多" data-en="Learn More"></a>
|
||||
<h1 class="landing-hero-title" data-cn="爱特工作室" data-en="IT STUDIO"></h1>
|
||||
<p class="landing-hero-subtitle" data-cn="中国海洋大学信息技术与工程实践团队" data-en="Technology and Engineering Practice Team at OUC"></p>
|
||||
<a class="landing-hero-btn" href="<?php echo esc_url(home_url('/about')); ?>" data-cn="了解更多" data-en="Learn More"></a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -27,7 +26,7 @@
|
||||
<section class="services-section">
|
||||
<div class="container">
|
||||
<div class="services-provided">
|
||||
<h2 data-cn="@ 服务提供" data-en="@ Services"></h2>
|
||||
<h2 data-cn="@ 服务提供" data-en="@ Services"></h2>
|
||||
<div class="services-grid-box">
|
||||
<div class="service-item service-resources">
|
||||
<div class="service-icon">
|
||||
@@ -39,7 +38,7 @@
|
||||
<path class="svc-muted" d="M51 35v13M51 48l3-3M51 48l-3-3" />
|
||||
</svg>
|
||||
</div>
|
||||
<span data-cn="资源站" data-en="Resources"></span>
|
||||
<span data-cn="资源站" data-en="Resources"></span>
|
||||
</div>
|
||||
<div class="service-item service-mirror">
|
||||
<div class="service-icon">
|
||||
@@ -53,7 +52,7 @@
|
||||
<path class="svc-accent" d="M15 36h12" />
|
||||
</svg>
|
||||
</div>
|
||||
<span data-cn="校内镜像站" data-en="Mirror Site"></span>
|
||||
<span data-cn="校内镜像站" data-en="Mirror Site"></span>
|
||||
</div>
|
||||
<div class="service-item service-git">
|
||||
<div class="service-icon">
|
||||
@@ -69,7 +68,7 @@
|
||||
<path class="svc-accent" d="M49 37c4 0 7 3 7 7" />
|
||||
</svg>
|
||||
</div>
|
||||
<span data-cn="代码托管" data-en="Git Hosting"></span>
|
||||
<span data-cn="代码托管" data-en="Git Hosting"></span>
|
||||
</div>
|
||||
<div class="service-item service-minecraft">
|
||||
<div class="service-icon">
|
||||
@@ -83,7 +82,7 @@
|
||||
<rect class="svc-dot" x="43" y="39" width="6" height="6" rx="1.2" />
|
||||
</svg>
|
||||
</div>
|
||||
<span data-cn="Minecraft服务器" data-en="Minecraft Server"></span>
|
||||
<span data-cn="Minecraft服务器" data-en="Minecraft Server"></span>
|
||||
</div>
|
||||
<div class="service-item service-forum">
|
||||
<div class="service-icon">
|
||||
@@ -97,7 +96,7 @@
|
||||
<circle class="svc-dot" cx="52" cy="24" r="1.7" />
|
||||
</svg>
|
||||
</div>
|
||||
<span data-cn="OUC论坛" data-en="OUC Forum"></span>
|
||||
<span data-cn="OUC论坛" data-en="OUC Forum"></span>
|
||||
</div>
|
||||
<div class="service-item service-repair">
|
||||
<div class="service-icon">
|
||||
@@ -110,7 +109,7 @@
|
||||
<circle class="svc-dot" cx="55" cy="24" r="2" />
|
||||
</svg>
|
||||
</div>
|
||||
<span data-cn="电脑维修" data-en="PC Repair"></span>
|
||||
<span data-cn="电脑维修" data-en="PC Repair"></span>
|
||||
</div>
|
||||
<div class="service-item service-workshop">
|
||||
<div class="service-icon">
|
||||
@@ -124,7 +123,7 @@
|
||||
<circle class="svc-dot" cx="30" cy="24" r="1.8" />
|
||||
</svg>
|
||||
</div>
|
||||
<span data-cn="五八工坊预约" data-en="Workshop Booking"></span>
|
||||
<span data-cn="五八工坊预约" data-en="Workshop Booking"></span>
|
||||
</div>
|
||||
<div class="service-item service-campus">
|
||||
<div class="service-icon">
|
||||
@@ -137,7 +136,7 @@
|
||||
<path class="svc-accent" d="M49.5 22H54.5M52 19.5v5" />
|
||||
</svg>
|
||||
</div>
|
||||
<span data-cn="OUC便民服务" data-en="OUC Services"></span>
|
||||
<span data-cn="OUC便民服务" data-en="OUC Services"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -149,8 +148,8 @@
|
||||
<div class="landing-updates-grid">
|
||||
<article class="landing-feed-box">
|
||||
<header class="landing-feed-head">
|
||||
<h2 data-cn="@ 公告通知" data-en="@ Announcements"></h2>
|
||||
<a href="<?php echo esc_url($announcement_archive_url); ?>" data-cn="更多" data-en="More"></a>
|
||||
<h2 data-cn="@ 公告通知" data-en="@ Announcements"></h2>
|
||||
<a href="<?php echo esc_url($announcement_archive_url); ?>" data-cn="更多" data-en="More"></a>
|
||||
</header>
|
||||
<ul class="landing-feed">
|
||||
<?php
|
||||
@@ -185,20 +184,20 @@
|
||||
wp_reset_postdata();
|
||||
else :
|
||||
?>
|
||||
<li class="landing-feed-empty" data-cn="暂无公告" data-en="No announcements found."></li>
|
||||
<li class="landing-feed-empty" data-cn="暂无公告" data-en="No announcements found."></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</article>
|
||||
|
||||
<article class="landing-feed-box">
|
||||
<header class="landing-feed-head">
|
||||
<h2 data-cn="@ 技术博客" data-en="@ Blog"></h2>
|
||||
<a href="<?php echo esc_url($blog_archive_url); ?>" data-cn="更多" data-en="More"></a>
|
||||
<h2 data-cn="@ 社团新闻" data-en="@ Club News"></h2>
|
||||
<a href="<?php echo esc_url($club_news_url); ?>" data-cn="更多" data-en="More"></a>
|
||||
</header>
|
||||
<ul class="landing-feed">
|
||||
<?php
|
||||
$blogs = new WP_Query(array(
|
||||
'post_type' => 'post',
|
||||
'post_type' => 'news',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 5,
|
||||
'orderby' => 'date',
|
||||
@@ -228,7 +227,7 @@
|
||||
wp_reset_postdata();
|
||||
else :
|
||||
?>
|
||||
<li class="landing-feed-empty" data-cn="暂无博客文章" data-en="No blog posts found."></li>
|
||||
<li class="landing-feed-empty" data-cn="暂无社团新闻" data-en="No club news found."></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</article>
|
||||
|
||||
Reference in New Issue
Block a user