- Trait-split content-pay, vip-service, balance-service, order-repository - Procedural split of user module into user-parts/* - Split scripts enqueue_public into part-1b/1c; settings bulk trait - Bootstrap: explicit notifications, widgets glob-only, home-modules init - ADR: freeze domain placement for pay/revenue/notify boundaries
592 lines
27 KiB
PHP
592 lines
27 KiB
PHP
<?php
|
|
defined('ABSPATH') || exit;
|
|
|
|
/**
|
|
* Scripts public enqueue continuation: fonts, icons, global JS, localize.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
trait AKSRT_Scripts_Part_1c {
|
|
|
|
/**
|
|
* Fonts / FA / global JS stack / aksrtData (split from enqueue_public).
|
|
*/
|
|
private function enqueue_public_fonts_js_and_data($base_uri, $core_dep, $deps, $is_fixed_homepage, $is_home_or_archive, $is_single_post, $is_single_resource, $path, $version): void {
|
|
// ===== 5. 字体 =====
|
|
// 5a. 拉丁字体 - Inter (UI) + Source Serif 4 (正文)
|
|
wp_enqueue_style(
|
|
'aksrt-fonts',
|
|
'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,500;0,8..60,600;0,8..60,700;1,8..60,400&display=swap',
|
|
[],
|
|
null
|
|
);
|
|
|
|
// 5b. 中文字体 - jsDelivr CDN (思源黑体 / 思源宋体)
|
|
// 仅 regular 字重,避免拖慢首屏;其它字重通过 system fallback (PingFang/微软雅黑)
|
|
// Fontsource v5 已按 unicode-range 自动分包,浏览器只会下载用到的简中子集
|
|
wp_enqueue_style(
|
|
'aksrt-fonts-cn',
|
|
'https://cdn.jsdelivr.net/npm/@fontsource/noto-sans-sc@5.2.9/400.css',
|
|
[],
|
|
null
|
|
);
|
|
wp_enqueue_style(
|
|
'aksrt-fonts-cn-serif',
|
|
'https://cdn.jsdelivr.net/npm/@fontsource/noto-serif-sc@5.2.9/400.css',
|
|
[],
|
|
null
|
|
);
|
|
|
|
// ===== 6. 图标系统 =====
|
|
// Font Awesome 5 全站加载(评论回复、单篇互动栏、profile 联系方式等
|
|
// 多处模板使用 fa-* 类名,作为全主题图标包统一使用)
|
|
wp_enqueue_style(
|
|
'aksrt-font-awesome-5',
|
|
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css',
|
|
[],
|
|
'5.15.4'
|
|
);
|
|
|
|
// ===== 7. JS =====
|
|
|
|
// Swiper.js(首页/归档/CMS 模块/单篇文章页加载)
|
|
$needs_swiper = $is_home_or_archive || $is_single_post || $is_single_resource;
|
|
if ($needs_swiper) {
|
|
wp_enqueue_style(
|
|
'aksrt-swiper',
|
|
$base_uri . '/assets/css/frontend/swiper-bundle.min.css',
|
|
[],
|
|
'11.0'
|
|
);
|
|
wp_enqueue_script(
|
|
'aksrt-swiper',
|
|
$base_uri . '/assets/js/swiper-bundle.min.js',
|
|
[],
|
|
'11.0',
|
|
true
|
|
);
|
|
}
|
|
|
|
wp_enqueue_script(
|
|
'aksrt-qrcode',
|
|
'https://cdn.jsdelivr.net/npm/kjua@0.9.0/dist/kjua.min.js',
|
|
[],
|
|
'0.9.0',
|
|
true
|
|
);
|
|
|
|
// Rehydrate system — must load before aksrt-script so AksrtFrontend is available
|
|
wp_enqueue_script(
|
|
'aksrt-rehydrate',
|
|
$base_uri . '/assets/js/rehydrate.js',
|
|
[],
|
|
file_exists(get_template_directory() . '/assets/js/rehydrate.js')
|
|
? (string) filemtime(get_template_directory() . '/assets/js/rehydrate.js')
|
|
: $version,
|
|
true
|
|
);
|
|
|
|
// Runtime infrastructure: tbquire / notyf / confirm / refreshModal / scrollTopTo / [data-*] declarative
|
|
$runtime_js = get_template_directory() . '/assets/js/aksrt-runtime.js';
|
|
if (file_exists($runtime_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-runtime',
|
|
$base_uri . '/assets/js/aksrt-runtime.js',
|
|
['aksrt-rehydrate'],
|
|
(string) filemtime($runtime_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Core modules (split from main.js) — register with AksrtFrontend
|
|
$core_modules = [
|
|
'aksrt-core-theme' => 'theme.js',
|
|
'aksrt-core-nav' => 'nav.js',
|
|
'aksrt-core-search' => 'search.js',
|
|
'aksrt-core-dropdown' => 'dropdown.js',
|
|
'aksrt-core-scroll' => 'scroll.js',
|
|
'aksrt-core-slider' => 'slider.js',
|
|
'aksrt-core-article' => 'article.js',
|
|
'aksrt-core-comments' => 'comments.js',
|
|
'aksrt-core-pagination' => 'pagination.js',
|
|
'aksrt-core-archive' => 'archive.js',
|
|
'aksrt-core-footer-tabbar' => 'footer-tabbar.js',
|
|
'aksrt-core-misc' => 'misc.js',
|
|
];
|
|
$core_handles = [];
|
|
foreach ($core_modules as $handle => $file) {
|
|
$path = get_template_directory() . '/assets/js/core/' . $file;
|
|
if (file_exists($path)) {
|
|
// Depend on aksrt-runtime so window.aksrtData (localized below) is available.
|
|
$deps = ['aksrt-rehydrate', 'aksrt-runtime'];
|
|
if ($handle === 'aksrt-core-slider') {
|
|
$deps = array_merge($deps, $needs_swiper ? ['aksrt-swiper'] : []);
|
|
}
|
|
wp_enqueue_script(
|
|
$handle,
|
|
$base_uri . '/assets/js/core/' . $file,
|
|
$deps,
|
|
(string) filemtime($path),
|
|
true
|
|
);
|
|
$core_handles[] = $handle;
|
|
}
|
|
}
|
|
|
|
wp_enqueue_script(
|
|
'aksrt-script',
|
|
$base_uri . '/assets/js/main.js',
|
|
array_merge(
|
|
['jquery', 'bootstrap5', 'aksrt-rehydrate', 'aksrt-runtime'],
|
|
$core_handles
|
|
),
|
|
file_exists(get_template_directory() . '/assets/js/main.js')
|
|
? (string) filemtime(get_template_directory() . '/assets/js/main.js')
|
|
: $version,
|
|
true
|
|
);
|
|
|
|
// SVG icon data + helper (must load before other scripts that use icons)
|
|
$svg_icon_js = get_template_directory() . '/assets/js/svg-icon.js';
|
|
if (file_exists($svg_icon_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-svg-icon',
|
|
$base_uri . '/assets/js/svg-icon.js',
|
|
[],
|
|
(string) filemtime($svg_icon_js),
|
|
false // load in <head> so icons are available early
|
|
);
|
|
}
|
|
|
|
$svg_helper_js = get_template_directory() . '/assets/js/svg-icon-helper.js';
|
|
if (file_exists($svg_helper_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-svg-icon-helper',
|
|
$base_uri . '/assets/js/svg-icon-helper.js',
|
|
['aksrt-svg-icon'],
|
|
(string) filemtime($svg_helper_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Page loading indicator (top progress bar)
|
|
$loader_js = get_template_directory() . '/assets/js/loader.js';
|
|
if (file_exists($loader_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-loader',
|
|
$base_uri . '/assets/js/loader.js',
|
|
[],
|
|
(string) filemtime($loader_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Code block enhancements (copy button + language label)
|
|
$precode_js = get_template_directory() . '/assets/js/precode.js';
|
|
if (file_exists($precode_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-precode',
|
|
$base_uri . '/assets/js/precode.js',
|
|
[],
|
|
(string) filemtime($precode_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Input field enhancements (auto-resize, counter, validation)
|
|
$input_expand_js = get_template_directory() . '/assets/js/input-expand.js';
|
|
if (file_exists($input_expand_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-input-expand',
|
|
$base_uri . '/assets/js/input-expand.js',
|
|
[],
|
|
(string) filemtime($input_expand_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Instant page prefetch (hover to preload)
|
|
$instant_page_js = get_template_directory() . '/assets/js/instant-page.js';
|
|
if (file_exists($instant_page_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-instant-page',
|
|
$base_uri . '/assets/js/instant-page.js',
|
|
[],
|
|
(string) filemtime($instant_page_js),
|
|
false // load in <head> for early prefetch capability
|
|
);
|
|
}
|
|
|
|
// Touch gesture support (swipe, pull-to-dismiss)
|
|
$mini_touch_js = get_template_directory() . '/assets/js/mini-touch.js';
|
|
if (file_exists($mini_touch_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-mini-touch',
|
|
$base_uri . '/assets/js/mini-touch.js',
|
|
[],
|
|
(string) filemtime($mini_touch_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Section navs: article TOC / scrollspy
|
|
$section_navs_js = get_template_directory() . '/assets/js/section-navs.js';
|
|
if (file_exists($section_navs_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-section-navs',
|
|
$base_uri . '/assets/js/section-navs.js',
|
|
['aksrt-rehydrate', 'aksrt-runtime'],
|
|
(string) filemtime($section_navs_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Video player (MP4/HLS/FLV)
|
|
$video_player_js = get_template_directory() . '/assets/js/video-player.js';
|
|
if (file_exists($video_player_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-video-player',
|
|
$base_uri . '/assets/js/video-player.js',
|
|
[],
|
|
(string) filemtime($video_player_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Image color extraction
|
|
$color_extract_js = get_template_directory() . '/assets/js/color-extract.js';
|
|
if (file_exists($color_extract_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-color-extract',
|
|
$base_uri . '/assets/js/color-extract.js',
|
|
[],
|
|
(string) filemtime($color_extract_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
$widget_set_js = get_template_directory() . '/assets/js/widget-set.js';
|
|
if (file_exists($widget_set_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-widget-set',
|
|
$base_uri . '/assets/js/widget-set.js',
|
|
['aksrt-script', 'aksrt-qrcode'],
|
|
(string) filemtime($widget_set_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// ===== 全局 UI 增强(Toast、骨架屏、悬停动效、灯箱、滚动感知)=====
|
|
$enhancements_css = get_template_directory() . '/assets/css/frontend/enhancements.css';
|
|
if (file_exists($enhancements_css)) {
|
|
wp_enqueue_style(
|
|
'aksrt-enhancements',
|
|
$base_uri . '/assets/css/frontend/enhancements.css',
|
|
[$core_dep],
|
|
(string) filemtime($enhancements_css)
|
|
);
|
|
}
|
|
|
|
$enhancements_js = get_template_directory() . '/assets/js/enhancements.js';
|
|
if (file_exists($enhancements_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-enhancements',
|
|
$base_uri . '/assets/js/enhancements.js',
|
|
['aksrt-script'],
|
|
(string) filemtime($enhancements_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
$enhancements2_js = get_template_directory() . '/assets/js/enhancements2.js';
|
|
if (file_exists($enhancements2_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-enhancements2',
|
|
$base_uri . '/assets/js/enhancements2.js',
|
|
['aksrt-script'],
|
|
(string) filemtime($enhancements2_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Reward (打赏)
|
|
$reward_js = get_template_directory() . '/assets/js/reward.js';
|
|
if (file_exists($reward_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-reward',
|
|
$base_uri . '/assets/js/reward.js',
|
|
['aksrt-script'],
|
|
(string) filemtime($reward_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Effects (count-up, countdown, marquee, tilt, FPS detection)
|
|
$effects_js = get_template_directory() . '/assets/js/effects.js';
|
|
if (file_exists($effects_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-effects',
|
|
$base_uri . '/assets/js/effects.js',
|
|
['aksrt-script'],
|
|
(string) filemtime($effects_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Yiyan (一言轮播)
|
|
$yiyan_js = get_template_directory() . '/assets/js/yiyan.js';
|
|
if (file_exists($yiyan_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-yiyan',
|
|
$base_uri . '/assets/js/yiyan.js',
|
|
[],
|
|
(string) filemtime($yiyan_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Frontend translate (默认关)
|
|
$translate_js = get_template_directory() . '/assets/js/frontend-translate.js';
|
|
if (file_exists($translate_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-frontend-translate',
|
|
$base_uri . '/assets/js/frontend-translate.js',
|
|
[],
|
|
(string) filemtime($translate_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Content protection (copy notice / right-click / F12)
|
|
$content_protect_js = get_template_directory() . '/assets/js/content-protect.js';
|
|
if (file_exists($content_protect_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-content-protect',
|
|
$base_uri . '/assets/js/content-protect.js',
|
|
[],
|
|
(string) filemtime($content_protect_js),
|
|
false // load in <head> for early binding
|
|
);
|
|
}
|
|
|
|
// Site notice popup (global, controlled by Settings)
|
|
$site_notice_css = get_template_directory() . '/assets/css/frontend/site-notice.css';
|
|
if (file_exists($site_notice_css)) {
|
|
wp_enqueue_style(
|
|
'aksrt-site-notice',
|
|
$base_uri . '/assets/css/frontend/site-notice.css',
|
|
[$core_dep],
|
|
(string) filemtime($site_notice_css)
|
|
);
|
|
}
|
|
$site_notice_js = get_template_directory() . '/assets/js/site-notice.js';
|
|
if (file_exists($site_notice_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-site-notice',
|
|
$base_uri . '/assets/js/site-notice.js',
|
|
[],
|
|
(string) filemtime($site_notice_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// 弹窗登录/注册(仅未登录用户)
|
|
if (!is_user_logged_in()) {
|
|
$modal_auth_js = get_template_directory() . '/assets/js/modal-auth.js';
|
|
if (file_exists($modal_auth_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-modal-auth',
|
|
$base_uri . '/assets/js/modal-auth.js',
|
|
['aksrt-script'],
|
|
(string) filemtime($modal_auth_js),
|
|
true
|
|
);
|
|
}
|
|
}
|
|
|
|
if ($is_fixed_homepage) {
|
|
$homepage_js_path = get_template_directory() . '/assets/js/homepage-fixed.js';
|
|
wp_enqueue_script(
|
|
'aksrt-homepage-fixed',
|
|
$base_uri . '/assets/js/homepage-fixed.js',
|
|
['aksrt-script'],
|
|
file_exists($homepage_js_path) ? (string) filemtime($homepage_js_path) : $version,
|
|
true
|
|
);
|
|
}
|
|
|
|
|
|
// Comment toolbar (emoji, code, bold, Ctrl+Enter) — only when the form is open.
|
|
if (is_singular() && comments_open()) {
|
|
$comment_tools_path = get_template_directory() . '/assets/js/comment-tools.js';
|
|
wp_enqueue_script(
|
|
'aksrt-comment-tools',
|
|
$base_uri . '/assets/js/comment-tools.js',
|
|
['aksrt-script'],
|
|
file_exists($comment_tools_path) ? (string) filemtime($comment_tools_path) : $version,
|
|
true
|
|
);
|
|
}
|
|
|
|
// Comment actions client (like / edit / delete / moderate / pin) — load
|
|
// wherever comments can exist, including closed-comment posts. Submission
|
|
// itself is handled by main.js initCommentSystem().
|
|
if (is_singular() && (comments_open() || (int) get_comments_number() > 0)) {
|
|
$comment_ajax_path = get_template_directory() . '/assets/js/comment-ajax.js';
|
|
if (file_exists($comment_ajax_path)) {
|
|
wp_enqueue_script(
|
|
'aksrt-comment-ajax',
|
|
$base_uri . '/assets/js/comment-ajax.js',
|
|
['aksrt-script'],
|
|
(string) filemtime($comment_ajax_path),
|
|
true
|
|
);
|
|
}
|
|
}
|
|
|
|
if (is_singular() || is_page_template('templates/pages/page-forums.php')) {
|
|
$page_template_path = get_template_directory() . '/assets/js/page-template.js';
|
|
if (file_exists($page_template_path)) {
|
|
wp_enqueue_script(
|
|
'aksrt-page-template',
|
|
$base_uri . '/assets/js/page-template.js',
|
|
['aksrt-script'],
|
|
(string) filemtime($page_template_path),
|
|
true
|
|
);
|
|
}
|
|
}
|
|
|
|
// Post/resource share functionality
|
|
if ($is_single_post || $is_single_resource) {
|
|
$weixin_share_path = get_template_directory() . '/assets/js/weixin-share.js';
|
|
if (file_exists($weixin_share_path)) {
|
|
wp_enqueue_script(
|
|
'aksrt-weixin-share',
|
|
$base_uri . '/assets/js/weixin-share.js',
|
|
['aksrt-script'],
|
|
(string) filemtime($weixin_share_path),
|
|
true
|
|
);
|
|
}
|
|
|
|
$post_share_path = get_template_directory() . '/assets/js/post-share.js';
|
|
if (file_exists($post_share_path)) {
|
|
wp_enqueue_script(
|
|
'aksrt-post-share',
|
|
$base_uri . '/assets/js/post-share.js',
|
|
['aksrt-script', 'aksrt-weixin-share', 'aksrt-share-data'],
|
|
(string) filemtime($post_share_path),
|
|
true
|
|
);
|
|
}
|
|
}
|
|
|
|
// Page navigation (TOC highlight, smooth scroll, doc search)
|
|
// 评论回复脚本
|
|
if (is_singular() && comments_open() && get_option('thread_comments')) {
|
|
wp_enqueue_script('comment-reply');
|
|
}
|
|
|
|
$runtime_routes = $this->resolve_frontend_routes();
|
|
|
|
// 数据注入 - 全站统一消费 window.aksrtData
|
|
// Attach to aksrt-runtime (loaded before all core modules) so ajaxUrl/nonce
|
|
// exist before pagination/search/article handlers run.
|
|
$aksrt_data_handle = wp_script_is('aksrt-runtime', 'registered') || wp_script_is('aksrt-runtime', 'enqueued')
|
|
? 'aksrt-runtime'
|
|
: 'aksrt-script';
|
|
wp_localize_script($aksrt_data_handle, 'aksrtData', [
|
|
'ajaxUrl' => admin_url('admin-ajax.php'),
|
|
'nonce' => wp_create_nonce('aksrt_public_nonce'),
|
|
'restNonce' => wp_create_nonce('wp_rest'),
|
|
'visibilityNonce' => wp_create_nonce('aksrt_visibility'),
|
|
'siteUrl' => home_url('/'),
|
|
'themeUrl' => AKSRT_URI,
|
|
'themeMode' => class_exists('AKSRT_Settings') ? AKSRT_Settings::theme_mode_js_value() : 'auto',
|
|
'debug' => defined('WP_DEBUG') && WP_DEBUG,
|
|
'debugLog' => defined('WP_DEBUG') && WP_DEBUG && defined('WP_DEBUG_LOG') && WP_DEBUG_LOG,
|
|
'postPaginationMode' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_pagination_mode() : 'load_more',
|
|
'commentPaginationMode' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_comment_pagination_mode() : 'numbered',
|
|
'homepagePostsPerPage' => function_exists('aksrt_homepage_get_tab_posts_per_page') ? aksrt_homepage_get_tab_posts_per_page() : (int) get_option('posts_per_page'),
|
|
'homepageDefaultSort' => class_exists('AKSRT_Settings') ? AKSRT_Settings::homepage_default_sort() : 'modified',
|
|
'homepageDefaultView' => class_exists('AKSRT_Settings') ? AKSRT_Settings::homepage_default_view() : 'list',
|
|
'homepageSortAjax' => class_exists('AKSRT_Settings') ? AKSRT_Settings::homepage_sort_ajax_enabled() : true,
|
|
'homepageStickyTabs' => class_exists('AKSRT_Settings') ? AKSRT_Settings::homepage_sticky_tabs_enabled() : true,
|
|
'homePostsListEnabled' => !class_exists('AKSRT_Settings') || AKSRT_Settings::home_posts_list_enabled(),
|
|
'homeListSortEnabled' => !class_exists('AKSRT_Settings') || AKSRT_Settings::home_list_sort_enabled(),
|
|
'homeListSortDropdown' => class_exists('AKSRT_Settings') && AKSRT_Settings::home_list_sort_dropdown(),
|
|
// AJAX 翻页文案
|
|
'ajaxTrigger' => (class_exists('AKSRT_Settings') && ($t = AKSRT_Settings::get_post_list_style_settings()['ajax_trigger_text'] ?? '') !== '') ? $t : __('加载更多', 'aksrt'),
|
|
'ajaxNomore' => (class_exists('AKSRT_Settings') && ($n = AKSRT_Settings::get_post_list_style_settings()['ajax_nomore_text'] ?? '') !== '') ? $n : __('没有更多了', 'aksrt'),
|
|
'ajaxLoading' => __('正在加载...', 'aksrt'),
|
|
'iasMax' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_list_style_settings()['ias_max'] : 3,
|
|
'commentIasAuto' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_comment_display_settings()['paging_ajax_ias'] : true,
|
|
'commentUploadEnabled' => class_exists('AKSRT_Settings') ? !empty((AKSRT_Settings::get_comment_display_settings()['toolbar']['upload_img'] ?? false)) : false,
|
|
'commentUploadUrl' => esc_url_raw(rest_url('aksrt/v1/comment/upload-image')),
|
|
'commentUploadMaxSize' => 2 * 1024 * 1024,
|
|
'commentIasMax' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_comment_display_settings()['paging_ajax_ias_max'] : 3,
|
|
'stickyEnabled' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_list_style_settings()['sticky_enabled'] : true,
|
|
'stickyPages' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_list_style_settings()['sticky_pages'] : ['home', 'cat'],
|
|
'badgeShow' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_list_style_settings()['badge_show'] : true,
|
|
'badgeTypes' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_list_style_settings()['badge_types'] : ['pay', 'tag', 'topics', 'cat'],
|
|
'search' => [
|
|
'mode' => class_exists('AKSRT_Settings') ? AKSRT_Settings::search_mode() : 'default',
|
|
'placeholder' => function_exists('aksrt_get_search_placeholder') ? aksrt_get_search_placeholder() : __('开启精彩搜索...', 'aksrt'),
|
|
'historyEnabled' => function_exists('aksrt_search_history_enabled') ? aksrt_search_history_enabled() : true,
|
|
'suggestionsEnabled' => function_exists('aksrt_search_suggestions_enabled') ? aksrt_search_suggestions_enabled() : false,
|
|
'hotKeywords' => function_exists('aksrt_get_search_hot_keywords') ? aksrt_get_search_hot_keywords() : [],
|
|
'popularTitle' => class_exists('AKSRT_Settings') ? AKSRT_Settings::search_popular_title() : __('热门搜索', 'aksrt'),
|
|
'contentTypes' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_search_content_types()['types'] : ['post', 'category', 'tag'],
|
|
'defaultType' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_search_content_types()['default'] : 'post',
|
|
],
|
|
// 用户状态
|
|
'isLoggedIn' => is_user_logged_in(),
|
|
'userId' => get_current_user_id(),
|
|
'cartUrl' => $runtime_routes['cart'],
|
|
'ordersUrl' => $runtime_routes['orders'],
|
|
'userCenterUrl' => function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/'),
|
|
'routes' => [
|
|
'home' => home_url('/'),
|
|
'login' => function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(),
|
|
'register' => function_exists('aksrt_get_register_url') ? aksrt_get_register_url() : wp_registration_url(),
|
|
'resetPassword' => function_exists('aksrt_get_reset_password_url') ? aksrt_get_reset_password_url() : wp_lostpassword_url(),
|
|
'profile' => function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/profile/'),
|
|
'cart' => $runtime_routes['cart'],
|
|
'orders' => $runtime_routes['orders'],
|
|
'resources' => $runtime_routes['resources'],
|
|
],
|
|
'shell' => [
|
|
'wrapperId' => '',
|
|
'navId' => 'site-nav',
|
|
'searchPanelId' => 'nav-search-panel',
|
|
'drawerId' => 'nav-drawer',
|
|
'userMenuId' => 'user-dropdown',
|
|
'floatActionsId' => 'float-right-btns',
|
|
'tabbarId' => 'footer-tabbar',
|
|
],
|
|
'themeUri' => get_template_directory_uri(),
|
|
'codeHighlight' => class_exists('AKSRT_Settings')
|
|
? AKSRT_Settings::get_code_highlight_config()
|
|
: ['enabled' => true, 'lightTheme' => 'enlighter', 'darkTheme' => 'monokai', 'lineNumbers' => false, 'showButtons' => true, 'maxHeight' => 500],
|
|
'lazyload' => class_exists('AKSRT_Settings')
|
|
? AKSRT_Settings::get_lazyload_config()
|
|
: ['enabled' => true, 'animation' => 'blur', 'placeholder_url' => '', 'blur' => true],
|
|
'systemNotice' => class_exists('AKSRT_Settings')
|
|
? AKSRT_Settings::get_system_notice_config()
|
|
: ['enabled' => false],
|
|
'contentProtect' => [
|
|
'enabled' => class_exists('AKSRT_Settings') && (bool) AKSRT_Settings::get_value('content_protect_enabled', false),
|
|
'copyNotice' => class_exists('AKSRT_Settings') && (bool) AKSRT_Settings::get_value('content_protect_copy_notice', false),
|
|
'copyNoticeText' => class_exists('AKSRT_Settings') ? (string) AKSRT_Settings::get_value('content_protect_copy_text', '来自本站,请尊重原创版权。') : '',
|
|
'disableRightClick'=> class_exists('AKSRT_Settings') && (bool) AKSRT_Settings::get_value('content_protect_right_click', false),
|
|
'detectDevTools' => class_exists('AKSRT_Settings') && (bool) AKSRT_Settings::get_value('content_protect_f12', false),
|
|
],
|
|
'translate' => class_exists('AKSRT_Settings')
|
|
? AKSRT_Settings::get_i18n_config()
|
|
: ['enabled' => false, 'autoDetect' => true, 'defaultLang' => 'zh-CN'],
|
|
]);
|
|
}
|
|
|
|
}
|