56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Document Index Card
|
|
*
|
|
* Shows a card for a document page on the document navigation index.
|
|
* Used in the document navigation page to list available documents.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$page_id = get_the_ID();
|
|
$children = get_pages([
|
|
'parent' => $page_id,
|
|
'sort_column' => 'menu_order',
|
|
'sort_order' => 'ASC',
|
|
'post_status' => 'publish',
|
|
]);
|
|
$child_count = count($children);
|
|
$thumb = get_the_post_thumbnail_url($page_id, 'medium');
|
|
$excerpt = wp_trim_words(get_the_excerpt(), 30, '...');
|
|
?>
|
|
<a href="<?php the_permalink(); ?>" class="aksrt-doc-index-card">
|
|
<?php if ($thumb) : ?>
|
|
<div class="aksrt-doc-index-card__thumb">
|
|
<img src="<?php echo esc_url($thumb); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('other') : ' loading="lazy"'; ?>>
|
|
</div>
|
|
<?php else : ?>
|
|
<div class="aksrt-doc-index-card__icon">
|
|
<i class="fas fa-book-open"></i>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="aksrt-doc-index-card__body">
|
|
<h3 class="aksrt-doc-index-card__title"><?php the_title(); ?></h3>
|
|
<?php if ($excerpt) : ?>
|
|
<p class="aksrt-doc-index-card__desc"><?php echo esc_html($excerpt); ?></p>
|
|
<?php endif; ?>
|
|
<div class="aksrt-doc-index-card__meta">
|
|
<?php if ($child_count > 0) : ?>
|
|
<span class="aksrt-doc-index-card__count">
|
|
<i class="fas fa-file-alt"></i>
|
|
<?php printf(esc_html__('%d 篇文章', 'aksrt'), $child_count); ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
<span class="aksrt-doc-index-card__date">
|
|
<i class="fas fa-clock"></i>
|
|
<?php echo esc_html(get_the_date('', $page_id)); ?>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<i class="fas fa-chevron-right aksrt-doc-index-card__arrow"></i>
|
|
</a>
|