614 lines
28 KiB
PHP
614 lines
28 KiB
PHP
<?php
|
|
/**
|
|
* @package AKSRT
|
|
*/
|
|
|
|
namespace AKSRT\Core;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
|
|
|
|
/**
|
|
* Scripts public enqueue continuation: fonts, icons, global JS, localize.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
trait ScriptsPart1c {
|
|
|
|
/**
|
|
* 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, $version): void {
|
|
$notyf_css = get_template_directory() . '/assets/css/frontend/notyf.css';
|
|
wp_enqueue_style(
|
|
'aksrt-notyf',
|
|
$base_uri . '/assets/css/frontend/notyf.css',
|
|
[$core_dep, '_fontawesome'],
|
|
file_exists($notyf_css) ? (string) filemtime($notyf_css) : $version
|
|
);
|
|
|
|
// ===== 7. JS =====
|
|
|
|
$needs_post_list_media = wp_style_is('aksrt-post-card', 'enqueued');
|
|
|
|
$runtime_uri = $base_uri . '/assets';
|
|
$runtime_loader_path = get_template_directory() . '/assets/js/runtime/loader.js';
|
|
$runtime_main_path = get_template_directory() . '/assets/js/runtime/main.min.js';
|
|
$runtime_loader_version = file_exists($runtime_loader_path) ? (string) filemtime($runtime_loader_path) : $version;
|
|
$runtime_version = file_exists($runtime_main_path) ? (string) filemtime($runtime_main_path) : $version;
|
|
wp_enqueue_script(
|
|
'loader_js',
|
|
$runtime_uri . '/js/runtime/loader.js',
|
|
['jquery', 'bootstrap'],
|
|
$runtime_loader_version,
|
|
true
|
|
);
|
|
wp_localize_script(
|
|
'loader_js',
|
|
'_win',
|
|
[
|
|
'views' => '',
|
|
'www' => home_url('/'),
|
|
'uri' => $runtime_uri,
|
|
'ver' => $runtime_version,
|
|
'pay_mark' => '¥',
|
|
'pay_currency_unit' => __('元', 'aksrt'),
|
|
'imgbox' => false,
|
|
'imgbox_type' => 'group',
|
|
'imgbox_thumbs' => false,
|
|
'imgbox_zoom' => false,
|
|
'imgbox_full' => false,
|
|
'imgbox_play' => false,
|
|
'imgbox_down' => false,
|
|
'ajax_url' => admin_url('admin-ajax.php'),
|
|
'ajaxpager' => '',
|
|
'ajax_trigger' => __('加载更多', 'aksrt'),
|
|
'ajax_nomore' => __('没有更多了', 'aksrt'),
|
|
'qj_loading' => __('加载中...', 'aksrt'),
|
|
'highlight_kg' => false,
|
|
'highlight_hh' => false,
|
|
'highlight_btn' => false,
|
|
'highlight_zt' => 'enlighter',
|
|
'highlight_white_zt' => 'enlighter',
|
|
'highlight_dark_zt' => 'dracula',
|
|
'upload_img_size' => 3,
|
|
'img_upload_multiple' => 6,
|
|
'upload_video_size' => 30,
|
|
'upload_file_size' => 30,
|
|
'upload_ext' => implode('|', array_keys(get_allowed_mime_types())),
|
|
'user_upload_nonce' => wp_create_nonce('user_upload'),
|
|
'post_action_nonce' => wp_create_nonce('post_action'),
|
|
'is_split_upload' => false,
|
|
'split_minimum_size' => 10,
|
|
'comment_upload_img' => false,
|
|
'translate_config' => [],
|
|
'i18n' => [
|
|
'load_more' => __('加载更多', 'aksrt'),
|
|
'processing' => __('处理中...', 'aksrt'),
|
|
'please_wait' => __('请稍候', 'aksrt'),
|
|
'done' => __('操作完成', 'aksrt'),
|
|
'confirm_clear_search' => __('确认清空搜索记录?', 'aksrt'),
|
|
'search_loading' => __('搜索中...', 'aksrt'),
|
|
'search_min_chars' => __('至少输入 %s 个字符', 'aksrt'),
|
|
],
|
|
]
|
|
);
|
|
|
|
$lazy_image_attr_path = get_template_directory() . '/assets/js/lazy-image-attr.js';
|
|
wp_enqueue_script(
|
|
'aksrt-lazy-image-attr',
|
|
$base_uri . '/assets/js/lazy-image-attr.js',
|
|
['loader_js'],
|
|
file_exists($lazy_image_attr_path) ? (string) filemtime($lazy_image_attr_path) : $version,
|
|
true
|
|
);
|
|
|
|
// AKSRT-only modules register after the legacy loader; navigation is owned by main.min.js.
|
|
wp_enqueue_script(
|
|
'aksrt-rehydrate',
|
|
$base_uri . '/assets/js/rehydrate.js',
|
|
['loader_js', 'aksrt-lazy-image-attr'],
|
|
file_exists(get_template_directory() . '/assets/js/rehydrate.js')
|
|
? (string) filemtime(get_template_directory() . '/assets/js/rehydrate.js')
|
|
: $version,
|
|
true
|
|
);
|
|
|
|
// AJAX 调试(WP_DEBUG 或 ?aksrt_ajax_debug=1):记录所有失败的
|
|
// jQuery ajax / fetch 请求,用于定位 vendor main.min.js 的 400 "0" 来源。
|
|
if (function_exists('aksrt_ajax_debug_enabled') && aksrt_ajax_debug_enabled()) {
|
|
$ajax_debug_path = get_template_directory() . '/assets/js/core/ajax-debug.js';
|
|
wp_enqueue_script(
|
|
'aksrt-ajax-debug',
|
|
$base_uri . '/assets/js/core/ajax-debug.js',
|
|
['loader_js'],
|
|
file_exists($ajax_debug_path) ? (string) filemtime($ajax_debug_path) : $version,
|
|
true
|
|
);
|
|
}
|
|
|
|
if ($needs_post_list_media) {
|
|
$grade_js = get_template_directory() . '/assets/js/grade.min.js';
|
|
wp_enqueue_script(
|
|
'aksrt-grade',
|
|
$base_uri . '/assets/js/grade.min.js',
|
|
[],
|
|
file_exists($grade_js) ? (string) filemtime($grade_js) : $version,
|
|
true
|
|
);
|
|
}
|
|
|
|
$notyf_js = get_template_directory() . '/assets/js/notyf.js';
|
|
wp_enqueue_script(
|
|
'aksrt-notyf',
|
|
$base_uri . '/assets/js/notyf.js',
|
|
['jquery'],
|
|
file_exists($notyf_js) ? (string) filemtime($notyf_js) : $version,
|
|
true
|
|
);
|
|
|
|
// Runtime infrastructure: tbquire / confirm / 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', 'aksrt-notyf'],
|
|
(string) filemtime($runtime_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Follow toggle: delegated [data-aksrt-follow] handler; the buttons render on
|
|
// user home / user center / single author bar and user cards anywhere.
|
|
// Depends on aksrt-runtime because aksrtData (REST root + nonce) is localized
|
|
// onto that handle and follow.js reads it at parse time.
|
|
$follow_js = get_template_directory() . '/assets/js/follow.js';
|
|
if (file_exists($follow_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-follow',
|
|
$base_uri . '/assets/js/follow.js',
|
|
['aksrt-notyf', 'aksrt-runtime'],
|
|
(string) filemtime($follow_js),
|
|
true
|
|
);
|
|
}
|
|
|
|
// Core modules (split from main.js) — register with AksrtFrontend
|
|
$core_modules = [
|
|
'aksrt-core-article' => 'article.js',
|
|
'aksrt-core-comments' => 'comments.js',
|
|
'aksrt-core-comment-fixed' => 'comment-fixed-input.js',
|
|
'aksrt-core-comment-move' => 'comment-move-form.js',
|
|
// Shared legacy-parity list/modal engines (before pagination consumers).
|
|
'aksrt-core-ajax-list' => 'ajax-list.js',
|
|
'aksrt-core-modal-telemetry' => 'modal-telemetry.js',
|
|
'aksrt-core-request' => 'request.js',
|
|
'aksrt-core-modal-cache' => 'modal-cache.js',
|
|
'aksrt-core-modal-state' => 'modal-state.js',
|
|
'aksrt-core-modal-runtime' => 'modal-runtime.js',
|
|
'aksrt-core-modal-triggers' => 'modal-triggers.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-misc' && $needs_post_list_media) {
|
|
$deps[] = 'aksrt-grade';
|
|
} elseif ($handle === 'aksrt-core-modal-runtime') {
|
|
$deps = array_merge($deps, [
|
|
'aksrt-core-modal-telemetry',
|
|
'aksrt-core-request',
|
|
'aksrt-core-modal-cache',
|
|
'aksrt-core-modal-state',
|
|
]);
|
|
} elseif ($handle === 'aksrt-core-modal-triggers') {
|
|
$deps[] = 'aksrt-core-modal-runtime';
|
|
}
|
|
wp_enqueue_script(
|
|
$handle,
|
|
$base_uri . '/assets/js/core/' . $file,
|
|
$deps,
|
|
(string) filemtime($path),
|
|
true
|
|
);
|
|
$core_handles[] = $handle;
|
|
}
|
|
}
|
|
|
|
// 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
|
|
);
|
|
}
|
|
|
|
// 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
|
|
);
|
|
}
|
|
|
|
// ===== 全局 UI 增强(骨架屏、悬停动效、灯箱、滚动感知)=====
|
|
$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',
|
|
['loader_js'],
|
|
(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',
|
|
['loader_js'],
|
|
(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',
|
|
['loader_js'],
|
|
(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',
|
|
['loader_js'],
|
|
(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 (默认关)
|
|
// 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
|
|
);
|
|
}
|
|
|
|
// One state machine owns modal and /sign/ authentication.
|
|
$auth_js = get_template_directory() . '/assets/js/auth.js';
|
|
if (file_exists($auth_js)) {
|
|
wp_enqueue_script(
|
|
'aksrt-auth',
|
|
$base_uri . '/assets/js/auth.js',
|
|
['aksrt-runtime'],
|
|
(string) filemtime($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',
|
|
['loader_js'],
|
|
file_exists($homepage_js_path) ? (string) filemtime($homepage_js_path) : $version,
|
|
true
|
|
);
|
|
}
|
|
|
|
|
|
// Comment toolbar (smilie/code/image/quick shortcodes) — post form.
|
|
$load_comment_tools = (is_singular() && comments_open());
|
|
if ($load_comment_tools) {
|
|
$comment_tools_path = get_template_directory() . '/assets/js/comment-tools.js';
|
|
wp_enqueue_script(
|
|
'aksrt-comment-tools',
|
|
$base_uri . '/assets/js/comment-tools.js',
|
|
['loader_js', 'aksrt-core-comment-fixed', 'aksrt-core-comment-move'],
|
|
file_exists($comment_tools_path) ? (string) filemtime($comment_tools_path) : $version,
|
|
true
|
|
);
|
|
$comment_tools_css = get_template_directory() . '/assets/css/frontend/comment-tools.css';
|
|
if (file_exists($comment_tools_css)) {
|
|
wp_enqueue_style(
|
|
'aksrt-comment-tools',
|
|
$base_uri . '/assets/css/frontend/comment-tools.css',
|
|
['aksrt-comments'],
|
|
(string) filemtime($comment_tools_css)
|
|
);
|
|
}
|
|
}
|
|
|
|
// Comment actions client (like / edit / delete / moderate / pin).
|
|
// Submit path lives in assets/js/core/comments.js (REST).
|
|
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',
|
|
['loader_js', 'aksrt-core-comments'],
|
|
(string) filemtime($comment_ajax_path),
|
|
true
|
|
);
|
|
}
|
|
}
|
|
|
|
if (is_singular()) {
|
|
$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',
|
|
['loader_js'],
|
|
(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',
|
|
['loader_js'],
|
|
(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',
|
|
['loader_js', 'aksrt-weixin-share', 'aksrt-share-data'],
|
|
(string) filemtime($post_share_path),
|
|
true
|
|
);
|
|
}
|
|
}
|
|
|
|
// Page navigation (TOC highlight, smooth scroll, doc search)
|
|
// 评论回复脚本:由 assets/js/core/comment-move-form.js 提供(legacy 同款机制),
|
|
// 不加载 WP comment-reply,避免两套 moveForm 冲突。
|
|
|
|
$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'
|
|
: 'loader_js';
|
|
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\Settings') ? \AKSRT\Settings\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\Settings') ? \AKSRT\Settings\Settings::get_post_pagination_mode() : 'load_more',
|
|
'commentPaginationMode' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\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\Settings') ? \AKSRT\Settings\Settings::homepage_default_sort() : 'modified',
|
|
'homepageSortAjax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_sort_ajax_enabled() : true,
|
|
'homepageStickyTabs' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_sticky_tabs_enabled() : true,
|
|
'homePostsListEnabled' => !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::home_posts_list_enabled(),
|
|
'homeListSortEnabled' => !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::home_list_sort_enabled(),
|
|
'homeListSortDropdown' => class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::home_list_sort_dropdown(),
|
|
// AJAX 翻页文案
|
|
'ajaxTrigger' => (class_exists('\AKSRT\Settings\Settings') && ($t = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_trigger'] ?? '') !== '') ? $t : '<i class="fa fas fa-angle-right"></i>加载更多',
|
|
'ajaxNomore' => (class_exists('\AKSRT\Settings\Settings') && ($n = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_nomore'] ?? '') !== '') ? $n : __('没有更多内容了', 'aksrt'),
|
|
'ajaxLoading' => __('正在加载...', 'aksrt'),
|
|
'iasMax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['ias_max'] : 3,
|
|
'commentIasAuto' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_display_settings()['paging_ajax_ias'] : true,
|
|
'commentUploadEnabled' => class_exists('\AKSRT\Settings\Settings') ? !empty((\AKSRT\Settings\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\Settings') ? \AKSRT\Settings\Settings::get_comment_display_settings()['paging_ajax_ias_max'] : 3,
|
|
'commentQuickPhrases' => class_exists('\AKSRT\Settings\Settings') ? (\AKSRT\Settings\Settings::get_comment_display_settings()['quick_phrases'] ?? []) : [],
|
|
'commentSmiliesBase' => function_exists('aksrt_comment_smilies_base_uri') ? aksrt_comment_smilies_base_uri() : (trailingslashit(get_template_directory_uri()) . 'assets/img/smilies/'),
|
|
'restUrl' => esc_url_raw(rest_url('aksrt/v1')),
|
|
// Alias used by modal-auth / follow / report (same value as restUrl).
|
|
'apiUrl' => esc_url_raw(rest_url('aksrt/v1')),
|
|
'frontendModalRollout' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_frontend_modal_rollout() : [
|
|
'vip' => true,
|
|
'order' => true,
|
|
'identity' => true,
|
|
],
|
|
'stickyEnabled' => class_exists('\AKSRT\Settings\Settings') ? !empty(\AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_s']) : true,
|
|
'stickyPages' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_s'] : ['home', 'cat'],
|
|
'badgeShow' => class_exists('\AKSRT\Settings\Settings') ? !empty(\AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show']) : true,
|
|
'badgeTypes' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show'] : ['pay', 'tag', 'cat'],
|
|
// 用户状态
|
|
'isLoggedIn' => is_user_logged_in(),
|
|
'userId' => get_current_user_id(),
|
|
'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/'),
|
|
'orders' => $runtime_routes['orders'],
|
|
'resources' => $runtime_routes['resources'],
|
|
],
|
|
'shell' => [
|
|
'wrapperId' => '',
|
|
'navId' => 'navbar-top',
|
|
'searchPanelId' => 'nav-search-panel',
|
|
'drawerId' => 'mobile-navbar',
|
|
'userMenuId' => 'sub-user-box',
|
|
'floatActionsId' => 'float-right-btns',
|
|
'tabbarId' => 'footer-tabbar',
|
|
],
|
|
'themeUri' => get_template_directory_uri(),
|
|
'lazyScopes' => [
|
|
'lazy_posts_thumb' => aksrt_is_lazy('lazy_posts_thumb'),
|
|
'lazy_avatar' => aksrt_is_lazy('lazy_avatar'),
|
|
'lazy_posts_content' => aksrt_is_lazy('lazy_posts_content'),
|
|
'lazy_comment' => aksrt_is_lazy('lazy_comment'),
|
|
'lazy_sider' => aksrt_is_lazy('lazy_sider'),
|
|
'lazy_cover' => aksrt_is_lazy('lazy_cover'),
|
|
'lazy_other' => aksrt_is_lazy('lazy_other'),
|
|
],
|
|
'lazyThumbs' => [
|
|
'default' => aksrt_get_lazy_thumb(),
|
|
'sm' => aksrt_get_lazy_thumb('sm'),
|
|
'lg' => aksrt_get_lazy_thumb('lg'),
|
|
],
|
|
'lazyAvatar' => aksrt_get_default_avatar_url(),
|
|
'codeHighlight' => class_exists('\AKSRT\Settings\Settings')
|
|
? \AKSRT\Settings\Settings::get_code_highlight_config()
|
|
: ['enabled' => true, 'lightTheme' => 'enlighter', 'darkTheme' => 'monokai', 'lineNumbers' => false, 'showButtons' => true, 'maxHeight' => 500],
|
|
'systemNotice' => class_exists('\AKSRT\Settings\Settings')
|
|
? \AKSRT\Settings\Settings::get_system_notice_config()
|
|
: ['enabled' => false],
|
|
'contentProtect' => [
|
|
'enabled' => class_exists('\AKSRT\Settings\Settings') && (bool) \AKSRT\Settings\Settings::get_value('content_protect_enabled', false),
|
|
'copyNotice' => class_exists('\AKSRT\Settings\Settings') && (bool) \AKSRT\Settings\Settings::get_value('content_protect_copy_notice', false),
|
|
'copyNoticeText' => class_exists('\AKSRT\Settings\Settings') ? (string) \AKSRT\Settings\Settings::get_value('content_protect_copy_text', '来自本站,请尊重原创版权。') : '',
|
|
'disableRightClick'=> class_exists('\AKSRT\Settings\Settings') && (bool) \AKSRT\Settings\Settings::get_value('content_protect_right_click', false),
|
|
'detectDevTools' => class_exists('\AKSRT\Settings\Settings') && (bool) \AKSRT\Settings\Settings::get_value('content_protect_f12', false),
|
|
],
|
|
'translate' => class_exists('\AKSRT\Settings\Settings')
|
|
? \AKSRT\Settings\Settings::get_i18n_config()
|
|
: ['enabled' => false, 'autoDetect' => true, 'defaultLang' => 'zh-CN'],
|
|
]);
|
|
}
|
|
|
|
}
|