Files
wordpress-theme-aksrt/page.php
T

118 lines
4.0 KiB
PHP

<?php
/**
* 固定页面模板
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
get_header();
$page_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_post_page_settings()
: ['reading_progress' => false, 'lightbox' => true];
$page_id = get_queried_object_id();
$page_content_style = get_post_meta($page_id, 'page_content_style', true);
$page_content_style = $page_content_style !== '' ? sanitize_html_class($page_content_style) : 'default';
$show_sidebar = function_exists('aksrt_is_show_sidebar') ? aksrt_is_show_sidebar() : true;
?>
<?php if (!empty($page_settings['reading_progress'])) : ?>
<div id="reading-progress-global" class="reading-progress-bar" role="progressbar" aria-label="<?php esc_attr_e('阅读进度', 'aksrt'); ?>" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"></div>
<?php endif; ?>
<main id="main-content" class="container page-content-<?php echo esc_attr($page_content_style); ?> page-id-<?php echo esc_attr((string) $page_id); ?>" tabindex="-1">
<?php if (is_active_sidebar('page_top_fluid_' . $page_id)) : ?>
<div class="fluid-widget-wrap">
<?php dynamic_sidebar('page_top_fluid_' . $page_id); ?>
</div>
<?php endif; ?>
<div class="content-wrap">
<div class="content-layout<?php echo $show_sidebar ? "" : " no-sidebar"; ?>">
<div class="content-layout__primary">
<?php if (is_active_sidebar('page_top_content_' . $page_id)) : ?>
<?php dynamic_sidebar('page_top_content_' . $page_id); ?>
<?php endif; ?>
<?php
while ( have_posts() ) :
the_post();
?>
<article <?php post_class('entry-page'); ?>>
<?php
$page_meta_header_style = get_post_meta(get_the_ID(), 'page_header_style', true);
if ($page_meta_header_style !== '' && in_array($page_meta_header_style, ['', '1', '2', '3', 'not'], true)) {
$ph_style_override = ($page_meta_header_style === 'not') ? '' : $page_meta_header_style;
set_query_var('aksrt_ph_style', $ph_style_override);
}
$page_cover = get_post_meta(get_the_ID(), 'page_header_cover_img', true);
if (!empty($page_cover)) {
set_query_var('aksrt_ph_cover', esc_url($page_cover));
}
set_query_var('aksrt_ph_title', get_the_title());
get_template_part('templates/parts/page-header');
?>
<?php if ( has_post_thumbnail() ) : ?>
<figure class="entry-thumb">
<?php the_post_thumbnail( 'large' ); ?>
</figure>
<?php endif; ?>
<div class="entry-content" data-aksrt-lightbox="<?php echo !empty($page_settings['lightbox']) ? '1' : '0'; ?>">
<?php the_content(); ?>
<?php
wp_link_pages(
array(
'before' => '<nav class="page-links"><span class="page-links-title">' . esc_html__( '分页:', 'aksrt' ) . '</span>',
'after' => '</nav>',
)
);
?>
</div>
</article>
<?php
if ( comments_open() || get_comments_number() ) {
echo '<div class="theme-box box-body radius8 main-shadow comments-card">';
comments_template();
echo '</div>';
}
endwhile;
?>
<?php if (is_active_sidebar('page_bottom_content_' . $page_id)) : ?>
<?php dynamic_sidebar('page_bottom_content_' . $page_id); ?>
<?php endif; ?>
</div>
<?php if ($show_sidebar) : ?>
<?php get_sidebar(); ?>
<?php endif; ?>
</div>
</div>
<?php if (is_active_sidebar('page_bottom_fluid_' . $page_id)) : ?>
<div class="fluid-widget-wrap">
<?php dynamic_sidebar('page_bottom_fluid_' . $page_id); ?>
</div>
<?php endif; ?>
</main>
<?php if (!empty($page_settings['lightbox'])) : ?>
<div class="lightbox-overlay" id="lightbox-overlay" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e('图片预览', 'aksrt'); ?>">
<button type="button" class="lightbox-close" aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fas fa-times"></i></button>
<img src="" alt="" class="lightbox-img">
<div class="lightbox-caption" aria-live="polite"></div>
</div>
<?php endif; ?>
<div class="toast-container" id="toast-container"></div>
<?php
get_footer();