导入 AKSRT 主题开发源码
This commit is contained in:
1 parent
9681dd3d48
commit
1268a55dd0
595 files changed
+127705
No files matched your search
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Special Page Cover
|
||||
*
|
||||
* Renders the cover section for a special/topic page with
|
||||
* background image, title, summary, and metadata.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$cover_img = get_the_post_thumbnail_url($post_id, 'large');
|
||||
$default_cover = isset($default_cover) ? $default_cover : '';
|
||||
$show_post_count = isset($show_post_count) ? $show_post_count : true;
|
||||
if (empty($cover_img) && !empty($default_cover)) {
|
||||
$cover_img = $default_cover;
|
||||
}
|
||||
$title = get_the_title();
|
||||
$excerpt = get_the_excerpt();
|
||||
$summary_len = isset($summary_len) ? (int) $summary_len : 200;
|
||||
|
||||
if ($excerpt) {
|
||||
$excerpt = wp_trim_words($excerpt, $summary_len, '...');
|
||||
}
|
||||
|
||||
// Per-page meta
|
||||
$cover_color = get_post_meta($post_id, '_aksrt_special_cover_color', true);
|
||||
$cover_style = '';
|
||||
if ($cover_color) {
|
||||
$cover_style = 'background-color:' . sanitize_hex_color($cover_color) . ';';
|
||||
}
|
||||
?>
|
||||
<header class="aksrt-special-cover" <?php echo $cover_style ? 'style="' . esc_attr($cover_style) . '"' : ''; ?>>
|
||||
<?php if ($cover_img) : ?>
|
||||
<div class="aksrt-special-cover__bg">
|
||||
<img src="<?php echo esc_url($cover_img); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('cover') : ' loading="lazy"'; ?> class="aksrt-special-cover__img">
|
||||
<div class="aksrt-special-cover__overlay"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-special-cover__content">
|
||||
<h1 class="aksrt-special-cover__title"><?php echo esc_html($title); ?></h1>
|
||||
|
||||
<?php if ($excerpt) : ?>
|
||||
<p class="aksrt-special-cover__summary"><?php echo esc_html($excerpt); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="aksrt-special-cover__meta">
|
||||
<span class="aksrt-special-cover__date">
|
||||
<i class="fas fa-calendar-alt"></i>
|
||||
<?php echo esc_html(get_the_date()); ?>
|
||||
</span>
|
||||
<?php
|
||||
if ($show_post_count) :
|
||||
$children = get_pages(['child_of' => $post_id, 'parent' => $post_id, 'post_status' => 'publish', 'fields' => 'ids']);
|
||||
if (!empty($children)) : ?>
|
||||
<span class="aksrt-special-cover__count">
|
||||
<i class="fas fa-file-alt"></i>
|
||||
<?php printf(esc_html__('%d 篇文章', 'aksrt'), count($children)); ?>
|
||||
</span>
|
||||
<?php endif; endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Special Page Grid
|
||||
*
|
||||
* Renders the content grid for a special/topic page.
|
||||
* Supports grid, list, and masonry layouts.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$posts = isset($posts) ? $posts : [];
|
||||
$layout = isset($layout) ? $layout : 'grid';
|
||||
$columns = isset($columns) ? (int) $columns : 2;
|
||||
$show_dates = isset($show_dates) ? $show_dates : true;
|
||||
|
||||
if (empty($posts)) return;
|
||||
?>
|
||||
<div class="aksrt-special-grid aksrt-special-grid--<?php echo esc_attr($layout); ?>" style="--aksrt-cols:<?php echo esc_attr((string) $columns); ?>">
|
||||
<?php foreach ($posts as $post) :
|
||||
setup_postdata($post);
|
||||
$img = get_the_post_thumbnail_url($post->ID, 'medium');
|
||||
?>
|
||||
<article class="aksrt-special-grid__item">
|
||||
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" class="aksrt-special-grid__link">
|
||||
<?php if ($img) : ?>
|
||||
<div class="aksrt-special-grid__thumb">
|
||||
<img src="<?php echo esc_url($img); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('other') : ' loading="lazy"'; ?>>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-special-grid__body">
|
||||
<h3 class="aksrt-special-grid__title"><?php echo esc_html($post->post_title); ?></h3>
|
||||
<?php if ($post->post_excerpt) : ?>
|
||||
<p class="aksrt-special-grid__desc"><?php echo esc_html(wp_trim_words($post->post_excerpt, 20)); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if ($show_dates) : ?>
|
||||
<time class="aksrt-special-grid__date" datetime="<?php echo esc_attr(get_the_date('c', $post->ID)); ?>">
|
||||
<?php echo esc_html(get_the_date('', $post->ID)); ?>
|
||||
</time>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
<?php endforeach; wp_reset_postdata(); ?>
|
||||
</div>
|
||||
Reference in new issue
Block a user