Merge pull request 'fix(homepage): align shell with zibll and restore post stream' (#89) from worktree-homepage-zibll-1to1 into main
Reviewed-on: CYL/wordpress-theme-aksrt#89
This commit is contained in:
@@ -931,13 +931,13 @@ export const pageDisplaySchemas = {
|
|||||||
icon: 'fas fa-home',
|
icon: 'fas fa-home',
|
||||||
description: '配置首页内容模型、主列表、分类 Tab、卡片样式与首页交互。实际编辑界面在 HomepageSettings.vue(customPage),此处补齐 page_display 的 schema 契约。',
|
description: '配置首页内容模型、主列表、分类 Tab、卡片样式与首页交互。实际编辑界面在 HomepageSettings.vue(customPage),此处补齐 page_display 的 schema 契约。',
|
||||||
defaults: {
|
defaults: {
|
||||||
homepage_content_model: 'mixed',
|
homepage_content_model: 'post',
|
||||||
homepage_tabs: [],
|
homepage_tabs: [],
|
||||||
homepage_card_style: 'default',
|
homepage_card_style: 'default',
|
||||||
homepage_multi_thumb_enabled: true,
|
homepage_multi_thumb_enabled: false,
|
||||||
homepage_multi_thumb_min_images: 3,
|
homepage_multi_thumb_min_images: 3,
|
||||||
homepage_sidebar_mini_enabled: true,
|
homepage_sidebar_mini_enabled: true,
|
||||||
homepage_default_sort: 'modified',
|
homepage_default_sort: 'date',
|
||||||
homepage_default_view: 'list',
|
homepage_default_view: 'list',
|
||||||
homepage_sort_ajax_enabled: true,
|
homepage_sort_ajax_enabled: true,
|
||||||
homepage_sticky_tabs_enabled: true,
|
homepage_sticky_tabs_enabled: true,
|
||||||
@@ -961,7 +961,7 @@ export const pageDisplaySchemas = {
|
|||||||
key: 'homepage_content_model',
|
key: 'homepage_content_model',
|
||||||
label: '首页内容模型',
|
label: '首页内容模型',
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
default: 'mixed',
|
default: 'post',
|
||||||
options: [
|
options: [
|
||||||
{ label: '混合模式', value: 'mixed' },
|
{ label: '混合模式', value: 'mixed' },
|
||||||
{ label: '纯文章', value: 'post' },
|
{ label: '纯文章', value: 'post' },
|
||||||
@@ -977,7 +977,7 @@ export const pageDisplaySchemas = {
|
|||||||
fields: [
|
fields: [
|
||||||
{ key: 'home_posts_list_s', label: '启用主列表', type: 'switch', default: true },
|
{ key: 'home_posts_list_s', label: '启用主列表', type: 'switch', default: true },
|
||||||
{ key: 'index_list_title', label: '区块标题', type: 'input', default: '最新发布', dependsOn: { key: 'home_posts_list_s', value: true } },
|
{ key: 'index_list_title', label: '区块标题', type: 'input', default: '最新发布', dependsOn: { key: 'home_posts_list_s', value: true } },
|
||||||
{ key: 'home_list1_orderby_option.orderby', label: '默认排序', type: 'select', default: 'modified', dependsOn: { key: 'home_posts_list_s', value: true }, options: sortOptions },
|
{ key: 'home_list1_orderby_option.orderby', label: '默认排序', type: 'select', default: 'date', dependsOn: { key: 'home_posts_list_s', value: true }, options: sortOptions },
|
||||||
{ key: 'home_list1_orderby_s', label: '启用排序栏', type: 'switch', default: true, dependsOn: { key: 'home_posts_list_s', value: true } },
|
{ key: 'home_list1_orderby_s', label: '启用排序栏', type: 'switch', default: true, dependsOn: { key: 'home_posts_list_s', value: true } },
|
||||||
{ key: 'home_list_sort_dropdown', label: '排序栏下拉模式', type: 'switch', default: false, dependsOn: { key: 'home_list1_orderby_s', value: true } },
|
{ key: 'home_list_sort_dropdown', label: '排序栏下拉模式', type: 'switch', default: false, dependsOn: { key: 'home_list1_orderby_s', value: true } },
|
||||||
{ key: 'home_list1_orderby_option', label: '可用排序选项', type: 'checkbox', default: ['modified', 'date', 'views', 'likes', 'comments'], dependsOn: { key: 'home_list1_orderby_s', value: true }, options: sortOptions },
|
{ key: 'home_list1_orderby_option', label: '可用排序选项', type: 'checkbox', default: ['modified', 'date', 'views', 'likes', 'comments'], dependsOn: { key: 'home_list1_orderby_s', value: true }, options: sortOptions },
|
||||||
|
|||||||
@@ -195,6 +195,7 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* Container — 三层叠加的父容器
|
* Container — 三层叠加的父容器
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
|
.header-slider-container,
|
||||||
.header-components-container {
|
.header-components-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
isolation: isolate; /* 创建独立堆叠上下文,内部 z-index 不外泄 */
|
isolation: isolate; /* 创建独立堆叠上下文,内部 z-index 不外泄 */
|
||||||
|
|||||||
+9
-1
@@ -238,7 +238,15 @@ $render_link_url = function ($raw) {
|
|||||||
|
|
||||||
<?php if ($hot_cat_count > 0) : ?>
|
<?php if ($hot_cat_count > 0) : ?>
|
||||||
<?php
|
<?php
|
||||||
$_hot_cats = get_categories(['orderby' => 'count', 'order' => 'DESC', 'number' => $hot_cat_count, 'hide_empty' => true]);
|
$_hot_cache_key = 'aksrt_footer_hot_cats_' . (int) $hot_cat_count;
|
||||||
|
$_hot_cats = wp_cache_get($_hot_cache_key, 'aksrt');
|
||||||
|
if (!is_array($_hot_cats)) {
|
||||||
|
$_hot_cats = get_categories(['orderby' => 'count', 'order' => 'DESC', 'number' => $hot_cat_count, 'hide_empty' => true]);
|
||||||
|
if (!is_array($_hot_cats)) {
|
||||||
|
$_hot_cats = [];
|
||||||
|
}
|
||||||
|
wp_cache_set($_hot_cache_key, $_hot_cats, 'aksrt', 12 * HOUR_IN_SECONDS);
|
||||||
|
}
|
||||||
if (!empty($_hot_cats)) :
|
if (!empty($_hot_cats)) :
|
||||||
?>
|
?>
|
||||||
<div class="site-footer__col col-lg-2 col-md-3 col-6">
|
<div class="site-footer__col col-lg-2 col-md-3 col-6">
|
||||||
|
|||||||
+23
-24
@@ -92,25 +92,9 @@ if (!empty($aksrt_bg_styles)) {
|
|||||||
|
|
||||||
<div id="aksrt-bg-vars" hidden <?php echo !empty($aksrt_bg_styles) ? "style=\"" . esc_attr(implode(';', $aksrt_bg_styles)) . "\"" : ""; ?>></div>
|
<div id="aksrt-bg-vars" hidden <?php echo !empty($aksrt_bg_styles) ? "style=\"" . esc_attr(implode(';', $aksrt_bg_styles)) . "\"" : ""; ?>></div>
|
||||||
|
|
||||||
<?php if (is_active_sidebar('all_top_fluid')) : ?>
|
|
||||||
<div class="fluid-widget-wrap">
|
|
||||||
<?php dynamic_sidebar('all_top_fluid'); ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if (is_active_sidebar('home_top_fluid') && (is_front_page() || is_home())) : ?>
|
|
||||||
<div class="fluid-widget-wrap">
|
|
||||||
<?php dynamic_sidebar('home_top_fluid'); ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if (is_active_sidebar('single_top_fluid') && is_singular()) : ?>
|
|
||||||
<div class="fluid-widget-wrap">
|
|
||||||
<?php dynamic_sidebar('single_top_fluid'); ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
// Fluid widget zones are rendered by page templates (homepage/single/archive)
|
||||||
|
// so they only appear once and stay in zibll order (after header-slider).
|
||||||
$aksrt_site_name = get_bloginfo('name');
|
$aksrt_site_name = get_bloginfo('name');
|
||||||
$aksrt_brand_name = function_exists('aksrt_get_site_logo_text') ? aksrt_get_site_logo_text() : $aksrt_site_name;
|
$aksrt_brand_name = function_exists('aksrt_get_site_logo_text') ? aksrt_get_site_logo_text() : $aksrt_site_name;
|
||||||
$aksrt_brand_name = $aksrt_brand_name !== '' ? $aksrt_brand_name : $aksrt_site_name;
|
$aksrt_brand_name = $aksrt_brand_name !== '' ? $aksrt_brand_name : $aksrt_site_name;
|
||||||
@@ -165,8 +149,14 @@ if (!empty($aksrt_bg_styles)) {
|
|||||||
current_user_can('manage_options')
|
current_user_can('manage_options')
|
||||||
|| (class_exists('AKSRT_Front_Submit') && AKSRT_Front_Submit::get_instance()->can_submit())
|
|| (class_exists('AKSRT_Front_Submit') && AKSRT_Front_Submit::get_instance()->can_submit())
|
||||||
);
|
);
|
||||||
|
$aksrt_show_header_slide = function_exists('aksrt_header_slide_is_show')
|
||||||
|
? aksrt_header_slide_is_show()
|
||||||
|
: false;
|
||||||
|
// Dual class contract: keep site-nav/* while aligning navbar/navbar-top with zibll.
|
||||||
$aksrt_nav_classes = [
|
$aksrt_nav_classes = [
|
||||||
'site-nav',
|
'site-nav',
|
||||||
|
'navbar',
|
||||||
|
'navbar-top',
|
||||||
'site-nav--' . $aksrt_header_settings['nav_style'],
|
'site-nav--' . $aksrt_header_settings['nav_style'],
|
||||||
$aksrt_header_settings['fixed'] ? 'site-nav--fixed' : 'site-nav--static',
|
$aksrt_header_settings['fixed'] ? 'site-nav--fixed' : 'site-nav--static',
|
||||||
];
|
];
|
||||||
@@ -203,14 +193,17 @@ if (!empty($aksrt_bg_styles)) {
|
|||||||
'header-layout-' . $aksrt_header_settings['layout'],
|
'header-layout-' . $aksrt_header_settings['layout'],
|
||||||
$aksrt_header_settings['fixed'] ? 'nav-fixed' : 'nav-static',
|
$aksrt_header_settings['fixed'] ? 'nav-fixed' : 'nav-static',
|
||||||
];
|
];
|
||||||
if (!empty($aksrt_header_settings['scroll_down_hide'])) {
|
if ($aksrt_show_header_slide) {
|
||||||
$aksrt_header_classes[] = 'show-slide';
|
$aksrt_header_classes[] = 'show-slide';
|
||||||
}
|
}
|
||||||
|
if (!empty($aksrt_header_settings['scroll_down_hide']) && !empty($aksrt_header_settings['fixed'])) {
|
||||||
|
$aksrt_header_classes[] = 'scroll-down-hide';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<header class="<?php echo esc_attr(implode(' ', array_map('sanitize_html_class', $aksrt_header_classes))); ?>">
|
<header class="<?php echo esc_attr(implode(' ', array_map('sanitize_html_class', $aksrt_header_classes))); ?>">
|
||||||
<nav class="<?php echo esc_attr(implode(' ', $aksrt_nav_classes)); ?> <?php echo esc_attr($aksrt_header_settings['mobile_layout']); ?>"<?php echo !empty($aksrt_nav_styles) ? ' style="' . esc_attr(implode(';', $aksrt_nav_styles)) . '"' : ''; ?> data-aksrt-shell="site-nav">
|
<nav class="<?php echo esc_attr(implode(' ', $aksrt_nav_classes)); ?> <?php echo esc_attr($aksrt_header_settings['mobile_layout']); ?>"<?php echo !empty($aksrt_nav_styles) ? ' style="' . esc_attr(implode(';', $aksrt_nav_styles)) . '"' : ''; ?> data-aksrt-shell="site-nav">
|
||||||
<div class="container-fluid container-header">
|
<div class="container-fluid container-header">
|
||||||
<div class="site-nav__row">
|
<div class="site-nav__row navbar-collapse">
|
||||||
<a href="<?php echo esc_url(home_url('/')); ?>" class="<?php echo esc_attr($aksrt_brand_class); ?> navbar-brand" aria-label="<?php echo esc_attr($aksrt_brand_name); ?>">
|
<a href="<?php echo esc_url(home_url('/')); ?>" class="<?php echo esc_attr($aksrt_brand_class); ?> navbar-brand" aria-label="<?php echo esc_attr($aksrt_brand_name); ?>">
|
||||||
<?php if ($aksrt_has_brand_logo) : ?>
|
<?php if ($aksrt_has_brand_logo) : ?>
|
||||||
<span class="site-brand__media navbar-logo"><?php echo $aksrt_brand_logo_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
|
<span class="site-brand__media navbar-logo"><?php echo $aksrt_brand_logo_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
|
||||||
@@ -383,10 +376,7 @@ if (!empty($aksrt_bg_styles)) {
|
|||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<?php if (empty($aksrt_header_settings['mobile_drawer'])) : ?>
|
<?php if (!empty($aksrt_header_settings['mobile_drawer'])) : ?>
|
||||||
<?php return; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div class="mobile-header nav-drawer-backdrop" id="nav-drawer-backdrop" aria-hidden="true"></div>
|
<div class="mobile-header nav-drawer-backdrop" id="nav-drawer-backdrop" aria-hidden="true"></div>
|
||||||
<div class="mobile-header nav-drawer" id="nav-drawer" data-aksrt-shell="nav-drawer" role="dialog" aria-modal="true" aria-labelledby="nav-drawer-title" aria-hidden="true">
|
<div class="mobile-header nav-drawer" id="nav-drawer" data-aksrt-shell="nav-drawer" role="dialog" aria-modal="true" aria-labelledby="nav-drawer-title" aria-hidden="true">
|
||||||
<nav class="mobile-navbar">
|
<nav class="mobile-navbar">
|
||||||
@@ -499,3 +489,12 @@ if (!empty($aksrt_bg_styles)) {
|
|||||||
<div class="fixed-body"></div>
|
<div class="fixed-body"></div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Zibll contract: header slider sits after </header> (+ mobile drawer), before page fluid/main.
|
||||||
|
if (function_exists('aksrt_header_slide')) {
|
||||||
|
aksrt_header_slide();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|||||||
@@ -644,8 +644,8 @@ trait AKSRT_Scripts_Part_1b {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMS 首页模块系统:仅在首页 + cms 形态加载
|
// Legacy freeform CMS home modules: only for non-fixed CMS archive previews.
|
||||||
$is_cms_home = ($is_home_or_archive && $is_cms_mode) || $is_fixed_homepage;
|
$is_cms_home = ($is_home_or_archive && $is_cms_mode) && !$is_fixed_homepage;
|
||||||
// 管理员预览模式(?aksrt_preview=...):无论站点风格都允许加载模块系统资源
|
// 管理员预览模式(?aksrt_preview=...):无论站点风格都允许加载模块系统资源
|
||||||
$is_preview = is_user_logged_in() && current_user_can('manage_options') && isset($_GET['aksrt_preview']);
|
$is_preview = is_user_logged_in() && current_user_can('manage_options') && isset($_GET['aksrt_preview']);
|
||||||
|
|
||||||
@@ -665,6 +665,8 @@ trait AKSRT_Scripts_Part_1b {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($is_fixed_homepage) {
|
if ($is_fixed_homepage) {
|
||||||
|
$enqueue_module('header-components'); // header-slider / hero
|
||||||
|
$enqueue_module('post-card');
|
||||||
$homepage_css_path = get_template_directory() . '/assets/css/frontend/homepage-fixed.css';
|
$homepage_css_path = get_template_directory() . '/assets/css/frontend/homepage-fixed.css';
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
'aksrt-homepage-fixed',
|
'aksrt-homepage-fixed',
|
||||||
|
|||||||
@@ -169,9 +169,9 @@ class AKSRT_Settings_Home_Cms {
|
|||||||
if (isset($s['home_list1_orderby_option']) && is_array($s['home_list1_orderby_option'])) {
|
if (isset($s['home_list1_orderby_option']) && is_array($s['home_list1_orderby_option'])) {
|
||||||
$orderby_option = $s['home_list1_orderby_option'];
|
$orderby_option = $s['home_list1_orderby_option'];
|
||||||
}
|
}
|
||||||
$default_sort = sanitize_key((string) ($orderby_option['orderby'] ?? $s['homepage_default_sort'] ?? 'modified'));
|
$default_sort = sanitize_key((string) ($orderby_option['orderby'] ?? $s['homepage_default_sort'] ?? 'date'));
|
||||||
if (!in_array($default_sort, $allowed_sorts, true)) {
|
if (!in_array($default_sort, $allowed_sorts, true)) {
|
||||||
$default_sort = 'modified';
|
$default_sort = 'date';
|
||||||
}
|
}
|
||||||
$sort_options_raw = $orderby_option['options'] ?? $s['home_list_sort_options'] ?? [];
|
$sort_options_raw = $orderby_option['options'] ?? $s['home_list_sort_options'] ?? [];
|
||||||
if (!is_array($sort_options_raw)) {
|
if (!is_array($sort_options_raw)) {
|
||||||
@@ -232,13 +232,13 @@ class AKSRT_Settings_Home_Cms {
|
|||||||
|
|
||||||
// AKSRT presentation extras.
|
// AKSRT presentation extras.
|
||||||
'homepage_card_style' => isset($s['homepage_card_style']) ? sanitize_key((string) $s['homepage_card_style']) : 'default',
|
'homepage_card_style' => isset($s['homepage_card_style']) ? sanitize_key((string) $s['homepage_card_style']) : 'default',
|
||||||
'homepage_multi_thumb_enabled' => !isset($s['homepage_multi_thumb_enabled']) || !empty($s['homepage_multi_thumb_enabled']),
|
'homepage_multi_thumb_enabled' => !empty($s['homepage_multi_thumb_enabled']),
|
||||||
'homepage_multi_thumb_min_images' => (int) ($s['homepage_multi_thumb_min_images'] ?? 3),
|
'homepage_multi_thumb_min_images' => (int) ($s['homepage_multi_thumb_min_images'] ?? 3),
|
||||||
'homepage_sidebar_mini_enabled' => !isset($s['homepage_sidebar_mini_enabled']) || !empty($s['homepage_sidebar_mini_enabled']),
|
'homepage_sidebar_mini_enabled' => !isset($s['homepage_sidebar_mini_enabled']) || !empty($s['homepage_sidebar_mini_enabled']),
|
||||||
'homepage_default_view' => isset($s['homepage_default_view']) ? sanitize_key((string) $s['homepage_default_view']) : 'list',
|
'homepage_default_view' => isset($s['homepage_default_view']) ? sanitize_key((string) $s['homepage_default_view']) : 'list',
|
||||||
'homepage_sort_ajax_enabled' => !isset($s['homepage_sort_ajax_enabled']) || !empty($s['homepage_sort_ajax_enabled']),
|
'homepage_sort_ajax_enabled' => !isset($s['homepage_sort_ajax_enabled']) || !empty($s['homepage_sort_ajax_enabled']),
|
||||||
'homepage_sticky_tabs_enabled' => !isset($s['homepage_sticky_tabs_enabled']) || !empty($s['homepage_sticky_tabs_enabled']),
|
'homepage_sticky_tabs_enabled' => !isset($s['homepage_sticky_tabs_enabled']) || !empty($s['homepage_sticky_tabs_enabled']),
|
||||||
'homepage_content_model' => isset($s['homepage_content_model']) && in_array($s['homepage_content_model'], ['post', 'mixed'], true) ? $s['homepage_content_model'] : 'mixed',
|
'homepage_content_model' => isset($s['homepage_content_model']) && in_array($s['homepage_content_model'], ['post', 'mixed'], true) ? $s['homepage_content_model'] : 'post',
|
||||||
'home_list_sort_dropdown' => !empty($s['home_list_sort_dropdown']),
|
'home_list_sort_dropdown' => !empty($s['home_list_sort_dropdown']),
|
||||||
'homepage_tab_posts_per_page' => max(1, min(20, (int) ($s['homepage_tab_posts_per_page'] ?? 6))),
|
'homepage_tab_posts_per_page' => max(1, min(20, (int) ($s['homepage_tab_posts_per_page'] ?? 6))),
|
||||||
'homepage_tab_limit' => max(1, min(12, (int) ($s['homepage_tab_limit'] ?? 4))),
|
'homepage_tab_limit' => max(1, min(12, (int) ($s['homepage_tab_limit'] ?? 4))),
|
||||||
@@ -296,7 +296,7 @@ class AKSRT_Settings_Home_Cms {
|
|||||||
|
|
||||||
public static function homepage_default_sort(): string {
|
public static function homepage_default_sort(): string {
|
||||||
$settings = self::get_homepage_fixed_settings();
|
$settings = self::get_homepage_fixed_settings();
|
||||||
return $settings['home_list1_orderby_option']['orderby'] ?? 'modified';
|
return $settings['home_list1_orderby_option']['orderby'] ?? 'date';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function homepage_default_view(): string {
|
public static function homepage_default_view(): string {
|
||||||
|
|||||||
+105
-50
@@ -38,21 +38,18 @@ if (!function_exists('aksrt_homepage_get_post_types')) {
|
|||||||
* Homepage latest feed post types.
|
* Homepage latest feed post types.
|
||||||
*
|
*
|
||||||
* Respects the homepage_content_model setting:
|
* Respects the homepage_content_model setting:
|
||||||
* - 'post': standard posts only
|
* - 'post': standard posts only (default)
|
||||||
* - 'mixed': posts + resource CPTs (default for existing sites)
|
* - 'mixed': posts + resource CPTs (explicit opt-in)
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
function aksrt_homepage_get_post_types(): array {
|
function aksrt_homepage_get_post_types(): array {
|
||||||
|
// Default: plain posts only (zibll main-query feel). Mixed/resource is opt-in.
|
||||||
$content_model = class_exists('AKSRT_Settings')
|
$content_model = class_exists('AKSRT_Settings')
|
||||||
? AKSRT_Settings::homepage_content_model()
|
? AKSRT_Settings::homepage_content_model()
|
||||||
: 'mixed';
|
: 'post';
|
||||||
|
|
||||||
if ($content_model === 'post') {
|
if ($content_model === 'mixed' && function_exists('aksrt_resource_post_types')) {
|
||||||
return ['post'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (function_exists('aksrt_resource_post_types')) {
|
|
||||||
return array_values(array_unique(aksrt_resource_post_types()));
|
return array_values(array_unique(aksrt_resource_post_types()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +203,7 @@ if (!function_exists('aksrt_homepage_get_sort_mode')) {
|
|||||||
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
|
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
|
||||||
$default_sort = class_exists('AKSRT_Settings')
|
$default_sort = class_exists('AKSRT_Settings')
|
||||||
? AKSRT_Settings::homepage_default_sort()
|
? AKSRT_Settings::homepage_default_sort()
|
||||||
: 'modified';
|
: 'date';
|
||||||
$override_sort = get_query_var('aksrt_homepage_sort_override');
|
$override_sort = get_query_var('aksrt_homepage_sort_override');
|
||||||
$sort = is_string($override_sort) && $override_sort !== ''
|
$sort = is_string($override_sort) && $override_sort !== ''
|
||||||
? sanitize_key($override_sort)
|
? sanitize_key($override_sort)
|
||||||
@@ -253,30 +250,44 @@ if (!function_exists('aksrt_homepage_apply_sort_args')) {
|
|||||||
function aksrt_homepage_apply_sort_args(array $args): array {
|
function aksrt_homepage_apply_sort_args(array $args): array {
|
||||||
$sort_mode = aksrt_homepage_get_sort_mode();
|
$sort_mode = aksrt_homepage_get_sort_mode();
|
||||||
|
|
||||||
|
// Meta sorts: keep posts without the meta key via OR NOT EXISTS so lists never collapse empty.
|
||||||
|
$apply_meta_sort = static function (array $args, string $meta_key): array {
|
||||||
|
$args['meta_key'] = $meta_key;
|
||||||
|
$args['orderby'] = [
|
||||||
|
'meta_value_num' => 'DESC',
|
||||||
|
'date' => 'DESC',
|
||||||
|
];
|
||||||
|
$args['meta_query'] = [
|
||||||
|
'relation' => 'OR',
|
||||||
|
[
|
||||||
|
'key' => $meta_key,
|
||||||
|
'compare' => 'EXISTS',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'key' => $meta_key,
|
||||||
|
'compare' => 'NOT EXISTS',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
return $args;
|
||||||
|
};
|
||||||
|
|
||||||
switch ($sort_mode) {
|
switch ($sort_mode) {
|
||||||
case 'date':
|
case 'modified':
|
||||||
$args['orderby'] = 'date';
|
$args['orderby'] = 'modified';
|
||||||
$args['order'] = 'DESC';
|
$args['order'] = 'DESC';
|
||||||
break;
|
break;
|
||||||
case 'downloads':
|
case 'downloads':
|
||||||
$args['meta_key'] = '_aksrt_res_download_count';
|
$args = $apply_meta_sort($args, '_aksrt_res_download_count');
|
||||||
$args['orderby'] = 'meta_value_num';
|
|
||||||
$args['order'] = 'DESC';
|
|
||||||
break;
|
break;
|
||||||
case 'views':
|
case 'views':
|
||||||
$args['meta_key'] = 'aksrt_post_views';
|
// Canonical public views key (align hotspot consumers later).
|
||||||
$args['orderby'] = 'meta_value_num';
|
$args = $apply_meta_sort($args, 'aksrt_post_views');
|
||||||
$args['order'] = 'DESC';
|
|
||||||
break;
|
break;
|
||||||
case 'likes':
|
case 'likes':
|
||||||
$args['meta_key'] = '_aksrt_like_count';
|
$args = $apply_meta_sort($args, '_aksrt_like_count');
|
||||||
$args['orderby'] = 'meta_value_num';
|
|
||||||
$args['order'] = 'DESC';
|
|
||||||
break;
|
break;
|
||||||
case 'favorites':
|
case 'favorites':
|
||||||
$args['meta_key'] = '_aksrt_favorite_count';
|
$args = $apply_meta_sort($args, '_aksrt_favorite_count');
|
||||||
$args['orderby'] = 'meta_value_num';
|
|
||||||
$args['order'] = 'DESC';
|
|
||||||
break;
|
break;
|
||||||
case 'comments':
|
case 'comments':
|
||||||
$args['orderby'] = 'comment_count';
|
$args['orderby'] = 'comment_count';
|
||||||
@@ -286,9 +297,9 @@ if (!function_exists('aksrt_homepage_apply_sort_args')) {
|
|||||||
$args['orderby'] = 'rand';
|
$args['orderby'] = 'rand';
|
||||||
unset($args['order']);
|
unset($args['order']);
|
||||||
break;
|
break;
|
||||||
case 'modified':
|
case 'date':
|
||||||
default:
|
default:
|
||||||
$args['orderby'] = 'modified';
|
$args['orderby'] = 'date';
|
||||||
$args['order'] = 'DESC';
|
$args['order'] = 'DESC';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -400,11 +411,12 @@ if (!function_exists('aksrt_homepage_get_latest_query')) {
|
|||||||
$query_args = [
|
$query_args = [
|
||||||
'post_type' => aksrt_homepage_get_post_types(),
|
'post_type' => aksrt_homepage_get_post_types(),
|
||||||
'post_status' => 'publish',
|
'post_status' => 'publish',
|
||||||
'posts_per_page' => (int) get_option('posts_per_page'),
|
'posts_per_page' => max(1, (int) get_option('posts_per_page')),
|
||||||
'paged' => aksrt_homepage_get_current_page(),
|
'paged' => aksrt_homepage_get_current_page(),
|
||||||
'ignore_sticky_posts' => false,
|
'ignore_sticky_posts' => false,
|
||||||
'orderby' => 'date',
|
'orderby' => 'date',
|
||||||
'order' => 'DESC',
|
'order' => 'DESC',
|
||||||
|
'no_found_rows' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$exclude_ids = class_exists('AKSRT_Settings')
|
$exclude_ids = class_exists('AKSRT_Settings')
|
||||||
@@ -758,7 +770,8 @@ if (!function_exists('aksrt_homepage_render_posts_grid')) {
|
|||||||
$query = $query instanceof WP_Query ? $query : aksrt_homepage_get_latest_query();
|
$query = $query instanceof WP_Query ? $query : aksrt_homepage_get_latest_query();
|
||||||
|
|
||||||
if (function_exists('aksrt_render_post_list')) {
|
if (function_exists('aksrt_render_post_list')) {
|
||||||
aksrt_render_post_list($query, ['mode' => 'list', 'context' => 'home'], true);
|
// Panel already provides posts-row.ajaxpager; avoid nested wrapper.
|
||||||
|
aksrt_render_post_list($query, ['mode' => 'list', 'context' => 'home', 'skip_wrapper' => true], true);
|
||||||
} else {
|
} else {
|
||||||
if (!$query->have_posts()) {
|
if (!$query->have_posts()) {
|
||||||
echo '<div class="no-results"><p>' . esc_html__('暂无文章', 'aksrt') . '</p></div>';
|
echo '<div class="no-results"><p>' . esc_html__('暂无文章', 'aksrt') . '</p></div>';
|
||||||
@@ -798,9 +811,51 @@ if (!function_exists('aksrt_homepage_render_section')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('aksrt_header_slide_is_show')) {
|
||||||
|
/**
|
||||||
|
* Whether the header multi-function slider should render (zibll header-slider contract).
|
||||||
|
*/
|
||||||
|
function aksrt_header_slide_is_show(): bool {
|
||||||
|
if (is_admin()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match zibll: only first page of the posts index / front page.
|
||||||
|
if (!(is_front_page() || is_home())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (function_exists('aksrt_homepage_get_current_page') && aksrt_homepage_get_current_page() > 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return function_exists('aksrt_homepage_module_hero_enabled')
|
||||||
|
? aksrt_homepage_module_hero_enabled()
|
||||||
|
: true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('aksrt_header_slide')) {
|
||||||
|
/**
|
||||||
|
* Render header slider after the site header (outside main).
|
||||||
|
*/
|
||||||
|
function aksrt_header_slide(): void {
|
||||||
|
if (!aksrt_header_slide_is_show()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reuse existing hero partial as the slider implementation.
|
||||||
|
get_template_part('templates/parts/home-modules/module', 'hero');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('aksrt_homepage_render_layout')) {
|
if (!function_exists('aksrt_homepage_render_layout')) {
|
||||||
/**
|
/**
|
||||||
* Render the fixed homepage layout (Zibll latest-first content stream).
|
* 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 {
|
function aksrt_homepage_render_layout(): void {
|
||||||
$current_page = aksrt_homepage_get_current_page();
|
$current_page = aksrt_homepage_get_current_page();
|
||||||
@@ -808,25 +863,19 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
|||||||
$tab_configs = $show_tabs ? aksrt_homepage_get_tab_configs() : [];
|
$tab_configs = $show_tabs ? aksrt_homepage_get_tab_configs() : [];
|
||||||
$latest_contract = aksrt_homepage_get_latest_panel_contract();
|
$latest_contract = aksrt_homepage_get_latest_panel_contract();
|
||||||
$has_sidebar = aksrt_homepage_has_sidebar();
|
$has_sidebar = aksrt_homepage_has_sidebar();
|
||||||
$hero_on = $show_tabs && aksrt_homepage_module_hero_enabled();
|
|
||||||
$banner_on = $show_tabs && aksrt_homepage_module_banner_enabled();
|
$banner_on = $show_tabs && aksrt_homepage_module_banner_enabled();
|
||||||
$main_list_enabled = !class_exists('AKSRT_Settings') || AKSRT_Settings::home_posts_list_enabled();
|
$main_list_enabled = !class_exists('AKSRT_Settings') || AKSRT_Settings::home_posts_list_enabled();
|
||||||
$list_title = class_exists('AKSRT_Settings')
|
$list_title = class_exists('AKSRT_Settings')
|
||||||
? AKSRT_Settings::home_list_title()
|
? AKSRT_Settings::home_list_title()
|
||||||
: __('最新发布', 'aksrt');
|
: __('最新发布', '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="site-main container aksrt-homepage" tabindex="-1">
|
<main id="main-content" role="main" class="container site-main aksrt-homepage" tabindex="-1">
|
||||||
<?php
|
|
||||||
aksrt_homepage_render_widget_zone(
|
|
||||||
['all_top_fluid', 'home_top_fluid'],
|
|
||||||
'fluid-widget-wrap aksrt-homepage__fluid-zone aksrt-homepage__fluid-zone--top'
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($hero_on && function_exists('aksrt_homepage_render_section')) {
|
|
||||||
aksrt_homepage_render_section('hero');
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="content-wrap aksrt-homepage__shell">
|
<div class="content-wrap aksrt-homepage__shell">
|
||||||
<div class="content-layout<?php echo $has_sidebar ? '' : ' content-layout--no-sidebar'; ?> aksrt-homepage__content-layout">
|
<div class="content-layout<?php echo $has_sidebar ? '' : ' content-layout--no-sidebar'; ?> aksrt-homepage__content-layout">
|
||||||
<div class="content-layout__primary aksrt-homepage__primary">
|
<div class="content-layout__primary aksrt-homepage__primary">
|
||||||
@@ -845,7 +894,7 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
|||||||
<section class="aksrt-homepage__stream home-tab-content" aria-label="<?php esc_attr_e('Homepage Content', 'aksrt'); ?>">
|
<section class="aksrt-homepage__stream home-tab-content" aria-label="<?php esc_attr_e('Homepage Content', 'aksrt'); ?>">
|
||||||
<?php if ($show_tabs && !empty($tab_configs)) : ?>
|
<?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">
|
<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="aksrt-homepage__tab-list scroll-x no-scrollbar" role="tablist" data-aksrt-home-tabs style="width:100%;">
|
<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">
|
<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">
|
<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')); ?>
|
<?php echo esc_html($list_title !== '' ? $list_title : __('最新发布', 'aksrt')); ?>
|
||||||
@@ -886,7 +935,7 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
|||||||
<?php aksrt_homepage_render_sortbar(); ?>
|
<?php aksrt_homepage_render_sortbar(); ?>
|
||||||
|
|
||||||
<div class="aksrt-homepage__panels tab-content">
|
<div class="aksrt-homepage__panels tab-content">
|
||||||
<div class="aksrt-homepage__panel posts-row ajaxpager tab-pane is-active" role="tabpanel" data-home-tab-panel="latest" id="index-tab-main">
|
<div class="aksrt-homepage__panel posts-row ajaxpager tab-pane fade in active is-active" role="tabpanel" data-home-tab-panel="latest" id="index-tab-main">
|
||||||
<div
|
<div
|
||||||
class="aksrt-homepage__panel-contract"
|
class="aksrt-homepage__panel-contract"
|
||||||
data-query-context="<?php echo esc_attr($latest_contract['query_context']); ?>"
|
data-query-context="<?php echo esc_attr($latest_contract['query_context']); ?>"
|
||||||
@@ -901,7 +950,7 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
|||||||
<?php if ($show_tabs && !empty($tab_configs)) : ?>
|
<?php if ($show_tabs && !empty($tab_configs)) : ?>
|
||||||
<?php foreach ($tab_configs as $tab_cfg) : ?>
|
<?php foreach ($tab_configs as $tab_cfg) : ?>
|
||||||
<div
|
<div
|
||||||
class="aksrt-homepage__panel ajaxpager tab-pane"
|
class="aksrt-homepage__panel posts-row ajaxpager tab-pane"
|
||||||
role="tabpanel"
|
role="tabpanel"
|
||||||
data-home-tab-panel="term-<?php echo (int) $tab_cfg['term_id']; ?>"
|
data-home-tab-panel="term-<?php echo (int) $tab_cfg['term_id']; ?>"
|
||||||
data-tab-orderby="<?php echo esc_attr($tab_cfg['orderby']); ?>"
|
data-tab-orderby="<?php echo esc_attr($tab_cfg['orderby']); ?>"
|
||||||
@@ -911,6 +960,15 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</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 endif; ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@@ -924,15 +982,12 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
|||||||
<?php aksrt_homepage_render_sidebar(); ?>
|
<?php aksrt_homepage_render_sidebar(); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
|
||||||
aksrt_homepage_render_widget_zone(
|
|
||||||
['home_bottom_fluid', 'all_bottom_fluid'],
|
|
||||||
'fluid-widget-wrap aksrt-homepage__fluid-zone aksrt-homepage__fluid-zone--bottom'
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
</main>
|
</main>
|
||||||
<?php
|
<?php
|
||||||
|
aksrt_homepage_render_widget_zone(
|
||||||
|
['home_bottom_fluid', 'all_bottom_fluid'],
|
||||||
|
'fluid-widget-wrap aksrt-homepage__fluid-zone aksrt-homepage__fluid-zone--bottom'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ if (!function_exists('aksrt_renderer_thumb')) {
|
|||||||
|
|
||||||
if ($has_real_img && !empty($lazy['enabled'])) {
|
if ($has_real_img && !empty($lazy['enabled'])) {
|
||||||
$img_html = '<span class="aksrt-skeleton"></span>'
|
$img_html = '<span class="aksrt-skeleton"></span>'
|
||||||
. '<img class="' . (!empty($cfg['thumb_fit']) && $cfg['thumb_fit'] === 'contain' ? 'fit-contain' : 'fit-cover') . ' aksrt-lazy" data-src="' . esc_url($img) . '" src="' . esc_url($lazy['placeholder_url']) . '" alt="' . esc_attr($title) . '">';
|
. '<img class="' . (!empty($cfg['thumb_fit']) && $cfg['thumb_fit'] === 'contain' ? 'fit-contain' : 'fit-cover') . ' aksrt-lazy lazyload" data-src="' . esc_url($img) . '" src="' . esc_url($lazy['placeholder_url']) . '" alt="' . esc_attr($title) . '">';
|
||||||
} else {
|
} else {
|
||||||
$img_html = '<img class="' . (!empty($cfg['thumb_fit']) && $cfg['thumb_fit'] === 'contain' ? 'fit-contain' : 'fit-cover') . '" src="' . esc_url($img) . '" alt="' . esc_attr($title) . '"' . ($has_real_img ? ' loading="lazy"' : '') . '>';
|
$img_html = '<img class="' . (!empty($cfg['thumb_fit']) && $cfg['thumb_fit'] === 'contain' ? 'fit-contain' : 'fit-cover') . '" src="' . esc_url($img) . '" alt="' . esc_attr($title) . '"' . ($has_real_img ? ' loading="lazy"' : '') . '>';
|
||||||
}
|
}
|
||||||
@@ -542,7 +542,7 @@ if (!function_exists('aksrt_renderer_mult_thumb')) {
|
|||||||
$html .= '<span>';
|
$html .= '<span>';
|
||||||
if (!empty($lazy['enabled'])) {
|
if (!empty($lazy['enabled'])) {
|
||||||
$html .= '<span class="aksrt-skeleton"></span>'
|
$html .= '<span class="aksrt-skeleton"></span>'
|
||||||
. '<img class="fit-cover aksrt-lazy" data-src="' . esc_url($image) . '" src="' . esc_url($lazy['placeholder_url']) . '" alt="">';
|
. '<img class="fit-cover aksrt-lazy lazyload" data-src="' . esc_url($image) . '" src="' . esc_url($lazy['placeholder_url']) . '" alt="">';
|
||||||
} else {
|
} else {
|
||||||
$html .= '<img class="fit-cover" src="' . esc_url($image) . '" alt="" loading="lazy">';
|
$html .= '<img class="fit-cover" src="' . esc_url($image) . '" alt="" loading="lazy">';
|
||||||
}
|
}
|
||||||
@@ -850,7 +850,7 @@ if (!function_exists('aksrt_renderer_mini')) {
|
|||||||
if ($cfg['show_thumb'] && !empty($data['has_img'])) {
|
if ($cfg['show_thumb'] && !empty($data['has_img'])) {
|
||||||
$lazy = $data['lazy'];
|
$lazy = $data['lazy'];
|
||||||
$thumb_img = !empty($lazy['enabled']) && !empty($data['has_real_img'])
|
$thumb_img = !empty($lazy['enabled']) && !empty($data['has_real_img'])
|
||||||
? '<span class="aksrt-skeleton"></span><img class="' . (!empty($cfg['thumb_fit']) && $cfg['thumb_fit'] === 'contain' ? 'fit-contain' : 'fit-cover') . ' aksrt-lazy" data-src="' . esc_url($data['img_url']) . '" src="' . esc_url($lazy['placeholder_url']) . '" alt="' . esc_attr($data['title']) . '">'
|
? '<span class="aksrt-skeleton"></span><img class="' . (!empty($cfg['thumb_fit']) && $cfg['thumb_fit'] === 'contain' ? 'fit-contain' : 'fit-cover') . ' aksrt-lazy lazyload" data-src="' . esc_url($data['img_url']) . '" src="' . esc_url($lazy['placeholder_url']) . '" alt="' . esc_attr($data['title']) . '">'
|
||||||
: '<img class="fit-cover" src="' . esc_url($data['img_url']) . '" alt="' . esc_attr($data['title']) . '"' . (!empty($data['has_real_img']) ? ' loading="lazy"' : '') . '>';
|
: '<img class="fit-cover" src="' . esc_url($data['img_url']) . '" alt="' . esc_attr($data['title']) . '"' . (!empty($data['has_real_img']) ? ' loading="lazy"' : '') . '>';
|
||||||
|
|
||||||
$thumb_html = '<a href="' . esc_url($data['permalink']) . '" class="item-thumbnail" aria-label="' . esc_attr($data['title']) . '"' . $target_attr . '>' . $thumb_img . '</a>';
|
$thumb_html = '<a href="' . esc_url($data['permalink']) . '" class="item-thumbnail" aria-label="' . esc_attr($data['title']) . '"' . $target_attr . '>' . $thumb_img . '</a>';
|
||||||
@@ -935,13 +935,17 @@ if (!function_exists('aksrt_render_post_list')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data_view = in_array($cfg['mode'], ['card', 'grid-cms'], true) ? 'card' : $cfg['mode'];
|
$data_view = in_array($cfg['mode'], ['card', 'grid-cms'], true) ? 'card' : $cfg['mode'];
|
||||||
|
// Homepage panel already provides .posts-row.ajaxpager — allow callers to skip nesting.
|
||||||
|
$skip_wrapper = !empty($config['skip_wrapper']);
|
||||||
$html = '';
|
$html = '';
|
||||||
|
|
||||||
if ($query instanceof WP_Query) {
|
if ($query instanceof WP_Query) {
|
||||||
if (!$query->have_posts()) {
|
if (!$query->have_posts()) {
|
||||||
$html = '<div class="no-results"><p>' . esc_html__('暂无文章', 'aksrt') . '</p></div>';
|
$html = '<div class="no-results"><p>' . esc_html__('暂无文章', 'aksrt') . '</p></div>';
|
||||||
} else {
|
} else {
|
||||||
$html .= '<div ' . $wrapper_attr . ' data-view="' . esc_attr($data_view) . '">';
|
if (!$skip_wrapper) {
|
||||||
|
$html .= '<div ' . $wrapper_attr . ' data-view="' . esc_attr($data_view) . '">';
|
||||||
|
}
|
||||||
$number = $cfg['number_offset'];
|
$number = $cfg['number_offset'];
|
||||||
while ($query->have_posts()) {
|
while ($query->have_posts()) {
|
||||||
$query->the_post();
|
$query->the_post();
|
||||||
@@ -952,19 +956,25 @@ if (!function_exists('aksrt_render_post_list')) {
|
|||||||
}
|
}
|
||||||
$html .= aksrt_render_post($cfg);
|
$html .= aksrt_render_post($cfg);
|
||||||
}
|
}
|
||||||
$html .= '</div>';
|
if (!$skip_wrapper) {
|
||||||
|
$html .= '</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
} else {
|
} else {
|
||||||
if (!have_posts()) {
|
if (!have_posts()) {
|
||||||
$html = '<div class="no-results"><p>' . esc_html__('暂无文章', 'aksrt') . '</p></div>';
|
$html = '<div class="no-results"><p>' . esc_html__('暂无文章', 'aksrt') . '</p></div>';
|
||||||
} else {
|
} else {
|
||||||
$html .= '<div ' . $wrapper_attr . ' data-view="' . esc_attr($data_view) . '">';
|
if (!$skip_wrapper) {
|
||||||
|
$html .= '<div ' . $wrapper_attr . ' data-view="' . esc_attr($data_view) . '">';
|
||||||
|
}
|
||||||
while (have_posts()) {
|
while (have_posts()) {
|
||||||
the_post();
|
the_post();
|
||||||
$html .= aksrt_render_post($cfg);
|
$html .= aksrt_render_post($cfg);
|
||||||
}
|
}
|
||||||
$html .= '</div>';
|
if (!$skip_wrapper) {
|
||||||
|
$html .= '</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,12 @@ if (!function_exists('aksrt_get_banners')):
|
|||||||
*/
|
*/
|
||||||
function aksrt_get_banners($limit = 8, $kind = 'hero') {
|
function aksrt_get_banners($limit = 8, $kind = 'hero') {
|
||||||
$kind = in_array($kind, array('hero', 'banner'), true) ? $kind : 'hero';
|
$kind = in_array($kind, array('hero', 'banner'), true) ? $kind : 'hero';
|
||||||
|
$limit = max(1, min(20, (int) $limit));
|
||||||
|
$cache_key = 'aksrt_banners_' . $kind . '_' . $limit;
|
||||||
|
$cached = wp_cache_get($cache_key, 'aksrt');
|
||||||
|
if (is_array($cached)) {
|
||||||
|
return $cached;
|
||||||
|
}
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'aksrt_banner',
|
'post_type' => 'aksrt_banner',
|
||||||
@@ -123,6 +129,7 @@ function aksrt_get_banners($limit = 8, $kind = 'hero') {
|
|||||||
'post_status' => 'publish',
|
'post_status' => 'publish',
|
||||||
'orderby' => 'menu_order',
|
'orderby' => 'menu_order',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
|
'no_found_rows' => true,
|
||||||
'meta_query' => 'hero' === $kind
|
'meta_query' => 'hero' === $kind
|
||||||
? array(
|
? array(
|
||||||
'relation' => 'OR',
|
'relation' => 'OR',
|
||||||
@@ -179,6 +186,7 @@ function aksrt_get_banners($limit = 8, $kind = 'hero') {
|
|||||||
wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wp_cache_set($cache_key, $banners, 'aksrt', 15 * MINUTE_IN_SECONDS);
|
||||||
return $banners;
|
return $banners;
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
@@ -1515,3 +1523,24 @@ function aksrt_user_can(string $cap, int $user_id = 0, ?int $context = null): bo
|
|||||||
return AKSRT_Settings::user_can($cap, $user_id, $context);
|
return AKSRT_Settings::user_can($cap, $user_id, $context);
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|
||||||
|
if (!function_exists('aksrt_flush_banner_cache')) :
|
||||||
|
/**
|
||||||
|
* Invalidate banner CPT object-cache keys used by aksrt_get_banners().
|
||||||
|
*/
|
||||||
|
function aksrt_flush_banner_cache($post_id = 0) {
|
||||||
|
if ($post_id && get_post_type($post_id) && get_post_type($post_id) !== 'aksrt_banner') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Group flush is not available on all object caches; delete common keys.
|
||||||
|
foreach (array('hero', 'banner') as $kind) {
|
||||||
|
for ($n = 1; $n <= 20; $n++) {
|
||||||
|
wp_cache_delete('aksrt_banners_' . $kind . '_' . $n, 'aksrt');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action('save_post_aksrt_banner', 'aksrt_flush_banner_cache');
|
||||||
|
add_action('deleted_post', 'aksrt_flush_banner_cache');
|
||||||
|
add_action('trashed_post', 'aksrt_flush_banner_cache');
|
||||||
|
endif;
|
||||||
|
|||||||
@@ -21,7 +21,19 @@ if (class_exists('AKSRT_Settings') && !AKSRT_Settings::homepage_module_banner_en
|
|||||||
}
|
}
|
||||||
|
|
||||||
$banners = function_exists('aksrt_get_banners') ? aksrt_get_banners(8, 'banner') : [];
|
$banners = function_exists('aksrt_get_banners') ? aksrt_get_banners(8, 'banner') : [];
|
||||||
if (empty($banners)) return;
|
if (empty($banners)) {
|
||||||
|
if (current_user_can('manage_options')) {
|
||||||
|
echo '<div class="home-module home-module--banner home-module--banner-empty box-body">';
|
||||||
|
echo '<p class="muted-2-color">' . esc_html__('No Banner slides found. Add banner slides in admin.', 'aksrt') . '</p>';
|
||||||
|
if (function_exists('aksrt_render_admin_quick_link')) {
|
||||||
|
echo '<div class="home-module__admin-tools">';
|
||||||
|
aksrt_render_admin_quick_link('page-display/header-components', __('Header / Banner settings', 'aksrt'));
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$cfg = get_query_var('aksrt_module_config', []);
|
$cfg = get_query_var('aksrt_module_config', []);
|
||||||
if (!is_array($cfg)) $cfg = [];
|
if (!is_array($cfg)) $cfg = [];
|
||||||
@@ -41,9 +53,9 @@ $swiper_config = [
|
|||||||
'spaceBetween' => ($slider_cfg['space_between'] ?? 0),
|
'spaceBetween' => ($slider_cfg['space_between'] ?? 0),
|
||||||
];
|
];
|
||||||
?>
|
?>
|
||||||
<div class="home-module home-module--banner">
|
<div class="home-module home-module--banner slide-widget mb20">
|
||||||
<div class="banner-module">
|
<div class="banner-module zib-slider">
|
||||||
<div class="swiper banner-module__swiper" data-swiper-config="<?php echo esc_attr(wp_json_encode($swiper_config)); ?>">
|
<div class="swiper new-swiper banner-module__swiper slide-widget-swiper" data-swiper-config="<?php echo esc_attr(wp_json_encode($swiper_config)); ?>">
|
||||||
<div class="swiper-wrapper">
|
<div class="swiper-wrapper">
|
||||||
<?php foreach ($banners as $index => $slide) :
|
<?php foreach ($banners as $index => $slide) :
|
||||||
$device_vis = $slide['device_visibility'] ?? 'all';
|
$device_vis = $slide['device_visibility'] ?? 'all';
|
||||||
|
|||||||
@@ -45,7 +45,10 @@ $card_icon_shape = $settings['header_components_card_icon_shape'] ?? 'circle';
|
|||||||
$slide_count = count($hero_banners);
|
$slide_count = count($hero_banners);
|
||||||
$visible_card_count = ($show_cards && !empty($icon_cards)) ? count($icon_cards) : 0;
|
$visible_card_count = ($show_cards && !empty($icon_cards)) ? count($icon_cards) : 0;
|
||||||
|
|
||||||
$container_classes = ['header-components-container', 'relative', 'card-' . $visible_card_count];
|
$container_classes = ['header-slider-container', 'header-components-container', 'relative', 'mb20', 'card-' . $visible_card_count];
|
||||||
|
if (in_array('pc', $filter_blur_devices, true) || in_array('mobile', $filter_blur_devices, true)) {
|
||||||
|
$container_classes[] = 'filter-blur';
|
||||||
|
}
|
||||||
if (in_array('pc', $filter_blur_devices, true)) {
|
if (in_array('pc', $filter_blur_devices, true)) {
|
||||||
$container_classes[] = 'has-blur-pc';
|
$container_classes[] = 'has-blur-pc';
|
||||||
}
|
}
|
||||||
@@ -70,7 +73,7 @@ $render_hero_search = static function (string $search_id) use ($search_placehold
|
|||||||
$_show_cat = !empty($search_cfg['show_input_cat']) && !empty($_cats);
|
$_show_cat = !empty($search_cfg['show_input_cat']) && !empty($_cats);
|
||||||
$_show_type = !empty($search_cfg['show_type']) && !empty($_types);
|
$_show_type = !empty($search_cfg['show_type']) && !empty($_types);
|
||||||
?>
|
?>
|
||||||
<div class="header-components-search">
|
<div class="header-slider-search header-components-search abs-center">
|
||||||
<div class="search-input">
|
<div class="search-input">
|
||||||
<form role="search" method="get" action="<?php echo esc_url(home_url('/')); ?>" class="search-form" data-aksrt-search-form="hero">
|
<form role="search" method="get" action="<?php echo esc_url(home_url('/')); ?>" class="search-form" data-aksrt-search-form="hero">
|
||||||
<input type="hidden" name="aksrt_search_type" value="<?php echo esc_attr($search_type); ?>">
|
<input type="hidden" name="aksrt_search_type" value="<?php echo esc_attr($search_type); ?>">
|
||||||
@@ -136,7 +139,7 @@ $render_icon_cards = static function () use ($show_cards, $icon_cards, $card_bg_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="header-components-card">
|
<div class="header-slider-card header-components-card container">
|
||||||
<div class="header-components-card__container container">
|
<div class="header-components-card__container container">
|
||||||
<?php if ($card_bg_mode === 'shared') : ?>
|
<?php if ($card_bg_mode === 'shared') : ?>
|
||||||
<div class="header-components-card__wrap header-components-card__wrap--shared">
|
<div class="header-components-card__wrap header-components-card__wrap--shared">
|
||||||
@@ -192,7 +195,7 @@ if (!empty($hero_banners)) :
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="<?php echo esc_attr(implode(' ', $container_classes)); ?>" id="aksrt-header-components"<?php if ($height_style !== '') : ?> style="<?php echo $height_style; ?>"<?php endif; ?>>
|
<div class="<?php echo esc_attr(implode(' ', $container_classes)); ?>" id="aksrt-header-components"<?php if ($height_style !== '') : ?> style="<?php echo $height_style; ?>"<?php endif; ?>>
|
||||||
<div class="swiper header-components slide-header" data-swiper-config="<?php echo esc_attr(wp_json_encode($swiper_config)); ?>">
|
<div class="relative zib-slider"><div class="swiper new-swiper header-components slide-index slide-header" data-swiper-config="<?php echo esc_attr(wp_json_encode($swiper_config)); ?>">
|
||||||
<div class="swiper-wrapper">
|
<div class="swiper-wrapper">
|
||||||
<?php foreach ($hero_banners as $index => $slide) :
|
<?php foreach ($hero_banners as $index => $slide) :
|
||||||
$device_vis = $slide['device_visibility'] ?? 'all';
|
$device_vis = $slide['device_visibility'] ?? 'all';
|
||||||
@@ -222,7 +225,7 @@ if (!empty($hero_banners)) :
|
|||||||
<div class="<?php echo esc_attr($slide_classes); ?>"<?php if (!empty($slide['link'])) : ?> data-link="<?php echo esc_url($slide['link']); ?>" data-target="<?php echo esc_attr($link_target); ?>"<?php endif; ?>>
|
<div class="<?php echo esc_attr($slide_classes); ?>"<?php if (!empty($slide['link'])) : ?> data-link="<?php echo esc_url($slide['link']); ?>" data-target="<?php echo esc_attr($link_target); ?>"<?php endif; ?>>
|
||||||
<div class="header-components__slide-bg">
|
<div class="header-components__slide-bg">
|
||||||
<?php if (!empty($slide['video_url'])) : ?>
|
<?php if (!empty($slide['video_url'])) : ?>
|
||||||
<video class="header-components__video" autoplay muted loop playsinline preload="auto">
|
<video class="header-components__video" autoplay muted loop playsinline preload="metadata">
|
||||||
<source src="<?php echo esc_url($slide['video_url']); ?>" type="video/mp4">
|
<source src="<?php echo esc_url($slide['video_url']); ?>" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -288,6 +291,7 @@ if (!empty($hero_banners)) :
|
|||||||
<?php $render_hero_search('header-search-input'); ?>
|
<?php $render_hero_search('header-search-input'); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php $render_icon_cards(); ?>
|
<?php $render_icon_cards(); ?>
|
||||||
<?php if (function_exists('aksrt_render_admin_quick_link')) : ?>
|
<?php if (function_exists('aksrt_render_admin_quick_link')) : ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user