fix(homepage): unify runtime rendering contract
This commit is contained in:
1 parent
bd6f55c42e
commit
bcebd37807
13 files changed
+951
-926
No files matched your search
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Fixed homepage layout renderer.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (!function_exists('aksrt_homepage_render_layout')) {
|
||||
/**
|
||||
* Render the fixed homepage layout (Zibll latest-first content stream).
|
||||
*
|
||||
* Order (zibll-aligned):
|
||||
* fluid top → main.container → top content → banner → tabs/list → bottom content → sidebar
|
||||
* → fluid bottom. Hero/header-slider is rendered from header.php, not here.
|
||||
*/
|
||||
function aksrt_homepage_render_layout(): void {
|
||||
$current_page = aksrt_homepage_get_current_page();
|
||||
$show_tabs = $current_page === 1;
|
||||
$tab_configs = $show_tabs ? aksrt_homepage_get_tab_configs() : [];
|
||||
$latest_contract = aksrt_homepage_get_latest_panel_contract();
|
||||
$view_mode = (($latest_contract['render_config_array']['mode'] ?? 'list') === 'card') ? 'card' : 'list';
|
||||
$banner_on = $show_tabs && aksrt_homepage_module_banner_enabled();
|
||||
$main_list_enabled = !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::home_posts_list_enabled();
|
||||
$list_title = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::home_list_title()
|
||||
: __('最新发布', 'aksrt');
|
||||
|
||||
// Fluid zones live outside <main>, once only (removed from header.php).
|
||||
aksrt_homepage_render_widget_zone(
|
||||
['all_top_fluid', 'home_top_fluid'],
|
||||
'fluid-widget-wrap aksrt-homepage__fluid-zone aksrt-homepage__fluid-zone--top'
|
||||
);
|
||||
?>
|
||||
<main id="main-content" role="main" class="container site-main aksrt-homepage" tabindex="-1">
|
||||
<div class="content-wrap aksrt-homepage__shell">
|
||||
<div class="content-layout aksrt-homepage__content-layout aksrt-homepage__primary">
|
||||
<?php
|
||||
aksrt_homepage_render_widget_zone(
|
||||
['home_top_content'],
|
||||
'aksrt-homepage__content-zone aksrt-homepage__content-zone--top'
|
||||
);
|
||||
|
||||
if ($banner_on && function_exists('aksrt_homepage_render_section')) {
|
||||
aksrt_homepage_render_section('banner');
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($main_list_enabled) : ?>
|
||||
<section class="aksrt-homepage__stream home-tab-content" aria-label="<?php esc_attr_e('Homepage Content', 'aksrt'); ?>">
|
||||
<?php if ($show_tabs && !empty($tab_configs)) : ?>
|
||||
<div class="index-tab affix-header-sm relative home-tab-nav-box aksrt-homepage__tabs mb10" data-sticky-tabs="<?php echo aksrt_homepage_sticky_tabs_enabled() ? 'true' : 'false'; ?>" offset-top="-8">
|
||||
<ul class="list-inline scroll-x no-scrollbar aksrt-homepage__tab-list" role="tablist" data-aksrt-home-tabs style="width:100%;">
|
||||
<li class="aksrt-homepage__tab-item is-active" role="presentation">
|
||||
<button type="button" class="aksrt-homepage__tab-button" role="tab" aria-selected="true" data-home-tab-target="latest">
|
||||
<?php echo esc_html($list_title !== '' ? $list_title : __('最新发布', 'aksrt')); ?>
|
||||
</button>
|
||||
</li>
|
||||
<?php foreach ($tab_configs as $tab_cfg) : ?>
|
||||
<li class="aksrt-homepage__tab-item" role="presentation">
|
||||
<button
|
||||
type="button"
|
||||
class="aksrt-homepage__tab-button"
|
||||
role="tab"
|
||||
aria-selected="false"
|
||||
data-home-tab-target="term-<?php echo (int) $tab_cfg['term_id']; ?>"
|
||||
data-tab-orderby="<?php echo esc_attr($tab_cfg['orderby']); ?>"
|
||||
>
|
||||
<?php echo esc_html($tab_cfg['title']); ?>
|
||||
</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php if (function_exists('aksrt_render_admin_quick_link')) { aksrt_render_admin_quick_link('page-display/homepage', __('首页设置', 'aksrt'), 'aksrt-admin-quicklink aksrt-homepage__admin-link'); } ?>
|
||||
</div>
|
||||
<?php elseif ($current_page > 1) : ?>
|
||||
<div class="box-body notop nobottom aksrt-homepage__titlebox">
|
||||
<div class="title-theme">
|
||||
<?php echo esc_html($list_title !== '' ? $list_title : __('最新发布', 'aksrt')); ?>
|
||||
<small class="aksrt-homepage__page-indicator ml10">
|
||||
<?php echo esc_html(sprintf(__('第 %d 页', 'aksrt'), $current_page)); ?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($list_title !== '') : ?>
|
||||
<div class="box-body notop nobottom aksrt-homepage__titlebox">
|
||||
<div class="title-theme"><?php echo esc_html($list_title); ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php aksrt_homepage_render_sortbar(); ?>
|
||||
|
||||
<div class="aksrt-homepage__panels tab-content">
|
||||
<div class="aksrt-homepage__panel aksrt-homepage__posts posts-row post-grid post-grid--home ajaxpager tab-pane is-active show" role="tabpanel" data-home-tab-panel="latest" data-view="<?php echo esc_attr($view_mode); ?>" id="index-tab-main">
|
||||
<div
|
||||
class="aksrt-homepage__panel-contract"
|
||||
data-query-context="<?php echo esc_attr($latest_contract['query_context']); ?>"
|
||||
data-query-vars="<?php echo esc_attr($latest_contract['query_vars']); ?>"
|
||||
data-render-config="<?php echo esc_attr($latest_contract['render_config']); ?>"
|
||||
data-page="1"
|
||||
data-tab="latest"
|
||||
></div>
|
||||
<?php aksrt_homepage_render_posts_grid(aksrt_homepage_get_latest_query(), true); ?>
|
||||
</div>
|
||||
|
||||
<?php if ($show_tabs && !empty($tab_configs)) : ?>
|
||||
<?php foreach ($tab_configs as $tab_cfg) : ?>
|
||||
<div
|
||||
class="aksrt-homepage__panel aksrt-homepage__posts posts-row post-grid post-grid--home ajaxpager tab-pane"
|
||||
data-view="<?php echo esc_attr($view_mode); ?>"
|
||||
role="tabpanel"
|
||||
data-home-tab-panel="term-<?php echo (int) $tab_cfg['term_id']; ?>"
|
||||
data-tab-orderby="<?php echo esc_attr($tab_cfg['orderby']); ?>"
|
||||
hidden
|
||||
></div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php else : ?>
|
||||
<section class="aksrt-homepage__stream home-tab-content aksrt-homepage__stream--disabled" aria-label="<?php esc_attr_e('Homepage Content', 'aksrt'); ?>">
|
||||
<div class="no-results box-body">
|
||||
<p><?php esc_html_e('首页主列表已关闭。', 'aksrt'); ?></p>
|
||||
<?php if (current_user_can('manage_options') && function_exists('aksrt_render_admin_quick_link')) : ?>
|
||||
<?php aksrt_render_admin_quick_link('page-display/homepage', __('打开首页设置并启用主列表', 'aksrt'), 'aksrt-admin-quicklink'); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
aksrt_homepage_render_widget_zone(
|
||||
['home_bottom_content'],
|
||||
'aksrt-homepage__content-zone aksrt-homepage__content-zone--bottom'
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php aksrt_homepage_render_sidebar(); ?>
|
||||
</main>
|
||||
<?php
|
||||
aksrt_homepage_render_widget_zone(
|
||||
['home_bottom_fluid', 'all_bottom_fluid'],
|
||||
'fluid-widget-wrap aksrt-homepage__fluid-zone aksrt-homepage__fluid-zone--bottom'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_render_fixed_homepage')) {
|
||||
/**
|
||||
* Render the new fixed homepage layout.
|
||||
*/
|
||||
function aksrt_render_fixed_homepage(): bool {
|
||||
if (!aksrt_is_fixed_homepage_request()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
get_header();
|
||||
aksrt_homepage_render_layout();
|
||||
get_footer();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user