[], 'quick_links' => [], 'more_links' => [], 'hot_categories' => 5, 'copyright_text' => '', 'layout_template' => 'template_1', ]; $footer = get_option('aksrt_footer_settings', []); $merged = array_merge($defaults, is_array($footer) ? $footer : []); $s = AKSRT_Settings::get_all(); $bridge_keys = [ 'footer_columns', 'footer_copyright', 'footer_icp', 'icp_number', 'footer_police', 'police_number', 'footer_theme_custom', 'footer_theme_bg_custom', 'footer_theme_bg', 'footer_theme_color_custom', 'footer_contact_wechat_img', 'footer_contact_qq', 'footer_contact_weibo', 'footer_contact_email', ]; foreach ($bridge_keys as $key) { if (isset($s[$key])) { $merged[$key] = $s[$key]; } } return $merged; } public static function get_footer_contacts(): array { $footer = self::get_footer_settings(); return array_filter($footer['contacts'], fn($c) => !empty($c['enabled'])); } public static function get_quick_links(): array { $footer = self::get_footer_settings(); $links = array_filter($footer['quick_links'], fn($l) => !empty($l['enabled'])); usort($links, fn($a, $b) => ($a['sort_order'] ?? 0) <=> ($b['sort_order'] ?? 0)); return array_values($links); } public static function get_more_links(): array { $footer = self::get_footer_settings(); $links = array_filter($footer['more_links'], fn($l) => !empty($l['enabled'])); usort($links, fn($a, $b) => ($a['sort_order'] ?? 0) <=> ($b['sort_order'] ?? 0)); return array_values($links); } public static function get_hot_categories_count(): int { $footer = self::get_footer_settings(); return max(1, min(20, (int) ($footer['hot_categories'] ?? 5))); } public static function get_copyright_text(): string { $footer = self::get_footer_settings(); return $footer['copyright_text'] ?: ''; } public static function get_footer_brand_settings(): array { $f = self::get_footer_settings(); return [ 'm_s' => is_array($f['footer_t1_m_s'] ?? null) ? $f['footer_t1_m_s'] : ['pc', 'mobile'], 'img' => (string) ($f['footer_t1_img'] ?? ''), 'img_dark' => (string) ($f['footer_t1_img_dark'] ?? ''), 'title' => (string) ($f['footer_t1_t'] ?? ''), 'custom_code' => (string) ($f['fcode_t1_code'] ?? ''), ]; } public static function get_footer_contact_extended_settings(): array { $f = self::get_footer_settings(); return [ 'm_s' => is_array($f['footer_contact_m_s'] ?? null) ? $f['footer_contact_m_s'] : ['pc', 'mobile'], 'wechat_img' => (string) ($f['footer_contact_wechat_img'] ?? ''), 'qq' => (string) ($f['footer_contact_qq'] ?? ''), 'weibo' => (string) ($f['footer_contact_weibo'] ?? ''), 'email' => (string) ($f['footer_contact_email'] ?? ''), 'more' => is_array($f['footer_contact_more'] ?? null) ? $f['footer_contact_more'] : [], 'code_1' => (string) ($f['fcode_t2_code_1'] ?? ''), 'code_2' => (string) ($f['fcode_t2_code_2'] ?? ''), ]; } public static function get_footer_mini_img_settings(): array { $f = self::get_footer_settings(); $raw_items = is_array($f['footer_mini_img'] ?? null) ? $f['footer_mini_img'] : []; $items = []; foreach ($raw_items as $item) { if (!is_array($item)) { continue; } $img = (string) ($item['img'] ?? $item['image'] ?? ''); if ($img === '') { continue; } $items[] = [ 'img' => $img, 'image' => $img, 'text' => (string) ($item['text'] ?? $item['label'] ?? ''), 'label' => (string) ($item['label'] ?? $item['text'] ?? ''), ]; } return [ 'm_s' => is_array($f['footer_mini_img_m_s'] ?? null) ? $f['footer_mini_img_m_s'] : ['pc', 'mobile'], 'items' => $items, ]; } public static function get_footer_customize_code(): string { $f = self::get_footer_settings(); return (string) ($f['fcode_customize_code'] ?? ''); } public static function get_footer_theme_config(): array { $s = AKSRT_Settings::get_all(); return [ 'custom' => !empty($s['footer_theme_custom']), 'bg_custom' => sanitize_hex_color((string) ($s['footer_theme_bg_custom'] ?? '')) ?: '', 'bg' => sanitize_hex_color((string) ($s['footer_theme_bg'] ?? '')) ?: '', 'color_custom' => sanitize_hex_color((string) ($s['footer_theme_color_custom'] ?? '')) ?: '', ]; } public static function get_site_profile(): string { return 'cms'; } public static function get_cms_features(): array { $defaults = [ 'resource_cpt_enabled' => true, 'download_login' => true, 'download_credit' => true, 'download_captcha' => false, 'search_include_resource' => true, ]; $s = AKSRT_Settings::get_all(); $saved = isset($s['cms_features']) && is_array($s['cms_features']) ? $s['cms_features'] : []; return array_merge($defaults, $saved); } public static function cms_feature(string $key, $default = null) { $f = self::get_cms_features(); return array_key_exists($key, $f) ? $f[$key] : $default; } public static function homepage_allowed_sorts(): array { return ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand']; } public static function homepage_sort_labels(): array { return [ 'modified' => __('更新', 'aksrt'), 'date' => __('发布', 'aksrt'), 'views' => __('浏览', 'aksrt'), 'likes' => __('点赞', 'aksrt'), 'comments' => __('评论', 'aksrt'), 'favorites' => __('收藏', 'aksrt'), 'downloads' => __('下载', 'aksrt'), 'rand' => __('随机', 'aksrt'), ]; } public static function get_homepage_fixed_settings(): array { $s = AKSRT_Settings::get_all(); $allowed_sorts = self::homepage_allowed_sorts(); // Zibll-aligned primary list contract. $main_list_enabled = array_key_exists('home_posts_list_s', $s) ? !empty($s['home_posts_list_s']) : (!isset($s['home_posts_list_enabled']) || !empty($s['home_posts_list_enabled'])); $sort_bar_enabled = array_key_exists('home_list1_orderby_s', $s) ? !empty($s['home_list1_orderby_s']) : (!isset($s['home_list_sort_enabled']) || !empty($s['home_list_sort_enabled'])); $orderby_option = []; if (isset($s['home_list1_orderby_option']) && is_array($s['home_list1_orderby_option'])) { $orderby_option = $s['home_list1_orderby_option']; } $default_sort = sanitize_key((string) ($orderby_option['orderby'] ?? $s['homepage_default_sort'] ?? 'date')); if (!in_array($default_sort, $allowed_sorts, true)) { $default_sort = 'date'; } $sort_options_raw = $orderby_option['options'] ?? $s['home_list_sort_options'] ?? []; if (!is_array($sort_options_raw)) { $sort_options_raw = []; } $sort_options = self::normalize_sort_options($sort_options_raw); if (!in_array($default_sort, $sort_options, true)) { array_unshift($sort_options, $default_sort); $sort_options = array_values(array_unique($sort_options)); } $list_title = ''; if (array_key_exists('index_list_title', $s)) { $list_title = sanitize_text_field((string) $s['index_list_title']); } elseif (array_key_exists('home_list_title', $s)) { $list_title = sanitize_text_field((string) $s['home_list_title']); } if ($list_title === '') { $list_title = __('最新发布', 'aksrt'); } $exclude_posts = self::normalize_int_array( $s['home_exclude_posts'] ?? $s['home_exclude_post_ids'] ?? [] ); $exclude_cats = self::normalize_int_array( $s['home_exclude_cats'] ?? $s['home_exclude_category_ids'] ?? [] ); $tabs_raw = []; if (isset($s['home_lists']) && is_array($s['home_lists'])) { $tabs_raw = $s['home_lists']; } elseif (isset($s['homepage_tabs']) && is_array($s['homepage_tabs'])) { $tabs_raw = $s['homepage_tabs']; } $settings = [ // Canonical Zibll keys. 'home_posts_list_s' => $main_list_enabled, 'home_list1_orderby_s' => $sort_bar_enabled, 'home_list1_orderby_option' => [ 'orderby' => $default_sort, 'options' => $sort_options, ], 'index_list_title' => $list_title, 'home_exclude_posts' => $exclude_posts, 'home_exclude_cats' => $exclude_cats, 'home_lists' => self::normalize_homepage_tabs($tabs_raw), // Convenience aliases for existing PHP/Vue callers during cutover of this slice. 'home_posts_list_enabled' => $main_list_enabled, 'home_list_sort_enabled' => $sort_bar_enabled, 'homepage_default_sort' => $default_sort, 'home_list_sort_options' => $sort_options, 'home_list_title' => $list_title, 'home_exclude_post_ids' => $exclude_posts, 'home_exclude_category_ids' => $exclude_cats, 'homepage_tabs' => self::normalize_homepage_tabs($tabs_raw), // AKSRT presentation extras. 'homepage_card_style' => isset($s['homepage_card_style']) ? sanitize_key((string) $s['homepage_card_style']) : 'default', 'homepage_multi_thumb_enabled' => !empty($s['homepage_multi_thumb_enabled']), '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_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_sticky_tabs_enabled' => !isset($s['homepage_sticky_tabs_enabled']) || !empty($s['homepage_sticky_tabs_enabled']), '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_limit' => max(1, min(12, (int) ($s['homepage_tab_limit'] ?? 4))), 'homepage_module_hero_enabled' => !isset($s['homepage_module_hero_enabled']) || !empty($s['homepage_module_hero_enabled']), 'homepage_module_banner_enabled' => !isset($s['homepage_module_banner_enabled']) || !empty($s['homepage_module_banner_enabled']), ]; if (!in_array($settings['homepage_card_style'], ['default', 'style2', 'style3'], true)) { $settings['homepage_card_style'] = 'default'; } $settings['homepage_multi_thumb_min_images'] = max(2, min(4, $settings['homepage_multi_thumb_min_images'])); if (!in_array($settings['homepage_default_view'], ['list', 'card'], true)) { $settings['homepage_default_view'] = 'list'; } return $settings; } /** * Homepage always uses ordinary posts. Kept for API stability. * * @return string Always 'post'. */ public static function homepage_content_model(): string { return 'post'; } public static function homepage_tabs(): array { $settings = self::get_homepage_fixed_settings(); return $settings['home_lists']; } /** @return array */ public static function home_lists(): array { return self::homepage_tabs(); } public static function homepage_card_style(): string { $settings = self::get_homepage_fixed_settings(); return $settings['homepage_card_style']; } public static function homepage_multi_thumb_enabled(): bool { $settings = self::get_homepage_fixed_settings(); return !empty($settings['homepage_multi_thumb_enabled']); } public static function homepage_multi_thumb_min_images(): int { $settings = self::get_homepage_fixed_settings(); return (int) $settings['homepage_multi_thumb_min_images']; } public static function homepage_sidebar_mini_enabled(): bool { $settings = self::get_homepage_fixed_settings(); return !empty($settings['homepage_sidebar_mini_enabled']); } public static function homepage_default_sort(): string { $settings = self::get_homepage_fixed_settings(); return $settings['home_list1_orderby_option']['orderby'] ?? 'date'; } public static function homepage_default_view(): string { $settings = self::get_homepage_fixed_settings(); return $settings['homepage_default_view']; } public static function homepage_sort_ajax_enabled(): bool { $settings = self::get_homepage_fixed_settings(); return !empty($settings['homepage_sort_ajax_enabled']); } public static function homepage_sticky_tabs_enabled(): bool { $settings = self::get_homepage_fixed_settings(); return !empty($settings['homepage_sticky_tabs_enabled']); } public static function home_posts_list_enabled(): bool { $settings = self::get_homepage_fixed_settings(); return !empty($settings['home_posts_list_s']); } public static function home_list_title(): string { $settings = self::get_homepage_fixed_settings(); return (string) $settings['index_list_title']; } public static function home_list_sort_enabled(): bool { $settings = self::get_homepage_fixed_settings(); return !empty($settings['home_list1_orderby_s']); } public static function home_list_sort_options(): array { $settings = self::get_homepage_fixed_settings(); return $settings['home_list1_orderby_option']['options'] ?? ['modified', 'date', 'views', 'likes', 'comments']; } public static function home_list_sort_dropdown(): bool { $settings = self::get_homepage_fixed_settings(); return !empty($settings['home_list_sort_dropdown']); } public static function home_exclude_post_ids(): array { $settings = self::get_homepage_fixed_settings(); return $settings['home_exclude_posts']; } public static function home_exclude_category_ids(): array { $settings = self::get_homepage_fixed_settings(); return $settings['home_exclude_cats']; } public static function homepage_tab_posts_per_page(): int { $settings = self::get_homepage_fixed_settings(); return (int) $settings['homepage_tab_posts_per_page']; } public static function homepage_tab_limit(): int { $settings = self::get_homepage_fixed_settings(); return (int) $settings['homepage_tab_limit']; } public static function get_paid_content_settings(): array { return AKSRT_Settings_Payment_Runtime::get_paid_content_settings(); } public static function get_content_coupon_settings(): array { return AKSRT_Settings_Payment_Runtime::get_content_coupon_settings(); } public static function get_payment_recharge_settings(): array { return AKSRT_Settings_Payment_Runtime::get_payment_recharge_settings(); } public static function get_payment_vip_settings(): array { return AKSRT_Settings_Payment_Runtime::get_payment_vip_settings(); } public static function get_payment_revenue_settings(): array { return AKSRT_Settings_Payment_Runtime::get_payment_revenue_settings(); } public static function get_payment_affiliate_settings(): array { return AKSRT_Settings_Payment_Runtime::get_payment_affiliate_settings(); } public static function get_payment_gateway_settings(): array { return AKSRT_Settings_Payment_Runtime::get_payment_gateway_settings(); } public static function get_order_settings(): array { return AKSRT_Settings_Payment_Runtime::get_order_settings(); } public static function get_card_pass_settings(): array { return AKSRT_Settings_Payment_Runtime::get_card_pass_settings(); } public static function get_withdrawal_settings(): array { return AKSRT_Settings_Payment_Runtime::get_withdrawal_settings(); } private static function normalize_sort_options(array $raw): array { $allowed = self::homepage_allowed_sorts(); $result = []; $seen = []; foreach ($raw as $key) { $key = sanitize_key((string) $key); if (in_array($key, $allowed, true) && !isset($seen[$key])) { $result[] = $key; $seen[$key] = true; } } if (empty($result)) { $result = ['modified', 'date', 'views', 'likes', 'comments']; } return $result; } private static function normalize_int_array($raw): array { if (!is_array($raw)) { return []; } return array_values(array_filter(array_map('absint', $raw), static fn($v) => $v > 0)); } private static function normalize_homepage_tabs(array $raw_tabs): array { $allowed_orderby = self::homepage_allowed_sorts(); $tabs = []; foreach ($raw_tabs as $tab) { if (!is_array($tab)) { continue; } $term_id = absint($tab['term_id'] ?? 0); if ($term_id <= 0) { continue; } $orderby = sanitize_key($tab['orderby'] ?? 'date'); if (!in_array($orderby, $allowed_orderby, true)) { $orderby = 'date'; } $tabs[] = [ 'term_id' => $term_id, 'title' => sanitize_text_field($tab['title'] ?? ''), 'orderby' => $orderby, 'enabled' => !empty($tab['enabled']), ]; } return $tabs; } private static function parse_slug_list(string $raw, array $fallback = []): array { $items = preg_split('/[\s,]+/', $raw, -1, PREG_SPLIT_NO_EMPTY); $normalized = []; foreach ((array) $items as $item) { $slug = sanitize_key((string) $item); if ($slug !== '' && !in_array($slug, $normalized, true)) { $normalized[] = $slug; } } return !empty($normalized) ? $normalized : $fallback; } private static function count_structured_lines(string $raw): int { $lines = preg_split('/[\r\n]+/', $raw, -1, PREG_SPLIT_NO_EMPTY); $count = 0; foreach ((array) $lines as $line) { if (trim((string) $line) !== '') { $count++; } } return $count; } }