feat(admin): rebuild page display settings
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
* 从 functions.php 中抽离的核心功能钩子:
|
||||
* - SMTP 邮件配置注入
|
||||
* - 评论开关控制
|
||||
* - Banner CPT 注册
|
||||
* - Admin Bar 隐藏
|
||||
*
|
||||
* @package AKSRT
|
||||
@@ -36,25 +35,3 @@ add_filter('comment_text', function ($comment_text, $comment = null, $args = [])
|
||||
}, 20, 3);
|
||||
|
||||
// ============================================================
|
||||
// 注册自定义文章类型 - Banner (REST API for SPA)
|
||||
// ============================================================
|
||||
|
||||
function aksrt_register_banner_cpt() {
|
||||
register_post_type('aksrt_banner', array(
|
||||
'labels' => array(
|
||||
'name' => __('Banners', 'aksrt'),
|
||||
'singular_name' => __('Banner', 'aksrt'),
|
||||
),
|
||||
'public' => false,
|
||||
'show_ui' => false,
|
||||
'show_in_rest' => true,
|
||||
'supports' => array('title'),
|
||||
'menu_icon' => 'dashicons-images-alt2',
|
||||
'capability_type' => 'post',
|
||||
'capabilities' => array('create_posts' => 'manage_options'),
|
||||
'map_meta_cap' => true,
|
||||
));
|
||||
}
|
||||
add_action('init', 'aksrt_register_banner_cpt');
|
||||
|
||||
// ============================================================
|
||||
|
||||
@@ -119,6 +119,67 @@ if (!function_exists('aksrt_archive_render_filter_group')) :
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_archive_build_term_filter_group')) :
|
||||
/**
|
||||
* Build one ordered category/tag filter group from the page-display fieldset.
|
||||
*
|
||||
* @param string $taxonomy category|post_tag.
|
||||
* @param array<string,mixed> $option lists/dropdown/dropdown_lists fieldset.
|
||||
* @param string $label Visible group label.
|
||||
* @param bool $ajax Whether to attach archive AJAX attributes.
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
function aksrt_archive_build_term_filter_group(string $taxonomy, array $option, string $label, bool $ajax): array {
|
||||
if (!in_array($taxonomy, ['category', 'post_tag'], true)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$ids = is_array($option['lists'] ?? null) ? $option['lists'] : [];
|
||||
if (!empty($option['dropdown']) && is_array($option['dropdown_lists'] ?? null)) {
|
||||
$ids = array_merge($ids, $option['dropdown_lists']);
|
||||
}
|
||||
$ids = array_values(array_unique(array_filter(array_map('absint', $ids))));
|
||||
if ($ids === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$terms = get_terms([
|
||||
'taxonomy' => $taxonomy,
|
||||
'hide_empty' => true,
|
||||
'include' => $ids,
|
||||
'orderby' => 'include',
|
||||
]);
|
||||
if (is_wp_error($terms) || $terms === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$query_key = $taxonomy === 'category' ? 'aksrt_filter_cat' : 'aksrt_filter_tag';
|
||||
$data_key = $taxonomy === 'category' ? 'data-filter-cat' : 'data-filter-tag';
|
||||
$current = isset($_GET[$query_key]) ? absint(wp_unslash($_GET[$query_key])) : 0;
|
||||
$chips = [[
|
||||
'label' => __('全部', 'aksrt'),
|
||||
'url' => remove_query_arg([$query_key, 'paged']),
|
||||
'active' => $current === 0,
|
||||
'attrs' => $ajax ? ' ' . $data_key . '=""' : '',
|
||||
]];
|
||||
|
||||
foreach ($terms as $term) {
|
||||
$term_id = (int) $term->term_id;
|
||||
$chips[] = [
|
||||
'label' => $term->name,
|
||||
'url' => add_query_arg($query_key, $term_id, remove_query_arg('paged')),
|
||||
'active' => $current === $term_id,
|
||||
'attrs' => $ajax ? ' ' . $data_key . '="' . $term_id . '"' : '',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'label' => $label,
|
||||
'chips' => $chips,
|
||||
];
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_archive_render_filter_bar')) :
|
||||
/**
|
||||
* Shared filter bar shell for category/tag archives.
|
||||
@@ -134,13 +195,15 @@ if (!function_exists('aksrt_archive_render_filter_bar')) :
|
||||
'meta_text' => '',
|
||||
'groups' => [],
|
||||
'sort_enabled' => false,
|
||||
'sort_current' => 'latest',
|
||||
'sort_current' => 'date',
|
||||
'sort_links' => [],
|
||||
'sort_labels' => [],
|
||||
'sort_as_main' => false,
|
||||
]);
|
||||
|
||||
$groups = is_array($args['groups'] ?? null) ? $args['groups'] : [];
|
||||
$sort_links = is_array($args['sort_links'] ?? null) ? $args['sort_links'] : [];
|
||||
$sort_labels = is_array($args['sort_labels'] ?? null) ? $args['sort_labels'] : [];
|
||||
$has_sort = !empty($args['sort_enabled']) && !empty($sort_links);
|
||||
if (empty($groups) && !$has_sort && (string) $args['meta_text'] === '') {
|
||||
return;
|
||||
@@ -170,7 +233,7 @@ if (!function_exists('aksrt_archive_render_filter_bar')) :
|
||||
$sort_chips = [];
|
||||
foreach ($sort_links as $sort_key => $sort_url) {
|
||||
$sort_chips[] = [
|
||||
'label' => $sort_key === 'oldest' ? __('最早', 'aksrt') : ($sort_key === 'popular' ? __('热门', 'aksrt') : __('最新', 'aksrt')),
|
||||
'label' => (string) ($sort_labels[$sort_key] ?? $sort_key),
|
||||
'url' => (string) $sort_url,
|
||||
'active' => (string) $args['sort_current'] === (string) $sort_key,
|
||||
'attrs' => $ajax ? ' data-filter-sort="' . esc_attr((string) $sort_key) . '"' : '',
|
||||
|
||||
@@ -90,28 +90,35 @@ endif;
|
||||
|
||||
if (!function_exists('aksrt_archive_get_sort_state')) :
|
||||
/**
|
||||
* Shared latest/oldest/popular sort state for term archives.
|
||||
* Build the canonical Zibll orderby state for term archives.
|
||||
*
|
||||
* @param array<string,mixed> $option Page-display orderby fieldset.
|
||||
* @return array{current:string,links:array<string,string>}
|
||||
*/
|
||||
function aksrt_archive_get_sort_state(): array {
|
||||
$current_orderby = sanitize_key((string) get_query_var('orderby'));
|
||||
$current_order = strtoupper(sanitize_key((string) get_query_var('order')));
|
||||
$current = 'latest';
|
||||
function aksrt_archive_get_sort_state(array $option = []): array {
|
||||
$all = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
|
||||
: ['modified', 'date', 'views', 'like', 'comment_count', 'favorite', 'rand'];
|
||||
$lists = is_array($option['lists'] ?? null) ? $option['lists'] : [];
|
||||
$lists = array_values(array_intersect(array_map('sanitize_key', $lists), $all));
|
||||
if (!empty($option['dropdown'])) {
|
||||
$lists = array_values(array_unique(array_merge($lists, $all)));
|
||||
}
|
||||
|
||||
if ($current_orderby === 'date' && $current_order === 'ASC') {
|
||||
$current = 'oldest';
|
||||
} elseif ($current_orderby === 'comment_count') {
|
||||
$current = 'popular';
|
||||
$current = isset($_GET['orderby']) ? sanitize_key(wp_unslash((string) $_GET['orderby'])) : 'date';
|
||||
if (!in_array($current, $all, true)) {
|
||||
$current = 'date';
|
||||
}
|
||||
|
||||
$base_url = remove_query_arg(['orderby', 'order', 'paged']);
|
||||
$links = [];
|
||||
foreach ($lists as $orderby) {
|
||||
$links[$orderby] = add_query_arg('orderby', $orderby, $base_url);
|
||||
}
|
||||
|
||||
return [
|
||||
'current' => $current,
|
||||
'links' => [
|
||||
'latest' => remove_query_arg(['orderby', 'order', 'paged']),
|
||||
'oldest' => add_query_arg(['orderby' => 'date', 'order' => 'asc', 'paged' => false]),
|
||||
'popular' => add_query_arg(['orderby' => 'comment_count', 'order' => 'desc', 'paged' => false]),
|
||||
],
|
||||
'links' => $links,
|
||||
];
|
||||
}
|
||||
endif;
|
||||
|
||||
@@ -141,7 +141,7 @@ if (!function_exists('aksrt_render_header_menu_buttons')) :
|
||||
* Publish + optional VIP open button for header CTA.
|
||||
*/
|
||||
function aksrt_render_header_menu_buttons(): string {
|
||||
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
|
||||
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::read_domain('page_display', 'header-nav') : [];
|
||||
$types = is_array($settings['nav_newposts_btns'] ?? null)
|
||||
? array_values(array_intersect(array_map('sanitize_key', $settings['nav_newposts_btns']), ['post']))
|
||||
: ['post'];
|
||||
@@ -180,7 +180,7 @@ if (!function_exists('aksrt_render_header_menu_buttons')) :
|
||||
$show_vip = false;
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$vs = \AKSRT\Settings\Settings::get_payment_vip_settings();
|
||||
$show_vip = !empty($vs['enabled']) && (!isset($settings['nav_pay_vip']) || !empty($settings['nav_pay_vip']));
|
||||
$show_vip = !empty($vs['enabled']);
|
||||
}
|
||||
if ($show_vip) {
|
||||
$is_vip = false;
|
||||
|
||||
@@ -143,11 +143,6 @@ if (!function_exists('aksrt_header_payvip_bar')) :
|
||||
return $html;
|
||||
}
|
||||
|
||||
// Open-VIP CTA only when user-box switch is on (zibll nav_user_pay_vip).
|
||||
if (isset($settings['nav_user_pay_vip']) && empty($settings['nav_user_pay_vip'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Match check-in CTA geometry (full width, 6px radius) — not top-nav navbar-cta chips.
|
||||
return '<div class="mt10 em09 aksrt-header-payvip">'
|
||||
. '<a class="pay-vip but block payvip-icon aksrt-header-payvip__cta" href="javascript:;" vip-level="1">'
|
||||
|
||||
@@ -51,15 +51,11 @@ if (!function_exists('aksrt_homepage_get_tab_terms')) {
|
||||
* Homepage category tabs with full config.
|
||||
*
|
||||
* Returns enabled tabs in config order, each with 'term', 'title', 'orderby'.
|
||||
* Uses homepage_tab_limit from settings.
|
||||
* Preserves every configured row in the saved order.
|
||||
*
|
||||
* @return array<int, array{term:WP_Term, title:string, orderby:string, term_id:int}>
|
||||
*/
|
||||
function aksrt_homepage_get_tab_configs(): array {
|
||||
$limit = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_tab_limit()
|
||||
: 4;
|
||||
|
||||
if (!class_exists('\AKSRT\Settings\Settings')) {
|
||||
return [];
|
||||
}
|
||||
@@ -73,12 +69,9 @@ if (!function_exists('aksrt_homepage_get_tab_terms')) {
|
||||
$configs = [];
|
||||
|
||||
foreach ($structured_tabs as $tab) {
|
||||
if (empty($tab['enabled']) || $tab['term_id'] <= 0) {
|
||||
if ($tab['term_id'] <= 0) {
|
||||
continue;
|
||||
}
|
||||
if (count($configs) >= $limit) {
|
||||
break;
|
||||
}
|
||||
if (isset($excluded_cat_ids[$tab['term_id']])) {
|
||||
continue;
|
||||
}
|
||||
@@ -95,7 +88,7 @@ if (!function_exists('aksrt_homepage_get_tab_terms')) {
|
||||
'term' => $term,
|
||||
'term_id' => (int) $tab['term_id'],
|
||||
'title' => $tab['title'] !== '' ? $tab['title'] : $term->name,
|
||||
'orderby' => $tab['orderby'] ?: 'date',
|
||||
'orderby' => $tab['orderby'] ?: 'modified',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -143,19 +136,6 @@ if (!function_exists('aksrt_homepage_sticky_tabs_enabled')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_homepage_module_banner_enabled')) {
|
||||
/**
|
||||
* Whether the fixed homepage should render the built-in banner section.
|
||||
*/
|
||||
function aksrt_homepage_module_banner_enabled(): bool {
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
return \AKSRT\Settings\Settings::homepage_module_banner_enabled();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_homepage_get_sort_mode')) {
|
||||
/**
|
||||
* Current homepage main-stream sort mode.
|
||||
@@ -163,10 +143,10 @@ if (!function_exists('aksrt_homepage_get_sort_mode')) {
|
||||
function aksrt_homepage_get_sort_mode(): string {
|
||||
$allowed = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
|
||||
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
|
||||
: ['modified', 'date', 'views', 'like', 'comment_count', 'favorite', 'rand'];
|
||||
$default_sort = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_default_sort()
|
||||
: 'date';
|
||||
: 'modified';
|
||||
$override_sort = get_query_var('aksrt_homepage_sort_override');
|
||||
$sort = is_string($override_sort) && $override_sort !== ''
|
||||
? sanitize_key($override_sort)
|
||||
@@ -187,8 +167,7 @@ if (!function_exists('aksrt_homepage_get_sort_items')) {
|
||||
? \AKSRT\Settings\Settings::homepage_sort_labels()
|
||||
: [
|
||||
'modified' => '更新', 'date' => '发布', 'views' => '浏览',
|
||||
'likes' => '点赞', 'comments' => '评论', 'favorites' => '收藏',
|
||||
'downloads' => '下载', 'rand' => '随机',
|
||||
'like' => '点赞', 'comment_count' => '评论', 'favorite' => '收藏', 'rand' => '随机',
|
||||
];
|
||||
|
||||
$enabled_keys = class_exists('\AKSRT\Settings\Settings')
|
||||
@@ -239,20 +218,17 @@ if (!function_exists('aksrt_homepage_apply_sort_args')) {
|
||||
$args['orderby'] = 'modified';
|
||||
$args['order'] = 'DESC';
|
||||
break;
|
||||
case 'downloads':
|
||||
$args = $apply_meta_sort($args, '_aksrt_res_download_count');
|
||||
break;
|
||||
case 'views':
|
||||
// Canonical public views key (align hotspot consumers later).
|
||||
$args = $apply_meta_sort($args, 'aksrt_post_views');
|
||||
break;
|
||||
case 'likes':
|
||||
case 'like':
|
||||
$args = $apply_meta_sort($args, '_aksrt_like_count');
|
||||
break;
|
||||
case 'favorites':
|
||||
case 'favorite':
|
||||
$args = $apply_meta_sort($args, '_aksrt_favorite_count');
|
||||
break;
|
||||
case 'comments':
|
||||
case 'comment_count':
|
||||
$args['orderby'] = 'comment_count';
|
||||
$args['order'] = 'DESC';
|
||||
break;
|
||||
@@ -278,10 +254,10 @@ if (!function_exists('aksrt_homepage_apply_named_sort_args')) {
|
||||
function aksrt_homepage_apply_named_sort_args(array $args, string $sort_mode): array {
|
||||
$allowed = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
|
||||
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
|
||||
: ['modified', 'date', 'views', 'like', 'comment_count', 'favorite', 'rand'];
|
||||
|
||||
if (!in_array($sort_mode, $allowed, true)) {
|
||||
$sort_mode = 'date';
|
||||
$sort_mode = 'modified';
|
||||
}
|
||||
|
||||
$previous = get_query_var('aksrt_homepage_sort_override');
|
||||
|
||||
@@ -372,7 +372,8 @@ if (!function_exists('aksrt_link_get_search_cover')) :
|
||||
$img = (string) get_post_meta($post_id, 'page_header_cover_img', true);
|
||||
}
|
||||
if ($img === '' && class_exists('\AKSRT\Settings\Settings')) {
|
||||
$img = (string) \AKSRT\Settings\Settings::get_value('page_header_cover_img', '');
|
||||
$other = \AKSRT\Settings\Settings::get_other_page_settings();
|
||||
$img = (string) ($other['header_cover_img'] ?? '');
|
||||
}
|
||||
if ($img === '') {
|
||||
$img = get_template_directory_uri() . '/assets/img/placeholder.svg';
|
||||
|
||||
@@ -168,10 +168,6 @@ if (!function_exists('aksrt_header_user_box_html')) :
|
||||
}
|
||||
}
|
||||
$payvip = function_exists('aksrt_header_payvip_bar') ? aksrt_header_payvip_bar($user_id) : '';
|
||||
// nav_user_pay_vip gate: empty payvip when switch off for non-VIP CTA only — helper already handles VIP status.
|
||||
if (empty($ctx['nav_user_pay_vip']) && $payvip !== '' && strpos($payvip, 'is-vip') === false) {
|
||||
$payvip = '';
|
||||
}
|
||||
$checkin = function_exists('aksrt_header_user_checkin_btn') ? aksrt_header_user_checkin_btn($user_id) : '';
|
||||
$wallet = function_exists('aksrt_header_user_wallet_mini') ? aksrt_header_user_wallet_mini($user_id) : '';
|
||||
$badges = function_exists('aksrt_header_user_badges_row') ? aksrt_header_user_badges_row($user_id) : '';
|
||||
@@ -201,8 +197,7 @@ if (!function_exists('aksrt_header_user_box_html')) :
|
||||
}
|
||||
|
||||
if (!empty($ctx['can_publish'])) {
|
||||
$all = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
|
||||
$pub_text = (string) ($all['nav_user_newposts_btn_text'] ?? '');
|
||||
$pub_text = (string) ($ctx['settings']['nav_user_newposts_btn_text'] ?? '');
|
||||
if ($pub_text === '') {
|
||||
$pub_text = __('发布内容', 'aksrt');
|
||||
}
|
||||
@@ -249,7 +244,7 @@ if (!function_exists('aksrt_header_user_box_html')) :
|
||||
$con .= '<div class="mt10 text-center">' . $href . '</div>';
|
||||
} else {
|
||||
$vip_guest = '';
|
||||
if (!empty($ctx['nav_user_pay_vip']) && class_exists('\AKSRT\Settings\Settings')) {
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$vs = \AKSRT\Settings\Settings::get_payment_vip_settings();
|
||||
if (!empty($vs['enabled'])) {
|
||||
$vip_guest = '<div><a class="em09 signin-loader but jb-red radius4 payvip-icon btn-block mt10" href="javascript:;">'
|
||||
@@ -296,7 +291,7 @@ if (!function_exists('aksrt_menu_button')) :
|
||||
$user_id = (int) ($ctx['user_id'] ?? 0);
|
||||
$button = '';
|
||||
|
||||
// Publish + VIP (respect nav_pay_vip).
|
||||
// Publish and membership actions.
|
||||
if (function_exists('aksrt_render_header_menu_buttons')) {
|
||||
$action_buttons = aksrt_render_header_menu_buttons();
|
||||
if ($action_buttons !== '') {
|
||||
|
||||
@@ -20,7 +20,7 @@ if (!function_exists('aksrt_get_header_nav_context')) :
|
||||
}
|
||||
|
||||
$settings = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_all()
|
||||
? \AKSRT\Settings\Settings::read_domain('page_display', 'header-nav')
|
||||
: [];
|
||||
$layout = sanitize_key((string) ($settings['header_layout'] ?? '1'));
|
||||
if (!in_array($layout, ['1', '2', '3'], true)) {
|
||||
@@ -79,8 +79,6 @@ if (!function_exists('aksrt_get_header_nav_context')) :
|
||||
'mobile_align' => $mobile_align,
|
||||
'fixed' => $nav_fixed,
|
||||
'scroll_down_hide' => (!isset($settings['nav_scroll_down_hide']) || !empty($settings['nav_scroll_down_hide'])) && $nav_fixed,
|
||||
'nav_pay_vip' => !isset($settings['nav_pay_vip']) || !empty($settings['nav_pay_vip']),
|
||||
'nav_user_pay_vip' => !isset($settings['nav_user_pay_vip']) || !empty($settings['nav_user_pay_vip']),
|
||||
'brand_name' => $brand_name,
|
||||
'logo_html' => $logo_html,
|
||||
'has_logo' => $logo_html !== '',
|
||||
|
||||
@@ -48,7 +48,6 @@ if (!function_exists('aksrt_homepage_get_latest_query')) {
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_homepage_get_tab_query')) {
|
||||
/**
|
||||
* Build a category-tab query.
|
||||
@@ -100,7 +99,6 @@ if (!function_exists('aksrt_homepage_get_tab_query')) {
|
||||
return $queries[$cache_key];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_homepage_has_active_sidebars')) {
|
||||
/**
|
||||
* Check whether any sidebar in the given stack is active.
|
||||
@@ -362,21 +360,3 @@ if (!function_exists('aksrt_homepage_render_posts_grid')) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_homepage_render_section')) {
|
||||
/**
|
||||
* Render the remaining first-class homepage banner section.
|
||||
*
|
||||
* These are fixed homepage sections, not a freeform module canvas bridge.
|
||||
*/
|
||||
function aksrt_homepage_render_section(string $type): void {
|
||||
$type = sanitize_key($type);
|
||||
if ($type !== 'banner') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fixed homepage owns these sections directly.
|
||||
// Header slider is rendered by aksrt_header_slide(), never by this module path.
|
||||
get_template_part('templates/parts/home-modules/module', $type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ if (!function_exists('aksrt_header_slide_excluded_page_templates')) {
|
||||
'templates/pages/page-verify-email.php',
|
||||
'templates/pages/page-download.php',
|
||||
'templates/pages/page-download-file.php',
|
||||
'templates/pages/page-forums.php',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -65,14 +64,6 @@ if (!function_exists('aksrt_header_slide_matches_query')) {
|
||||
return is_singular('post');
|
||||
case 'search':
|
||||
return is_search();
|
||||
case 'topics':
|
||||
return is_tax('topics');
|
||||
case 'forum_home':
|
||||
return is_page_template('templates/pages/page-forums.php');
|
||||
case 'forum_plate':
|
||||
return is_singular('plate') || is_post_type_archive('plate');
|
||||
case 'forum_post':
|
||||
return is_singular('forum_post');
|
||||
case 'page':
|
||||
if (!is_page()) {
|
||||
return false;
|
||||
|
||||
@@ -12,7 +12,7 @@ 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 top → main.container → top content → tabs/list → bottom content → sidebar
|
||||
* → fluid bottom. Hero/header-slider is rendered from header.php, not here.
|
||||
*/
|
||||
function aksrt_homepage_render_layout(): void {
|
||||
@@ -21,7 +21,6 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
||||
$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()
|
||||
@@ -42,9 +41,6 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
||||
'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) : ?>
|
||||
@@ -54,7 +50,7 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
||||
<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')); ?>
|
||||
<?php echo wp_kses_post($list_title !== '' ? $list_title : __('最新发布', 'aksrt')); ?>
|
||||
</button>
|
||||
</li>
|
||||
<?php foreach ($tab_configs as $tab_cfg) : ?>
|
||||
@@ -67,7 +63,7 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
||||
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']); ?>
|
||||
<?php echo wp_kses_post($tab_cfg['title']); ?>
|
||||
</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
@@ -77,7 +73,7 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
||||
<?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')); ?>
|
||||
<?php echo wp_kses_post($list_title !== '' ? $list_title : __('最新发布', 'aksrt')); ?>
|
||||
<small class="aksrt-homepage__page-indicator ml10">
|
||||
<?php echo esc_html(sprintf(__('第 %d 页', 'aksrt'), $current_page)); ?>
|
||||
</small>
|
||||
@@ -85,7 +81,7 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
||||
</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 class="title-theme"><?php echo wp_kses_post($list_title); ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -7,115 +7,6 @@
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
// ============================================================
|
||||
// 模板标签:Banner 幻灯片
|
||||
// ============================================================
|
||||
|
||||
if (!function_exists('aksrt_decode_slide_layers')):
|
||||
/**
|
||||
* Decode the layers JSON meta for a slide.
|
||||
*
|
||||
* @param int $post_id
|
||||
* @return array
|
||||
*/
|
||||
function aksrt_decode_slide_layers(int $post_id): array {
|
||||
$json = get_post_meta($post_id, '_layers', true);
|
||||
if (!is_string($json) || $json === '') {
|
||||
return [];
|
||||
}
|
||||
$decoded = json_decode($json, true);
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_slider_config')):
|
||||
/**
|
||||
* Get the global slider config for content-stream Banner rendering.
|
||||
* Falls back to sensible defaults when no config is saved.
|
||||
*
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
function aksrt_get_slider_config(): array {
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
return \AKSRT\Settings\Settings::get_slider_config();
|
||||
}
|
||||
return [
|
||||
'effect' => 'fade', 'loop' => true, 'autoplay_interval' => 5000,
|
||||
'pagination' => true, 'navigation' => true, 'auto_height' => false,
|
||||
'pc_height' => '', 'mobile_height' => '', 'space_between' => 0,
|
||||
];
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_get_banners')):
|
||||
/**
|
||||
* 获取已启用的首页内容流 Banner。
|
||||
*
|
||||
* @param int $limit 最大数量
|
||||
* @return array
|
||||
*/
|
||||
function aksrt_get_banners($limit = 8) {
|
||||
$limit = max(1, min(20, (int) $limit));
|
||||
$cache_key = 'aksrt_banners_' . $limit;
|
||||
$cached = wp_cache_get($cache_key, 'aksrt');
|
||||
if (is_array($cached)) {
|
||||
return $cached;
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'aksrt_banner',
|
||||
'posts_per_page' => $limit,
|
||||
'post_status' => 'publish',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'no_found_rows' => true,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_aksrt_kind',
|
||||
'value' => 'banner',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$query = new WP_Query($args);
|
||||
$banners = array();
|
||||
|
||||
if ($query->have_posts()) {
|
||||
while ($query->have_posts()) {
|
||||
$query->the_post();
|
||||
$id = get_the_ID();
|
||||
|
||||
// 只返回启用的
|
||||
$enabled = get_post_meta($id, '_enabled', true);
|
||||
if ($enabled === '0') continue;
|
||||
|
||||
$banners[] = array(
|
||||
'id' => $id,
|
||||
'title' => get_the_title(),
|
||||
'subtitle' => get_post_meta($id, '_subtitle', true),
|
||||
'description' => get_post_meta($id, '_description', true),
|
||||
'image' => get_post_meta($id, '_image_url', true),
|
||||
'video_url' => get_post_meta($id, '_video_url', true),
|
||||
'link' => get_post_meta($id, '_link_url', true),
|
||||
'link_target' => get_post_meta($id, '_link_target', true) ?: '_self',
|
||||
'text_align' => get_post_meta($id, '_text_align', true) ?: 'left',
|
||||
'device_visibility' => get_post_meta($id, '_device_visibility', true) ?: 'all',
|
||||
'show_text' => get_post_meta($id, '_show_text', true) !== '0',
|
||||
'show_meta' => get_post_meta($id, '_show_meta', true) === '1',
|
||||
'text_size_pc' => get_post_meta($id, '_text_size_pc', true) ?: '',
|
||||
'text_size_m' => get_post_meta($id, '_text_size_m', true) ?: '',
|
||||
'text_parallax' => get_post_meta($id, '_text_parallax', true) === '1',
|
||||
'layers' => aksrt_decode_slide_layers($id),
|
||||
);
|
||||
}
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
wp_cache_set($cache_key, $banners, 'aksrt', 15 * MINUTE_IN_SECONDS);
|
||||
return $banners;
|
||||
}
|
||||
endif;
|
||||
|
||||
// ============================================================
|
||||
// 模板标签:图标覆盖卡片(顶部多功能组件叠加层)
|
||||
// 完全模仿 zibll 的 zib_icon_cover_card
|
||||
|
||||
@@ -378,25 +378,6 @@ function aksrt_user_can(string $cap, int $user_id = 0, ?int $context = null): bo
|
||||
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.
|
||||
for ($n = 1; $n <= 20; $n++) {
|
||||
wp_cache_delete('aksrt_banners_' . $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;
|
||||
|
||||
|
||||
if (!function_exists('aksrt_should_use_footer_tabbar_single_extend')) :
|
||||
/**
|
||||
* Whether single-post extended footer tabbar should replace the default items.
|
||||
|
||||
@@ -292,7 +292,7 @@ function aksrt_get_search_facets_data(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
$allowed = ['category', 'topics', 'post_tag'];
|
||||
$allowed = ['category', 'post_tag'];
|
||||
$data = [];
|
||||
foreach ($raw as $taxonomy => $ids) {
|
||||
$taxonomy = sanitize_key((string) $taxonomy);
|
||||
@@ -393,7 +393,6 @@ function aksrt_get_search_tab_nav_filter(string $type): string {
|
||||
if ($type === 'post') {
|
||||
$labels = [
|
||||
'category' => __('分类', 'aksrt'),
|
||||
'topics' => __('专题', 'aksrt'),
|
||||
'post_tag' => __('标签', 'aksrt'),
|
||||
];
|
||||
$current = isset($_REQUEST['trem']) ? absint(wp_unslash($_REQUEST['trem'])) : 0;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* AKSRT Theme - Template Tags Module
|
||||
*
|
||||
* 模板标签 / 辅助函数集合:
|
||||
* - Banner 幻灯片获取
|
||||
* - 友情链接 / 站点 Logo / Favicon / About 信息
|
||||
* - 社交链接渲染
|
||||
* - 文章分类标签 / 阅读时间 / 评论数
|
||||
@@ -190,14 +189,6 @@ function aksrt_is_show_sidebar_filter(): bool {
|
||||
}
|
||||
}
|
||||
|
||||
// Search page display setting can force off.
|
||||
if (is_search() && class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_other_page_settings')) {
|
||||
$other = \AKSRT\Settings\Settings::get_other_page_settings();
|
||||
if (is_array($other) && array_key_exists('page_search_sidebar', $other) && empty($other['page_search_sidebar'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Scene switches above already gated; when enabled, show the column
|
||||
// (widgets may be empty — matches zibll empty sidebar column policy).
|
||||
if (is_home() || is_front_page()) {
|
||||
@@ -295,4 +286,3 @@ function aksrt_body_layout_classes(): array {
|
||||
return ['site-layout-' . $layout];
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user