refactor(autoload): migrate theme classes to Composer PSR-4

Move 288 types from global AKSRT_* + inc/classes manual requires into
namespace AKSRT\{Domain} under src/AKSRT/, wire composer.json psr-4,
and slim bootstrap to helpers/modules/hooks only. Split multi-class
widget/gateway files, update admin contract audit paths, and document
the layout in ADR/README.
This commit is contained in:
2026-07-17 13:29:22 +08:00
parent 8f349b40fb
commit aaf458af1c
404 changed files with 13602 additions and 7705 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ defined('ABSPATH') || exit;
get_header();
$other_page_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_other_page_settings()
$other_page_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_other_page_settings()
: [
'page_404_message' => __('页面未找到', 'aksrt'),
'page_404_search' => true,
+26 -39
View File
@@ -26,49 +26,36 @@ AKSRT 是一款现代化的 WordPress 主题,采用**原生 WordPress 主题
```
AKSRT-theme/
├── functions.php # 入口文件(精简版:常量+bootstrap加载+实例初始化)
├── functions.php # 入口:常量 + Composer autoload + bootstrap + 单例 init
├── style.css # WordPress 主题声明头
├── composer.json # 第三方依赖 + 主题 PSR-4(AKSRT\ → src/AKSRT/)
│
├── *.php # WP 核心模板保留根目录
│ ├── index.php # 首页(文章列表 Loop)
│ ├── single.php # 文章详情页
│ ├── page.php # 默认页面模板
│ ├── front-page.php # 首页静态页面
│ ├── archive.php # 归档页
│ ├── author.php # 作者存档
│ ├── search.php # 搜索结果
│ ├── 404.php # 错误页
│ ├── header.php / footer.php # 页头/页脚
│ ├── sidebar.php # 侧边栏
│ └── comments.php # 评论模板
│
├── inc/ # 核心代码目录
│ ├── bootstrap.php # 自动加载器(统一 require 所有模块)
│ ├── core-hooks.php # 核心功能钩子(Gravatar/SMTP/评论/CPT等)
│ │
│ ├── classes/ # ← 类文件按领域目录组织
│ │ ├── core/ # 主题壳层(setup/scripts/templates/SEO/DB…)
│ │ ├── frontend/ # 前端渲染辅助(inline style / custom code…)
│ │ ├── settings/ # 设置门面 + 运行时 delegates
│ │ ├── admin/ # SPA 编排 + 域控制器 + schema + native ops
│ │ ├── auth/ # 登录/OAuth/验证码/审核/邮箱
│ │ ├── user/ # 用户中心/主页/徽章/等级/关注
│ │ ├── credits/ # 积分/钱包/签到/邀请
│ │ ├── content/ # 下载 token / 付费内容 / VIP / 可见性
│ │ ├── payment/ # 订单/网关/售后/物流/充值卡/分成
│ │ │ └── gateways/ # 支付宝/微信/PayPal/Stripe
│ │ ├── forum/ # 论坛服务 + 收银台 + meta box
│ │ ├── shop/ # 商城服务 + meta box + 评价
│ │ ├── sms/ # 短信编排 + 各云厂商 adapter
│ │ ├── ai/ # AI / SEO prompt
│ │ ├── messages/ # 站内信/私信/公告/举报
│ │ ├── extensions/ # MeiliSearch / 推送 / IP / 内容审核
│ │ └── widgets/ # 小工具实现 + 注册中心
│ │
│ └── helpers/ # ← 辅助函数文件
│ ├── aksrt-icons.php # SVG 图标系统(读取/缓存/映射)
│ ├── aksrt-template-tags.php # 模板标签(Banners/友链/Logo/SEO Head)
│ └── aksrt-frontend-tags.php # 前端标签(阅读时长/面包屑/评论回调)
├── src/AKSRT/ # Composer PSR-4 类型根(namespace AKSRT\)
│ ├── Admin/ # SPA 编排 + 域控制器 + Schema + Native ops
│ ├── Auth/ # 登录 / OAuth / 审核 / 邮箱
│ ├── Content/ # 下载 token / 付费内容 / VIP / 可见性
│ ├── Core/ # 主题壳层(Setup / Scripts / Templates / SEO / DB…)
│ ├── Credits/ # 积分 / 钱包 / 签到 / 邀请
│ ├── Extensions/ # MeiliSearch / 推送 / IP / 内容审核
│ ├── Forum/ # 论坛服务 + 收银台
│ ├── Frontend/ # 前端渲染辅助
│ ├── Messages/ # 站内信 / 私信 / 公告 / 举报
│ ├── Payment/ # 订单 / 网关 / 售后 / 物流 / 分成
│ │ └── Gateways/ # 支付宝 / 微信 / PayPal / Stripe
│ ├── Settings/ # 设置门面 + 运行时 delegates
│ ├── Shop/ # 商城服务 + meta box
│ ├── Sms/ # 短信编排 + 云厂商 adapter
│ ├── Ai/ # AI / SEO prompt
│ ├── User/ # 用户中心 / 主页 / 徽章 / 等级 / 关注
│ └── Widgets/ # 小工具类(一类一文件)
│
├── inc/ # 过程式引导与辅助
│ ├── bootstrap.php # helpers + modules + core-hooks(类由 Composer 加载)
│ ├── core-hooks.php # 核心功能钩子
│ ├── modules/ # 非类过程式模块(captcha / user-parts / widgets 注册…)
│ └── helpers/ # 辅助函数
│
├── templates/ # 模板目录(与 inc/ 隔离)
│ ├── pages/ # 自定义页面模板
+8 -8
View File
@@ -10,8 +10,8 @@ defined('ABSPATH') || exit;
get_header();
$term = get_queried_object();
if (class_exists('AKSRT_Docs_Presenter')) {
$docs_presenter = AKSRT_Docs_Presenter::get_instance();
if (class_exists('\AKSRT\Core\DocsPresenter')) {
$docs_presenter = \AKSRT\Core\DocsPresenter::get_instance();
if ($term instanceof WP_Term && $term->taxonomy === 'category') {
$doc_candidates = get_posts([
'post_type' => 'page',
@@ -33,8 +33,8 @@ if (!$term instanceof WP_Term) {
return;
}
$archive_settings = class_exists('AKSRT_Term_Meta')
? AKSRT_Term_Meta::resolve_archive_settings($term)
$archive_settings = class_exists('\AKSRT\Core\TermMeta')
? \AKSRT\Core\TermMeta::resolve_archive_settings($term)
: [
'layout_mode' => 'card',
'header_style' => 'cover',
@@ -54,15 +54,15 @@ $description = !empty($archive_settings['show_desc']) ? wp_kses_post((string) $a
$header_style = (string) $archive_settings['header_style'];
$layout_mode = (string) $archive_settings['layout_mode'];
$card_style = (string) ($archive_settings['card_style'] ?? 'standard');
$filter_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_post_filter_settings()
$filter_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_post_filter_settings()
: ['enabled' => false, 'sort' => false, 'ajax_enabled' => false];
if (!empty($filter_settings['enabled']) && !in_array('cat', $filter_settings['custom_filter_show'] ?? ['cat', 'tag'], true)) {
$filter_settings['enabled'] = false;
}
$ajax_filter = !empty($filter_settings['ajax_enabled']) && !empty($filter_settings['enabled']);
$cat_filter_config = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_filter_config_for_category((int) $term->term_id)
$cat_filter_config = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_filter_config_for_category((int) $term->term_id)
: ['dimensions' => []];
$custom_dimensions = is_array($cat_filter_config['dimensions'] ?? null) ? $cat_filter_config['dimensions'] : [];
$sort_state = function_exists('aksrt_archive_get_sort_state') ? aksrt_archive_get_sort_state() : ['current' => 'latest', 'links' => []];
+7 -2
View File
@@ -1,6 +1,6 @@
{
"name": "aksrt/theme",
"description": "AKSRT WordPress Theme - OAuth dependencies",
"description": "AKSRT WordPress Theme",
"type": "wordpress-theme",
"require": {
"php": ">=7.4",
@@ -14,5 +14,10 @@
"audit": {
"block-insecure": false
}
},
"autoload": {
"psr-4": {
"AKSRT\\": "src/AKSRT/"
}
}
}
}
+16 -16
View File
@@ -12,14 +12,14 @@ defined('ABSPATH') || exit;
// 数据准备
$blog_name = function_exists('aksrt_get_site_logo_text') ? aksrt_get_site_logo_text() : get_bloginfo('name');
$has_settings = class_exists('AKSRT_Settings');
$has_settings = class_exists('\AKSRT\Settings\Settings');
$search_placeholder = function_exists('aksrt_get_search_placeholder') ? aksrt_get_search_placeholder() : __('开启精彩搜索', 'aksrt');
$search_hot_keywords = function_exists('aksrt_get_search_hot_keywords') ? aksrt_get_search_hot_keywords() : [];
$search_history_enabled = function_exists('aksrt_search_history_enabled') ? aksrt_search_history_enabled() : true;
$search_suggest_enabled = function_exists('aksrt_search_suggestions_enabled') ? aksrt_search_suggestions_enabled() : false;
// 联系图标 / 社交链接(legacy contacts list — fallback for more icons)
$footer_contacts = $has_settings ? AKSRT_Settings::get_footer_contacts() : [];
$footer_contacts = $has_settings ? \AKSRT\Settings\Settings::get_footer_contacts() : [];
if (empty($footer_contacts) && function_exists('aksrt_get_about_info')) {
$about = aksrt_get_about_info();
$footer_contacts = $about['contacts'] ?? [];
@@ -27,22 +27,22 @@ if (empty($footer_contacts) && function_exists('aksrt_get_about_info')) {
// 友情链接 / 快速链接(仅当 fcode_t2_code_1 为空时回退)
$friend_links = function_exists('aksrt_get_friend_links') ? aksrt_get_friend_links() : [];
$quick_links = $has_settings ? AKSRT_Settings::get_quick_links() : [];
$more_links = $has_settings ? AKSRT_Settings::get_more_links() : [];
$hot_cat_count = $has_settings ? AKSRT_Settings::get_hot_categories_count() : 0;
$quick_links = $has_settings ? \AKSRT\Settings\Settings::get_quick_links() : [];
$more_links = $has_settings ? \AKSRT\Settings\Settings::get_more_links() : [];
$hot_cat_count = $has_settings ? \AKSRT\Settings\Settings::get_hot_categories_count() : 0;
// 备案 / 版权(customize 为空时回退)
$filing = $has_settings ? AKSRT_Settings::get_filing_settings() : ['icp_enabled' => true, 'icp_number' => '', 'police_enabled' => true, 'police_number' => ''];
$filing = $has_settings ? \AKSRT\Settings\Settings::get_filing_settings() : ['icp_enabled' => true, 'icp_number' => '', 'police_enabled' => true, 'police_number' => ''];
$icp_number = !empty($filing['icp_enabled']) ? (string) ($filing['icp_number'] ?? '') : '';
$police_number = !empty($filing['police_enabled']) ? (string) ($filing['police_number'] ?? '') : '';
$footer_text = $has_settings ? AKSRT_Settings::footer_text() : '';
$copyright_text = $has_settings ? AKSRT_Settings::get_copyright_text() : '';
$footer_text = $has_settings ? \AKSRT\Settings\Settings::footer_text() : '';
$copyright_text = $has_settings ? \AKSRT\Settings\Settings::get_copyright_text() : '';
// §2.3 三列结构化字段(Zibll keys)
$footer_brand = $has_settings ? AKSRT_Settings::get_footer_brand_settings() : ['m_s' => ['pc', 'mobile'], 'img' => '', 'img_dark' => '', 'title' => '', 'custom_code' => ''];
$footer_contact_ext = $has_settings ? AKSRT_Settings::get_footer_contact_extended_settings() : ['m_s' => ['pc', 'mobile'], 'wechat_img' => '', 'qq' => '', 'weibo' => '', 'email' => '', 'more' => [], 'code_1' => '', 'code_2' => ''];
$footer_mini = $has_settings ? AKSRT_Settings::get_footer_mini_img_settings() : ['m_s' => ['pc', 'mobile'], 'items' => []];
$footer_customize_code = $has_settings ? AKSRT_Settings::get_footer_customize_code() : '';
$footer_brand = $has_settings ? \AKSRT\Settings\Settings::get_footer_brand_settings() : ['m_s' => ['pc', 'mobile'], 'img' => '', 'img_dark' => '', 'title' => '', 'custom_code' => ''];
$footer_contact_ext = $has_settings ? \AKSRT\Settings\Settings::get_footer_contact_extended_settings() : ['m_s' => ['pc', 'mobile'], 'wechat_img' => '', 'qq' => '', 'weibo' => '', 'email' => '', 'more' => [], 'code_1' => '', 'code_2' => ''];
$footer_mini = $has_settings ? \AKSRT\Settings\Settings::get_footer_mini_img_settings() : ['m_s' => ['pc', 'mobile'], 'items' => []];
$footer_customize_code = $has_settings ? \AKSRT\Settings\Settings::get_footer_customize_code() : '';
// 设备可见性 → Zibll hidden-xs(仅在不含 mobile 时隐藏移动端)
$_brand_show_sm = in_array('mobile', (array) ($footer_brand['m_s'] ?? []), true);
@@ -324,11 +324,11 @@ if ($_footer_conter === '') {
<!-- 浮动右侧按钮组 -->
<?php
$floating_settings = $has_settings ? AKSRT_Settings::get_floating_buttons_settings() : [];
$floating_items = $has_settings ? AKSRT_Settings::get_floating_buttons_items() : [];
$floating_settings = $has_settings ? \AKSRT\Settings\Settings::get_floating_buttons_settings() : [];
$floating_items = $has_settings ? \AKSRT\Settings\Settings::get_floating_buttons_items() : [];
$floating_enabled = !empty($floating_settings['enabled']) && !empty($floating_items);
$tabbar_settings = $has_settings ? AKSRT_Settings::get_footer_tabbar_settings() : [];
$tabbar_items = $has_settings ? AKSRT_Settings::get_footer_tabbar_items() : [];
$tabbar_settings = $has_settings ? \AKSRT\Settings\Settings::get_footer_tabbar_settings() : [];
$tabbar_items = $has_settings ? \AKSRT\Settings\Settings::get_footer_tabbar_items() : [];
$tabbar_enabled = !empty($tabbar_settings['enabled']) && !empty($tabbar_items);
$floating_classes = 'float-right';
$floating_classes .= ' ' . (!empty($floating_settings['style']) ? sanitize_html_class($floating_settings['style']) : 'round');
+177 -172
View File
@@ -41,8 +41,8 @@ if (!function_exists('aksrt_get_setting')) {
* @return array
*/
function aksrt_get_all_settings() {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::get_all();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::get_all();
}
$settings = get_option('aksrt_settings', array());
@@ -66,9 +66,14 @@ if (!function_exists('aksrt_get_setting')) {
// 加载 Composer 依赖(OAuth2 客户端库等)
// ============================================================
$composer_autoload = AKSRT_DIR . '/vendor/autoload.php';
if (file_exists($composer_autoload)) {
require_once $composer_autoload;
if (!file_exists($composer_autoload)) {
wp_die(
esc_html__('AKSRT requires Composer dependencies. Run composer install in the theme directory.', 'aksrt'),
esc_html__('AKSRT theme', 'aksrt'),
['response' => 500]
);
}
require_once $composer_autoload;
// ============================================================
// 加载 Bootstrap(辅助函数 → 类文件 → 核心钩子)
@@ -114,223 +119,223 @@ if (get_option('aksrt_flushed_version') !== AKSRT_VERSION) {
// ============================================================
// 初始化所有单例实例
// ============================================================
AKSRT_Setup::get_instance()->init();
AKSRT_Scripts::get_instance()->init();
AKSRT_Admin::get_instance()->init();
AKSRT_OAuth::get_instance()->init();
\AKSRT\Core\Setup::get_instance()->init();
\AKSRT\Core\Scripts::get_instance()->init();
\AKSRT\Admin\Admin::get_instance()->init();
\AKSRT\Auth\OAuth::get_instance()->init();
// 初始化代理登录(根据配置模式选择性加载)
$aksrt_proxy_mode = AKSRT_Settings::oauth_proxy_mode();
if ($aksrt_proxy_mode === 'client' && class_exists('AKSRT_OAuth_Proxy_Client')) {
AKSRT_OAuth_Proxy_Client::get_instance()->init();
$aksrt_proxy_mode = \AKSRT\Settings\Settings::oauth_proxy_mode();
if ($aksrt_proxy_mode === 'client' && class_exists('\AKSRT\Auth\OAuthProxyClient')) {
\AKSRT\Auth\OAuthProxyClient::get_instance()->init();
}
if ($aksrt_proxy_mode === 'server' && class_exists('AKSRT_OAuth_Proxy_Server')) {
AKSRT_OAuth_Proxy_Server::get_instance()->init();
if ($aksrt_proxy_mode === 'server' && class_exists('\AKSRT\Auth\OAuthProxyServer')) {
\AKSRT\Auth\OAuthProxyServer::get_instance()->init();
}
AKSRT_Settings::get_instance()->init();
AKSRT_Auth_Router::get_instance()->init();
AKSRT_Templates::get_instance()->init();
AKSRT_Moderation::get_instance()->init();
\AKSRT\Settings\Settings::get_instance()->init();
\AKSRT\Auth\Router::get_instance()->init();
\AKSRT\Core\Templates::get_instance()->init();
\AKSRT\Auth\Moderation::get_instance()->init();
// 短代码统一注册入口(registry)
if (class_exists('AKSRT_Shortcodes')) {
if (class_exists('\AKSRT\Core\Shortcodes')) {
add_action('init', function () {
AKSRT_Shortcodes::get_instance()->register();
\AKSRT\Core\Shortcodes::get_instance()->register();
});
}
// 用户限制/封禁系统
if (class_exists('AKSRT_User_Restriction')) {
AKSRT_User_Restriction::get_instance()->init();
if (class_exists('\AKSRT\User\Restriction')) {
\AKSRT\User\Restriction::get_instance()->init();
}
// 用户中心 & 公开主页协调类
if (class_exists('AKSRT_User_Center')) {
AKSRT_User_Center::get_instance()->init();
if (class_exists('\AKSRT\User\Center')) {
\AKSRT\User\Center::get_instance()->init();
}
if (class_exists('AKSRT_User_Home')) {
AKSRT_User_Home::get_instance()->init();
if (class_exists('\AKSRT\User\Home')) {
\AKSRT\User\Home::get_instance()->init();
}
// 数据表迁移器:注册 hook(after_switch_theme + admin_init 双触发)
if (class_exists('AKSRT_DB_Migrator')) {
AKSRT_DB_Migrator::init();
if (class_exists('\AKSRT\Core\DBMigrator')) {
\AKSRT\Core\DBMigrator::init();
}
// 积分获取入口(注册赠送 / 评论奖励 / 签到 / 邀请)
if (class_exists('AKSRT_Credits_Earn')) {
AKSRT_Credits_Earn::get_instance()->init();
if (class_exists('\AKSRT\Credits\Earn')) {
\AKSRT\Credits\Earn::get_instance()->init();
}
if (class_exists('AKSRT_Signin')) {
AKSRT_Signin::get_instance()->init();
if (class_exists('\AKSRT\Credits\Signin')) {
\AKSRT\Credits\Signin::get_instance()->init();
}
if (class_exists('AKSRT_Invite')) {
AKSRT_Invite::get_instance()->init();
if (class_exists('\AKSRT\Credits\Invite')) {
\AKSRT\Credits\Invite::get_instance()->init();
}
if (class_exists('AKSRT_Creator_Revenue')) {
AKSRT_Creator_Revenue::get_instance()->init();
if (class_exists('AKSRT\\Payment\\CreatorRevenue')) {
\AKSRT\Payment\CreatorRevenue::get_instance()->init();
}
if (class_exists('AKSRT_Download')) {
AKSRT_Download::get_instance()->init();
if (class_exists('\AKSRT\Content\Download')) {
\AKSRT\Content\Download::get_instance()->init();
}
if (class_exists('AKSRT_Content_Pay')) {
AKSRT_Content_Pay::get_instance()->init();
if (class_exists('\AKSRT\Content\Pay')) {
\AKSRT\Content\Pay::get_instance()->init();
}
if (class_exists('AKSRT_Topic_Pay')) {
AKSRT_Topic_Pay::get_instance()->init();
if (class_exists('\AKSRT\Forum\TopicPay')) {
\AKSRT\Forum\TopicPay::get_instance()->init();
}
if (class_exists('AKSRT_Plate_Follow_Pay')) {
AKSRT_Plate_Follow_Pay::get_instance()->init();
if (class_exists('\AKSRT\Forum\PlateFollowPay')) {
\AKSRT\Forum\PlateFollowPay::get_instance()->init();
}
if (class_exists('AKSRT_Vip_Service')) {
AKSRT_Vip_Service::get_instance()->init();
if (class_exists('\AKSRT\Content\VipService')) {
\AKSRT\Content\VipService::get_instance()->init();
}
if (class_exists('AKSRT_Charge_Card')) {
AKSRT_Charge_Card::get_instance()->init();
if (class_exists('\AKSRT\Payment\ChargeCard')) {
\AKSRT\Payment\ChargeCard::get_instance()->init();
}
if (class_exists('AKSRT_Balance_Service')) {
AKSRT_Balance_Service::get_instance()->init();
if (class_exists('\AKSRT\Credits\BalanceService')) {
\AKSRT\Credits\BalanceService::get_instance()->init();
}
// Download State & Docs Presenter are pure service singletons (no hooks)
if (class_exists('AKSRT_Download_State')) {
AKSRT_Download_State::get_instance();
if (class_exists('\AKSRT\Content\DownloadState')) {
\AKSRT\Content\DownloadState::get_instance();
}
if (class_exists('AKSRT_Docs_Presenter')) {
AKSRT_Docs_Presenter::get_instance();
if (class_exists('\AKSRT\Core\DocsPresenter')) {
\AKSRT\Core\DocsPresenter::get_instance();
}
// Homepage module preview REST + query var (render still via helpers / static methods)
if (class_exists('AKSRT_Home_Modules')) {
AKSRT_Home_Modules::get_instance()->init();
if (class_exists('\AKSRT\Core\HomeModules')) {
\AKSRT\Core\HomeModules::get_instance()->init();
}
if (class_exists('AKSRT_Content_Visibility')) {
AKSRT_Content_Visibility::get_instance()->init();
if (class_exists('\AKSRT\Content\Visibility')) {
\AKSRT\Content\Visibility::get_instance()->init();
}
if (class_exists('AKSRT_SMS')) {
AKSRT_SMS::get_instance()->init();
if (class_exists('\AKSRT\Sms\SMS')) {
\AKSRT\Sms\SMS::get_instance()->init();
}
if (class_exists('AKSRT_AI')) {
AKSRT_AI::get_instance(); // config-gated; available when admin enables
if (class_exists('\AKSRT\Ai\AI')) {
\AKSRT\Ai\AI::get_instance(); // config-gated; available when admin enables
}
if (class_exists('AKSRT_WeChat_Notify')) {
AKSRT_WeChat_Notify::get_instance()->init();
if (class_exists('\AKSRT\Payment\WeChatNotify')) {
\AKSRT\Payment\WeChatNotify::get_instance()->init();
}
if (class_exists('AKSRT_Message')) {
AKSRT_Message::get_instance()->init();
if (class_exists('\AKSRT\Messages\Message')) {
\AKSRT\Messages\Message::get_instance()->init();
}
if (class_exists('AKSRT_Private_Message')) {
AKSRT_Private_Message::get_instance()->init();
if (class_exists('\AKSRT\Messages\PrivateMessage')) {
\AKSRT\Messages\PrivateMessage::get_instance()->init();
}
if (class_exists('AKSRT_Report_Center')) {
AKSRT_Report_Center::get_instance()->init();
if (class_exists('\AKSRT\Messages\ReportCenter')) {
\AKSRT\Messages\ReportCenter::get_instance()->init();
}
if (class_exists('AKSRT_Comment_Actions')) {
AKSRT_Comment_Actions::get_instance()->init();
if (class_exists('\AKSRT\Core\CommentActions')) {
\AKSRT\Core\CommentActions::get_instance()->init();
}
if (class_exists('AKSRT_Go_Redirect')) {
AKSRT_Go_Redirect::get_instance()->init();
if (class_exists('\AKSRT\Core\GoRedirect')) {
\AKSRT\Core\GoRedirect::get_instance()->init();
}
if (class_exists('AKSRT_Site_Notice')) {
AKSRT_Site_Notice::get_instance()->init();
if (class_exists('\AKSRT\Messages\SiteNotice')) {
\AKSRT\Messages\SiteNotice::get_instance()->init();
}
if (class_exists('AKSRT_API_Audit')) {
AKSRT_API_Audit::get_instance()->init();
if (class_exists('\AKSRT\Extensions\APIAudit')) {
\AKSRT\Extensions\APIAudit::get_instance()->init();
}
if (class_exists('AKSRT_MeiliSearch')) {
AKSRT_MeiliSearch::get_instance()->init();
if (class_exists('\AKSRT\Extensions\MeiliSearch')) {
\AKSRT\Extensions\MeiliSearch::get_instance()->init();
// Async single post index (debounced)
add_action('aksrt_meilisearch_index_single', function (int $post_id) {
AKSRT_MeiliSearch::get_instance()->index_post($post_id);
\AKSRT\Extensions\MeiliSearch::get_instance()->index_post($post_id);
});
}
if (class_exists('AKSRT_Search_Push')) {
AKSRT_Search_Push::get_instance()->init();
if (class_exists('\AKSRT\Extensions\SearchPush')) {
\AKSRT\Extensions\SearchPush::get_instance()->init();
}
if (class_exists('AKSRT_SEO_Head')) {
AKSRT_SEO_Head::get_instance()->init();
if (class_exists('\AKSRT\Core\SEOHead')) {
\AKSRT\Core\SEOHead::get_instance()->init();
}
if (class_exists('AKSRT_Update_Checker')) {
AKSRT_Update_Checker::get_instance()->init();
if (class_exists('\AKSRT\Core\UpdateChecker')) {
\AKSRT\Core\UpdateChecker::get_instance()->init();
}
if (class_exists('AKSRT_Category_Rewrite')) {
AKSRT_Category_Rewrite::get_instance()->init();
if (class_exists('\AKSRT\Core\CategoryRewrite')) {
\AKSRT\Core\CategoryRewrite::get_instance()->init();
}
if (class_exists('AKSRT_Front_Submit')) {
AKSRT_Front_Submit::get_instance()->init();
if (class_exists('\AKSRT\Core\FrontSubmit')) {
\AKSRT\Core\FrontSubmit::get_instance()->init();
}
if (class_exists('AKSRT_Order')) {
AKSRT_Order::get_instance()->init();
if (class_exists('\AKSRT\Payment\Order')) {
\AKSRT\Payment\Order::get_instance()->init();
}
// Register built-in payment gateways
if (class_exists('AKSRT_Payment_Gateway')) {
$gw = AKSRT_Payment_Gateway::get_instance();
if (class_exists('\AKSRT\Payment\Gateway')) {
$gw = \AKSRT\Payment\Gateway::get_instance();
// 注册支付回调路由(/payment/{gateway}/notify|return|cancel)。
$gw->init();
if (class_exists('AKSRT_Balance_Gateway')) {
$gw->register('balance', new AKSRT_Balance_Gateway());
if (class_exists('\AKSRT\Payment\BalanceGateway')) {
$gw->register('balance', new \AKSRT\Payment\BalanceGateway());
}
if (class_exists('AKSRT_Alipay_Gateway')) {
$gw->register('alipay', new AKSRT_Alipay_Gateway());
if (class_exists('\AKSRT\Payment\Gateways\AlipayGateway')) {
$gw->register('alipay', new \AKSRT\Payment\Gateways\AlipayGateway());
}
if (class_exists('AKSRT_WechatPay_Gateway')) {
$gw->register('wechatpay', new AKSRT_WechatPay_Gateway());
if (class_exists('\AKSRT\Payment\Gateways\WechatPayGateway')) {
$gw->register('wechatpay', new \AKSRT\Payment\Gateways\WechatPayGateway());
}
if (class_exists('AKSRT_PayPal_Gateway')) {
$gw->register('paypal', new AKSRT_PayPal_Gateway());
if (class_exists('\AKSRT\Payment\Gateways\PayPalGateway')) {
$gw->register('paypal', new \AKSRT\Payment\Gateways\PayPalGateway());
}
if (class_exists('AKSRT_Stripe_Gateway')) {
$gw->register('stripe', new AKSRT_Stripe_Gateway());
if (class_exists('\AKSRT\Payment\Gateways\StripeGateway')) {
$gw->register('stripe', new \AKSRT\Payment\Gateways\StripeGateway());
}
do_action('aksrt_register_payment_gateways', $gw);
}
if (class_exists('AKSRT_Forum')) {
AKSRT_Forum::get_instance()->init();
if (class_exists('\AKSRT\Forum\Forum')) {
\AKSRT\Forum\Forum::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Resource_Meta_Box')) {
AKSRT_Resource_Meta_Box::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Core\ResourceMetaBox')) {
\AKSRT\Core\ResourceMetaBox::get_instance()->init();
}
// 分类/标签局部配置(term meta 字段)
if (class_exists('AKSRT_Term_Meta')) {
AKSRT_Term_Meta::get_instance()->init();
if (class_exists('\AKSRT\Core\TermMeta')) {
\AKSRT\Core\TermMeta::get_instance()->init();
}
// 商城 taxonomy term meta + shop_discount 优惠活动
if (class_exists('AKSRT_Shop_Term_Meta')) {
AKSRT_Shop_Term_Meta::get_instance()->init();
if (class_exists('\AKSRT\Shop\TermMeta')) {
\AKSRT\Shop\TermMeta::get_instance()->init();
}
// 商品后台列表自定义列(销量/综合数据/商家/优惠活动)
if (is_admin() && class_exists('AKSRT_Admin_Shop_Controller')) {
AKSRT_Admin_Shop_Controller::get_instance()->init_product_admin_columns();
if (is_admin() && class_exists('\AKSRT\Admin\ShopController')) {
\AKSRT\Admin\ShopController::get_instance()->init_product_admin_columns();
}
// 商品原生编辑 meta box(价格/库存/发货售后)
if (is_admin() && class_exists('AKSRT_Product_Meta_Box')) {
AKSRT_Product_Meta_Box::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Shop\ProductMetaBox')) {
\AKSRT\Shop\ProductMetaBox::get_instance()->init();
}
// 商品原生变体 meta box
if (is_admin() && class_exists('AKSRT_Product_Variants_Meta_Box')) {
AKSRT_Product_Variants_Meta_Box::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Shop\ProductVariantsMetaBox')) {
\AKSRT\Shop\ProductVariantsMetaBox::get_instance()->init();
}
// 论坛版块版主 meta box
if (is_admin() && class_exists('AKSRT_Plate_Meta_Box')) {
AKSRT_Plate_Meta_Box::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Forum\PlateMetaBox')) {
\AKSRT\Forum\PlateMetaBox::get_instance()->init();
}
// 论坛帖子原生列表治理列/筛选/批量
if (is_admin() && class_exists('AKSRT_Topic_Admin_List')) {
AKSRT_Topic_Admin_List::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Forum\TopicAdminList')) {
\AKSRT\Forum\TopicAdminList::get_instance()->init();
}
// 论坛帖子治理 meta box
if (is_admin() && class_exists('AKSRT_Topic_Meta_Box')) {
AKSRT_Topic_Meta_Box::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Forum\TopicMetaBox')) {
\AKSRT\Forum\TopicMetaBox::get_instance()->init();
}
// 论坛版块列表列
if (is_admin() && class_exists('AKSRT_Plate_Admin_List')) {
AKSRT_Plate_Admin_List::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Forum\PlateAdminList')) {
\AKSRT\Forum\PlateAdminList::get_instance()->init();
}
@@ -338,87 +343,87 @@ if (is_admin() && class_exists('AKSRT_Plate_Admin_List')) {
// 商品评价/评分系统
if (class_exists('AKSRT_Product_Review')) {
AKSRT_Product_Review::get_instance()->init();
if (class_exists('\AKSRT\Shop\ProductReview')) {
\AKSRT\Shop\ProductReview::get_instance()->init();
}
// 文章局部配置 meta box(仅后台)
if (is_admin() && class_exists('AKSRT_Post_Meta_Box')) {
AKSRT_Post_Meta_Box::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Core\PostMetaBox')) {
\AKSRT\Core\PostMetaBox::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_SEO_Meta_Box')) {
AKSRT_SEO_Meta_Box::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Core\SEOMetaBox')) {
\AKSRT\Core\SEOMetaBox::get_instance()->init();
}
// 绔欑偣璁块棶閲忕粺璁?
if (class_exists('AKSRT_Stats_Tracker')) {
AKSRT_Stats_Tracker::init();
if (class_exists('\AKSRT\Core\StatsTracker')) {
\AKSRT\Core\StatsTracker::init();
}
// Email rollback window (24h): user list row action + admin-post handler.
if (class_exists('AKSRT_Email_Rollback')) {
AKSRT_Email_Rollback::get_instance()->init();
if (class_exists('\AKSRT\Auth\EmailRollback')) {
\AKSRT\Auth\EmailRollback::get_instance()->init();
}
// WordPress 原生"用户"菜单:积分管理
if (class_exists('AKSRT_User_Credits_Admin')) {
AKSRT_User_Credits_Admin::get_instance()->init();
if (class_exists('\AKSRT\User\CreditsAdmin')) {
\AKSRT\User\CreditsAdmin::get_instance()->init();
}
if (class_exists('AKSRT_User_Balance_Admin')) {
AKSRT_User_Balance_Admin::get_instance()->init();
if (class_exists('\AKSRT\User\BalanceAdmin')) {
\AKSRT\User\BalanceAdmin::get_instance()->init();
}
if (class_exists('AKSRT_User_Badges')) {
AKSRT_User_Badges::get_instance()->init();
if (class_exists('\AKSRT\User\Badges')) {
\AKSRT\User\Badges::get_instance()->init();
}
if (class_exists('AKSRT_User_Badges_Admin')) {
AKSRT_User_Badges_Admin::get_instance()->init();
if (class_exists('\AKSRT\User\BadgesAdmin')) {
\AKSRT\User\BadgesAdmin::get_instance()->init();
}
if (class_exists('AKSRT_User_Level')) {
AKSRT_User_Level::get_instance()->init();
if (class_exists('\AKSRT\User\Level')) {
\AKSRT\User\Level::get_instance()->init();
}
if (class_exists('AKSRT_User_Metrics')) {
AKSRT_User_Metrics::get_instance()->init();
if (class_exists('\AKSRT\User\Metrics')) {
\AKSRT\User\Metrics::get_instance()->init();
}
// WordPress 原生侧栏:支付/订单运营中心(zibll zibpay 对齐)
if (is_admin() && class_exists('AKSRT_Admin_Pay_Menus')) {
AKSRT_Admin_Pay_Menus::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayMenus')) {
\AKSRT\Admin\Native\PayMenus::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_Coupons')) {
AKSRT_Admin_Pay_Coupons::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayCoupons')) {
\AKSRT\Admin\Native\PayCoupons::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_Charge_Cards')) {
AKSRT_Admin_Pay_Charge_Cards::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayChargeCards')) {
\AKSRT\Admin\Native\PayChargeCards::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_Shipping')) {
AKSRT_Admin_Pay_Shipping::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayShipping')) {
\AKSRT\Admin\Native\PayShipping::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_After_Sale')) {
AKSRT_Admin_Pay_After_Sale::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayAfterSale')) {
\AKSRT\Admin\Native\PayAfterSale::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_Orders')) {
AKSRT_Admin_Pay_Orders::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayOrders')) {
\AKSRT\Admin\Native\PayOrders::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_Products')) {
AKSRT_Admin_Pay_Products::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayProducts')) {
\AKSRT\Admin\Native\PayProducts::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_Download_Logs')) {
AKSRT_Admin_Pay_Download_Logs::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayDownloadLogs')) {
\AKSRT\Admin\Native\PayDownloadLogs::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_Withdrawals')) {
AKSRT_Admin_Pay_Withdrawals::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayWithdrawals')) {
\AKSRT\Admin\Native\PayWithdrawals::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_Income')) {
AKSRT_Admin_Pay_Income::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayIncome')) {
\AKSRT\Admin\Native\PayIncome::get_instance()->init();
}
if (is_admin() && class_exists('AKSRT_Admin_Pay_Rebate')) {
AKSRT_Admin_Pay_Rebate::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\PayRebate')) {
\AKSRT\Admin\Native\PayRebate::get_instance()->init();
}
// WordPress 原生用户菜单:消息/邀请码/认证/禁封(zibll users.php 子菜单对齐)
if (is_admin() && class_exists('AKSRT_Admin_Users_Menus')) {
AKSRT_Admin_Users_Menus::get_instance()->init();
if (is_admin() && class_exists('\AKSRT\Admin\Native\UsersMenus')) {
\AKSRT\Admin\Native\UsersMenus::get_instance()->init();
}
// ============================================================
+9 -9
View File
@@ -7,8 +7,8 @@
defined('ABSPATH') || exit;
$aksrt_header_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_header_nav_settings()
$aksrt_header_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_header_nav_settings()
: [
'fixed' => true,
'search_enabled' => true,
@@ -24,8 +24,8 @@ $aksrt_header_settings = class_exists('AKSRT_Settings')
];
$aksrt_initial_theme_mode = '';
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'initial_theme_mode')) {
$aksrt_initial_theme_mode = AKSRT_Settings::initial_theme_mode();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'initial_theme_mode')) {
$aksrt_initial_theme_mode = \AKSRT\Settings\Settings::initial_theme_mode();
}
$aksrt_has_initial_theme = in_array($aksrt_initial_theme_mode, ['dark', 'light'], true);
@@ -52,7 +52,7 @@ $aksrt_body_classes[] = 'mobile-header-' . $aksrt_header_settings['mobile_layout
$aksrt_body_classes[] = 'mobile-nav-' . $aksrt_header_settings['mobile_align'];
// 全局背景系统
$aksrt_bg_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_global_background_settings() : [];
$aksrt_bg_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_global_background_settings() : [];
$aksrt_bg_styles = [];
if (!empty($aksrt_bg_settings['bg_color'])) {
$aksrt_bg_styles[] = '--aksrt-bg-color:' . sanitize_hex_color($aksrt_bg_settings['bg_color']);
@@ -128,7 +128,7 @@ if (!empty($aksrt_bg_styles)) {
$aksrt_show_user_entry = !empty($aksrt_header_settings['user_menu']);
$aksrt_current_user = wp_get_current_user();
$aksrt_user_credit = function_exists('aksrt_user_credits') && is_user_logged_in() ? (int) aksrt_user_credits(get_current_user_id()) : 0;
$aksrt_currency_name = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
$aksrt_currency_name = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt');
$aksrt_orders_url = function_exists('aksrt_get_orders_page_url') ? aksrt_get_orders_page_url() : '';
$aksrt_publish_url = admin_url('post-new.php');
$aksrt_messages_url = function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '';
@@ -147,12 +147,12 @@ if (!empty($aksrt_bg_styles)) {
$aksrt_theme_settings_url = function_exists('aksrt_get_admin_settings_url')
? aksrt_get_admin_settings_url('')
: admin_url('admin.php?page=aksrt-settings');
$aksrt_theme_toggle_positions = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_theme_mode_button_positions()
$aksrt_theme_toggle_positions = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_theme_mode_button_positions()
: ['pc_nav', 'm_menu'];
$aksrt_can_publish = !empty($aksrt_header_settings['publish_btn']) && (
current_user_can('manage_options')
|| (class_exists('AKSRT_Front_Submit') && AKSRT_Front_Submit::get_instance()->can_submit())
|| (class_exists('\AKSRT\Core\FrontSubmit') && \AKSRT\Core\FrontSubmit::get_instance()->can_submit())
);
$aksrt_show_header_slide = function_exists('aksrt_header_slide_is_show')
? aksrt_header_slide_is_show()
+2 -2
View File
@@ -7,8 +7,8 @@
defined('ABSPATH') || exit;
$system_tools = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_system_tools_settings()
$system_tools = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_system_tools_settings()
: ['close_attachment_page' => true];
if (!empty($system_tools['close_attachment_page'])) {
+19 -349
View File
@@ -2,8 +2,8 @@
/**
* AKSRT Theme Bootstrap Loader
*
* 统一加载入口:辅助函数 → 类文件 → 实例初始化
* 类文件按领域目录组织(inc/classes/{domain}/),路径集中在此维护。
* Helpers + procedural modules + core hooks.
* Domain classes load via Composer PSR-4 (src/AKSRT).
*
* @package AKSRT
* @version 3.4.0
@@ -11,14 +11,7 @@
defined('ABSPATH') || exit;
// ============================================================
// 翻译加载延迟到 after_setup_theme(WordPress 6.7+ 要求)
// 由 AKSRT_Setup::load_textdomain() 处理
// ============================================================
// ============================================================
// 阶段1:加载辅助函数(必须在类之前,类会调用这些函数)
// ============================================================
// Stage 1: helpers
require_once AKSRT_DIR . '/inc/helpers/aksrt-icons.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-domain-model.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-template-tags.php';
@@ -46,7 +39,6 @@ require_once AKSRT_DIR . '/inc/helpers/aksrt-null.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-identity.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-rewards.php';
require_once AKSRT_DIR . '/inc/helpers/menu-decoration.php';
require_once AKSRT_DIR . '/inc/helpers/class-aksrt-nav-walker.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-transactions.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-commerce.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-user-dashboard.php';
@@ -54,368 +46,46 @@ require_once AKSRT_DIR . '/inc/helpers/aksrt-user-center.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-user-home.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-shortcodes.php';
// Stage 2: procedural modules
require_once AKSRT_DIR . '/inc/modules/captcha.php';
require_once AKSRT_DIR . '/inc/modules/user-hub.php';
require_once AKSRT_DIR . '/inc/modules/user-notifications.php';
require_once AKSRT_DIR . '/inc/modules/creator-revenue.php';
require_once AKSRT_DIR . '/inc/modules/widgets-register.php';
// ============================================================
// 阶段2:加载类文件(settings 必须在 admin 之前)
// 领域目录:core / frontend / settings / admin / auth / user /
// credits / content / payment / forum / shop / sms / ai /
// messages / extensions / widgets
// ============================================================
// --- core: setup / scripts / frontend render helpers ---
require_once AKSRT_DIR . '/inc/classes/core/setup-traits/trait-aksrt-setup-part-1.php';
require_once AKSRT_DIR . '/inc/classes/core/setup-traits/trait-aksrt-setup-part-2.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-setup.php';
require_once AKSRT_DIR . '/inc/classes/core/scripts-traits/trait-aksrt-scripts-part-1b.php';
require_once AKSRT_DIR . '/inc/classes/core/scripts-traits/trait-aksrt-scripts-part-1c.php';
require_once AKSRT_DIR . '/inc/classes/core/scripts-traits/trait-aksrt-scripts-part-2.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-scripts.php';
require_once AKSRT_DIR . '/inc/classes/frontend/class-aksrt-inline-style-builder.php';
require_once AKSRT_DIR . '/inc/classes/frontend/class-aksrt-custom-code-renderer.php';
require_once AKSRT_DIR . '/inc/classes/frontend/class-aksrt-loading-overlay-renderer.php';
// --- settings: groups + runtime delegates + facade ---
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-domain-groups.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-display-page-groups.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-credits-payment-groups.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-category-integration-groups.php';
require_once AKSRT_DIR . '/inc/classes/settings/trait-aksrt-settings-auth-reader.php';
require_once AKSRT_DIR . '/inc/classes/settings/trait-aksrt-settings-homepage-reader.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-mail.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-theme-search.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-post-display.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-home-cms.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-payment-runtime.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-display-runtime.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-category-runtime.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-user-runtime.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-credits-runtime.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-integration.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-extension-runtime.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-forum-shop.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings-capabilities.php';
require_once AKSRT_DIR . '/inc/classes/settings/trait-aksrt-settings-facade-bulk.php';
require_once AKSRT_DIR . '/inc/classes/settings/class-aksrt-settings.php';
// --- admin: SPA controllers + schema + native ops ---
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-controller-base.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-user-controller-invite-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-user-controller-report-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-user-controller-verify-integrations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-user-controller-auth-phone-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-user-controller-restriction-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-user-controller-follow-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-shop-controller-product-admin-columns.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-shop-controller-frontend-flow-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-shop-controller-product-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-shop-controller-order-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-shop-controller-fulfillment-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-shop-controller-coupon-gateway-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-shop-controller-variant-export-operations.php';
require_once AKSRT_DIR . '/inc/classes/admin/global-ctrl-traits/trait-aksrt-admin-global-controller-part-1.php';
require_once AKSRT_DIR . '/inc/classes/admin/global-ctrl-traits/trait-aksrt-admin-global-controller-part-2.php';
require_once AKSRT_DIR . '/inc/classes/admin/global-ctrl-traits/trait-aksrt-admin-homepage-settings-rest.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-global-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-page-display-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-post-list-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-permissions-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-user-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-payment-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-tools-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-schema-provider.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-global.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-page-display.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/post-list/class-aksrt-admin-schema-post-list-list.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-post-list.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-permissions.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-users.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-payment.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-extensions-ip.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-extensions-audit.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-extensions-push.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-extensions-security.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-extensions-docs-mode.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-extensions.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-tools-import-export.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-tools-health.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-tools-backup.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-tools-email-rollback.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-tools.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-shop-basic.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-shop-list.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-shop-contact.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-shop-single.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-shop-product-defaults.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-shop-shipping-config.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-shop-timing.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-shop.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-basic.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-names.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-homepage.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-board-page.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-post-page.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-reply.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-permissions.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-other.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-upload.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum-credits.php';
require_once AKSRT_DIR . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum.php';
require_once AKSRT_DIR . '/inc/classes/admin/import-export-traits/trait-aksrt-admin-import-export-controller-part-1.php';
require_once AKSRT_DIR . '/inc/classes/admin/import-export-traits/trait-aksrt-admin-import-export-controller-part-2.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-import-export-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-shop-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/forum-ctrl-traits/trait-aksrt-admin-forum-controller-part-1.php';
require_once AKSRT_DIR . '/inc/classes/admin/forum-ctrl-traits/trait-aksrt-admin-forum-controller-part-2.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-forum-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-extension-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-comment-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-message-controller.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-menus.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-coupons.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-charge-cards.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-shipping.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-after-sale.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-orders.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-products.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-download-logs.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-withdrawals.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-income.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-pay-rebate.php';
require_once AKSRT_DIR . '/inc/classes/admin/native/class-aksrt-admin-users-menus.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin.php';
// --- core: presentation / infra shells used by admin + front ---
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-comment-actions.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-go-redirect.php';
require_once AKSRT_DIR . '/inc/classes/messages/class-aksrt-site-notice.php';
require_once AKSRT_DIR . '/inc/classes/extensions/class-aksrt-api-audit.php';
require_once AKSRT_DIR . '/inc/classes/extensions/class-aksrt-meilisearch.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-update-checker.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-category-rewrite.php';
// --- auth ---
require_once AKSRT_DIR . '/inc/classes/auth/class-aksrt-auth-email-verification.php';
require_once AKSRT_DIR . '/inc/classes/auth/auth-traits/trait-aksrt-auth-service-part-1a.php';
require_once AKSRT_DIR . '/inc/classes/auth/auth-traits/trait-aksrt-auth-service-part-1b.php';
require_once AKSRT_DIR . '/inc/classes/auth/class-aksrt-auth-service.php';
require_once AKSRT_DIR . '/inc/classes/auth/oauth-traits/trait-aksrt-oauth-part-1.php';
require_once AKSRT_DIR . '/inc/classes/auth/oauth-traits/trait-aksrt-oauth-part-2.php';
require_once AKSRT_DIR . '/inc/classes/auth/class-aksrt-oauth.php';
require_once AKSRT_DIR . '/inc/classes/auth/class-aksrt-oauth-proxy-client.php';
require_once AKSRT_DIR . '/inc/classes/auth/class-aksrt-oauth-proxy-server.php';
require_once AKSRT_DIR . '/inc/classes/auth/class-aksrt-captcha.php';
require_once AKSRT_DIR . '/inc/classes/auth/moderation-traits/trait-aksrt-moderation-part-1.php';
require_once AKSRT_DIR . '/inc/classes/auth/moderation-traits/trait-aksrt-moderation-part-2.php';
require_once AKSRT_DIR . '/inc/classes/auth/class-aksrt-moderation.php';
require_once AKSRT_DIR . '/inc/classes/auth/class-aksrt-auth-router.php';
require_once AKSRT_DIR . '/inc/classes/auth/class-aksrt-email-rollback.php';
// --- user ---
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-notifications.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-center.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-home.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-restriction.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-credits-admin.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-balance-admin.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-badges.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-badges-admin.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-level.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-user-metrics.php';
require_once AKSRT_DIR . '/inc/classes/user/class-aksrt-follow.php';
// --- core: templates + stats + DB migrator ---
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-templates.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-stats-tracker.php';
require_once AKSRT_DIR . '/inc/classes/core/db-traits/trait-aksrt-db-migrator-part-2.php';
require_once AKSRT_DIR . '/inc/classes/core/db-traits/trait-aksrt-db-migrator-part-3.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-db-migrator.php';
// --- credits / wallet ---
require_once AKSRT_DIR . '/inc/classes/credits/class-aksrt-credits.php';
require_once AKSRT_DIR . '/inc/classes/credits/class-aksrt-balance.php';
require_once AKSRT_DIR . '/inc/classes/credits/balance-service-traits/trait-aksrt-balance-service-rest.php';
require_once AKSRT_DIR . '/inc/classes/credits/balance-service-traits/trait-aksrt-balance-service-charge.php';
require_once AKSRT_DIR . '/inc/classes/credits/balance-service-traits/trait-aksrt-balance-service-points.php';
require_once AKSRT_DIR . '/inc/classes/credits/class-aksrt-balance-service.php';
require_once AKSRT_DIR . '/inc/classes/credits/class-aksrt-points-free.php';
require_once AKSRT_DIR . '/inc/classes/credits/class-aksrt-credits-earn.php';
require_once AKSRT_DIR . '/inc/classes/credits/class-aksrt-signin.php';
require_once AKSRT_DIR . '/inc/classes/credits/class-aksrt-invite.php';
// --- content pay / download / VIP ---
require_once AKSRT_DIR . '/inc/classes/content/class-aksrt-download.php';
require_once AKSRT_DIR . '/inc/classes/content/content-pay-traits/trait-aksrt-content-pay-rest.php';
require_once AKSRT_DIR . '/inc/classes/content/content-pay-traits/trait-aksrt-content-pay-orders.php';
require_once AKSRT_DIR . '/inc/classes/content/content-pay-traits/trait-aksrt-content-pay-helpers.php';
require_once AKSRT_DIR . '/inc/classes/content/class-aksrt-content-pay.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-topic-pay.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-plate-follow-pay.php';
require_once AKSRT_DIR . '/inc/classes/content/vip-service-traits/trait-aksrt-vip-service-rest.php';
require_once AKSRT_DIR . '/inc/classes/content/vip-service-traits/trait-aksrt-vip-service-purchase.php';
require_once AKSRT_DIR . '/inc/classes/content/vip-service-traits/trait-aksrt-vip-service-packages.php';
require_once AKSRT_DIR . '/inc/classes/content/class-aksrt-vip-service.php';
require_once AKSRT_DIR . '/inc/classes/content/class-aksrt-download-state.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-docs-presenter.php';
// CMS 首页模块(预览 REST + 默认模板;模板主路径仍在 helpers)
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-home-modules.php';
require_once AKSRT_DIR . '/inc/classes/content/class-aksrt-content-visibility.php';
// --- extensions ---
require_once AKSRT_DIR . '/inc/classes/extensions/class-aksrt-ip-geo.php';
require_once AKSRT_DIR . '/inc/classes/extensions/class-aksrt-content-audit.php';
require_once AKSRT_DIR . '/inc/classes/extensions/class-aksrt-search-push.php';
// --- sms ---
require_once AKSRT_DIR . '/inc/classes/sms/class-aksrt-sms-signature-helper.php';
require_once AKSRT_DIR . '/inc/classes/sms/class-aksrt-sms-provider.php';
require_once AKSRT_DIR . '/inc/classes/sms/class-aksrt-sms-provider-aliyun.php';
require_once AKSRT_DIR . '/inc/classes/sms/class-aksrt-sms-provider-tencent.php';
require_once AKSRT_DIR . '/inc/classes/sms/class-aksrt-sms-provider-huawei.php';
require_once AKSRT_DIR . '/inc/classes/sms/class-aksrt-sms-provider-custom.php';
require_once AKSRT_DIR . '/inc/classes/sms/class-aksrt-sms-provider-factory.php';
require_once AKSRT_DIR . '/inc/classes/sms/class-aksrt-sms.php';
// --- payment ---
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-wechat-notify.php';
require_once AKSRT_DIR . '/inc/classes/messages/class-aksrt-message.php';
require_once AKSRT_DIR . '/inc/classes/messages/class-aksrt-private-message.php';
require_once AKSRT_DIR . '/inc/classes/messages/class-aksrt-report-center.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-coupon.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-order.php';
require_once AKSRT_DIR . '/inc/classes/payment/order-repository-traits/trait-aksrt-order-repository-core.php';
require_once AKSRT_DIR . '/inc/classes/payment/order-repository-traits/trait-aksrt-order-repository-admin.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-order-repository.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-payment-gateway.php';
require_once AKSRT_DIR . '/inc/classes/payment/gateways/class-aksrt-alipay-gateway.php';
require_once AKSRT_DIR . '/inc/classes/payment/gateways/class-aksrt-wechatpay-gateway.php';
require_once AKSRT_DIR . '/inc/classes/payment/gateways/class-aksrt-paypal-gateway.php';
require_once AKSRT_DIR . '/inc/classes/payment/gateways/class-aksrt-stripe-gateway.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-revenue.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-creator-revenue.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-withdrawal.php';
// --- core: front submit ---
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-front-submit.php';
// --- forum ---
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-forum-permission-service.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-forum-draft-service.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-forum-comment-service.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-forum-score-service.php';
require_once AKSRT_DIR . '/inc/classes/forum/board-service-traits/trait-aksrt-forum-board-service-part-1.php';
require_once AKSRT_DIR . '/inc/classes/forum/board-service-traits/trait-aksrt-forum-board-service-part-2.php';
require_once AKSRT_DIR . '/inc/classes/forum/board-service-traits/trait-aksrt-forum-board-service-part-3.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-forum-board-service.php';
require_once AKSRT_DIR . '/inc/classes/forum/topic-service-traits/trait-aksrt-forum-topic-service-part-1.php';
require_once AKSRT_DIR . '/inc/classes/forum/topic-service-traits/trait-aksrt-forum-topic-service-part-2.php';
require_once AKSRT_DIR . '/inc/classes/forum/topic-service-traits/trait-aksrt-forum-topic-service-part-3.php';
require_once AKSRT_DIR . '/inc/classes/forum/topic-service-traits/trait-aksrt-forum-topic-service-part-4.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-forum-topic-service.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-forum-moderation-service.php';
require_once AKSRT_DIR . '/inc/classes/forum/view-builder-traits/trait-aksrt-forum-view-builder-part-1.php';
require_once AKSRT_DIR . '/inc/classes/forum/view-builder-traits/trait-aksrt-forum-view-builder-part-2.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-forum-view-builder.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-forum.php';
// --- shop ---
require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-shop-cart-service.php';
require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-shop-checkout-service.php';
require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-shop-address-service.php';
require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-shop-product-service.php';
require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-product-meta-box.php';
require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-product-variants-meta-box.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-plate-meta-box.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-topic-admin-list.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-topic-meta-box.php';
require_once AKSRT_DIR . '/inc/classes/forum/class-aksrt-plate-admin-list.php';
require_once AKSRT_DIR . '/inc/classes/shop/shop-traits/trait-aksrt-shop-part-1.php';
require_once AKSRT_DIR . '/inc/classes/shop/shop-traits/trait-aksrt-shop-part-2.php';
require_once AKSRT_DIR . '/inc/classes/shop/shop-traits/trait-aksrt-shop-part-3.php';
require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-shop.php';
// --- payment: after-sale / shipping / charge-card / rebate / discount ---
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-after-sale.php';
require_once AKSRT_DIR . '/inc/classes/payment/shipping-traits/trait-aksrt-shipping-part-1.php';
require_once AKSRT_DIR . '/inc/classes/payment/shipping-traits/trait-aksrt-shipping-part-2.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-shipping.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-charge-card.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-rebate.php';
require_once AKSRT_DIR . '/inc/classes/payment/class-aksrt-discount.php';
// --- ai ---
require_once AKSRT_DIR . '/inc/classes/ai/class-aksrt-ai.php';
require_once AKSRT_DIR . '/inc/classes/ai/class-aksrt-ai-seo.php';
require_once AKSRT_DIR . '/inc/classes/ai/class-aksrt-ai-prompt.php';
require_once AKSRT_DIR . '/inc/classes/admin/class-aksrt-admin-ai-controller.php';
// --- core: SEO / term / post meta boxes ---
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-seo-meta-box.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-seo-head.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-term-meta.php';
require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-shop-term-meta.php';
require_once AKSRT_DIR . '/inc/classes/shop/class-aksrt-product-review.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-post-meta-box.php';
require_once AKSRT_DIR . '/inc/classes/core/class-aksrt-resource-meta-box.php';
// --- widgets ---
// 包文件(多 widget 合一)+ 独立 widget 文件 + 注册中心。
// 使用单一 glob:目录内所有 class-*.php(含 original/new/batch1/registry)。
// require_once 幂等;新增 widget 只需丢进 widgets/ 即可被加载。
$aksrt_widgets_dir = AKSRT_DIR . '/inc/classes/widgets/';
if (is_dir($aksrt_widgets_dir)) {
foreach (glob($aksrt_widgets_dir . 'class-*.php') as $aksrt_widget_file) {
require_once $aksrt_widget_file;
}
}
// ============================================================
// 阶段3:核心功能模块(Gravatar替换 / SMTP邮件)
// ============================================================
// Stage 3: core hooks
require_once AKSRT_DIR . '/inc/core-hooks.php';
// ============================================================
// 阶段4:邮箱验证 — 启动 Auth Service 全局钩子(authenticate 拦截)
// ============================================================
if (class_exists('AKSRT_Auth_Service')) {
AKSRT_Auth_Service::init();
// Stage 4: auth service hooks
if (class_exists(\AKSRT\Auth\Service::class)) {
\AKSRT\Auth\Service::init();
}
// ============================================================
// 阶段5:邮箱验证 — 一次性 backfill(幂等)+ cron 异步回填
// 兼容站点已通过 SQL 直接打开开关、未走 REST 保存路径的情况。
// ============================================================
// Stage 5: email verification backfill
add_action('init', function () {
// 紧急降级:直接跳过迁移
if (defined('AKSRT_NO_EMAIL_GATE') && AKSRT_NO_EMAIL_GATE) {
return;
}
if (!class_exists('AKSRT_Auth_Service') || !class_exists('AKSRT_Settings')) {
if (!class_exists(\AKSRT\Auth\Service::class) || !class_exists(\AKSRT\Settings\Settings::class)) {
return;
}
if (!AKSRT_Settings::registration_requires_email_verification()) {
if (!\AKSRT\Settings\Settings::registration_requires_email_verification()) {
return;
}
if (get_option('aksrt_email_verification_backfill_done')) {
return;
}
// 在 admin 上下文下不要拖慢前台,仅 admin/cron 触发
if (!is_admin() && !(defined('DOING_CRON') && DOING_CRON)) {
return;
}
AKSRT_Auth_Service::backfill_legacy_users_as_verified();
\AKSRT\Auth\Service::backfill_legacy_users_as_verified();
}, 5);
// 异步分批回填的 cron 钩子(仅在用户量 > 50000 时使用)
add_action('aksrt_email_verification_backfill_batch', function ($offset = 0) {
if (class_exists('AKSRT_Auth_Service')) {
AKSRT_Auth_Service::run_async_backfill_batch((int) $offset);
if (class_exists(\AKSRT\Auth\Service::class)) {
\AKSRT\Auth\Service::run_async_backfill_batch((int) $offset);
}
}, 10, 1);
// ============================================================
// 阶段6:设置迁移 — 将旧 option key 映射到新 Schema 结构
// 仅在后台上下文执行,前台不触发。
// ============================================================
add_action('admin_init', function () {
}, 5);
@@ -1,25 +0,0 @@
<?php
/**
* AKSRT_Admin_Schema_Extensions schema builder.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
class AKSRT_Admin_Schema_Extensions {
public static function build(): array {
return [
'domain' => 'extensions',
'title' => '扩展&增强',
'sections' => [
'ip' => AKSRT_Admin_Schema_Extensions_IP::build(),
'audit' => AKSRT_Admin_Schema_Extensions_Audit::build(),
'push' => AKSRT_Admin_Schema_Extensions_Push::build(),
'security' => AKSRT_Admin_Schema_Extensions_Security::build(),
'docs-mode' => AKSRT_Admin_Schema_Extensions_Docs_Mode::build(),
],
];
}
}
@@ -1,28 +0,0 @@
<?php
/**
* AKSRT_Admin_Schema_Shop schema builder.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
class AKSRT_Admin_Schema_Shop {
public static function build(): array {
return [
'key' => 'shop',
'title' => '商城&商品',
'version' => '1.0.0',
'sections' => [
'basic' => AKSRT_Admin_Schema_Shop_Basic::build(),
'list' => AKSRT_Admin_Schema_Shop_List::build(),
'contact' => AKSRT_Admin_Schema_Shop_Contact::build(),
'single' => AKSRT_Admin_Schema_Shop_Single::build(),
'product-defaults' => AKSRT_Admin_Schema_Shop_Product_Defaults::build(),
'shipping-config' => AKSRT_Admin_Schema_Shop_Shipping_Config::build(),
'timing' => AKSRT_Admin_Schema_Shop_Timing::build(),
],
];
}
}
@@ -1,24 +0,0 @@
<?php
/**
* AKSRT_Admin_Schema_Tools schema builder.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
class AKSRT_Admin_Schema_Tools {
public static function build(): array {
return [
'domain' => 'tools',
'title' => '工具&诊断',
'sections' => [
'import-export' => AKSRT_Admin_Schema_Tools_Import_Export::build(),
'health' => AKSRT_Admin_Schema_Tools_Health::build(),
'backup' => AKSRT_Admin_Schema_Tools_Backup::build(),
'email-rollback' => AKSRT_Admin_Schema_Tools_Email_Rollback::build(),
],
];
}
}
@@ -1,26 +0,0 @@
<?php
/**
* AKSRT Order Repository
*
* 订单存储:使用专用表 {prefix}aksrt_order。
* 提供 CRUD、查询、统计。一次性迁移入口保留用于旧数据导入。
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
class AKSRT_Order_Repository {
use AKSRT_Order_Repository_Core;
use AKSRT_Order_Repository_Admin;
private static $instance = null;
public static function get_instance(): self {
if (null === self::$instance) self::$instance = new self();
return self::$instance;
}
}
-15
View File
@@ -1,15 +0,0 @@
<?php
/**
* AKSRT User system module hub (procedural).
*
* Loads user-parts/*; keeps historical path for bootstrap.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
require_once __DIR__ . '/user-parts/aksrt-user-template-registry.php';
require_once __DIR__ . '/user-parts/aksrt-user-urls.php';
require_once __DIR__ . '/user-parts/aksrt-user-routing.php';
require_once __DIR__ . '/user-parts/aksrt-user-account-ajax.php';
@@ -1,564 +0,0 @@
<?php
/**
* AKSRT 第一批通用小工具 — v4.0 Zibll-aligned
*
* New widgets:
* 1. AKSRT_Search_Widget — 搜索框
* 2. AKSRT_Notice_Widget — 公告通知
* 3. AKSRT_Recent_Comments_Widget — 最新评论
* 4. AKSRT_Friend_Links_Widget — 友情链接
* 5. AKSRT_Icon_Cards_Widget — 图标卡片
* 6. AKSRT_Buttons_Widget — 按钮组
* 7. AKSRT_Custom_HTML_Gap_Widget — 自定义 HTML / 间距
*
* @package AKSRT
* @version 4.0.0
*/
defined('ABSPATH') || exit;
// ============================================================
// 1. 搜索框小工具
// ============================================================
class AKSRT_Search_Widget extends WP_Widget {
public function __construct() {
parent::__construct('aksrt_search', esc_html__('AKSRT 搜索', 'aksrt'), [
'description' => esc_html__('带样式的搜索框', 'aksrt'),
]);
}
public function widget($args, $instance): void {
echo $args['before_widget'];
$title = apply_filters('widget_title', $instance['title'] ?? '', $instance, $this->id_base);
if ($title) echo $args['before_title'] . esc_html($title) . $args['after_title'];
$placeholder = sanitize_text_field($instance['placeholder'] ?? __('搜索文章...', 'aksrt'));
?>
<div class="widget-search-box">
<form role="search" method="get" action="<?php echo esc_url(home_url('/')); ?>">
<div class="widget-search-box__inner">
<input type="search" name="s" class="widget-search-box__input" placeholder="<?php echo esc_attr($placeholder); ?>" value="<?php echo esc_attr(get_search_query()); ?>" autocomplete="off">
<button type="submit" class="widget-search-box__btn" aria-label="<?php esc_attr_e('搜索', 'aksrt'); ?>">
<i class="fas fa-search"></i>
</button>
</div>
</form>
</div>
<?php
echo $args['after_widget'];
}
public function form($instance): void {
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('标题(可选):', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title'] ?? ''); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('placeholder'); ?>"><?php esc_html_e('占位文本:', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('placeholder'); ?>" name="<?php echo $this->get_field_name('placeholder'); ?>" value="<?php echo esc_attr($instance['placeholder'] ?? __('搜索文章...', 'aksrt')); ?>">
</p>
<?php
}
public function update($new_instance, $old_instance): array {
return [
'title' => sanitize_text_field($new_instance['title'] ?? ''),
'placeholder' => sanitize_text_field($new_instance['placeholder'] ?? ''),
];
}
}
// ============================================================
// 2. 公告通知小工具
// ============================================================
class AKSRT_Notice_Widget extends WP_Widget {
public function __construct() {
parent::__construct('aksrt_notice', esc_html__('AKSRT 公告', 'aksrt'), [
'description' => esc_html__('显示公告/通知信息', 'aksrt'),
]);
}
public function widget($args, $instance): void {
echo $args['before_widget'];
$title = apply_filters('widget_title', $instance['title'] ?? '', $instance, $this->id_base);
$content = wp_kses_post($instance['content'] ?? '');
$style = sanitize_key($instance['style'] ?? 'info');
$icon = sanitize_text_field($instance['icon'] ?? 'fas fa-bullhorn');
if ($title) echo $args['before_title'] . esc_html($title) . $args['after_title'];
?>
<div class="widget-notice widget-notice--<?php echo esc_attr($style); ?>">
<?php if ($icon) : ?>
<div class="widget-notice__icon"><i class="<?php echo esc_attr($icon); ?>" aria-hidden="true"></i></div>
<?php endif; ?>
<div class="widget-notice__content"><?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
</div>
<?php
echo $args['after_widget'];
}
public function form($instance): void {
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('标题(可选):', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title'] ?? ''); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('content'); ?>"><?php esc_html_e('公告内容:', 'aksrt'); ?></label>
<textarea class="widefat" rows="4" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>"><?php echo esc_textarea($instance['content'] ?? ''); ?></textarea>
</p>
<p>
<label for="<?php echo $this->get_field_id('style'); ?>"><?php esc_html_e('样式:', 'aksrt'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('style'); ?>" name="<?php echo $this->get_field_name('style'); ?>">
<option value="info" <?php selected($instance['style'] ?? '', 'info'); ?>><?php esc_html_e('信息(蓝色)', 'aksrt'); ?></option>
<option value="success" <?php selected($instance['style'] ?? '', 'success'); ?>><?php esc_html_e('成功(绿色)', 'aksrt'); ?></option>
<option value="warning" <?php selected($instance['style'] ?? '', 'warning'); ?>><?php esc_html_e('警告(黄色)', 'aksrt'); ?></option>
<option value="danger" <?php selected($instance['style'] ?? '', 'danger'); ?>><?php esc_html_e('危险(红色)', 'aksrt'); ?></option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('icon'); ?>"><?php esc_html_e('图标类名:', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('icon'); ?>" name="<?php echo $this->get_field_name('icon'); ?>" value="<?php echo esc_attr($instance['icon'] ?? 'fas fa-bullhorn'); ?>">
<small style="color:#666;"><?php esc_html_e('Font Awesome 类名,如: fas fa-bullhorn', 'aksrt'); ?></small>
</p>
<?php
}
public function update($new_instance, $old_instance): array {
return [
'title' => sanitize_text_field($new_instance['title'] ?? ''),
'content' => wp_kses_post($new_instance['content'] ?? ''),
'style' => in_array($new_instance['style'] ?? '', ['info', 'success', 'warning', 'danger'], true) ? $new_instance['style'] : 'info',
'icon' => sanitize_text_field($new_instance['icon'] ?? 'fas fa-bullhorn'),
];
}
}
// ============================================================
// 3. 最新评论小工具
// ============================================================
class AKSRT_Recent_Comments_Widget extends WP_Widget {
public function __construct() {
parent::__construct('aksrt_recent_comments', esc_html__('AKSRT 最新评论', 'aksrt'), [
'description' => esc_html__('显示最新评论列表', 'aksrt'),
]);
}
public function widget($args, $instance): void {
echo $args['before_widget'];
$title = apply_filters('widget_title', $instance['title'] ?? __('最新评论', 'aksrt'), $instance, $this->id_base);
$count = max(1, min(20, (int) ($instance['count'] ?? 5)));
$show_avatar = !empty($instance['show_avatar']);
if ($title) echo $args['before_title'] . esc_html($title) . $args['after_title'];
$comments = get_comments([
'number' => $count,
'status' => 'approve',
'post_status' => 'publish',
]);
if ($comments) : ?>
<div class="widget-recent-comments">
<?php foreach ($comments as $comment) :
$post = get_post($comment->comment_post_ID);
if (!$post) continue;
?>
<div class="widget-recent-comments__item">
<?php if ($show_avatar) : ?>
<div class="widget-recent-comments__avatar">
<?php echo get_avatar($comment, 32); ?>
</div>
<?php endif; ?>
<div class="widget-recent-comments__body">
<div class="widget-recent-comments__meta">
<strong class="widget-recent-comments__author"><?php echo esc_html($comment->comment_author); ?></strong>
<span class="widget-recent-comments__time"><?php echo esc_html(human_time_diff(strtotime($comment->comment_date), current_time('timestamp'))); ?></span>
</div>
<p class="widget-recent-comments__text">
<a href="<?php echo esc_url(get_comment_link($comment)); ?>"><?php echo esc_html(wp_trim_words($comment->comment_content, 15, '...')); ?></a>
</p>
<span class="widget-recent-comments__post">
<?php esc_html_e('于', 'aksrt'); ?> <a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php echo esc_html(get_the_title($post->ID)); ?></a>
</span>
</div>
</div>
<?php endforeach; ?>
</div>
<?php else : ?>
<?php echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无评论', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无评论', 'aksrt') . '</p>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php endif;
echo $args['after_widget'];
}
public function form($instance): void {
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('标题:', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title'] ?? __('最新评论', 'aksrt')); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('count'); ?>"><?php esc_html_e('显示数量:', 'aksrt'); ?></label>
<input class="tiny-text" type="number" min="1" max="20" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" value="<?php echo (int) ($instance['count'] ?? 5); ?>">
</p>
<p>
<label><input type="checkbox" name="<?php echo $this->get_field_name('show_avatar'); ?>" value="1" <?php checked(!empty($instance['show_avatar'])); ?>> <?php esc_html_e('显示头像', 'aksrt'); ?></label>
</p>
<?php
}
public function update($new_instance, $old_instance): array {
return [
'title' => sanitize_text_field($new_instance['title'] ?? ''),
'count' => max(1, min(20, (int) ($new_instance['count'] ?? 5))),
'show_avatar' => !empty($new_instance['show_avatar']),
];
}
}
// ============================================================
// 4. 友情链接小工具
// ============================================================
class AKSRT_Friend_Links_Widget extends WP_Widget {
public function __construct() {
parent::__construct('aksrt_friend_links', esc_html__('AKSRT 友情链接', 'aksrt'), [
'description' => esc_html__('显示友情链接列表', 'aksrt'),
]);
}
public function widget($args, $instance): void {
echo $args['before_widget'];
$title = apply_filters('widget_title', $instance['title'] ?? __('友情链接', 'aksrt'), $instance, $this->id_base);
$show_icon = !empty($instance['show_icon']);
$columns = max(1, min(4, (int) ($instance['columns'] ?? 2)));
if ($title) echo $args['before_title'] . esc_html($title) . $args['after_title'];
$links = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_friend_links() : [];
if (!empty($links)) : ?>
<div class="widget-friend-links" style="--fl-columns:<?php echo (int) $columns; ?>;">
<?php foreach ($links as $link) :
$name = sanitize_text_field($link['name'] ?? '');
$url = esc_url($link['url'] ?? '');
$desc = sanitize_text_field($link['description'] ?? '');
$icon = esc_url($link['icon'] ?? '');
if ($name === '' || $url === '') continue;
?>
<a href="<?php echo $url; ?>" class="widget-friend-links__item" target="_blank" rel="noopener noreferrer" title="<?php echo esc_attr($desc); ?>">
<?php if ($show_icon && $icon) : ?>
<img src="<?php echo $icon; ?>" alt="" class="widget-friend-links__icon" width="16" height="16"<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('widget') : ' loading="lazy"'; ?>>
<?php endif; ?>
<span class="widget-friend-links__name"><?php echo esc_html($name); ?></span>
</a>
<?php endforeach; ?>
</div>
<?php else : ?>
<?php echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无友情链接', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无友情链接', 'aksrt') . '</p>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php endif;
echo $args['after_widget'];
}
public function form($instance): void {
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('标题:', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title'] ?? __('友情链接', 'aksrt')); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('columns'); ?>"><?php esc_html_e('列数:', 'aksrt'); ?></label>
<input class="tiny-text" type="number" min="1" max="4" id="<?php echo $this->get_field_id('columns'); ?>" name="<?php echo $this->get_field_name('columns'); ?>" value="<?php echo (int) ($instance['columns'] ?? 2); ?>">
</p>
<p>
<label><input type="checkbox" name="<?php echo $this->get_field_name('show_icon'); ?>" value="1" <?php checked(!empty($instance['show_icon'])); ?>> <?php esc_html_e('显示站点图标', 'aksrt'); ?></label>
</p>
<p style="color:#666;font-size:12px;"><?php esc_html_e('链接数据在后台"友链管理"中配置。', 'aksrt'); ?></p>
<?php
}
public function update($new_instance, $old_instance): array {
return [
'title' => sanitize_text_field($new_instance['title'] ?? ''),
'columns' => max(1, min(4, (int) ($new_instance['columns'] ?? 2))),
'show_icon'=> !empty($new_instance['show_icon']),
];
}
}
// ============================================================
// 5. 图标卡片小工具
// ============================================================
class AKSRT_Icon_Cards_Widget extends WP_Widget {
public function __construct() {
parent::__construct('aksrt_icon_cards', esc_html__('AKSRT 图标卡片', 'aksrt'), [
'description' => esc_html__('显示图标+文字卡片网格', 'aksrt'),
]);
}
public function widget($args, $instance): void {
echo $args['before_widget'];
$title = apply_filters('widget_title', $instance['title'] ?? '', $instance, $this->id_base);
$cards = isset($instance['cards']) && is_array($instance['cards']) ? $instance['cards'] : [];
$columns = max(1, min(4, (int) ($instance['columns'] ?? 2)));
if ($title) echo $args['before_title'] . esc_html($title) . $args['after_title'];
if (!empty($cards)) : ?>
<div class="widget-icon-cards" style="--ic-columns:<?php echo (int) $columns; ?>;">
<?php foreach ($cards as $card) :
$card_title = sanitize_text_field($card['title'] ?? '');
$card_icon = sanitize_text_field($card['icon'] ?? '');
$card_link = esc_url($card['link'] ?? '');
$card_desc = sanitize_text_field($card['description'] ?? '');
if ($card_title === '') continue;
$tag = $card_link !== '' ? 'a' : 'div';
$extra = $card_link !== '' ? ' href="' . $card_link . '" target="_blank" rel="noopener"' : '';
?>
<<?php echo $tag; ?> class="widget-icon-cards__item"<?php echo $extra; ?>>
<?php if ($card_icon) : ?>
<div class="widget-icon-cards__icon"><i class="<?php echo esc_attr($card_icon); ?>" aria-hidden="true"></i></div>
<?php endif; ?>
<div class="widget-icon-cards__text">
<div class="widget-icon-cards__title"><?php echo esc_html($card_title); ?></div>
<?php if ($card_desc) : ?>
<div class="widget-icon-cards__desc"><?php echo esc_html($card_desc); ?></div>
<?php endif; ?>
</div>
</<?php echo $tag; ?>>
<?php endforeach; ?>
</div>
<?php endif;
echo $args['after_widget'];
}
public function form($instance): void {
$cards = isset($instance['cards']) && is_array($instance['cards']) ? $instance['cards'] : [];
while (count($cards) < 4) {
$cards[] = ['title' => '', 'icon' => '', 'link' => '', 'description' => ''];
}
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('标题(可选):', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title'] ?? ''); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('columns'); ?>"><?php esc_html_e('列数:', 'aksrt'); ?></label>
<input class="tiny-text" type="number" min="1" max="4" id="<?php echo $this->get_field_id('columns'); ?>" name="<?php echo $this->get_field_name('columns'); ?>" value="<?php echo (int) ($instance['columns'] ?? 2); ?>">
</p>
<hr>
<?php foreach ($cards as $i => $card) : ?>
<div style="border:1px solid #ddd;padding:6px;margin-bottom:6px;border-radius:4px;">
<p style="margin:0 0 4px;"><input class="widefat" type="text" name="<?php echo $this->get_field_name("cards[{$i}][title]"); ?>" value="<?php echo esc_attr($card['title']); ?>" placeholder="<?php esc_attr_e('标题', 'aksrt'); ?>"></p>
<p style="margin:0 0 4px;"><input class="widefat" type="text" name="<?php echo $this->get_field_name("cards[{$i}][icon]"); ?>" value="<?php echo esc_attr($card['icon']); ?>" placeholder="<?php esc_attr_e('图标类名 (如 fas fa-star)', 'aksrt'); ?>"></p>
<p style="margin:0 0 4px;"><input class="widefat" type="text" name="<?php echo $this->get_field_name("cards[{$i}][description]"); ?>" value="<?php echo esc_attr($card['description']); ?>" placeholder="<?php esc_attr_e('描述(可选)', 'aksrt'); ?>"></p>
<p style="margin:0;"><input class="widefat" type="url" name="<?php echo $this->get_field_name("cards[{$i}][link]"); ?>" value="<?php echo esc_attr($card['link']); ?>" placeholder="<?php esc_attr_e('链接(可选)', 'aksrt'); ?>"></p>
</div>
<?php endforeach;
}
public function update($new_instance, $old_instance): array {
$cards = [];
if (isset($new_instance['cards']) && is_array($new_instance['cards'])) {
foreach ($new_instance['cards'] as $card) {
if (!is_array($card)) continue;
$cards[] = [
'title' => sanitize_text_field($card['title'] ?? ''),
'icon' => sanitize_text_field($card['icon'] ?? ''),
'link' => esc_url_raw($card['link'] ?? ''),
'description' => sanitize_text_field($card['description'] ?? ''),
];
}
}
return [
'title' => sanitize_text_field($new_instance['title'] ?? ''),
'columns' => max(1, min(4, (int) ($new_instance['columns'] ?? 2))),
'cards' => $cards,
];
}
}
// ============================================================
// 6. 按钮组小工具
// ============================================================
class AKSRT_Buttons_Widget extends WP_Widget {
public function __construct() {
parent::__construct('aksrt_buttons', esc_html__('AKSRT 按钮组', 'aksrt'), [
'description' => esc_html__('显示一组自定义按钮', 'aksrt'),
]);
}
public function widget($args, $instance): void {
echo $args['before_widget'];
$title = apply_filters('widget_title', $instance['title'] ?? '', $instance, $this->id_base);
$buttons = isset($instance['buttons']) && is_array($instance['buttons']) ? $instance['buttons'] : [];
$layout = sanitize_key($instance['layout'] ?? 'vertical');
if ($title) echo $args['before_title'] . esc_html($title) . $args['after_title'];
if (!empty($buttons)) : ?>
<div class="widget-buttons widget-buttons--<?php echo esc_attr($layout); ?>">
<?php foreach ($buttons as $btn) :
$btn_text = sanitize_text_field($btn['text'] ?? '');
$btn_url = esc_url($btn['url'] ?? '');
$btn_style = sanitize_key($btn['style'] ?? 'primary');
$btn_icon = sanitize_text_field($btn['icon'] ?? '');
$btn_target = !empty($btn['new_window']) ? '_blank' : '_self';
if ($btn_text === '' || $btn_url === '') continue;
?>
<a href="<?php echo $btn_url; ?>" class="widget-buttons__btn widget-buttons__btn--<?php echo esc_attr($btn_style); ?>" target="<?php echo esc_attr($btn_target); ?>" rel="noopener">
<?php if ($btn_icon) : ?><i class="<?php echo esc_attr($btn_icon); ?>" aria-hidden="true"></i> <?php endif; ?>
<?php echo esc_html($btn_text); ?>
</a>
<?php endforeach; ?>
</div>
<?php endif;
echo $args['after_widget'];
}
public function form($instance): void {
$buttons = isset($instance['buttons']) && is_array($instance['buttons']) ? $instance['buttons'] : [];
while (count($buttons) < 3) {
$buttons[] = ['text' => '', 'url' => '', 'style' => 'primary', 'icon' => '', 'new_window' => false];
}
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('标题(可选):', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title'] ?? ''); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('layout'); ?>"><?php esc_html_e('布局:', 'aksrt'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>" name="<?php echo $this->get_field_name('layout'); ?>">
<option value="vertical" <?php selected($instance['layout'] ?? '', 'vertical'); ?>><?php esc_html_e('垂直', 'aksrt'); ?></option>
<option value="horizontal" <?php selected($instance['layout'] ?? '', 'horizontal'); ?>><?php esc_html_e('水平', 'aksrt'); ?></option>
</select>
</p>
<hr>
<?php foreach ($buttons as $i => $btn) : ?>
<div style="border:1px solid #ddd;padding:6px;margin-bottom:6px;border-radius:4px;">
<p style="margin:0 0 4px;">
<input class="widefat" type="text" name="<?php echo $this->get_field_name("buttons[{$i}][text]"); ?>" value="<?php echo esc_attr($btn['text']); ?>" placeholder="<?php esc_attr_e('按钮文字', 'aksrt'); ?>">
</p>
<p style="margin:0 0 4px;">
<input class="widefat" type="url" name="<?php echo $this->get_field_name("buttons[{$i}][url]"); ?>" value="<?php echo esc_attr($btn['url']); ?>" placeholder="<?php esc_attr_e('链接地址', 'aksrt'); ?>">
</p>
<p style="margin:0 0 4px;">
<select class="widefat" name="<?php echo $this->get_field_name("buttons[{$i}][style]"); ?>">
<option value="primary" <?php selected($btn['style'] ?? '', 'primary'); ?>><?php esc_html_e('主要', 'aksrt'); ?></option>
<option value="secondary" <?php selected($btn['style'] ?? '', 'secondary'); ?>><?php esc_html_e('次要', 'aksrt'); ?></option>
<option value="outline" <?php selected($btn['style'] ?? '', 'outline'); ?>><?php esc_html_e('线框', 'aksrt'); ?></option>
<option value="text" <?php selected($btn['style'] ?? '', 'text'); ?>><?php esc_html_e('文字', 'aksrt'); ?></option>
</select>
</p>
<p style="margin:0 0 4px;">
<input class="widefat" type="text" name="<?php echo $this->get_field_name("buttons[{$i}][icon]"); ?>" value="<?php echo esc_attr($btn['icon'] ?? ''); ?>" placeholder="<?php esc_attr_e('图标(可选)', 'aksrt'); ?>">
</p>
<p style="margin:0;">
<label><input type="checkbox" name="<?php echo $this->get_field_name("buttons[{$i}][new_window]"); ?>" value="1" <?php checked(!empty($btn['new_window'])); ?>> <?php esc_html_e('新窗口打开', 'aksrt'); ?></label>
</p>
</div>
<?php endforeach;
}
public function update($new_instance, $old_instance): array {
$buttons = [];
if (isset($new_instance['buttons']) && is_array($new_instance['buttons'])) {
$allowed_styles = ['primary', 'secondary', 'outline', 'text'];
foreach ($new_instance['buttons'] as $btn) {
if (!is_array($btn)) continue;
$style = sanitize_key($btn['style'] ?? 'primary');
if (!in_array($style, $allowed_styles, true)) $style = 'primary';
$buttons[] = [
'text' => sanitize_text_field($btn['text'] ?? ''),
'url' => esc_url_raw($btn['url'] ?? ''),
'style' => $style,
'icon' => sanitize_text_field($btn['icon'] ?? ''),
'new_window' => !empty($btn['new_window']),
];
}
}
return [
'title' => sanitize_text_field($new_instance['title'] ?? ''),
'layout' => in_array($new_instance['layout'] ?? '', ['vertical', 'horizontal'], true) ? $new_instance['layout'] : 'vertical',
'buttons' => $buttons,
];
}
}
// ============================================================
// 7. 自定义 HTML / 间距小工具
// ============================================================
class AKSRT_Custom_HTML_Gap_Widget extends WP_Widget {
public function __construct() {
parent::__construct('aksrt_custom_html_gap', esc_html__('AKSRT 自定义HTML/间距', 'aksrt'), [
'description' => esc_html__('插入自定义 HTML 或间距', 'aksrt'),
]);
}
public function widget($args, $instance): void {
$mode = sanitize_key($instance['mode'] ?? 'html');
if ($mode === 'gap') {
$height = max(0, min(200, (int) ($instance['gap_height'] ?? 20)));
echo '<div class="widget-custom-gap" style="height:' . (int) $height . 'px;" aria-hidden="true"></div>';
return;
}
echo $args['before_widget'];
$title = apply_filters('widget_title', $instance['title'] ?? '', $instance, $this->id_base);
if ($title) echo $args['before_title'] . esc_html($title) . $args['after_title'];
echo '<div class="widget-custom-html">' . wp_kses_post($instance['content'] ?? '') . '</div>';
echo $args['after_widget'];
}
public function form($instance): void {
$mode = sanitize_key($instance['mode'] ?? 'html');
?>
<p>
<label for="<?php echo $this->get_field_id('mode'); ?>"><?php esc_html_e('模式:', 'aksrt'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('mode'); ?>" name="<?php echo $this->get_field_name('mode'); ?>">
<option value="html" <?php selected($mode, 'html'); ?>><?php esc_html_e('自定义 HTML', 'aksrt'); ?></option>
<option value="gap" <?php selected($mode, 'gap'); ?>><?php esc_html_e('间距', 'aksrt'); ?></option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('标题(仅 HTML 模式,可选):', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title'] ?? ''); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('content'); ?>"><?php esc_html_e('HTML 内容:', 'aksrt'); ?></label>
<textarea class="widefat" rows="6" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>"><?php echo esc_textarea($instance['content'] ?? ''); ?></textarea>
</p>
<p>
<label for="<?php echo $this->get_field_id('gap_height'); ?>"><?php esc_html_e('间距高度(px,仅间距模式):', 'aksrt'); ?></label>
<input class="tiny-text" type="number" min="0" max="200" id="<?php echo $this->get_field_id('gap_height'); ?>" name="<?php echo $this->get_field_name('gap_height'); ?>" value="<?php echo (int) ($instance['gap_height'] ?? 20); ?>">
</p>
<?php
}
public function update($new_instance, $old_instance): array {
return [
'mode' => in_array($new_instance['mode'] ?? '', ['html', 'gap'], true) ? $new_instance['mode'] : 'html',
'title' => sanitize_text_field($new_instance['title'] ?? ''),
'content' => wp_kses_post($new_instance['content'] ?? ''),
'gap_height' => max(0, min(200, (int) ($new_instance['gap_height'] ?? 20))),
];
}
}
+8 -8
View File
@@ -85,8 +85,8 @@ add_action('init', 'aksrt_register_topics_taxonomy');
function aksrt_register_forum_cpt() {
// Respect bbs_s switch — skip CPT registration when forum is disabled.
// Admin context always registers so the backend settings page works.
if (!is_admin() && class_exists('AKSRT_Settings')) {
$forum = AKSRT_Settings::get_forum_settings();
if (!is_admin() && class_exists('\AKSRT\Settings\Settings')) {
$forum = \AKSRT\Settings\Settings::get_forum_settings();
if (empty($forum['enabled'])) {
return;
}
@@ -97,8 +97,8 @@ function aksrt_register_forum_cpt() {
$topic_slug = 'topic';
$forum_enabled = true;
$forum_settings = [];
if (class_exists('AKSRT_Settings')) {
$forum_settings = AKSRT_Settings::get_forum_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$forum_settings = \AKSRT\Settings\Settings::get_forum_settings();
$plate_slug = !empty($forum_settings['other']['plate_slug']) ? $forum_settings['other']['plate_slug'] : 'board';
$topic_slug = !empty($forum_settings['other']['posts_slug']) ? $forum_settings['other']['posts_slug'] : 'topic';
$forum_enabled = !empty($forum_settings['enabled']);
@@ -202,8 +202,8 @@ add_action('init', 'aksrt_register_forum_cpt');
// ============================================================
function aksrt_register_forum_plate_cpt() {
if (!is_admin() && class_exists('AKSRT_Settings')) {
$forum = AKSRT_Settings::get_forum_settings();
if (!is_admin() && class_exists('\AKSRT\Settings\Settings')) {
$forum = \AKSRT\Settings\Settings::get_forum_settings();
if (empty($forum['enabled'])) {
return;
}
@@ -212,8 +212,8 @@ function aksrt_register_forum_plate_cpt() {
$plate_slug = 'board';
$forum_enabled = true;
$forum = [];
if (class_exists('AKSRT_Settings')) {
$forum = AKSRT_Settings::get_forum_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$forum = \AKSRT\Settings\Settings::get_forum_settings();
$plate_slug = !empty($forum['other']['plate_slug']) ? $forum['other']['plate_slug'] : 'board';
$forum_enabled = !empty($forum['enabled']);
}
+19 -19
View File
@@ -19,8 +19,8 @@ add_action('admin_menu', function () {
// ============================================================
function aksrt_get_gravatar_source() {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::avatar_source();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::avatar_source();
}
$source = aksrt_get_setting('avatar_source', 'cn.cravatar.com');
@@ -87,8 +87,8 @@ add_action('phpmailer_init', function ($phpmailer) {
if (!empty($mail['from_address'])) {
$from_name = isset($mail['from_name']) ? $mail['from_name'] : '';
// mail_showname 覆盖 from_name
if (class_exists('AKSRT_Settings')) {
$branding = AKSRT_Settings::get_mail_branding();
if (class_exists('\AKSRT\Settings\Settings')) {
$branding = \AKSRT\Settings\Settings::get_mail_branding();
if ($branding['showname'] !== '') {
$from_name = $branding['showname'];
}
@@ -99,8 +99,8 @@ add_action('phpmailer_init', function ($phpmailer) {
$phpmailer->FromName = $mail['from_name'];
}
// mail_showname 全局覆盖 FromName
if (class_exists('AKSRT_Settings')) {
$branding = AKSRT_Settings::get_mail_branding();
if (class_exists('\AKSRT\Settings\Settings')) {
$branding = \AKSRT\Settings\Settings::get_mail_branding();
if ($branding['showname'] !== '') {
$phpmailer->FromName = $branding['showname'];
}
@@ -109,8 +109,8 @@ add_action('phpmailer_init', function ($phpmailer) {
// mail_title_prefix:为所有邮件主题添加前缀
add_filter('wp_mail', function ($atts) {
if (!class_exists('AKSRT_Settings') || empty($atts['subject'])) return $atts;
$branding = AKSRT_Settings::get_mail_branding();
if (!class_exists('\AKSRT\Settings\Settings') || empty($atts['subject'])) return $atts;
$branding = \AKSRT\Settings\Settings::get_mail_branding();
if ($branding['title_prefix'] !== '' && strpos($atts['subject'], $branding['title_prefix']) !== 0) {
$atts['subject'] = $branding['title_prefix'] . ' ' . $atts['subject'];
}
@@ -198,8 +198,8 @@ function aksrt_save_category_meta(int $term_id) {
delete_term_meta($term_id, 'aksrt_category_recommend_desc');
}
if (class_exists('AKSRT_Settings')) {
AKSRT_Settings::flush_category_recommend_cache();
if (class_exists('\AKSRT\Settings\Settings')) {
\AKSRT\Settings\Settings::flush_category_recommend_cache();
}
}
@@ -301,11 +301,11 @@ add_action('pre_get_posts', function ($query) {
$orderby = isset($_GET['orderby']) ? sanitize_key((string) $_GET['orderby']) : 'date';
if ($orderby === 'downloads') {
$query->set('meta_key', AKSRT_Domain_Model::RESOURCE_DOWNLOAD_COUNT_KEY);
$query->set('meta_key', \AKSRT\Core\DomainModel::RESOURCE_DOWNLOAD_COUNT_KEY);
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
} elseif ($orderby === 'views') {
$query->set('meta_key', AKSRT_Domain_Model::RESOURCE_VIEW_COUNT_KEY);
$query->set('meta_key', \AKSRT\Core\DomainModel::RESOURCE_VIEW_COUNT_KEY);
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
}
@@ -317,7 +317,7 @@ add_action('pre_get_posts', function ($query) {
$meta_query = [
'relation' => 'AND',
[
'key' => AKSRT_Domain_Model::RESOURCE_MARKER_KEY,
'key' => \AKSRT\Core\DomainModel::RESOURCE_MARKER_KEY,
'value' => '1',
'compare' => '=',
],
@@ -327,19 +327,19 @@ add_action('pre_get_posts', function ($query) {
$meta_query[] = [
'relation' => 'OR',
[
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
'value' => 0,
'compare' => '=',
'type' => 'NUMERIC',
],
[
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
'compare' => 'NOT EXISTS',
],
];
} elseif ($price_filter === 'paid') {
$meta_query[] = [
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
'value' => 0,
'compare' => '>',
'type' => 'NUMERIC',
@@ -349,21 +349,21 @@ add_action('pre_get_posts', function ($query) {
if ($price_min !== null || $price_max !== null) {
if ($price_min !== null && $price_max !== null) {
$meta_query[] = [
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
'value' => [$price_min, $price_max],
'compare' => 'BETWEEN',
'type' => 'NUMERIC',
];
} elseif ($price_min !== null) {
$meta_query[] = [
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
'value' => $price_min,
'compare' => '>=',
'type' => 'NUMERIC',
];
} else {
$meta_query[] = [
'key' => AKSRT_Domain_Model::PAY_PRICE_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_PRICE_KEY,
'value' => $price_max,
'compare' => '<=',
'type' => 'NUMERIC',
+4 -4
View File
@@ -16,8 +16,8 @@ if (!function_exists('aksrt_archive_get_list_style_settings')) :
* @return array<string,mixed>
*/
function aksrt_archive_get_list_style_settings(): array {
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_post_list_style_settings()
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_post_list_style_settings()
: [];
return [
@@ -184,8 +184,8 @@ if (!function_exists('aksrt_resolve_post_list_render_config')) :
];
// Multi-thumb from global thumb settings + category allowlist.
if (class_exists('AKSRT_Settings')) {
$thumb_settings = AKSRT_Settings::get_post_thumb_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$thumb_settings = \AKSRT\Settings\Settings::get_post_thumb_settings();
if (!empty($thumb_settings['multi_enabled'])) {
$config['multi_thumb_enabled'] = true;
$config['multi_thumb_limit'] = (int) ($thumb_settings['multi_count'] ?? 4);
+3 -3
View File
@@ -18,8 +18,8 @@ if (!function_exists('aksrt_get_auth_agreement_view')) {
$required = true;
$page_ref = '';
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'user_agreement_settings')) {
$cfg = AKSRT_Settings::user_agreement_settings();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'user_agreement_settings')) {
$cfg = \AKSRT\Settings\Settings::user_agreement_settings();
$enabled = !empty($cfg['enabled']);
$required = !empty($cfg['required']);
$page_ref = (string) ($cfg['page'] ?? '');
@@ -61,7 +61,7 @@ if (!function_exists('aksrt_get_auth_sign_logo_html')) {
* Shared logo block for full-page sign shell.
*/
function aksrt_get_auth_sign_logo_html(): string {
$logo_url = class_exists('AKSRT_Settings') ? AKSRT_Settings::user_logo_url() : '';
$logo_url = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::user_logo_url() : '';
$home = home_url('/');
$name = get_bloginfo('name');
if ($logo_url) {
+10 -10
View File
@@ -21,8 +21,8 @@ if (!function_exists('aksrt_comments_template_query_args')) :
? sanitize_key((string) wp_unslash($_GET['aksrt_comment_order']))
: '';
if ($order === '') {
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_comment_display_settings()
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_comment_display_settings()
: [];
$order = (($settings['order'] ?? 'desc') === 'asc') ? 'oldest' : 'newest';
}
@@ -70,8 +70,8 @@ if (!function_exists('aksrt_comments_build_context')) :
* @return array<string,mixed>
*/
function aksrt_comments_build_context(): array {
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_comment_display_settings()
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_comment_display_settings()
: [
'order' => 'desc',
'nested_depth' => 3,
@@ -115,8 +115,8 @@ if (!function_exists('aksrt_comments_build_context')) :
'submit_text' => (string) ($settings['submit_text'] ?? __('提交评论', 'aksrt')),
'title_text' => (string) ($settings['title'] ?? __('评论', 'aksrt')),
'corderby_enabled' => !empty($settings['corderby']),
'oauth_providers' => class_exists('AKSRT_OAuth')
? AKSRT_OAuth::get_instance()->get_auth_providers_data()
'oauth_providers' => class_exists('\AKSRT\Auth\OAuth')
? \AKSRT\Auth\OAuth::get_instance()->get_auth_providers_data()
: [],
];
}
@@ -150,8 +150,8 @@ if (!function_exists('aksrt_comments_normalize_order')) :
function aksrt_comments_normalize_order(string $order = ''): string {
$order = sanitize_key($order);
if (!in_array($order, ['newest', 'oldest', 'hottest'], true)) {
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_comment_display_settings()
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_comment_display_settings()
: [];
$order = (($settings['order'] ?? 'desc') === 'asc') ? 'oldest' : 'newest';
}
@@ -169,8 +169,8 @@ if (!function_exists('aksrt_comments_query_for_post')) :
* @return array{comments:array<int,\WP_Comment>,total:int,max_pages:int,page:int,order:string,author_only:bool,settings:array}
*/
function aksrt_comments_query_for_post(int $post_id, array $args = []): array {
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_comment_display_settings()
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_comment_display_settings()
: [];
$order = aksrt_comments_normalize_order((string) ($args['order'] ?? ''));
$author_only = !empty($args['author_only']);
+4 -4
View File
@@ -15,11 +15,11 @@ if (!function_exists('aksrt_coupon_usage_exists')) {
* Whether a coupon_usage row already exists for this order.
*/
function aksrt_coupon_usage_exists(string $order_number): bool {
if ($order_number === '' || !class_exists('AKSRT_DB_Migrator')) {
if ($order_number === '' || !class_exists('\AKSRT\Core\DBMigrator')) {
return false;
}
global $wpdb;
$table = AKSRT_DB_Migrator::table('coupon_usage');
$table = \AKSRT\Core\DBMigrator::table('coupon_usage');
if ($table === '') {
return false;
}
@@ -39,7 +39,7 @@ if (!function_exists('aksrt_burn_order_coupon')) {
* @return bool True when a burn was attempted (or already burned).
*/
function aksrt_burn_order_coupon(string $order_number, array $meta, int $buyer_id = 0): bool {
if ($order_number === '' || !class_exists('AKSRT_Coupon')) {
if ($order_number === '' || !class_exists('\AKSRT\Payment\Coupon')) {
return false;
}
if (aksrt_coupon_usage_exists($order_number)) {
@@ -53,7 +53,7 @@ if (!function_exists('aksrt_burn_order_coupon')) {
return false;
}
$coupon_api = AKSRT_Coupon::get_instance();
$coupon_api = \AKSRT\Payment\Coupon::get_instance();
$coupon_api->use_coupon($coupon_code);
// Prefer snapshot id: post-increment validate may fail on usage_limit edge.
+4 -4
View File
@@ -22,8 +22,8 @@ if (!function_exists('aksrt_user_credits')) {
function aksrt_user_credits(int $user_id = 0): int {
if ($user_id <= 0) $user_id = get_current_user_id();
if ($user_id <= 0) return 0;
if (!class_exists('AKSRT_Credits')) return 0;
return AKSRT_Credits::balance($user_id);
if (!class_exists('\AKSRT\Credits\Credits')) return 0;
return \AKSRT\Credits\Credits::balance($user_id);
}
}
@@ -69,9 +69,9 @@ if (!function_exists('aksrt_credits_label')) {
if (isset($map[$reason])) {
return $map[$reason];
}
if (str_starts_with($reason, 'free_') && class_exists('AKSRT_Points_Free')) {
if (str_starts_with($reason, 'free_') && class_exists('\AKSRT\Credits\PointsFree')) {
$key = substr($reason, 5);
$cat = AKSRT_Points_Free::catalog();
$cat = \AKSRT\Credits\PointsFree::catalog();
if (isset($cat[$key][0])) {
return (string) $cat[$key][0];
}
+1 -444
View File
@@ -1,451 +1,8 @@
<?php
/**
* AKSRT Domain Model Registry
*
* Canonical keys, defaults, and state machines shared by helpers and services.
* Domain model class: AKSRT\Core\DomainModel (Composer PSR-4).
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
class AKSRT_Domain_Model {
public const POST_META_KEY = 'aksrt_post_meta';
public const TERM_META_KEY = 'aksrt_term_meta';
public const PAY_META_KEY = '_aksrt_pay';
public const PAY_TYPE_KEY = '_aksrt_pay_type';
public const PAY_PRICE_KEY = '_aksrt_pay_price';
public const RESOURCE_MARKER_KEY = '_aksrt_is_resource';
public const RESOURCE_DOWNLOAD_COUNT_KEY = '_aksrt_res_download_count';
public const RESOURCE_VIEW_COUNT_KEY = '_aksrt_res_view_count';
public const RESOURCE_SALES_VOLUME_KEY = '_aksrt_sales_volume';
public const POST_VIEW_COUNT_KEY = 'aksrt_post_views';
public const ORDER_MIGRATED_OPTION = 'aksrt_order_migrated_to_table';
public const RESOURCE_PAY_META_MIGRATED = 'aksrt_resource_pay_meta_migrated';
public const ORDER_PRODUCT_RESOURCE = 'resource';
public const ORDER_PRODUCT_VIP = 'vip';
public const ORDER_PRODUCT_RECHARGE = 'recharge';
/** Cash purchase of points (zibll order_type=9). */
public const ORDER_PRODUCT_POINTS_BUY = 'points_buy';
public const ORDER_PRODUCT_SHOP = 'shop_product';
/** Paid plate follow (zibll order_type=11). product_id = plate post ID. */
public const ORDER_PRODUCT_PLATE_FOLLOW = 'plate_follow';
public const PAY_TYPE_NO = 'no';
public const PAY_TYPE_READING = 'reading';
public const PAY_TYPE_DOWNLOAD = 'download';
public const PAY_TYPE_GALLERY = 'gallery';
public const PAY_TYPE_VIDEO = 'video';
public const PAY_TYPE_VIP = 'vip';
public const ORDER_STATUS_CREATED = 'created';
public const ORDER_STATUS_PENDING = 'pending';
public const ORDER_STATUS_PAID = 'paid';
public const ORDER_STATUS_DELIVERED = 'delivered';
public const ORDER_STATUS_COMPLETED = 'completed';
public const ORDER_STATUS_CANCELLED = 'cancelled';
public const ORDER_STATUS_EXPIRED = 'expired';
public const ORDER_STATUS_REFUNDING = 'refunding';
public const ORDER_STATUS_REFUNDED = 'refunded';
public const ORDER_STATUS_PENDING_REVIEW = 'pending_review';
public const SHIPPING_STATUS_PENDING = 0;
public const SHIPPING_STATUS_SHIPPED = 1;
public const SHIPPING_STATUS_COMPLETED = 2;
/**
* @return array<string, mixed>
*/
public static function default_post_meta(): array {
return [
'cover_images' => '',
'custom_excerpt' => '',
'layout_override' => '',
'header_image_mode' => '',
'show_toc' => '',
'show_reading_progress' => '',
'enable_lightbox' => '',
'show_related' => '',
'related_count' => 0,
'enable_like' => '',
'enable_favorite' => '',
'enable_share' => '',
'enable_print' => '',
'enable_pdf' => '',
'copyright_text' => '',
'is_featured' => false,
// §3.8 文章扩展字段
'thumbnail_url' => '',
'featured_slide' => '',
'featured_video' => '',
// Episode list: [ ['url' => string, 'title' => string], ... ]
'featured_video_episode' => [],
'subtitle' => '',
'views' => 0,
'likes' => 0,
'maxheight' => 0,
];
}
/**
* @return array<string, mixed>
*/
public static function default_term_meta(): array {
return [
'cover_url' => '',
'description' => '',
'layout_mode' => '',
'show_sidebar' => '',
'show_header' => true,
'show_featured' => false,
];
}
/**
* @return array<string, mixed>
*/
public static function default_pay_meta(): array {
return [
'pay_type' => self::PAY_TYPE_NO,
'pay_modo' => '0', // '0' cash | 'points' credits (Zibll)
'price' => 0.0,
'points_price' => 0,
'original_price' => 0.0,
'vip1_price' => 0.0,
'vip2_price' => 0.0,
'vip1_points' => 0,
'vip2_points' => 0,
'pay_limit' => 0, // 0 all | 1 VIP1+ | 2 VIP2 only (Zibll)
'version' => '',
'size' => '',
'license' => '',
'compat' => '',
'demo_url' => '',
'video_url' => '',
'downloads' => [],
'attributes' => [],
'gallery' => [],
'require_login' => false,
'require_captcha' => false,
// §3.8 电商增强字段
'virtual_sales' => 0,
'stock' => -1,
'card_keys' => [],
'purchase_limit' => 0,
'free_preview' => '',
'show_sales' => true,
// Zibll: free daily quota overbuy price (cash or points by pay_modo).
'download_limit_over_price' => 0.0,
// Content cashier: coupon + buyer-facing 推广折扣 (zibll posts_zibpay).
'coupon_s' => false,
'coupon_desc' => '',
'pay_rebate_discount' => 0.0,
];
}
/**
* @return array<string, string>
*/
public static function pay_type_labels(): array {
return [
self::PAY_TYPE_NO => '不付费',
self::PAY_TYPE_READING => '付费阅读',
self::PAY_TYPE_DOWNLOAD => '付费下载',
self::PAY_TYPE_GALLERY => '付费图库',
self::PAY_TYPE_VIDEO => '付费视频',
self::PAY_TYPE_VIP => 'VIP 专属',
];
}
public static function normalize_pay_type(string $pay_type): string {
$pay_type = sanitize_key($pay_type);
return array_key_exists($pay_type, self::pay_type_labels()) ? $pay_type : self::PAY_TYPE_NO;
}
public static function is_resource_pay_type(string $pay_type): bool {
return self::normalize_pay_type($pay_type) === self::PAY_TYPE_DOWNLOAD;
}
/**
* @param mixed $value
* @return array<int, array<string, string>>
*/
public static function sanitize_downloads($value): array {
if (!is_array($value)) {
return [];
}
$allowed_types = ['direct', 'net_disk', 'external'];
$downloads = [];
foreach ($value as $row) {
if (!is_array($row)) {
continue;
}
$url = isset($row['url']) ? esc_url_raw((string) $row['url']) : '';
if ($url === '') {
continue;
}
$type = isset($row['type']) && in_array($row['type'], $allowed_types, true)
? (string) $row['type']
: 'direct';
$extract_code = '';
foreach ([
'extract_code',
'extractCode',
'extract',
'extract_key',
'extraction_code',
'extractionCode',
'code',
'password',
'pwd',
'pan_code',
'panCode',
'pan_password',
'panPassword',
'access_code',
'accessCode',
] as $extract_key) {
if (isset($row[$extract_key]) && !is_array($row[$extract_key])) {
$candidate = trim((string) $row[$extract_key]);
if ($candidate !== '') {
$extract_code = sanitize_text_field($candidate);
break;
}
}
}
$downloads[] = [
'label' => isset($row['label']) ? sanitize_text_field((string) $row['label']) : '',
'url' => $url,
'type' => $type,
'extract_code' => $extract_code,
];
}
return array_values($downloads);
}
/**
* @param mixed $value
* @return array<int, array<string, string>>
*/
public static function sanitize_attributes($value): array {
if (!is_array($value)) {
return [];
}
$attributes = [];
foreach ($value as $row) {
if (!is_array($row)) {
continue;
}
$key = sanitize_text_field((string) ($row['key'] ?? ''));
$item_value = sanitize_text_field((string) ($row['value'] ?? ''));
if ($key === '' && $item_value === '') {
continue;
}
$attributes[] = [
'key' => $key,
'value' => $item_value,
];
}
return array_values($attributes);
}
/**
* @param mixed $value
* @return string[]
*/
public static function sanitize_gallery($value): array {
if (!is_array($value)) {
return [];
}
$gallery = [];
foreach ($value as $url) {
$url = esc_url_raw((string) $url);
if ($url !== '') {
$gallery[] = $url;
}
}
return array_values(array_unique($gallery));
}
/**
* Sanitize card/key codes for auto-delivery.
* Each entry is a non-empty sanitized string (one code per line).
*/
public static function sanitize_card_keys($value): array {
if (!is_array($value)) {
return [];
}
$keys = [];
foreach ($value as $key) {
$key = sanitize_text_field((string) $key);
if ($key !== '') {
$keys[] = $key;
}
}
return $keys;
}
/**
* @param array<string, mixed> $raw
* @return array<string, mixed>
*/
public static function sanitize_pay_meta(array $raw): array {
$meta = self::default_pay_meta();
$meta['pay_type'] = self::normalize_pay_type((string) ($raw['pay_type'] ?? $meta['pay_type']));
$pay_modo = sanitize_key((string) ($raw['pay_modo'] ?? '0'));
$meta['pay_modo'] = $pay_modo === 'points' ? 'points' : '0';
$meta['price'] = max(0, (float) ($raw['price'] ?? 0));
$meta['points_price'] = max(0, (int) ($raw['points_price'] ?? $raw['price'] ?? 0));
$meta['original_price'] = max(0, (float) ($raw['original_price'] ?? 0));
$meta['vip1_price'] = max(0, (float) ($raw['vip1_price'] ?? 0));
$meta['vip2_price'] = max(0, (float) ($raw['vip2_price'] ?? 0));
$meta['vip1_points'] = max(0, (int) ($raw['vip1_points'] ?? $raw['vip1_price'] ?? 0));
$meta['vip2_points'] = max(0, (int) ($raw['vip2_points'] ?? $raw['vip2_price'] ?? 0));
$pay_limit = (int) ($raw['pay_limit'] ?? 0);
$meta['pay_limit'] = in_array($pay_limit, [0, 1, 2], true) ? $pay_limit : 0;
$meta['version'] = sanitize_text_field((string) ($raw['version'] ?? ''));
$meta['size'] = sanitize_text_field((string) ($raw['size'] ?? ''));
$meta['license'] = sanitize_text_field((string) ($raw['license'] ?? ''));
$meta['compat'] = sanitize_text_field((string) ($raw['compat'] ?? ''));
$meta['demo_url'] = esc_url_raw((string) ($raw['demo_url'] ?? ''));
$meta['video_url'] = esc_url_raw((string) ($raw['video_url'] ?? ''));
$meta['downloads'] = self::sanitize_downloads($raw['downloads'] ?? []);
$meta['attributes'] = self::sanitize_attributes($raw['attributes'] ?? []);
$meta['gallery'] = self::sanitize_gallery($raw['gallery'] ?? []);
$meta['require_login'] = !empty($raw['require_login']);
$meta['require_captcha'] = !empty($raw['require_captcha']);
// §3.8 电商增强字段
$meta['virtual_sales'] = max(0, (int) ($raw['virtual_sales'] ?? 0));
$meta['stock'] = (int) ($raw['stock'] ?? -1);
$meta['card_keys'] = self::sanitize_card_keys($raw['card_keys'] ?? []);
$meta['purchase_limit'] = max(0, (int) ($raw['purchase_limit'] ?? 0));
$meta['free_preview'] = wp_kses_post((string) ($raw['free_preview'] ?? ''));
$meta['show_sales'] = !isset($raw['show_sales']) || !empty($raw['show_sales']);
$meta['download_limit_over_price'] = max(0, (float) ($raw['download_limit_over_price'] ?? 0));
$meta['coupon_s'] = !empty($raw['coupon_s']);
$meta['coupon_desc'] = sanitize_textarea_field((string) ($raw['coupon_desc'] ?? ''));
$meta['pay_rebate_discount'] = max(0, (float) ($raw['pay_rebate_discount'] ?? 0));
return $meta;
}
/**
* @return array<string, string>
*/
public static function order_status_labels(): array {
return [
self::ORDER_STATUS_CREATED => __('已创建', 'aksrt'),
self::ORDER_STATUS_PENDING => __('待支付', 'aksrt'),
self::ORDER_STATUS_PAID => __('已支付', 'aksrt'),
self::ORDER_STATUS_DELIVERED => __('已发货', 'aksrt'),
self::ORDER_STATUS_COMPLETED => __('已完成', 'aksrt'),
self::ORDER_STATUS_CANCELLED => __('已取消', 'aksrt'),
self::ORDER_STATUS_EXPIRED => __('已过期', 'aksrt'),
self::ORDER_STATUS_REFUNDING => __('退款中', 'aksrt'),
self::ORDER_STATUS_REFUNDED => __('已退款', 'aksrt'),
self::ORDER_STATUS_PENDING_REVIEW => __('待评价', 'aksrt'),
];
}
/**
* @return array<string, string[]>
*/
public static function order_transitions(): array {
return [
self::ORDER_STATUS_CREATED => [
self::ORDER_STATUS_PENDING,
self::ORDER_STATUS_CANCELLED,
],
self::ORDER_STATUS_PENDING => [
self::ORDER_STATUS_PAID,
self::ORDER_STATUS_CANCELLED,
self::ORDER_STATUS_EXPIRED,
],
self::ORDER_STATUS_PAID => [
self::ORDER_STATUS_DELIVERED,
self::ORDER_STATUS_COMPLETED,
self::ORDER_STATUS_REFUNDING,
],
self::ORDER_STATUS_DELIVERED => [
self::ORDER_STATUS_COMPLETED,
self::ORDER_STATUS_PENDING_REVIEW,
self::ORDER_STATUS_REFUNDING,
],
self::ORDER_STATUS_COMPLETED => [
self::ORDER_STATUS_PENDING_REVIEW,
self::ORDER_STATUS_REFUNDING,
],
self::ORDER_STATUS_CANCELLED => [],
self::ORDER_STATUS_EXPIRED => [
self::ORDER_STATUS_PENDING,
],
self::ORDER_STATUS_REFUNDING => [
self::ORDER_STATUS_REFUNDED,
self::ORDER_STATUS_PAID,
],
self::ORDER_STATUS_REFUNDED => [],
self::ORDER_STATUS_PENDING_REVIEW => [
self::ORDER_STATUS_COMPLETED,
self::ORDER_STATUS_REFUNDING,
],
];
}
public static function normalize_order_status(string $status, string $default = self::ORDER_STATUS_PENDING): string {
$status = sanitize_key($status);
return array_key_exists($status, self::order_status_labels()) ? $status : $default;
}
public static function can_transition_order_status(string $from, string $to): bool {
$from = self::normalize_order_status($from, self::ORDER_STATUS_CREATED);
$to = self::normalize_order_status($to);
$transitions = self::order_transitions();
return isset($transitions[$from]) && in_array($to, $transitions[$from], true);
}
/**
* @return string[]
*/
public static function paid_order_statuses(): array {
return [
self::ORDER_STATUS_PAID,
self::ORDER_STATUS_DELIVERED,
self::ORDER_STATUS_COMPLETED,
];
}
public static function is_paid_order_status(string $status): bool {
return in_array(self::normalize_order_status($status), self::paid_order_statuses(), true);
}
/**
* @return string[]
*/
public static function vip_active_order_statuses(): array {
return self::paid_order_statuses();
}
}
+8 -8
View File
@@ -162,8 +162,8 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
if (!($post instanceof WP_Post)) {
return [];
}
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_post_page_settings()
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_post_page_settings()
: [
'toc_enabled' => true,
'toc_depth' => 3,
@@ -233,7 +233,7 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) :
}
// Keep related_type as source alias for older callers.
$settings['related_type'] = (string) $settings['related_source'];
$meta = class_exists('AKSRT_Post_Meta_Box') ? AKSRT_Post_Meta_Box::get_meta($post->ID) : [];
$meta = class_exists('\AKSRT\Core\PostMetaBox') ? \AKSRT\Core\PostMetaBox::get_meta($post->ID) : [];
// show_toc new route: '' follow | '1' on | '0' off
if (array_key_exists('show_toc', $meta) && $meta['show_toc'] !== '' && $meta['show_toc'] !== null) {
$settings['toc_enabled'] = (string) $meta['show_toc'] === '1';
@@ -854,15 +854,15 @@ if (!function_exists('aksrt_comment_action_permissions')) :
if (function_exists('aksrt_user_can')) {
return aksrt_user_can($cap, $uid, $ctx);
}
if (class_exists('AKSRT_Settings_Capabilities')) {
return AKSRT_Settings_Capabilities::user_can($cap, $uid, $ctx);
if (class_exists('\AKSRT\Settings\Capabilities')) {
return \AKSRT\Settings\Capabilities::user_can($cap, $uid, $ctx);
}
return false;
};
$edit_window = 10;
if (class_exists('AKSRT_Settings')) {
$display = AKSRT_Settings::get_comment_display_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$display = \AKSRT\Settings\Settings::get_comment_display_settings();
$edit_window = (int) ($display['edit_window'] ?? 10);
}
$within_window = $edit_window > 0
@@ -1049,7 +1049,7 @@ if (!function_exists('aksrt_comment_callback')) :
* Canonical comment list item renderer.
*
* This is the single contract used by first-page rendering (comments.php),
* AJAX pagination (AKSRT_Admin::ajax_load_more_comments) and the post-submit
* AJAX pagination (\AKSRT\Admin\Admin::ajax_load_more_comments) and the post-submit
* list reload (main.js reloadCommentList(), which refetches the rendered
* page). Emits a stable `data-comment-id` plus reply, like, management
* (edit/delete/moderate) and pin controls gated through
+47 -47
View File
@@ -56,20 +56,20 @@ if (!function_exists('aksrt_homepage_get_tab_terms')) {
* @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')
? AKSRT_Settings::homepage_tab_limit()
$limit = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_tab_limit()
: 4;
if (!class_exists('AKSRT_Settings')) {
if (!class_exists('\AKSRT\Settings\Settings')) {
return [];
}
$structured_tabs = AKSRT_Settings::homepage_tabs();
$structured_tabs = \AKSRT\Settings\Settings::homepage_tabs();
if (empty($structured_tabs)) {
return [];
}
$excluded_cat_ids = array_flip(AKSRT_Settings::home_exclude_category_ids());
$excluded_cat_ids = array_flip(\AKSRT\Settings\Settings::home_exclude_category_ids());
$configs = [];
foreach ($structured_tabs as $tab) {
@@ -119,8 +119,8 @@ if (!function_exists('aksrt_homepage_get_tab_posts_per_page')) {
* Per-tab homepage post count.
*/
function aksrt_homepage_get_tab_posts_per_page(): int {
if (class_exists('AKSRT_Settings')) {
$count = AKSRT_Settings::homepage_tab_posts_per_page();
if (class_exists('\AKSRT\Settings\Settings')) {
$count = \AKSRT\Settings\Settings::homepage_tab_posts_per_page();
if ($count > 0) {
return max(1, min(20, $count));
}
@@ -135,8 +135,8 @@ if (!function_exists('aksrt_homepage_get_default_view_mode')) {
* Default homepage view mode.
*/
function aksrt_homepage_get_default_view_mode(): string {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::homepage_default_view();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::homepage_default_view();
}
return 'list';
@@ -148,8 +148,8 @@ if (!function_exists('aksrt_homepage_sticky_tabs_enabled')) {
* Whether homepage tabs should stick below the primary nav.
*/
function aksrt_homepage_sticky_tabs_enabled(): bool {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::homepage_sticky_tabs_enabled();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::homepage_sticky_tabs_enabled();
}
return true;
@@ -161,8 +161,8 @@ if (!function_exists('aksrt_homepage_module_hero_enabled')) {
* Whether the fixed homepage should render the built-in hero section.
*/
function aksrt_homepage_module_hero_enabled(): bool {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::homepage_module_hero_enabled();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::homepage_module_hero_enabled();
}
return true;
@@ -174,8 +174,8 @@ 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')) {
return AKSRT_Settings::homepage_module_banner_enabled();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::homepage_module_banner_enabled();
}
return true;
@@ -187,11 +187,11 @@ if (!function_exists('aksrt_homepage_get_sort_mode')) {
* Current homepage main-stream sort mode.
*/
function aksrt_homepage_get_sort_mode(): string {
$allowed = class_exists('AKSRT_Settings')
? AKSRT_Settings::homepage_allowed_sorts()
$allowed = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
$default_sort = class_exists('AKSRT_Settings')
? AKSRT_Settings::homepage_default_sort()
$default_sort = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_default_sort()
: 'date';
$override_sort = get_query_var('aksrt_homepage_sort_override');
$sort = is_string($override_sort) && $override_sort !== ''
@@ -209,16 +209,16 @@ if (!function_exists('aksrt_homepage_get_sort_items')) {
* @return array<string,string>
*/
function aksrt_homepage_get_sort_items(): array {
$all_labels = class_exists('AKSRT_Settings')
? AKSRT_Settings::homepage_sort_labels()
$all_labels = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_sort_labels()
: [
'modified' => '更新', 'date' => '发布', 'views' => '浏览',
'likes' => '点赞', 'comments' => '评论', 'favorites' => '收藏',
'downloads' => '下载', 'rand' => '随机',
];
$enabled_keys = class_exists('AKSRT_Settings')
? AKSRT_Settings::home_list_sort_options()
$enabled_keys = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::home_list_sort_options()
: array_keys($all_labels);
$items = [];
@@ -302,8 +302,8 @@ if (!function_exists('aksrt_homepage_apply_named_sort_args')) {
* Apply a specific named sort to query args (used by per-tab orderby).
*/
function aksrt_homepage_apply_named_sort_args(array $args, string $sort_mode): array {
$allowed = class_exists('AKSRT_Settings')
? AKSRT_Settings::homepage_allowed_sorts()
$allowed = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
if (!in_array($sort_mode, $allowed, true)) {
@@ -324,21 +324,21 @@ if (!function_exists('aksrt_homepage_render_sortbar')) {
* Render the main-stream sort bar.
*/
function aksrt_homepage_render_sortbar(): void {
if (class_exists('AKSRT_Settings') && !AKSRT_Settings::home_list_sort_enabled()) {
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::home_list_sort_enabled()) {
return;
}
$current = aksrt_homepage_get_sort_mode();
$sort_ajax_enabled = class_exists('AKSRT_Settings')
? AKSRT_Settings::homepage_sort_ajax_enabled()
$sort_ajax_enabled = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_sort_ajax_enabled()
: true;
$is_dropdown = class_exists('AKSRT_Settings')
? AKSRT_Settings::home_list_sort_dropdown()
$is_dropdown = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::home_list_sort_dropdown()
: false;
$base_url = remove_query_arg('home_sort', get_pagenum_link(aksrt_homepage_get_current_page()));
$sort_items = aksrt_homepage_get_sort_items();
$all_labels = class_exists('AKSRT_Settings')
? AKSRT_Settings::homepage_sort_labels()
$all_labels = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_sort_labels()
: $sort_items;
?>
<div class="aksrt-homepage__sortbar" data-sort-ajax="<?php echo $sort_ajax_enabled ? 'true' : 'false'; ?>" aria-label="<?php esc_attr_e('Homepage Sort', 'aksrt'); ?>">
@@ -415,15 +415,15 @@ if (!function_exists('aksrt_homepage_get_latest_query')) {
'no_found_rows' => false,
];
$exclude_ids = class_exists('AKSRT_Settings')
? AKSRT_Settings::home_exclude_post_ids()
$exclude_ids = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::home_exclude_post_ids()
: [];
if (!empty($exclude_ids)) {
$query_args['post__not_in'] = $exclude_ids;
}
$exclude_cat_ids = class_exists('AKSRT_Settings')
? AKSRT_Settings::home_exclude_category_ids()
$exclude_cat_ids = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::home_exclude_category_ids()
: [];
if (!empty($exclude_cat_ids)) {
$query_args['category__not_in'] = $exclude_cat_ids;
@@ -456,8 +456,8 @@ if (!function_exists('aksrt_homepage_get_tab_query')) {
$query_args = [
'post_type' => aksrt_homepage_get_post_types(),
'post_status' => 'publish',
'posts_per_page' => class_exists('AKSRT_Settings')
? AKSRT_Settings::homepage_tab_posts_per_page()
'posts_per_page' => class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_tab_posts_per_page()
: 6,
'ignore_sticky_posts' => true,
'orderby' => 'date',
@@ -472,8 +472,8 @@ if (!function_exists('aksrt_homepage_get_tab_query')) {
],
];
$exclude_ids = class_exists('AKSRT_Settings')
? AKSRT_Settings::home_exclude_post_ids()
$exclude_ids = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::home_exclude_post_ids()
: [];
if (!empty($exclude_ids)) {
$query_args['post__not_in'] = $exclude_ids;
@@ -616,8 +616,8 @@ if (!function_exists('aksrt_homepage_render_pagination')) {
$query_page = (int) $query->get('paged');
$current_page = min(max(1, $query_page > 0 ? $query_page : aksrt_homepage_get_current_page()), $max_pages);
$pagination_mode = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_post_pagination_mode()
$pagination_mode = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_post_pagination_mode()
: 'numbered';
if ($pagination_mode === 'numbered') {
@@ -951,8 +951,8 @@ if (!function_exists('aksrt_header_slide_is_show')) {
return false;
}
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_header_components_settings()
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_header_components_settings()
: [];
$show_on = isset($settings['show_on_pages']) ? (array) $settings['show_on_pages'] : [];
$allowed = array_values(array_intersect(
@@ -1013,9 +1013,9 @@ if (!function_exists('aksrt_homepage_render_layout')) {
$latest_contract = aksrt_homepage_get_latest_panel_contract();
$has_sidebar = aksrt_homepage_has_sidebar();
$banner_on = $show_tabs && aksrt_homepage_module_banner_enabled();
$main_list_enabled = !class_exists('AKSRT_Settings') || AKSRT_Settings::home_posts_list_enabled();
$list_title = class_exists('AKSRT_Settings')
? AKSRT_Settings::home_list_title()
$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()
: __('最新发布', 'aksrt');
// Fluid zones live outside <main>, once only (removed from header.php).
+5 -5
View File
@@ -15,8 +15,8 @@ if (!function_exists('aksrt_get_user_identity_signals')) {
if ($user_id <= 0) {
return [];
}
if (class_exists('AKSRT_User_Home')) {
$signals = AKSRT_User_Home::get_instance()->get_profile_signals($user_id);
if (class_exists('\AKSRT\User\Home')) {
$signals = \AKSRT\User\Home::get_instance()->get_profile_signals($user_id);
return is_array($signals) ? array_values($signals) : [];
}
return [];
@@ -217,13 +217,13 @@ if (!function_exists('aksrt_is_blog_comment_hot')) {
return true;
}
$threshold = 10;
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_comment_display_settings')) {
$display = AKSRT_Settings::get_comment_display_settings();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_comment_display_settings')) {
$display = \AKSRT\Settings\Settings::get_comment_display_settings();
if (isset($display['hot_threshold'])) {
$threshold = max(1, (int) $display['hot_threshold']);
}
}
$all = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_all() : [];
$all = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
if (isset($all['comment_hot_threshold'])) {
$threshold = max(1, (int) $all['comment_hot_threshold']);
}
+68 -68
View File
@@ -17,22 +17,22 @@ defined('ABSPATH') || exit;
// ============================================================
if (!defined('AKSRT_PAY_TYPE_NO')) {
define('AKSRT_PAY_TYPE_NO', AKSRT_Domain_Model::PAY_TYPE_NO);
define('AKSRT_PAY_TYPE_NO', \AKSRT\Core\DomainModel::PAY_TYPE_NO);
}
if (!defined('AKSRT_PAY_TYPE_READING')) {
define('AKSRT_PAY_TYPE_READING', AKSRT_Domain_Model::PAY_TYPE_READING);
define('AKSRT_PAY_TYPE_READING', \AKSRT\Core\DomainModel::PAY_TYPE_READING);
}
if (!defined('AKSRT_PAY_TYPE_DOWNLOAD')) {
define('AKSRT_PAY_TYPE_DOWNLOAD', AKSRT_Domain_Model::PAY_TYPE_DOWNLOAD);
define('AKSRT_PAY_TYPE_DOWNLOAD', \AKSRT\Core\DomainModel::PAY_TYPE_DOWNLOAD);
}
if (!defined('AKSRT_PAY_TYPE_GALLERY')) {
define('AKSRT_PAY_TYPE_GALLERY', AKSRT_Domain_Model::PAY_TYPE_GALLERY);
define('AKSRT_PAY_TYPE_GALLERY', \AKSRT\Core\DomainModel::PAY_TYPE_GALLERY);
}
if (!defined('AKSRT_PAY_TYPE_VIDEO')) {
define('AKSRT_PAY_TYPE_VIDEO', AKSRT_Domain_Model::PAY_TYPE_VIDEO);
define('AKSRT_PAY_TYPE_VIDEO', \AKSRT\Core\DomainModel::PAY_TYPE_VIDEO);
}
if (!defined('AKSRT_PAY_TYPE_VIP')) {
define('AKSRT_PAY_TYPE_VIP', AKSRT_Domain_Model::PAY_TYPE_VIP);
define('AKSRT_PAY_TYPE_VIP', \AKSRT\Core\DomainModel::PAY_TYPE_VIP);
}
/**
@@ -62,7 +62,7 @@ if (!function_exists('aksrt_is_vip_exempt')) {
}
function aksrt_get_pay_types(): array {
return AKSRT_Domain_Model::pay_type_labels();
return \AKSRT\Core\DomainModel::pay_type_labels();
return [
AKSRT_PAY_TYPE_NO => __('不付费', 'aksrt'),
@@ -85,14 +85,14 @@ if (!function_exists('aksrt_list_cash_payment_methods')) {
? ['balance', 'alipay', 'wechatpay', 'paypal', 'stripe']
: ['alipay', 'wechatpay', 'paypal', 'stripe'];
if (!class_exists('AKSRT_Payment_Gateway')) {
if (!class_exists('\AKSRT\Payment\Gateway')) {
return $logged_in
? [['id' => 'balance', 'name' => __('站内余额', 'aksrt')]]
: [['id' => 'alipay', 'name' => __('支付宝', 'aksrt')]];
}
$methods = [];
$gw = AKSRT_Payment_Gateway::get_instance();
$gw = \AKSRT\Payment\Gateway::get_instance();
foreach ($ids as $id) {
$g = $gw->get_gateway($id);
if (!$g) {
@@ -126,9 +126,9 @@ if (!function_exists('aksrt_get_pay_meta')) {
$p = get_post($post);
if (!($p instanceof WP_Post)) return aksrt_default_pay_meta();
$meta = get_post_meta($p->ID, AKSRT_Domain_Model::PAY_META_KEY, true);
$meta = get_post_meta($p->ID, \AKSRT\Core\DomainModel::PAY_META_KEY, true);
if (is_array($meta) && isset($meta['pay_type'])) {
return wp_parse_args(AKSRT_Domain_Model::sanitize_pay_meta($meta), aksrt_default_pay_meta());
return wp_parse_args(\AKSRT\Core\DomainModel::sanitize_pay_meta($meta), aksrt_default_pay_meta());
}
return aksrt_default_pay_meta();
@@ -137,7 +137,7 @@ if (!function_exists('aksrt_get_pay_meta')) {
if (!function_exists('aksrt_default_pay_meta')) {
function aksrt_default_pay_meta(): array {
return AKSRT_Domain_Model::default_pay_meta();
return \AKSRT\Core\DomainModel::default_pay_meta();
return [
'pay_type' => AKSRT_PAY_TYPE_NO,
@@ -190,10 +190,10 @@ if (!function_exists('aksrt_get_download_box_meta')) {
}
$pay_meta = aksrt_get_pay_meta($p);
$download_count = (int) get_post_meta($p->ID, AKSRT_Domain_Model::RESOURCE_DOWNLOAD_COUNT_KEY, true);
$view_count = (int) get_post_meta($p->ID, AKSRT_Domain_Model::POST_VIEW_COUNT_KEY, true);
$download_count = (int) get_post_meta($p->ID, \AKSRT\Core\DomainModel::RESOURCE_DOWNLOAD_COUNT_KEY, true);
$view_count = (int) get_post_meta($p->ID, \AKSRT\Core\DomainModel::POST_VIEW_COUNT_KEY, true);
$virtual_sales = max(0, (int) ($pay_meta['virtual_sales'] ?? 0));
$sales_volume = (int) get_post_meta($p->ID, AKSRT_Domain_Model::RESOURCE_SALES_VOLUME_KEY, true);
$sales_volume = (int) get_post_meta($p->ID, \AKSRT\Core\DomainModel::RESOURCE_SALES_VOLUME_KEY, true);
$show_sales = !isset($pay_meta['show_sales']) || !empty($pay_meta['show_sales']);
$pay_modo = (($pay_meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0';
$pay_limit = (int) ($pay_meta['pay_limit'] ?? 0);
@@ -242,11 +242,11 @@ if (!function_exists('aksrt_get_download_box_meta')) {
if (!function_exists('aksrt_get_user_content_paid_order')) {
function aksrt_get_user_content_paid_order(int $post_id, int $user_id = 0): ?array {
$uid = $user_id > 0 ? $user_id : get_current_user_id();
if ($uid <= 0 || $post_id <= 0 || !class_exists('AKSRT_Order_Repository')) {
if ($uid <= 0 || $post_id <= 0 || !class_exists('\AKSRT\Payment\OrderRepository')) {
return null;
}
$orders = AKSRT_Order_Repository::get_instance()->get_user_orders($uid, [
'product_type' => AKSRT_Domain_Model::ORDER_PRODUCT_RESOURCE,
$orders = \AKSRT\Payment\OrderRepository::get_instance()->get_user_orders($uid, [
'product_type' => \AKSRT\Core\DomainModel::ORDER_PRODUCT_RESOURCE,
'status' => '',
'limit' => 20,
'offset' => 0,
@@ -256,7 +256,7 @@ if (!function_exists('aksrt_get_user_content_paid_order')) {
continue;
}
$status = (string) ($order['status'] ?? '');
if (AKSRT_Domain_Model::is_paid_order_status($status)) {
if (\AKSRT\Core\DomainModel::is_paid_order_status($status)) {
return $order;
}
}
@@ -272,7 +272,7 @@ if (!function_exists('aksrt_bump_content_sales_volume')) {
if ($post_id <= 0 || $delta === 0) {
return 0;
}
$key = AKSRT_Domain_Model::RESOURCE_SALES_VOLUME_KEY;
$key = \AKSRT\Core\DomainModel::RESOURCE_SALES_VOLUME_KEY;
$cur = (int) get_post_meta($post_id, $key, true);
$next = max(0, $cur + $delta);
update_post_meta($post_id, $key, $next);
@@ -298,8 +298,8 @@ if (!function_exists('aksrt_allow_guest_content_pay')) {
if ($pay_modo === 'points') {
return false; // points require login
}
$order = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_order_settings() : [];
$paid = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_paid_content_settings() : [];
$order = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_order_settings() : [];
$paid = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_paid_content_settings() : [];
$allow = !empty($order['no_logged_in']) || !empty($paid['no_logged_in']);
/**
* Filter guest content pay allow.
@@ -317,8 +317,8 @@ if (!function_exists('aksrt_allow_guest_content_pay')) {
if (!function_exists('aksrt_guest_pay_cookie_days')) {
function aksrt_guest_pay_cookie_days(int $post_id = 0): int {
$days = 15;
if (class_exists('AKSRT_Settings')) {
$order = AKSRT_Settings::get_order_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$order = \AKSRT\Settings\Settings::get_order_settings();
$days = max(1, min(31, (int) ($order['cookie_day'] ?? 15)));
}
/**
@@ -368,8 +368,8 @@ if (!function_exists('aksrt_content_order_cookie_token_key')) {
*/
if (!function_exists('aksrt_allow_guest_forum_pay')) {
function aksrt_allow_guest_forum_pay($post = null): bool {
$order = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_order_settings() : [];
$paid = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_paid_content_settings() : [];
$order = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_order_settings() : [];
$paid = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_paid_content_settings() : [];
$allow = !empty($order['no_logged_in']) || !empty($paid['no_logged_in']);
/**
* @param bool $allow
@@ -429,14 +429,14 @@ if (!function_exists('aksrt_get_guest_paid_order')) {
if ($product_id <= 0 || empty($_COOKIE['aksrt_pay_' . $product_id])) {
return null;
}
if (!class_exists('AKSRT_Order_Repository') || !class_exists('AKSRT_Domain_Model')) {
if (!class_exists('\AKSRT\Payment\OrderRepository') || !class_exists('\AKSRT\Core\DomainModel')) {
return null;
}
$order_number = sanitize_text_field((string) $_COOKIE['aksrt_pay_' . $product_id]);
if ($order_number === '') {
return null;
}
$order = AKSRT_Order_Repository::get_instance()->get($order_number);
$order = \AKSRT\Payment\OrderRepository::get_instance()->get($order_number);
if (!$order) {
return null;
}
@@ -453,7 +453,7 @@ if (!function_exists('aksrt_get_guest_paid_order')) {
return null;
}
$status = (string) ($order['status'] ?? '');
if (!AKSRT_Domain_Model::is_paid_order_status($status)) {
if (!\AKSRT\Core\DomainModel::is_paid_order_status($status)) {
return null;
}
@@ -484,8 +484,8 @@ if (!function_exists('aksrt_get_guest_paid_order')) {
*/
if (!function_exists('aksrt_get_guest_content_paid_order')) {
function aksrt_get_guest_content_paid_order(int $post_id): ?array {
$type = class_exists('AKSRT_Domain_Model')
? AKSRT_Domain_Model::ORDER_PRODUCT_RESOURCE
$type = class_exists('\AKSRT\Core\DomainModel')
? \AKSRT\Core\DomainModel::ORDER_PRODUCT_RESOURCE
: 'resource';
return aksrt_get_guest_paid_order($post_id, $type);
}
@@ -505,8 +505,8 @@ if (!function_exists('aksrt_guest_has_paid_access')) {
*/
if (!function_exists('aksrt_guest_has_plate_follow_access')) {
function aksrt_guest_has_plate_follow_access(int $plate_id): bool {
$type = class_exists('AKSRT_Domain_Model')
? AKSRT_Domain_Model::ORDER_PRODUCT_PLATE_FOLLOW
$type = class_exists('\AKSRT\Core\DomainModel')
? \AKSRT\Core\DomainModel::ORDER_PRODUCT_PLATE_FOLLOW
: 'plate_follow';
return null !== aksrt_get_guest_paid_order($plate_id, $type);
}
@@ -524,7 +524,7 @@ if (!function_exists('aksrt_guest_has_plate_follow_access')) {
*/
if (!function_exists('aksrt_get_user_pay_price')) {
function aksrt_get_user_pay_price($post = null, int $user_id = 0): array {
$meta = function_exists('aksrt_get_pay_meta') ? aksrt_get_pay_meta($post) : AKSRT_Domain_Model::default_pay_meta();
$meta = function_exists('aksrt_get_pay_meta') ? aksrt_get_pay_meta($post) : \AKSRT\Core\DomainModel::default_pay_meta();
$pay_modo = (($meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0';
$pay_limit = (int) ($meta['pay_limit'] ?? 0);
if (!in_array($pay_limit, [0, 1, 2], true)) {
@@ -540,10 +540,10 @@ if (!function_exists('aksrt_get_user_pay_price')) {
$vip_level = max($vip_level, 2);
}
$currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
$currency = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt');
$cash_symbol = '¥';
if (class_exists('AKSRT_Settings')) {
$paid = AKSRT_Settings::get_paid_content_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$paid = \AKSRT\Settings\Settings::get_paid_content_settings();
$cash_symbol = (string) ($paid['display']['currency_symbol'] ?? '¥');
}
@@ -604,12 +604,12 @@ if (!function_exists('aksrt_is_content_coupon_allowed')) {
if (!empty($meta['coupon_s'])) {
return true;
}
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_content_coupon_settings')) {
$cfg = AKSRT_Settings::get_content_coupon_settings();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_content_coupon_settings')) {
$cfg = \AKSRT\Settings\Settings::get_content_coupon_settings();
return !empty($cfg['enabled']);
}
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_paid_content_settings')) {
$paid = AKSRT_Settings::get_paid_content_settings();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_paid_content_settings')) {
$paid = \AKSRT\Settings\Settings::get_paid_content_settings();
return !empty($paid['coupon_post_s']);
}
return false;
@@ -627,17 +627,17 @@ if (!function_exists('aksrt_get_post_rebate_discount')) {
if ($fixed <= 0) {
return 0.0;
}
if (!class_exists('AKSRT_Settings') || !method_exists('AKSRT_Settings', 'get_payment_affiliate_settings')) {
if (!class_exists('\AKSRT\Settings\Settings') || !method_exists('\AKSRT\Settings\Settings', 'get_payment_affiliate_settings')) {
return 0.0;
}
$aff = AKSRT_Settings::get_payment_affiliate_settings();
$aff = \AKSRT\Settings\Settings::get_payment_affiliate_settings();
if (empty($aff['enabled'])) {
return 0.0;
}
$uid = $user_id > 0 ? $user_id : (function_exists('get_current_user_id') ? (int) get_current_user_id() : 0);
$referrer_id = 0;
if (class_exists('AKSRT_Invite') && method_exists(AKSRT_Invite::get_instance(), 'get_referrer')) {
$referrer_id = (int) AKSRT_Invite::get_instance()->get_referrer($uid);
if (class_exists('\AKSRT\Credits\Invite') && method_exists(\AKSRT\Credits\Invite::get_instance(), 'get_referrer')) {
$referrer_id = (int) \AKSRT\Credits\Invite::get_instance()->get_referrer($uid);
}
if ($referrer_id <= 0) {
return 0.0;
@@ -673,10 +673,10 @@ if (!function_exists('aksrt_is_allow_points_deduction')) {
function aksrt_is_allow_points_deduction(string $context = 'content'): bool {
// Mirror zibll hard-off first.
$allowed = false;
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_all')) {
$all = AKSRT_Settings::get_all();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_all')) {
$all = \AKSRT\Settings\Settings::get_all();
// Even if switch on, default remains false like zibll until product enables it.
if (!empty($all['points_deduction_s']) && class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'credits_enabled') && AKSRT_Settings::credits_enabled()) {
if (!empty($all['points_deduction_s']) && class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'credits_enabled') && \AKSRT\Settings\Settings::credits_enabled()) {
$allowed = false; // still disabled at runtime
}
}
@@ -744,9 +744,9 @@ if (!function_exists('aksrt_has_paid_access')) {
$p = get_post($post);
if (!($p instanceof WP_Post)) return true;
// 单一真相:付费访问由 AKSRT_Content_Visibility(基于订单 + VIP)裁决。
if (class_exists('AKSRT_Content_Visibility')) {
$state = AKSRT_Content_Visibility::get_post_access_state($p, $user_id);
// 单一真相:付费访问由 \AKSRT\Content\Visibility(基于订单 + VIP)裁决。
if (class_exists('\AKSRT\Content\Visibility')) {
$state = \AKSRT\Content\Visibility::get_post_access_state($p, $user_id);
return !empty($state['has_paid_access']);
}
@@ -769,8 +769,8 @@ if (!function_exists('aksrt_can_access_content')) {
$p = get_post($post);
if (!($p instanceof WP_Post)) return true;
if (class_exists('AKSRT_Content_Visibility')) {
return AKSRT_Content_Visibility::can_view_paid_content($p);
if (class_exists('\AKSRT\Content\Visibility')) {
return \AKSRT\Content\Visibility::can_view_paid_content($p);
}
$pay_type = aksrt_get_pay_meta($p)['pay_type'];
@@ -789,7 +789,7 @@ if (!function_exists('aksrt_can_download')) {
/**
* 下载授权门禁 —— 单一合同。
*
* 实际判定交给 AKSRT_Content_Visibility::can_download_resource()。
* 实际判定交给 \AKSRT\Content\Visibility::can_download_resource()。
* 不再使用 download_credit 做按次扣积分门禁。
*
* @param int|WP_Post|null $post
@@ -797,8 +797,8 @@ if (!function_exists('aksrt_can_download')) {
* @return true|WP_Error
*/
function aksrt_can_download($post = null, int $user_id = 0) {
if (class_exists('AKSRT_Content_Visibility')) {
return AKSRT_Content_Visibility::can_download_resource($post, $user_id);
if (class_exists('\AKSRT\Content\Visibility')) {
return \AKSRT\Content\Visibility::can_download_resource($post, $user_id);
}
$p = get_post($post);
@@ -811,8 +811,8 @@ if (!function_exists('aksrt_can_download')) {
return new WP_Error('aksrt_not_downloadable', __('该内容不是可下载资源。', 'aksrt'));
}
$paid_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_paid_content_settings()
$paid_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_paid_content_settings()
: ['download_login' => true];
$uid = $user_id > 0 ? $user_id : get_current_user_id();
@@ -885,10 +885,10 @@ if (!function_exists('aksrt_get_single_download_page_url')) {
*/
if (!function_exists('aksrt_is_download_alone_page_enabled')) {
function aksrt_is_download_alone_page_enabled(): bool {
if (!class_exists('AKSRT_Settings')) {
if (!class_exists('\AKSRT\Settings\Settings')) {
return false;
}
$paid = AKSRT_Settings::get_paid_content_settings();
$paid = \AKSRT\Settings\Settings::get_paid_content_settings();
return !empty($paid['down_alone_page']) || !empty($paid['download']['alone_page']);
}
}
@@ -910,10 +910,10 @@ if (!function_exists('aksrt_get_pay_price_label')) {
? (int) ($priced['pay_limit'] ?? 0)
: (int) ($meta['pay_limit'] ?? 0);
$vip_level = is_array($priced) ? (int) ($priced['vip_level'] ?? 0) : 0;
$currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
$currency = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt');
$cash_symbol = '¥';
if (class_exists('AKSRT_Settings')) {
$paid = AKSRT_Settings::get_paid_content_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$paid = \AKSRT\Settings\Settings::get_paid_content_settings();
$cash_symbol = (string) ($paid['display']['currency_symbol'] ?? '¥');
}
@@ -1007,8 +1007,8 @@ if (!function_exists('aksrt_get_pay_type_badge')) {
if (!function_exists('aksrt_get_pay_service_html')) {
function aksrt_get_pay_service_html(string $class = 'resource-download-box__guarantee'): string {
$service = [];
if (class_exists('AKSRT_Settings')) {
$order = AKSRT_Settings::get_order_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$order = \AKSRT\Settings\Settings::get_order_settings();
$service = is_array($order['service'] ?? null) ? $order['service'] : [];
}
@@ -1141,10 +1141,10 @@ if (!function_exists('aksrt_get_paywall_html')) {
$pay_modo = is_array($priced) ? ((($priced['modo'] ?? '0') === 'points') ? 'points' : '0') : ((($meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0');
$price = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($meta['price'] ?? 0);
$vip_level = is_array($priced) ? (int) ($priced['vip_level'] ?? 0) : 0;
$currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
$currency = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt');
$cash_symbol = '¥';
if (class_exists('AKSRT_Settings')) {
$paid = AKSRT_Settings::get_paid_content_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$paid = \AKSRT\Settings\Settings::get_paid_content_settings();
$cash_symbol = (string) ($paid['display']['currency_symbol'] ?? '¥');
}
$price_text = $pay_modo === 'points'
+9 -9
View File
@@ -206,11 +206,11 @@ if (!function_exists('aksrt_renderer_curated_images')) {
$images = [];
$limit = max(1, min(8, $limit));
if (!class_exists('AKSRT_Post_Meta_Box')) {
if (!class_exists('\AKSRT\Core\PostMetaBox')) {
return [];
}
$cover_images = (string) AKSRT_Post_Meta_Box::get_meta_value($post_id, 'cover_images', '');
$cover_images = (string) \AKSRT\Core\PostMetaBox::get_meta_value($post_id, 'cover_images', '');
if ($cover_images === '') {
return [];
}
@@ -267,8 +267,8 @@ if (!function_exists('aksrt_renderer_random_fallback_image')) {
get_template_directory_uri() . '/assets/img/placeholder.svg',
];
if (class_exists('AKSRT_Settings')) {
$thumb = AKSRT_Settings::get_post_thumb_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$thumb = \AKSRT\Settings\Settings::get_post_thumb_settings();
$spare = $thumb['spare_images'] ?? [];
if (is_array($spare) && !empty($spare)) {
foreach ($spare as $url) {
@@ -327,7 +327,7 @@ if (!function_exists('aksrt_renderer_resolve_images')) {
$has_real = true;
}
$thumb_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_thumb_settings() : [];
$thumb_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_thumb_settings() : [];
$allow_fallback = !empty($thumb_settings['rand_thumb']) || !empty($cfg['thumb_if_has']);
if ($primary === '' && $allow_fallback) {
$primary = aksrt_renderer_random_fallback_image($post_id);
@@ -349,8 +349,8 @@ if (!function_exists('aksrt_renderer_lazyload_config')) {
* @return array<string,mixed>
*/
function aksrt_renderer_lazyload_config(): array {
if (class_exists('AKSRT_Settings')) {
$lazy = AKSRT_Settings::get_lazyload_config();
if (class_exists('\AKSRT\Settings\Settings')) {
$lazy = \AKSRT\Settings\Settings::get_lazyload_config();
return [
'enabled' => !empty($lazy['enabled']) && !empty($lazy['posts_thumb_enabled']),
'placeholder_url' => (string) ($lazy['placeholder_url'] ?? ''),
@@ -411,8 +411,8 @@ if (!function_exists('aksrt_renderer_collect_post_data')) {
$categories = get_the_category($post_id) ?: [];
$tags = get_the_tags($post_id) ?: [];
$custom_excerpt = class_exists('AKSRT_Post_Meta_Box')
? (string) AKSRT_Post_Meta_Box::get_meta_value($post_id, 'custom_excerpt', '')
$custom_excerpt = class_exists('\AKSRT\Core\PostMetaBox')
? (string) \AKSRT\Core\PostMetaBox::get_meta_value($post_id, 'custom_excerpt', '')
: '';
$custom_subtitle = (string) get_post_meta($post_id, '_subtitle', true);
$excerpt_source = $custom_excerpt !== '' ? $custom_excerpt : (string) get_the_excerpt($post_id);
+22 -22
View File
@@ -30,11 +30,11 @@ if (!function_exists('aksrt_get_resource_meta')) {
$pay_meta = function_exists('aksrt_get_pay_meta')
? aksrt_get_pay_meta($p)
: AKSRT_Domain_Model::default_pay_meta();
$download_count = (int) get_post_meta($p->ID, AKSRT_Domain_Model::RESOURCE_DOWNLOAD_COUNT_KEY, true);
: \AKSRT\Core\DomainModel::default_pay_meta();
$download_count = (int) get_post_meta($p->ID, \AKSRT\Core\DomainModel::RESOURCE_DOWNLOAD_COUNT_KEY, true);
$legacy_download_count = (int) get_post_meta($p->ID, 'download_count', true);
$resource_view_count = (int) get_post_meta($p->ID, AKSRT_Domain_Model::RESOURCE_VIEW_COUNT_KEY, true);
$common_view_count = (int) get_post_meta($p->ID, AKSRT_Domain_Model::POST_VIEW_COUNT_KEY, true);
$resource_view_count = (int) get_post_meta($p->ID, \AKSRT\Core\DomainModel::RESOURCE_VIEW_COUNT_KEY, true);
$common_view_count = (int) get_post_meta($p->ID, \AKSRT\Core\DomainModel::POST_VIEW_COUNT_KEY, true);
// Normalize downloads extract_code aliases for legacy rows still stored on pay meta.
$downloads = array_values(is_array($pay_meta['downloads'] ?? null) ? $pay_meta['downloads'] : []);
@@ -76,7 +76,7 @@ if (!function_exists('aksrt_get_resource_meta')) {
'vip2_price' => (float) ($pay_meta['vip2_price'] ?? 0),
'vip1_points' => (int) ($pay_meta['vip1_points'] ?? 0),
'vip2_points' => (int) ($pay_meta['vip2_points'] ?? 0),
'pay_type' => (string) ($pay_meta['pay_type'] ?? AKSRT_Domain_Model::PAY_TYPE_DOWNLOAD),
'pay_type' => (string) ($pay_meta['pay_type'] ?? \AKSRT\Core\DomainModel::PAY_TYPE_DOWNLOAD),
'license' => (string) ($pay_meta['license'] ?? ''),
'compat' => (string) ($pay_meta['compat'] ?? ''),
'demo_url' => (string) ($pay_meta['demo_url'] ?? ''),
@@ -94,7 +94,7 @@ if (!function_exists('aksrt_get_resource_meta')) {
if (!function_exists('aksrt_default_resource_meta')) {
function aksrt_default_resource_meta(): array {
$meta = AKSRT_Domain_Model::default_pay_meta();
$meta = \AKSRT\Core\DomainModel::default_pay_meta();
return [
'version' => (string) ($meta['version'] ?? ''),
@@ -108,7 +108,7 @@ if (!function_exists('aksrt_default_resource_meta')) {
'vip2_price' => (float) ($meta['vip2_price'] ?? 0),
'vip1_points' => (int) ($meta['vip1_points'] ?? 0),
'vip2_points' => (int) ($meta['vip2_points'] ?? 0),
'pay_type' => AKSRT_Domain_Model::PAY_TYPE_DOWNLOAD,
'pay_type' => \AKSRT\Core\DomainModel::PAY_TYPE_DOWNLOAD,
'license' => (string) ($meta['license'] ?? ''),
'compat' => (string) ($meta['compat'] ?? ''),
'demo_url' => (string) ($meta['demo_url'] ?? ''),
@@ -216,7 +216,7 @@ if (!function_exists('aksrt_resource_card_badge_text')) {
}
if ($pay_modo === 'points') {
$currency = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
$currency = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt');
$amount = function_exists('aksrt_resource_price_amount')
? aksrt_resource_price_amount($price)
: (string) (int) $price;
@@ -224,8 +224,8 @@ if (!function_exists('aksrt_resource_card_badge_text')) {
}
$symbol = '¥';
if (class_exists('AKSRT_Settings')) {
$paid = AKSRT_Settings::get_paid_content_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$paid = \AKSRT\Settings\Settings::get_paid_content_settings();
$symbol = (string) ($paid['display']['currency_symbol'] ?? '¥');
}
$amount = function_exists('aksrt_format_price')
@@ -284,8 +284,8 @@ if (!function_exists('aksrt_resource_preview_images')) {
$limit = max(1, min(8, $limit));
$images = [];
if (class_exists('AKSRT_Post_Meta_Box')) {
$cover_images = (string) AKSRT_Post_Meta_Box::get_meta_value($p->ID, 'cover_images', '');
if (class_exists('\AKSRT\Core\PostMetaBox')) {
$cover_images = (string) \AKSRT\Core\PostMetaBox::get_meta_value($p->ID, 'cover_images', '');
if ($cover_images !== '') {
$cover_ids = array_filter(array_map('absint', preg_split('/[\s,]+/', $cover_images) ?: []));
foreach ($cover_ids as $attachment_id) {
@@ -363,11 +363,11 @@ if (!function_exists('aksrt_resource_meta_strip')) {
*/
if (!function_exists('aksrt_is_download_credit_exempt_user')) {
function aksrt_is_download_credit_exempt_user(int $user_id = 0): bool {
if ($user_id <= 0 || !class_exists('AKSRT_Settings')) {
if ($user_id <= 0 || !class_exists('\AKSRT\Settings\Settings')) {
return false;
}
$paid_settings = AKSRT_Settings::get_paid_content_settings();
$paid_settings = \AKSRT\Settings\Settings::get_paid_content_settings();
if (empty($paid_settings['vip_free_download']) || empty($paid_settings['vip_exempt_roles'])) {
return false;
}
@@ -385,7 +385,7 @@ if (!function_exists('aksrt_can_download')) {
/**
* 是否可下载。
*
* 单一合同:委托 AKSRT_Content_Visibility(收银台订单解锁 / VIP / 登录 / 日限额)。
* 单一合同:委托 \AKSRT\Content\Visibility(收银台订单解锁 / VIP / 登录 / 日限额)。
* 不再用 cms_features.download_credit 做「按次扣积分」门禁。
*
* @param int|WP_Post|null $post
@@ -393,8 +393,8 @@ if (!function_exists('aksrt_can_download')) {
* @return true|WP_Error
*/
function aksrt_can_download($post = null, int $user_id = 0) {
if (class_exists('AKSRT_Content_Visibility')) {
return AKSRT_Content_Visibility::can_download_resource($post, $user_id);
if (class_exists('\AKSRT\Content\Visibility')) {
return \AKSRT\Content\Visibility::can_download_resource($post, $user_id);
}
$p = get_post($post);
@@ -403,8 +403,8 @@ if (!function_exists('aksrt_can_download')) {
}
$uid = $user_id > 0 ? $user_id : get_current_user_id();
$paid_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_paid_content_settings()
$paid_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_paid_content_settings()
: ['download_login' => true];
if (!empty($paid_settings['download_login']) && $uid <= 0) {
@@ -432,10 +432,10 @@ if (!function_exists('aksrt_resource_download_cost')) {
$uid = function_exists('get_current_user_id') ? (int) get_current_user_id() : 0;
// Paid order → unlocked.
if ($p instanceof WP_Post && $uid > 0 && class_exists('AKSRT_Order')) {
if (AKSRT_Order::get_instance()->has_paid_access(
if ($p instanceof WP_Post && $uid > 0 && class_exists('\AKSRT\Payment\Order')) {
if (\AKSRT\Payment\Order::get_instance()->has_paid_access(
$uid,
AKSRT_Domain_Model::ORDER_PRODUCT_RESOURCE,
\AKSRT\Core\DomainModel::ORDER_PRODUCT_RESOURCE,
(int) $p->ID
)) {
return 0;
+6 -6
View File
@@ -11,10 +11,10 @@ defined('ABSPATH') || exit;
if (!function_exists('aksrt_rewards_enabled')) {
function aksrt_rewards_enabled(): bool {
if (!class_exists('AKSRT_Settings') || !method_exists('AKSRT_Settings', 'get_post_page_settings')) {
if (!class_exists('\AKSRT\Settings\Settings') || !method_exists('\AKSRT\Settings\Settings', 'get_post_page_settings')) {
return false;
}
$s = AKSRT_Settings::get_post_page_settings();
$s = \AKSRT\Settings\Settings::get_post_page_settings();
return !empty($s['rewards_enabled']) || !empty($s['post_rewards_s']);
}
}
@@ -54,8 +54,8 @@ if (!function_exists('aksrt_get_rewards_button')) {
return '';
}
$label = '赞赏';
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_post_page_settings')) {
$s = AKSRT_Settings::get_post_page_settings();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_post_page_settings')) {
$s = \AKSRT\Settings\Settings::get_post_page_settings();
$label = (string) ($s['rewards_btn_text'] ?? $s['rewards_text'] ?? $label);
if ($label === '') {
$label = '赞赏';
@@ -77,8 +77,8 @@ if (!function_exists('aksrt_render_rewards_modal_for_user')) {
$done[$user_id] = true;
$urls = aksrt_get_user_rewards_img_urls($user_id);
$label = '赞赏';
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_post_page_settings')) {
$s = AKSRT_Settings::get_post_page_settings();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_post_page_settings')) {
$s = \AKSRT\Settings\Settings::get_post_page_settings();
$label = (string) ($s['rewards_text'] ?? $label);
if ($label === '') {
$label = __('赞赏', 'aksrt');
+1 -331
View File
@@ -1,338 +1,8 @@
<?php
/**
* AKSRT Shortcodes Registry — 短代码统一注册入口
*
* Phase 9 收口:所有主题短代码集中在此注册,不再散落到
* `AKSRT_Content_Visibility` / `AKSRT_Templates` 等业务类的 init() 中。
* 业务渲染仍由各自类/模板实现,registry 只负责「注册 → 委派」。
*
* 详见 shortcode-registry.md。
* Shortcodes class: AKSRT\Core\Shortcodes (Composer PSR-4).
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (!class_exists('AKSRT_Shortcodes')) :
class AKSRT_Shortcodes {
private static $instance = null;
public static function get_instance(): self {
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
/**
* 注册全部短代码。在 `init` 上调用一次。
*/
public function register(): void {
// 隐藏内容(评论/登录/密码可见)→ AKSRT_Content_Visibility
add_shortcode('aksrt_hide', [$this, 'render_hide']);
// §3.8 用户友好短代码别名
add_shortcode('hide', [$this, 'render_hide_comment']);
add_shortcode('reply', [$this, 'render_reply']);
add_shortcode('vip', [$this, 'render_vip']);
add_shortcode('payshow', [$this, 'render_payshow']);
// Zibll-compatible hidecontent alias (type=payshow|reply|login|vip|password|…)
add_shortcode('hidecontent', [$this, 'render_hidecontent']);
add_shortcode('content', [$this, 'render_content_gate']);
// 文章归档 / 个人资料卡 → AKSRT_Templates 模板
add_shortcode('aksrt_archive', [$this, 'render_archive']);
add_shortcode('aksrt_profile', [$this, 'render_profile']);
// 文章列表(统一渲染器)
add_shortcode('aksrt_posts', [$this, 'render_posts']);
}
/**
* [aksrt_hide mode="comment|login|password"]...[/aksrt_hide]
*/
public function render_hide(array $atts, string $content = ''): string {
if (!class_exists('AKSRT_Content_Visibility')) {
return '';
}
return AKSRT_Content_Visibility::get_instance()->render_hide_shortcode($atts, $content);
}
/**
* [hide]...[/hide] — 评论后可见(默认 mode=comment)
*/
public function render_hide_comment(array $atts = [], string $content = ''): string {
$atts = shortcode_atts(['message' => ''], $atts, 'hide');
return $this->render_hide(['mode' => 'comment', 'message' => $atts['message']], $content);
}
/**
* [reply]...[/reply] — 回复(评论)后可见
*/
public function render_reply(array $atts = [], string $content = ''): string {
$atts = shortcode_atts(['message' => ''], $atts, 'reply');
$msg = $atts['message'] ?: __('回复本文后可查看隐藏内容', 'aksrt');
return $this->render_hide(['mode' => 'comment', 'message' => $msg], $content);
}
/**
* [vip]...[/vip] — VIP 用户可见
*/
public function render_vip(array $atts = [], string $content = ''): string {
$atts = shortcode_atts(['message' => ''], $atts, 'vip');
$uid = get_current_user_id();
$is_vip = $uid > 0 && function_exists('aksrt_is_vip') && aksrt_is_vip($uid);
if ($is_vip) {
return '<div class="aksrt-hidden-content aksrt-hidden-content--unlocked aksrt-hidden-content--vip">'
. do_shortcode($content) . '</div>';
}
$message = $atts['message'] ?: __('此内容仅 VIP 用户可见', 'aksrt');
$html = '<div class="aksrt-hidden-content aksrt-hidden-content--locked aksrt-hidden-content--vip">';
$html .= '<div class="aksrt-hidden-content__message">';
$html .= '<i class="fas fa-crown" aria-hidden="true"></i> ';
$html .= '<span>' . esc_html($message) . '</span>';
$html .= '</div>';
if ($uid <= 0) {
$html .= '<a href="' . esc_url(wp_login_url(get_permalink())) . '" class="aksrt-hidden-content__login-btn btn-primary btn-sm">';
$html .= esc_html__('登录后查看', 'aksrt') . '</a>';
}
$html .= '</div>';
return $html;
}
/**
* [payshow]...[/payshow] — 付费后可见(文章 content-pay 或论坛主题解锁)
*/
public function render_payshow(array $atts = [], string $content = ''): string {
$atts = shortcode_atts(['message' => ''], $atts, 'payshow');
$pid = get_the_ID();
$can_view = $this->viewer_can_see_paid_block($pid);
if ($can_view) {
return '<div class="aksrt-hidden-content aksrt-hidden-content--unlocked aksrt-hidden-content--payshow">'
. do_shortcode($content) . '</div>';
}
$message = $atts['message'] ?: __('此内容需付费后查看', 'aksrt');
$uid = get_current_user_id();
$html = '<div class="aksrt-hidden-content aksrt-hidden-content--locked aksrt-hidden-content--payshow">';
$html .= '<div class="aksrt-hidden-content__message">';
$html .= '<i class="fas fa-lock" aria-hidden="true"></i> ';
$html .= '<span>' . esc_html($message) . '</span>';
$html .= '</div>';
if ($uid <= 0) {
$html .= '<a href="' . esc_url(wp_login_url(get_permalink())) . '" class="aksrt-hidden-content__login-btn btn-primary btn-sm">';
$html .= esc_html__('登录后购买查看', 'aksrt') . '</a>';
}
$html .= '</div>';
return $html;
}
/**
* Zibll [hidecontent type="payshow|reply|login|…"]…[/hidecontent]
*/
public function render_hidecontent(array $atts = [], string $content = ''): string {
$atts = shortcode_atts([
'type' => 'payshow',
'message' => '',
'pass' => '',
], $atts, 'hidecontent');
$type = sanitize_key((string) $atts['type']);
$msg = (string) $atts['message'];
switch ($type) {
case 'reply':
case 'comment':
return $this->render_reply(['message' => $msg], $content);
case 'login':
case 'signin':
return $this->render_hide([
'mode' => 'login',
'message' => $msg !== '' ? $msg : __('登录后可查看隐藏内容', 'aksrt'),
], $content);
case 'password':
case 'pass':
return $this->render_hide([
'mode' => 'password',
'message' => $msg,
'pass' => (string) $atts['pass'],
], $content);
case 'vip':
return $this->render_vip(['message' => $msg], $content);
case 'payshow':
case 'pay':
case 'points':
default:
return $this->render_payshow(['message' => $msg], $content);
}
}
/**
* Whether current viewer may see a paid hide block on this post/topic.
*/
private function viewer_can_see_paid_block(int $pid): bool {
if ($pid <= 0) {
return false;
}
$post = get_post($pid);
if (!$post instanceof WP_Post) {
return false;
}
$uid = get_current_user_id();
if ($uid > 0 && ((int) $post->post_author === $uid || user_can($uid, 'manage_options'))) {
return true;
}
// Forum topics: paid/credits unlock list or orders.
if ($post->post_type === 'aksrt_forum_topic' && class_exists('AKSRT_Forum')) {
$forum = AKSRT_Forum::get_instance();
$visibility = sanitize_key((string) get_post_meta($pid, '_aksrt_visibility', true));
if ($visibility === 'public' || $visibility === '') {
return true;
}
if (method_exists($forum, 'has_user_unlocked_topic') && $forum->has_user_unlocked_topic($uid, $pid)) {
return true;
}
if (method_exists($forum, 'has_user_paid_topic') && $forum->has_user_paid_topic($uid, $pid)) {
return true;
}
// Free VIP price counts as paid for cash topics.
if ($visibility === 'pay' && method_exists($forum, 'resolve_topic_pay_price')) {
$price = $forum->resolve_topic_pay_price($pid, $uid);
if (!empty($price['is_free'])) {
return true;
}
}
return false;
}
if (class_exists('AKSRT_Content_Visibility')) {
return AKSRT_Content_Visibility::can_view_paid_content($pid);
}
return false;
}
/**
* [content type="admin|author|vip"]...[/content] — 按角色/身份控制可见性
*/
public function render_content_gate(array $atts = [], string $content = ''): string {
$atts = shortcode_atts(['type' => 'admin', 'message' => ''], $atts, 'content');
$type = sanitize_key((string) $atts['type']);
$uid = get_current_user_id();
$pid = get_the_ID();
$allowed = false;
switch ($type) {
case 'admin':
$allowed = $uid > 0 && user_can($uid, 'manage_options');
break;
case 'author':
if ($uid > 0 && $pid) {
$post = get_post($pid);
$allowed = $post && (int) $post->post_author === $uid;
}
break;
case 'vip':
$allowed = $uid > 0 && function_exists('aksrt_is_vip') && aksrt_is_vip($uid);
break;
case 'login':
$allowed = $uid > 0;
break;
}
if ($allowed) {
return '<div class="aksrt-hidden-content aksrt-hidden-content--unlocked aksrt-hidden-content--role">'
. do_shortcode($content) . '</div>';
}
$default_msgs = [
'admin' => __('此内容仅管理员可见', 'aksrt'),
'author' => __('此内容仅作者可见', 'aksrt'),
'vip' => __('此内容仅 VIP 用户可见', 'aksrt'),
'login' => __('此内容仅登录用户可见', 'aksrt'),
];
$message = $atts['message'] ?: ($default_msgs[$type] ?? __('此内容已隐藏', 'aksrt'));
$html = '<div class="aksrt-hidden-content aksrt-hidden-content--locked aksrt-hidden-content--role">';
$html .= '<div class="aksrt-hidden-content__message">';
$html .= '<i class="fas fa-eye-slash" aria-hidden="true"></i> ';
$html .= '<span>' . esc_html($message) . '</span>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
/**
* [aksrt_archive] 文章归档
*/
public function render_archive(array $atts = [], string $content = ''): string {
if (!class_exists('AKSRT_Templates')) {
return '';
}
return AKSRT_Templates::get_instance()->render_archive_shortcode($atts, $content);
}
/**
* [aksrt_profile] 个人资料卡
*/
public function render_profile(array $atts = [], string $content = ''): string {
if (!class_exists('AKSRT_Templates')) {
return '';
}
return AKSRT_Templates::get_instance()->render_profile_shortcode($atts, $content);
}
/**
* [aksrt_posts count="6" cat="" tag="" orderby="date" order="DESC" mode="card"]
*
* 用统一渲染器输出文章列表,避免内容里手写卡片循环。
*/
public function render_posts(array $atts = [], string $content = ''): string {
if (!function_exists('aksrt_render_post_list')) {
return '';
}
$a = shortcode_atts([
'count' => 6,
'cat' => '',
'tag' => '',
'orderby' => 'date',
'order' => 'DESC',
'mode' => 'card',
], $atts, 'aksrt_posts');
$query_args = [
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => max(1, min(24, (int) $a['count'])),
'orderby' => sanitize_key((string) $a['orderby']) ?: 'date',
'order' => strtoupper((string) $a['order']) === 'ASC' ? 'ASC' : 'DESC',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
];
$cat = sanitize_text_field((string) $a['cat']);
if ($cat !== '') {
$query_args[is_numeric($cat) ? 'cat' : 'category_name'] = $cat;
}
$tag = sanitize_text_field((string) $a['tag']);
if ($tag !== '') {
$query_args[is_numeric($tag) ? 'tag_id' : 'tag'] = $tag;
}
$mode = in_array($a['mode'], ['card', 'list', 'mini'], true) ? $a['mode'] : 'card';
$query = new WP_Query($query_args);
$html = aksrt_render_post_list($query, [
'context' => 'widget',
'mode' => $mode,
], false);
wp_reset_postdata();
return '<div class="aksrt-shortcode-posts">' . $html . '</div>';
}
}
endif;
+5 -5
View File
@@ -22,10 +22,10 @@ if (!function_exists('aksrt_get_the_subtitle')) :
if ($post_id <= 0) {
return '';
}
// New route: subtitle lives in AKSRT_Post_Meta_Box aggregate meta.
// New route: subtitle lives in \AKSRT\Core\PostMetaBox aggregate meta.
$subtitle = '';
if (class_exists('AKSRT_Post_Meta_Box')) {
$meta = AKSRT_Post_Meta_Box::get_meta($post_id);
if (class_exists('\AKSRT\Core\PostMetaBox')) {
$meta = \AKSRT\Core\PostMetaBox::get_meta($post_id);
$subtitle = trim((string) ($meta['subtitle'] ?? ''));
}
if ($subtitle === '') {
@@ -82,8 +82,8 @@ if (!function_exists('aksrt_get_posts_meta_items_html')) :
$html .= '<span class="item meta-view"><i class="fa fa-eye" aria-hidden="true"></i> ' . esc_html((string) $views_label) . '</span>';
$like_on = true;
if (class_exists('AKSRT_Settings')) {
$page = AKSRT_Settings::get_post_page_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$page = \AKSRT\Settings\Settings::get_post_page_settings();
$like_on = !isset($page['like_enabled']) || !empty($page['like_enabled']);
}
if ($like_on && $post->post_type === 'post') {
+5 -5
View File
@@ -368,8 +368,8 @@ if (!function_exists('aksrt_single_render_author_card')) :
$avatar = function_exists('aksrt_get_avatar_html')
? aksrt_get_avatar_html($author_id, 80, ['class' => 'avatar avatar-lg'])
: get_avatar($author_id, 80, '', esc_attr($author_name), ['class' => 'avatar avatar-lg']);
$page_s = class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_post_page_settings')
? AKSRT_Settings::get_post_page_settings()
$page_s = class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_post_page_settings')
? \AKSRT\Settings\Settings::get_post_page_settings()
: [];
$card_limit = max(0, min(12, (int) ($page_s['author_card_limit'] ?? 6)));
$card_orderby = sanitize_key((string) ($page_s['author_card_orderby'] ?? 'views'));
@@ -406,10 +406,10 @@ if (!function_exists('aksrt_single_render_author_card')) :
}
$is_self = is_user_logged_in() && get_current_user_id() === $author_id;
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink());
$aksrt_pm_on = class_exists('AKSRT_Settings') && !empty(AKSRT_Settings::private_message_settings()['enabled']);
$aksrt_pm_on = class_exists('\AKSRT\Settings\Settings') && !empty(\AKSRT\Settings\Settings::private_message_settings()['enabled']);
$aksrt_msg_url = function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '';
$aksrt_post_settings = class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_post_page_settings')
? AKSRT_Settings::get_post_page_settings()
$aksrt_post_settings = class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_post_page_settings')
? \AKSRT\Settings\Settings::get_post_page_settings()
: [];
$rewards_on = !empty($aksrt_post_settings['rewards_enabled'])
|| !empty($aksrt_post_settings['post_rewards_enabled'])
+3 -3
View File
@@ -60,7 +60,7 @@ if (!function_exists('aksrt_single_build_context')) :
);
}
$paid_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_paid_content_settings() : [];
$paid_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_paid_content_settings() : [];
$paid_display = is_array($paid_settings['display'] ?? null) ? $paid_settings['display'] : [];
$paid_box_position = sanitize_key((string) ($paid_display['box_position'] ?? 'top'));
// Zibll positions: box_top | top | bottom | box_bottom (do not collapse).
@@ -149,10 +149,10 @@ if (!function_exists('aksrt_single_is_docs_page')) :
* Docs fast-path: true when the current post should leave the unified single surface.
*/
function aksrt_single_is_docs_page(int $post_id): bool {
if (!class_exists('AKSRT_Docs_Presenter')) {
if (!class_exists('\AKSRT\Core\DocsPresenter')) {
return false;
}
return (bool) AKSRT_Docs_Presenter::get_instance()->is_docs_page($post_id);
return (bool) \AKSRT\Core\DocsPresenter::get_instance()->is_docs_page($post_id);
}
endif;
+55 -55
View File
@@ -78,8 +78,8 @@ if (!function_exists('aksrt_get_sidebar_config_safe')):
* @return array{enabled:bool,position:string,width:int,home:bool,category:bool,tag:bool,single:bool,page:bool,search:bool}
*/
function aksrt_get_sidebar_config_safe(): array {
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_sidebar_config')) {
$cfg = AKSRT_Settings::get_sidebar_config();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_sidebar_config')) {
$cfg = \AKSRT\Settings\Settings::get_sidebar_config();
if (is_array($cfg)) {
return $cfg;
}
@@ -157,10 +157,10 @@ function aksrt_is_show_sidebar_filter(): bool {
}
// Category/tag term meta can still force off (existing AKSRT contract).
if ((is_category() || is_tag()) && class_exists('AKSRT_Term_Meta') && method_exists('AKSRT_Term_Meta', 'resolve_archive_settings')) {
if ((is_category() || is_tag()) && class_exists('\AKSRT\Core\TermMeta') && method_exists('\AKSRT\Core\TermMeta', 'resolve_archive_settings')) {
$term_id = (int) get_queried_object_id();
if ($term_id > 0) {
$resolved = AKSRT_Term_Meta::resolve_archive_settings($term_id);
$resolved = \AKSRT\Core\TermMeta::resolve_archive_settings($term_id);
if (is_array($resolved) && array_key_exists('show_sidebar', $resolved) && empty($resolved['show_sidebar'])) {
return false;
}
@@ -168,8 +168,8 @@ function aksrt_is_show_sidebar_filter(): bool {
}
// Search page display setting can force off.
if (is_search() && class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_other_page_settings')) {
$other = AKSRT_Settings::get_other_page_settings();
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;
}
@@ -272,8 +272,8 @@ if (!function_exists('aksrt_get_slider_config')):
* @return array<string,mixed>
*/
function aksrt_get_slider_config(): array {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::get_slider_config();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::get_slider_config();
}
return [
'effect' => 'fade', 'loop' => true, 'autoplay_interval' => 5000,
@@ -548,8 +548,8 @@ if (!function_exists('aksrt_get_friend_links')):
* @return array
*/
function aksrt_get_friend_links() {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::get_friend_links();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::get_friend_links();
}
$links = get_option('aksrt_friend_links', array());
@@ -570,8 +570,8 @@ if (!function_exists('aksrt_get_site_logo_url')):
* @return string
*/
function aksrt_get_site_logo_url() {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::logo_url();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::logo_url();
}
return (string) aksrt_get_setting('logo_url', '');
@@ -585,8 +585,8 @@ if (!function_exists('aksrt_get_favicon_url')):
* @return string
*/
function aksrt_get_favicon_url() {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::favicon_url();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::favicon_url();
}
$favicon = (string) aksrt_get_setting('favicon_url', '');
@@ -611,8 +611,8 @@ if (!function_exists('aksrt_get_site_logo_dark_url')):
* @return string
*/
function aksrt_get_site_logo_dark_url(): string {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::logo_dark_url();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::logo_dark_url();
}
return (string) aksrt_get_setting('site_logo_dark', aksrt_get_setting('logo_url_dark', ''));
@@ -626,8 +626,8 @@ if (!function_exists('aksrt_get_site_logo_text')):
* @return string
*/
function aksrt_get_site_logo_text(): string {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::logo_text();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::logo_text();
}
$text = trim((string) aksrt_get_setting('logo_text', ''));
@@ -642,8 +642,8 @@ if (!function_exists('aksrt_get_site_logo_width')):
* @return int
*/
function aksrt_get_site_logo_width(): int {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::logo_width();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::logo_width();
}
$width = (int) aksrt_get_setting('logo_width', 150);
@@ -681,8 +681,8 @@ function aksrt_get_adaptive_theme_img(string $white_src = '', string $dark_src =
}
$is_dark = false;
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'initial_theme_mode')) {
$is_dark = AKSRT_Settings::initial_theme_mode() === 'dark';
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'initial_theme_mode')) {
$is_dark = \AKSRT\Settings\Settings::initial_theme_mode() === 'dark';
}
$this_src = $is_dark ? $dark_src : $white_src;
@@ -697,8 +697,8 @@ if (!function_exists('aksrt_get_search_placeholder')):
* @return string
*/
function aksrt_get_search_placeholder(): string {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::search_placeholder();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::search_placeholder();
}
$placeholder = trim((string) aksrt_get_setting('search_placeholder', ''));
@@ -713,13 +713,13 @@ if (!function_exists('aksrt_get_search_hot_keywords')):
* @return array<int,string>
*/
function aksrt_get_search_hot_keywords(): array {
if (class_exists('AKSRT_Settings')) {
if (!AKSRT_Settings::hot_search_enabled()) {
if (class_exists('\AKSRT\Settings\Settings')) {
if (!\AKSRT\Settings\Settings::hot_search_enabled()) {
return [];
}
$keywords = AKSRT_Settings::hot_search_keywords();
$keywords = \AKSRT\Settings\Settings::hot_search_keywords();
// 置顶词前置
$sticky = AKSRT_Settings::search_popular_sticky();
$sticky = \AKSRT\Settings\Settings::search_popular_sticky();
if (!empty($sticky)) {
$keywords = array_values(array_unique(array_merge($sticky, $keywords)));
}
@@ -778,8 +778,8 @@ function aksrt_render_search_hot_keywords($keywords = null, string $class = 'aks
$class = 'aksrt-search-hot-keywords';
}
$label = class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'search_popular_title')
? (string) AKSRT_Settings::search_popular_title()
$label = class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'search_popular_title')
? (string) \AKSRT\Settings\Settings::search_popular_title()
: __('热门搜索', 'aksrt');
if ($label === '') {
$label = __('热门搜索', 'aksrt');
@@ -803,8 +803,8 @@ if (!function_exists('aksrt_search_history_enabled')):
* @return bool
*/
function aksrt_search_history_enabled(): bool {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::search_history_enabled();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::search_history_enabled();
}
return !empty(aksrt_get_setting('search_history_enabled', true));
@@ -818,8 +818,8 @@ if (!function_exists('aksrt_search_suggestions_enabled')):
* @return bool
*/
function aksrt_search_suggestions_enabled(): bool {
if (class_exists('AKSRT_Settings')) {
return AKSRT_Settings::search_suggestions_enabled();
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::search_suggestions_enabled();
}
return aksrt_get_setting('search_type', 'default') === 'ajax'
@@ -836,7 +836,7 @@ if (!function_exists('aksrt_get_search_form_type')):
function aksrt_get_search_form_type(): string {
$configured = ['post' => __('文章', 'aksrt')];
if (class_exists('AKSRT_Settings')) {
if (class_exists('\AKSRT\Settings\Settings')) {
$configured = aksrt_get_search_type_options();
}
@@ -871,11 +871,11 @@ function aksrt_get_search_type_options(): array {
'tag' => __('标签', 'aksrt'),
];
if (!class_exists('AKSRT_Settings')) {
if (!class_exists('\AKSRT\Settings\Settings')) {
return ['post' => $label_map['post']];
}
$config = AKSRT_Settings::get_search_content_types();
$config = \AKSRT\Settings\Settings::get_search_content_types();
$types = isset($config['types']) && is_array($config['types']) ? $config['types'] : ['post'];
$options = [];
@@ -904,8 +904,8 @@ function aksrt_get_default_search_type(): string {
$options = function_exists('aksrt_get_search_type_options') ? aksrt_get_search_type_options() : ['post' => __('文章', 'aksrt')];
$allowed = array_keys($options);
if (class_exists('AKSRT_Settings')) {
$config = AKSRT_Settings::get_search_content_types();
if (class_exists('\AKSRT\Settings\Settings')) {
$config = \AKSRT\Settings\Settings::get_search_content_types();
$default = sanitize_key((string) ($config['default'] ?? 'post'));
if (in_array($default, $allowed, true)) {
return $default;
@@ -923,11 +923,11 @@ if (!function_exists('aksrt_get_search_default_category_id')):
* @return int
*/
function aksrt_get_search_default_category_id(): int {
if (!class_exists('AKSRT_Settings') || !AKSRT_Settings::search_cat_enabled()) {
if (!class_exists('\AKSRT\Settings\Settings') || !\AKSRT\Settings\Settings::search_cat_enabled()) {
return 0;
}
return max(0, absint(AKSRT_Settings::search_cat_in()));
return max(0, absint(\AKSRT\Settings\Settings::search_cat_in()));
}
endif;
@@ -968,7 +968,7 @@ function aksrt_get_search_form_state(): array {
$type = function_exists('aksrt_get_search_form_type') ? aksrt_get_search_form_type() : 'post';
$default_category = function_exists('aksrt_get_search_default_category_id') ? aksrt_get_search_default_category_id() : 0;
$current_category = isset($_GET['aksrt_category']) ? absint(wp_unslash($_GET['aksrt_category'])) : $default_category;
$category_enabled = class_exists('AKSRT_Settings') ? AKSRT_Settings::search_cat_enabled() : false;
$category_enabled = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::search_cat_enabled() : false;
$categories = $category_enabled ? aksrt_get_search_categories() : [];
return [
@@ -1055,8 +1055,8 @@ if (!function_exists('aksrt_render_comment_pagination')) {
* 渲染评论列表分页(根据后台配置选择模式)
*/
function aksrt_render_comment_pagination(): void {
$comment_pagination_mode = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_comment_pagination_mode()
$comment_pagination_mode = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_comment_pagination_mode()
: 'numbered';
if ($comment_pagination_mode === 'numbered') {
@@ -1136,10 +1136,10 @@ if (!function_exists('aksrt_render_comment_pagination')) {
*/
function aksrt_auto_image_alt(string $content): string {
if (is_admin()) return $content;
if (!class_exists('AKSRT_Settings')) return $content;
if (!class_exists('\AKSRT\Settings\Settings')) return $content;
// schema key = seo_auto_alt; runtime alias = auto_image_alt
$auto_alt = AKSRT_Settings::get_value('seo_auto_alt', false)
?: AKSRT_Settings::get_value('auto_image_alt', false);
$auto_alt = \AKSRT\Settings\Settings::get_value('seo_auto_alt', false)
?: \AKSRT\Settings\Settings::get_value('auto_image_alt', false);
if (!$auto_alt) return $content;
// Only on singular pages
@@ -1185,8 +1185,8 @@ add_filter('the_content', 'aksrt_auto_image_alt', 999);
* @return bool
*/
function aksrt_is_lazyload_enabled(string $scope = 'other'): bool {
if (!class_exists('AKSRT_Settings')) return true; // 默认开
$cfg = AKSRT_Settings::get_lazyload_config();
if (!class_exists('\AKSRT\Settings\Settings')) return true; // 默认开
$cfg = \AKSRT\Settings\Settings::get_lazyload_config();
if (!$cfg['enabled']) return false;
return !empty($cfg[$scope] ?? true);
}
@@ -1206,7 +1206,7 @@ function aksrt_lazy_img_attrs(string $url, string $scope = 'other', string $extr
if (empty($url)) return '';
if (aksrt_is_lazyload_enabled($scope)) {
$cfg = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_lazyload_config() : [];
$cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_lazyload_config() : [];
$placeholder = $cfg['placeholder_url'] ?? '';
$animation = $cfg['animation'] ?? 'blur';
$cls = trim('fit-cover aksrt-lazy ' . $extra_class);
@@ -1245,7 +1245,7 @@ if (!function_exists('aksrt_user_can')) :
/**
* Check if a user has a specific front-end capability from the user_caps matrix.
*
* Delegates to AKSRT_Settings::user_can(). WP admins always pass.
* Delegates to \AKSRT\Settings\Settings::user_can(). WP admins always pass.
*
* @param string $cap Capability id (e.g. 'new_post_add', 'comment_edit').
* @param int $user_id User ID. Defaults to current user.
@@ -1256,10 +1256,10 @@ function aksrt_user_can(string $cap, int $user_id = 0, ?int $context = null): bo
if ($user_id <= 0) {
$user_id = get_current_user_id();
}
if (!class_exists('AKSRT_Settings')) {
if (!class_exists('\AKSRT\Settings\Settings')) {
return $user_id > 0;
}
return AKSRT_Settings::user_can($cap, $user_id, $context);
return \AKSRT\Settings\Settings::user_can($cap, $user_id, $context);
}
endif;
@@ -1294,10 +1294,10 @@ if (!function_exists('aksrt_should_use_footer_tabbar_single_extend')) :
if (!is_singular('post')) {
return false;
}
if (!class_exists('AKSRT_Settings') || !method_exists('AKSRT_Settings', 'get_footer_tabbar_single')) {
if (!class_exists('\AKSRT\Settings\Settings') || !method_exists('\AKSRT\Settings\Settings', 'get_footer_tabbar_single')) {
return false;
}
return AKSRT_Settings::get_footer_tabbar_single() === 'extend';
return \AKSRT\Settings\Settings::get_footer_tabbar_single() === 'extend';
}
endif;
+16 -16
View File
@@ -10,23 +10,23 @@
defined('ABSPATH') || exit;
function aksrt_get_order_status_labels(): array {
if (class_exists('AKSRT_Domain_Model')) {
return AKSRT_Domain_Model::order_status_labels();
if (class_exists('\AKSRT\Core\DomainModel')) {
return \AKSRT\Core\DomainModel::order_status_labels();
}
return [];
}
function aksrt_get_product_page_view(int $product_id): array {
if ($product_id <= 0 || !class_exists('AKSRT_Shop')) {
if ($product_id <= 0 || !class_exists('\AKSRT\Shop\Shop')) {
return [];
}
return AKSRT_Shop::get_instance()->get_product_detail_view($product_id);
return \AKSRT\Shop\Shop::get_instance()->get_product_detail_view($product_id);
}
function aksrt_get_product_edit_page_view(int $user_id, int $product_id = 0): array {
if ($user_id <= 0 || !class_exists('AKSRT_Shop')) {
if ($user_id <= 0 || !class_exists('\AKSRT\Shop\Shop')) {
return [
'allowed' => false,
'is_edit' => false,
@@ -34,11 +34,11 @@ function aksrt_get_product_edit_page_view(int $user_id, int $product_id = 0): ar
];
}
return AKSRT_Shop::get_instance()->get_product_edit_view($user_id, $product_id);
return \AKSRT\Shop\Shop::get_instance()->get_product_edit_view($user_id, $product_id);
}
function aksrt_get_cart_page_view(int $user_id): array {
if ($user_id <= 0 || !class_exists('AKSRT_Shop')) {
if ($user_id <= 0 || !class_exists('\AKSRT\Shop\Shop')) {
return [
'payment_methods' => [],
'shipping_methods' => [],
@@ -49,11 +49,11 @@ function aksrt_get_cart_page_view(int $user_id): array {
];
}
return AKSRT_Shop::get_instance()->get_cart_page_view($user_id);
return \AKSRT\Shop\Shop::get_instance()->get_cart_page_view($user_id);
}
function aksrt_get_orders_page_view(int $user_id, int $paged = 1, int $per_page = 20, string $status = ''): array {
if ($user_id <= 0 || !class_exists('AKSRT_Shop')) {
if ($user_id <= 0 || !class_exists('\AKSRT\Shop\Shop')) {
return [
'items' => [],
'total' => 0,
@@ -62,7 +62,7 @@ function aksrt_get_orders_page_view(int $user_id, int $paged = 1, int $per_page
];
}
return AKSRT_Shop::get_instance()->get_order_center_view($user_id, [
return \AKSRT\Shop\Shop::get_instance()->get_order_center_view($user_id, [
'page' => $paged,
'per_page' => $per_page,
'status' => $status,
@@ -75,12 +75,12 @@ function aksrt_get_revenue_page_view(int $user_id): array {
$total_withdrawn = 0.0;
$records = [];
if (class_exists('AKSRT_Credits')) {
$balance = (float) AKSRT_Credits::balance($user_id);
if (class_exists('\AKSRT\Credits\Credits')) {
$balance = (float) \AKSRT\Credits\Credits::balance($user_id);
}
if (class_exists('AKSRT_Revenue')) {
$revenues = AKSRT_Revenue::get_instance()->get_user_revenues($user_id, ['limit' => 200]);
if (class_exists('\AKSRT\Payment\Revenue')) {
$revenues = \AKSRT\Payment\Revenue::get_instance()->get_user_revenues($user_id, ['limit' => 200]);
foreach ($revenues as $rev) {
$row = is_array($rev) ? $rev : (array) $rev;
$total_earned += (float) ($row['amount'] ?? 0);
@@ -93,8 +93,8 @@ function aksrt_get_revenue_page_view(int $user_id): array {
}
}
if (class_exists('AKSRT_Withdrawal')) {
$withdrawals = AKSRT_Withdrawal::get_instance()->get_user_withdrawals($user_id, ['limit' => 200]);
if (class_exists('\AKSRT\Payment\Withdrawal')) {
$withdrawals = \AKSRT\Payment\Withdrawal::get_instance()->get_user_withdrawals($user_id, ['limit' => 200]);
foreach ($withdrawals as $w) {
$wrow = is_array($w) ? $w : (array) $w;
$total_withdrawn += (float) ($wrow['amount'] ?? 0);
+10 -10
View File
@@ -283,8 +283,8 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) {
* @return array{tabs:array,keys:array<int,string>,default:string,active:string,urls:array<string,string>}
*/
function aksrt_user_center_resolve_tabs(): array {
$tabs = class_exists('AKSRT_User_Center')
? AKSRT_User_Center::get_instance()->get_dashboard_tabs()
$tabs = class_exists('\AKSRT\User\Center')
? \AKSRT\User\Center::get_instance()->get_dashboard_tabs()
: [
'profile' => ['label' => __('个人信息', 'aksrt'), 'icon' => 'user'],
'posts' => ['label' => __('我的文章', 'aksrt'), 'icon' => 'file-alt'],
@@ -411,8 +411,8 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
function aksrt_get_user_center_render_context(WP_User $current_user): array {
$user_id = (int) $current_user->ID;
$user_center_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_user_center_settings()
$user_center_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_user_center_settings()
: [
'tabs' => ['profile', 'posts', 'comments', 'favorites'],
'avatar_upload' => true,
@@ -438,7 +438,7 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
$user_contacts = $dashboard['user_contacts'] ?? get_user_meta($user_id, 'aksrt_user_contacts', true);
$user_contacts = is_array($user_contacts) ? $user_contacts : [];
$user_background_url = (string) ($dashboard['background_url'] ?? get_user_meta($user_id, 'aksrt_background_image', true));
$allow_bg_upload = !empty($user_center_settings['cover_upload']) && class_exists('AKSRT_Settings') && aksrt_get_setting('allow_background_upload', false);
$allow_bg_upload = !empty($user_center_settings['cover_upload']) && class_exists('\AKSRT\Settings\Settings') && aksrt_get_setting('allow_background_upload', false);
$post_status_filter = isset($_GET['post_status']) ? sanitize_key(wp_unslash($_GET['post_status'])) : 'publish';
if (!in_array($post_status_filter, ['all', 'publish', 'draft', 'pending', 'private'], true)) {
@@ -454,8 +454,8 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
$svgs = aksrt_user_center_empty_svgs();
require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
$vip_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_payment_vip_settings() : [];
$affiliate_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_payment_affiliate_settings() : [];
$vip_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_vip_settings() : [];
$affiliate_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_affiliate_settings() : [];
$show_credit_tabs = (bool) ($dashboard['credits_enabled'] ?? false);
$currency_name = (string) ($dashboard['currency_name'] ?? __('积分', 'aksrt'));
$balance_enabled = (bool) ($dashboard['balance_enabled'] ?? false);
@@ -502,9 +502,9 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
'wallet_balance' => $wallet_balance,
'vip_settings' => $vip_settings,
'show_invite_section' => $show_credit_tabs
&& class_exists('AKSRT_Settings')
&& AKSRT_Settings::invite_enabled()
&& AKSRT_Settings::invite_registration_enabled(),
&& class_exists('\AKSRT\Settings\Settings')
&& \AKSRT\Settings\Settings::invite_enabled()
&& \AKSRT\Settings\Settings::invite_registration_enabled(),
'user_email' => (string) $current_user->user_email,
'runtime_config' => aksrt_user_center_runtime_config($user_id, $tabs['default'], $active_tab, $tabs['urls']),
'cover_upload_config' => aksrt_user_center_cover_upload_config($allow_bg_upload),
+9 -9
View File
@@ -67,26 +67,26 @@ function aksrt_get_user_dashboard_view(int $user_id, array $args = []): array {
$user_contacts = [];
}
$user_center_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_user_center_settings()
$user_center_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_user_center_settings()
: ['social_links' => true];
$background_url = get_user_meta($user_id, 'aksrt_background_image', true) ?: '';
$credits_enabled = class_exists('AKSRT_Settings') && AKSRT_Settings::credits_enabled();
$credits_enabled = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled();
$credit_balance = $credits_enabled && $is_own_profile && function_exists('aksrt_user_credits')
? (float) aksrt_user_credits($user_id)
: 0.0;
$currency_name = $credits_enabled && class_exists('AKSRT_Settings')
? AKSRT_Settings::get_currency_name()
$currency_name = $credits_enabled && class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_currency_name()
: __('积分', 'aksrt');
// Cash wallet (Zibll pay_balance) — separate from points.
$balance_enabled = $is_own_profile && class_exists('AKSRT_Balance') && AKSRT_Balance::enabled();
$wallet_balance = $balance_enabled ? AKSRT_Balance::balance($user_id) : 0.0;
$balance_enabled = $is_own_profile && class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled();
$wallet_balance = $balance_enabled ? \AKSRT\Credits\Balance::balance($user_id) : 0.0;
$user_home_manager = $include_governance && class_exists('AKSRT_User_Home')
? AKSRT_User_Home::get_instance()
$user_home_manager = $include_governance && class_exists('\AKSRT\User\Home')
? \AKSRT\User\Home::get_instance()
: null;
$profile_signals = $user_home_manager ? $user_home_manager->get_profile_signals($user_id) : [];
$profile_notice = $user_home_manager ? $user_home_manager->get_profile_notice($user_id) : [];
+10 -10
View File
@@ -24,8 +24,8 @@ if (!function_exists('aksrt_get_user_home_page_context')) {
: [];
$is_own_profile = !empty($dashboard['is_own_profile']);
$user_home_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_user_home_settings()
$user_home_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_user_home_settings()
: [
'tabs' => ['posts', 'favorites', 'comments', 'follow'],
'sidebar' => false,
@@ -34,8 +34,8 @@ if (!function_exists('aksrt_get_user_home_page_context')) {
'posts_per_page' => 10,
];
$user_center_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_user_center_settings()
$user_center_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_user_center_settings()
: ['social_links' => true];
$post_count = (int) ($dashboard['post_count'] ?? 0);
@@ -48,7 +48,7 @@ if (!function_exists('aksrt_get_user_home_page_context')) {
$credit_balance = $dashboard['credit_balance'] ?? 0.0;
$currency_name = $dashboard['currency_name'] ?? __('积分', 'aksrt');
$user_home_manager = class_exists('AKSRT_User_Home') ? AKSRT_User_Home::get_instance() : null;
$user_home_manager = class_exists('\AKSRT\User\Home') ? \AKSRT\User\Home::get_instance() : null;
$visible_tabs = $user_home_manager ? $user_home_manager->get_visible_tabs($is_own_profile) : [];
$enabled_tabs = array_keys($visible_tabs);
@@ -79,17 +79,17 @@ if (!function_exists('aksrt_get_user_home_page_context')) {
$display_tabs = $is_mobile ? $enabled_tabs_mobile : $enabled_tabs_pc;
$default_tab = !empty($display_tabs) ? $display_tabs[0] : $enabled_tabs[0];
$forum_instance = class_exists('AKSRT_Forum') ? AKSRT_Forum::get_instance() : null;
$forum_instance = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
$forum_stats = $forum_instance ? $forum_instance->get_user_forum_stats($user_id) : [];
$forum_topic_count = (int) ($forum_stats['topic_count'] ?? 0);
$product_count = 0;
if (class_exists('AKSRT_Shop')) {
$product_count = (int) AKSRT_Shop::get_instance()->count_author_products($user_id);
if (class_exists('\AKSRT\Shop\Shop')) {
$product_count = (int) \AKSRT\Shop\Shop::get_instance()->count_author_products($user_id);
}
$follow_count = 0;
if (class_exists('AKSRT_Follow')) {
$follow_count = (int) AKSRT_Follow::get_instance()->get_follower_count($user_id);
if (class_exists('\AKSRT\User\Follow')) {
$follow_count = (int) \AKSRT\User\Follow::get_instance()->get_follower_count($user_id);
}
$plate_count = 0;
+13 -13
View File
@@ -28,11 +28,11 @@ function aksrt_get_user_vip_level(int $user_id = 0): int {
return 0;
}
if (!class_exists('AKSRT_Settings')) {
if (!class_exists('\AKSRT\Settings\Settings')) {
return 0;
}
$vip_settings = AKSRT_Settings::get_payment_vip_settings();
$vip_settings = \AKSRT\Settings\Settings::get_payment_vip_settings();
if (empty($vip_settings['enabled'])) {
return 0;
}
@@ -42,7 +42,7 @@ function aksrt_get_user_vip_level(int $user_id = 0): int {
$vip2_enabled = !empty($levels[2]['enabled']);
// 1. 角色豁免:特权角色取当前启用最高档。
$paid_settings = AKSRT_Settings::get_paid_content_settings();
$paid_settings = \AKSRT\Settings\Settings::get_paid_content_settings();
$exempt_roles = $paid_settings['vip_exempt_roles'] ?? [];
if (!empty($exempt_roles)) {
$user = get_userdata($user_id);
@@ -75,8 +75,8 @@ function aksrt_get_user_vip_level(int $user_id = 0): int {
}
// 3. 订单兜底(meta 无有效等级时)。
if ($candidate <= 0 && class_exists('AKSRT_Order')) {
$order_mgr = AKSRT_Order::get_instance();
if ($candidate <= 0 && class_exists('\AKSRT\Payment\Order')) {
$order_mgr = \AKSRT\Payment\Order::get_instance();
$valid_order = method_exists($order_mgr, 'get_valid_vip_order')
? $order_mgr->get_valid_vip_order($user_id)
: null;
@@ -141,11 +141,11 @@ function aksrt_is_vip2(int $user_id = 0): bool {
* @return string
*/
function aksrt_get_vip_badge_text(): string {
if (!class_exists('AKSRT_Settings')) {
if (!class_exists('\AKSRT\Settings\Settings')) {
return 'VIP';
}
$vip_settings = AKSRT_Settings::get_payment_vip_settings();
$vip_settings = \AKSRT\Settings\Settings::get_payment_vip_settings();
return sanitize_text_field($vip_settings['badge_text'] ?? 'VIP');
}
@@ -158,11 +158,11 @@ if (!function_exists('aksrt_get_user_free_download_limit')) {
if ($user_id <= 0) {
$user_id = get_current_user_id();
}
if ($user_id <= 0 || !class_exists('AKSRT_Settings')) {
if ($user_id <= 0 || !class_exists('\AKSRT\Settings\Settings')) {
return 0;
}
$vip = AKSRT_Settings::get_payment_vip_settings();
$vip = \AKSRT\Settings\Settings::get_payment_vip_settings();
$level = function_exists('aksrt_get_user_vip_level') ? aksrt_get_user_vip_level($user_id) : 0;
$levels = is_array($vip['levels'] ?? null) ? $vip['levels'] : [];
$benefit = is_array($vip['benefit'] ?? null) ? $vip['benefit'] : [];
@@ -183,11 +183,11 @@ if (!function_exists('aksrt_get_user_download_speed')) {
if ($user_id <= 0) {
$user_id = get_current_user_id();
}
if ($user_id <= 0 || !class_exists('AKSRT_Settings')) {
if ($user_id <= 0 || !class_exists('\AKSRT\Settings\Settings')) {
return 0;
}
$vip = AKSRT_Settings::get_payment_vip_settings();
$vip = \AKSRT\Settings\Settings::get_payment_vip_settings();
$level = function_exists('aksrt_get_user_vip_level') ? aksrt_get_user_vip_level($user_id) : 0;
$levels = is_array($vip['levels'] ?? null) ? $vip['levels'] : [];
$benefit = is_array($vip['benefit'] ?? null) ? $vip['benefit'] : [];
@@ -356,8 +356,8 @@ function aksrt_get_vip_info(int $user_id = 0): array {
}
$name = __('普通用户', 'aksrt');
if ($is_vip && class_exists('AKSRT_Settings')) {
$vip = AKSRT_Settings::get_payment_vip_settings();
if ($is_vip && class_exists('\AKSRT\Settings\Settings')) {
$vip = \AKSRT\Settings\Settings::get_payment_vip_settings();
$name = (string) ($vip['levels'][$level]['name'] ?? ($badge_text . __('会员', 'aksrt')));
} elseif ($is_vip) {
$name = $badge_text . __('会员', 'aksrt');
+3 -3
View File
@@ -11,7 +11,7 @@
defined('ABSPATH') || exit;
/**
* Get menu decoration settings from AKSRT_Settings.
* Get menu decoration settings from \AKSRT\Settings\Settings.
*
* @return array
*/
@@ -21,8 +21,8 @@ function aksrt_get_menu_decoration_settings(): array {
return $cache;
}
if (class_exists('AKSRT_Settings')) {
$all = AKSRT_Settings::get_all();
if (class_exists('\AKSRT\Settings\Settings')) {
$all = \AKSRT\Settings\Settings::get_all();
} else {
$all = [];
}
@@ -14,18 +14,18 @@ if (!$credits_enabled) {
}
$card_pass_credits = ['enabled' => false, 'desc' => '', 'only_password' => true];
if (class_exists('AKSRT_Charge_Card')) {
$opts = AKSRT_Charge_Card::get_instance()->get_public_options();
if (class_exists('\AKSRT\Payment\ChargeCard')) {
$opts = \AKSRT\Payment\ChargeCard::get_instance()->get_public_options();
$card_pass_credits = is_array($opts['credits'] ?? null) ? $opts['credits'] : $card_pass_credits;
}
$all_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_all() : [];
$all_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
$points_uid = (int) ($user_id ?? get_current_user_id());
$points_transfer_on = !empty($all_settings['points_transfer_s']);
if ($points_transfer_on && class_exists('AKSRT_Settings_Capabilities') && !AKSRT_Settings_Capabilities::user_can('points_transfer', $points_uid)) {
if ($points_transfer_on && class_exists('\AKSRT\Settings\Capabilities') && !\AKSRT\Settings\Capabilities::user_can('points_transfer', $points_uid)) {
$points_transfer_on = false;
}
$points_buy_on = class_exists('AKSRT_Balance_Service') && AKSRT_Balance_Service::get_instance()->points_buy_enabled();
$points_buy_view = $points_buy_on ? AKSRT_Balance_Service::get_instance()->get_points_buy_view((int) ($user_id ?? 0)) : [];
$points_buy_on = class_exists('\AKSRT\Credits\BalanceService') && \AKSRT\Credits\BalanceService::get_instance()->points_buy_enabled();
$points_buy_view = $points_buy_on ? \AKSRT\Credits\BalanceService::get_instance()->get_points_buy_view((int) ($user_id ?? 0)) : [];
$currency = (string) ($currency_name ?? __('积分', 'aksrt'));
?>
<div class="uc-asset-card uc-asset-card--points zib-widget">
@@ -9,11 +9,11 @@
defined('ABSPATH') || exit;
if (!class_exists('AKSRT_User_Level')) {
if (!class_exists('\AKSRT\User\Level')) {
return;
}
$cfg = AKSRT_User_Level::settings();
$cfg = \AKSRT\User\Level::settings();
if (empty($cfg['enabled'])) {
return;
}
@@ -23,8 +23,8 @@ if ($user_id <= 0) {
return;
}
$level = AKSRT_User_Level::get_level($user_id);
$integral = AKSRT_User_Level::get_integral($user_id);
$level = \AKSRT\User\Level::get_level($user_id);
$integral = \AKSRT\User\Level::get_integral($user_id);
$max = max(1, (int) ($cfg['max'] ?? 10));
$prefix = (string) ($cfg['prefix'] ?? 'Lv.');
$opt = is_array($cfg['level_opt'] ?? null) ? $cfg['level_opt'] : [];
@@ -36,7 +36,7 @@ if (!$is_max) {
$next_need = (int) ($opt['upgrade_integral_' . ($level + 1)] ?? 0);
if ($next_need <= $integral) {
// Resolve again in case meta lag.
$level = AKSRT_User_Level::resolve_level($integral, $cfg);
$level = \AKSRT\User\Level::resolve_level($integral, $cfg);
$is_max = $level >= $max;
$next_need = $is_max ? $integral : (int) ($opt['upgrade_integral_' . ($level + 1)] ?? $integral);
$name = (string) ($opt['name_' . $level] ?? ($prefix . $level));
@@ -7,7 +7,7 @@
defined('ABSPATH') || exit;
if (!class_exists('AKSRT_Points_Free') || !AKSRT_Points_Free::enabled()) {
if (!class_exists('\AKSRT\Credits\PointsFree') || !\AKSRT\Credits\PointsFree::enabled()) {
return;
}
@@ -26,8 +26,8 @@ $aksrt_points_task_action = static function (string $key): array {
$forum_on = false;
$forum_home = '';
$forum_compose = '';
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_forum_settings')) {
$f = AKSRT_Settings::get_forum_settings();
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_forum_settings')) {
$f = \AKSRT\Settings\Settings::get_forum_settings();
$forum_on = !empty($f['enabled']);
}
if ($forum_on) {
@@ -126,10 +126,10 @@ $aksrt_points_task_action = static function (string $key): array {
};
$user_id = (int) ($user_id ?? get_current_user_id());
$today = AKSRT_Points_Free::today_total($user_id);
$day_max = (int) AKSRT_Points_Free::settings()['day_max'];
$tasks = AKSRT_Points_Free::task_list_for_user($user_id);
$detail = AKSRT_Points_Free::date_detail($user_id);
$today = \AKSRT\Credits\PointsFree::today_total($user_id);
$day_max = (int) \AKSRT\Credits\PointsFree::settings()['day_max'];
$tasks = \AKSRT\Credits\PointsFree::task_list_for_user($user_id);
$detail = \AKSRT\Credits\PointsFree::date_detail($user_id);
$pane = isset($points_tasks_pane) ? sanitize_key((string) $points_tasks_pane) : 'tasks';
?>
@@ -23,8 +23,8 @@ if (function_exists('aksrt_is_captcha_enabled_for') && aksrt_is_captcha_enabled_
endif;
$signin_dates = [];
if (class_exists('AKSRT_Signin')) {
$signin_log = AKSRT_Signin::get_instance()->get_recent_signins($user_id, 30);
if (class_exists('\AKSRT\Credits\Signin')) {
$signin_log = \AKSRT\Credits\Signin::get_instance()->get_recent_signins($user_id, 30);
$signin_dates = array_filter(array_map(static function ($entry) {
return $entry['signin_date'] ?? '';
}, $signin_log));
@@ -18,8 +18,8 @@ defined('ABSPATH') || exit;
</div>
<?php
$credits_page = max(1, isset($_GET['credits_page']) ? (int) $_GET['credits_page'] : 1);
if (class_exists('AKSRT_Credits')) {
$log = AKSRT_Credits::get_log(['user_id' => $user_id, 'page' => $credits_page, 'per_page' => 10]);
if (class_exists('\AKSRT\Credits\Credits')) {
$log = \AKSRT\Credits\Credits::get_log(['user_id' => $user_id, 'page' => $credits_page, 'per_page' => 10]);
} else {
$log = ['items' => [], 'total' => 0];
}
@@ -43,9 +43,9 @@ $renew_desc = '';
$upgrade_desc = '';
$points_exchange = ['enabled' => false, 'packages' => [], 'desc' => ''];
$user_points = 0;
$currency_name = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_currency_name() : __('积分', 'aksrt');
if (class_exists('AKSRT_Vip_Service')) {
$catalog = AKSRT_Vip_Service::get_instance()->get_catalog($user_id);
$currency_name = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt');
if (class_exists('\AKSRT\Content\VipService')) {
$catalog = \AKSRT\Content\VipService::get_instance()->get_catalog($user_id);
$packages = is_array($catalog['level_packages'] ?? null) ? $catalog['level_packages'] : [];
$methods = is_array($catalog['payment_methods'] ?? null) ? $catalog['payment_methods'] : [];
$renew_desc = (string) ($catalog['renew_desc'] ?? '');
@@ -60,8 +60,8 @@ if (class_exists('AKSRT_Vip_Service')) {
}
$cash_symbol = '¥';
if (class_exists('AKSRT_Settings')) {
$paid_display = AKSRT_Settings::get_paid_content_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$paid_display = \AKSRT\Settings\Settings::get_paid_content_settings();
$cash_symbol = (string) ($paid_display['display']['currency_symbol'] ?? '¥');
}
@@ -72,8 +72,8 @@ if ($vip_level > 0) {
$points_pkgs = is_array($points_exchange['packages'] ?? null) ? $points_exchange['packages'] : [];
$card_pass_vip = ['enabled' => false, 'desc' => '', 'only_password' => true];
if (class_exists('AKSRT_Charge_Card')) {
$card_opts = AKSRT_Charge_Card::get_instance()->get_public_options();
if (class_exists('\AKSRT\Payment\ChargeCard')) {
$card_opts = \AKSRT\Payment\ChargeCard::get_instance()->get_public_options();
$card_pass_vip = is_array($card_opts['vip'] ?? null) ? $card_opts['vip'] : $card_pass_vip;
} elseif (!empty($vip_settings['benefit']['pass_charge'])) {
$card_pass_vip = [
@@ -14,44 +14,44 @@ if (empty($balance_enabled)) {
}
$wallet = (float) ($wallet_balance ?? 0.0);
$wallet_fmt = class_exists('AKSRT_Balance')
? AKSRT_Balance::format($wallet)
$wallet_fmt = class_exists('\AKSRT\Credits\Balance')
? \AKSRT\Credits\Balance::format($wallet)
: number_format_i18n($wallet, 2);
$recharge = class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'get_payment_recharge_settings')
? AKSRT_Settings::get_payment_recharge_settings()
$recharge = class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_payment_recharge_settings')
? \AKSRT\Settings\Settings::get_payment_recharge_settings()
: [];
$uid = (int) ($user_id ?? get_current_user_id());
$transfer_on = !empty($recharge['transfer']['enabled']);
if ($transfer_on && class_exists('AKSRT_Settings_Capabilities') && !AKSRT_Settings_Capabilities::user_can('balance_transfer', $uid)) {
if ($transfer_on && class_exists('\AKSRT\Settings\Capabilities') && !\AKSRT\Settings\Capabilities::user_can('balance_transfer', $uid)) {
$transfer_on = false;
}
$exchange_on = !empty($recharge['exchange']['enabled']);
$all_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_all() : [];
$all_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
$withdraw_on = !empty($all_settings['pay_balance_withdraw_s']);
if ($withdraw_on && class_exists('AKSRT_Settings_Capabilities') && !AKSRT_Settings_Capabilities::user_can('balance_withdraw', $uid)) {
if ($withdraw_on && class_exists('\AKSRT\Settings\Capabilities') && !\AKSRT\Settings\Capabilities::user_can('balance_withdraw', $uid)) {
$withdraw_on = false;
}
$withdraw_min = max(1, (float) ($all_settings['pay_balance_withdraw_lowest_money'] ?? $all_settings['pay_rebate_withdraw_lowest_money'] ?? 50));
$withdraw_pending_hold = 0.0;
$withdraw_history = [];
if ($withdraw_on && class_exists('AKSRT_Withdrawal')) {
$wd_svc = AKSRT_Withdrawal::get_instance();
if ($withdraw_on && class_exists('\AKSRT\Payment\Withdrawal')) {
$wd_svc = \AKSRT\Payment\Withdrawal::get_instance();
$withdraw_pending_hold = $wd_svc->sum_pending_hold((int) ($user_id ?? 0));
$withdraw_history = $wd_svc->get_user_withdrawals((int) ($user_id ?? 0), ['limit' => 30]);
}
$withdraw_processing = $withdraw_pending_hold > 0;
$card_pass_balance = ['enabled' => false, 'desc' => '', 'only_password' => true];
if (class_exists('AKSRT_Charge_Card')) {
$opts = AKSRT_Charge_Card::get_instance()->get_public_options();
if (class_exists('\AKSRT\Payment\ChargeCard')) {
$opts = \AKSRT\Payment\ChargeCard::get_instance()->get_public_options();
$card_pass_balance = is_array($opts['balance'] ?? null) ? $opts['balance'] : $card_pass_balance;
} elseif (!empty($recharge['pass_charge'])) {
$card_pass_balance = is_array($recharge['pass_charge']) ? $recharge['pass_charge'] : $card_pass_balance;
}
$charge_view = [];
if (class_exists('AKSRT_Balance_Service')) {
$charge_view = AKSRT_Balance_Service::get_instance()->get_charge_view((int) $user_id);
if (class_exists('\AKSRT\Credits\BalanceService')) {
$charge_view = \AKSRT\Credits\BalanceService::get_instance()->get_charge_view((int) $user_id);
}
$packages = is_array($charge_view['packages'] ?? null) ? $charge_view['packages'] : [];
$methods = is_array($charge_view['payment_methods'] ?? null) ? $charge_view['payment_methods'] : [];
@@ -101,7 +101,7 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
<?php endif; ?>
<?php if ($withdraw_on) : ?>
<div class="uc-asset-card__foot muted-2-color em09 flex jsb ac mt6">
<span><?php printf(esc_html__('处理中冻结 %s', 'aksrt'), esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::format((float) $withdraw_pending_hold) : number_format_i18n((float) $withdraw_pending_hold, 2))); ?></span>
<span><?php printf(esc_html__('处理中冻结 %s', 'aksrt'), esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format((float) $withdraw_pending_hold) : number_format_i18n((float) $withdraw_pending_hold, 2))); ?></span>
<button type="button" class="muted-color" data-aksrt-withdraw-history-open><?php esc_html_e('提现记录', 'aksrt'); ?></button>
</div>
<?php endif; ?>
@@ -288,12 +288,12 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
<div class="uc-withdraw-history__item border-bottom padding-h10">
<div class="flex jsb ac">
<span class="badg badg-sm <?php echo esc_attr($st_class); ?>"><?php echo esc_html($status_labels[$st] ?? $st); ?></span>
<b class="em12"><?php echo esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::format($gross) : number_format_i18n($gross, 2)); ?></b>
<b class="em12"><?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($gross) : number_format_i18n($gross, 2)); ?></b>
</div>
<div class="muted-2-color em09 mt6">
<?php echo esc_html((string) ($wd['created_at'] ?? '')); ?>
<?php if (abs($gross - $net) > 0.001) : ?>
· <?php printf(esc_html__('到账 %s', 'aksrt'), esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::format($net) : number_format_i18n($net, 2))); ?>
· <?php printf(esc_html__('到账 %s', 'aksrt'), esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($net) : number_format_i18n($net, 2))); ?>
<?php endif; ?>
</div>
<?php if (!empty($wd['note'])) : ?>
@@ -319,8 +319,8 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
</div>
<?php
$wallet_page = max(1, isset($_GET['wallet_page']) ? (int) $_GET['wallet_page'] : 1);
$wlog = class_exists('AKSRT_Balance')
? AKSRT_Balance::get_log(['user_id' => (int) $user_id, 'page' => $wallet_page, 'per_page' => 10])
$wlog = class_exists('\AKSRT\Credits\Balance')
? \AKSRT\Credits\Balance::get_log(['user_id' => (int) $user_id, 'page' => $wallet_page, 'per_page' => 10])
: ['items' => [], 'total' => 0];
if (!empty($wlog['items'])) :
?>
@@ -328,7 +328,7 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
<?php foreach ($wlog['items'] as $row) :
$delta = (float) $row['delta'];
$delta_class = $delta >= 0 ? 'is-positive' : 'is-negative';
$delta_txt = ($delta > 0 ? '+' : '') . (class_exists('AKSRT_Balance') ? AKSRT_Balance::format($delta) : number_format_i18n($delta, 2));
$delta_txt = ($delta > 0 ? '+' : '') . (class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($delta) : number_format_i18n($delta, 2));
?>
<div class="uc-transactions__item">
<div class="uc-transactions__icon <?php echo esc_attr($delta_class); ?>">
@@ -336,7 +336,7 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
</div>
<div class="uc-transactions__info">
<div class="uc-transactions__reason">
<?php echo esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::reason_label((string) $row['reason']) : (string) $row['reason']); ?>
<?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::reason_label((string) $row['reason']) : (string) $row['reason']); ?>
<?php if (!empty($row['remark'])) : ?>
<span class="uc-transactions__remark">(<?php echo esc_html((string) $row['remark']); ?>)</span>
<?php endif; ?>
@@ -349,7 +349,7 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
<?php
printf(
esc_html__('余额 %s', 'aksrt'),
esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::format((float) $row['balance_after']) : number_format_i18n((float) $row['balance_after'], 2))
esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format((float) $row['balance_after']) : number_format_i18n((float) $row['balance_after'], 2))
);
?>
</span>
@@ -44,7 +44,7 @@ if (!empty($show_vip)) {
if ($show_credits) {
require $dir . '/credits-signin.php';
}
if (class_exists('AKSRT_User_Level')) {
if (class_exists('\AKSRT\User\Level')) {
require $dir . '/credits-level.php';
}
@@ -54,7 +54,7 @@ if ($show_wallet || $show_credits) :
if ($active_record === '' || !in_array($active_record, ['balance', 'points', 'points_free', 'points_date'], true)) {
$active_record = $show_wallet ? 'balance' : 'points';
}
$show_tasks = $show_credits && class_exists('AKSRT_Points_Free') && AKSRT_Points_Free::enabled();
$show_tasks = $show_credits && class_exists('\AKSRT\Credits\PointsFree') && \AKSRT\Credits\PointsFree::enabled();
?>
<div class="uc-asset-tabs zib-widget">
<ul class="uc-asset-tabs__nav list-inline tab-nav-theme font-bold">
@@ -82,8 +82,8 @@ if ($show_wallet || $show_credits) :
// Render only the ledger portion by reusing balance log markup.
$user_id = (int) ($user_id ?? 0);
$wallet_page = max(1, isset($_GET['wallet_page']) ? (int) $_GET['wallet_page'] : 1);
$wlog = class_exists('AKSRT_Balance')
? AKSRT_Balance::get_log(['user_id' => $user_id, 'page' => $wallet_page, 'per_page' => 10])
$wlog = class_exists('\AKSRT\Credits\Balance')
? \AKSRT\Credits\Balance::get_log(['user_id' => $user_id, 'page' => $wallet_page, 'per_page' => 10])
: ['items' => [], 'total' => 0];
?>
<div class="uc-transactions uc-transactions--wallet">
@@ -92,7 +92,7 @@ if ($show_wallet || $show_credits) :
<?php foreach ($wlog['items'] as $row) :
$delta = (float) $row['delta'];
$delta_class = $delta >= 0 ? 'is-positive' : 'is-negative';
$delta_txt = ($delta > 0 ? '+' : '') . (class_exists('AKSRT_Balance') ? AKSRT_Balance::format($delta) : number_format_i18n($delta, 2));
$delta_txt = ($delta > 0 ? '+' : '') . (class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($delta) : number_format_i18n($delta, 2));
?>
<div class="uc-transactions__item">
<div class="uc-transactions__icon <?php echo esc_attr($delta_class); ?>">
@@ -100,7 +100,7 @@ if ($show_wallet || $show_credits) :
</div>
<div class="uc-transactions__info">
<div class="uc-transactions__reason">
<?php echo esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::reason_label((string) $row['reason']) : (string) $row['reason']); ?>
<?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::reason_label((string) $row['reason']) : (string) $row['reason']); ?>
<?php if (!empty($row['remark'])) : ?>
<span class="uc-transactions__remark">(<?php echo esc_html((string) $row['remark']); ?>)</span>
<?php endif; ?>
@@ -109,7 +109,7 @@ if ($show_wallet || $show_credits) :
</div>
<div class="uc-transactions__amount">
<span class="uc-transactions__delta <?php echo esc_attr($delta_class); ?>"><?php echo esc_html($delta_txt); ?></span>
<span class="uc-transactions__balance"><?php printf(esc_html__('余额 %s', 'aksrt'), esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::format((float) ($row['balance_after'] ?? 0)) : number_format_i18n((float) ($row['balance_after'] ?? 0), 2))); ?></span>
<span class="uc-transactions__balance"><?php printf(esc_html__('余额 %s', 'aksrt'), esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format((float) ($row['balance_after'] ?? 0)) : number_format_i18n((float) ($row['balance_after'] ?? 0), 2))); ?></span>
<?php if (!empty($row['ref_id'])) : ?>
<span class="uc-transactions__ref muted-2-color em09"><?php printf(esc_html__('单号 %s', 'aksrt'), esc_html((string) $row['ref_id'])); ?></span>
<?php endif; ?>
@@ -61,7 +61,7 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
</div>
</div>
<div class="uc-header__actions">
<?php if (class_exists('AKSRT_User_Badges') && AKSRT_User_Badges::enabled()) : ?>
<?php if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled()) : ?>
<button type="button" class="btn-ghost btn-sm" data-aksrt-badges-open>
<i class="fas fa-award" aria-hidden="true"></i> <?php esc_html_e('我的徽章', 'aksrt'); ?>
</button>
@@ -85,7 +85,7 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
</div>
</div>
<?php if (class_exists('AKSRT_User_Badges') && AKSRT_User_Badges::enabled()) : ?>
<?php if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled()) : ?>
<div class="uc-modal" id="aksrt-badges-modal" hidden data-aksrt-badges-modal data-user-id="<?php echo (int) $user_id; ?>" data-can-wear="1">
<div class="uc-modal__overlay" data-aksrt-badges-close></div>
<div class="uc-modal__dialog" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e('我的徽章', 'aksrt'); ?>">
@@ -9,7 +9,7 @@
defined('ABSPATH') || exit;
$oauth = class_exists('AKSRT_OAuth') ? AKSRT_OAuth::get_instance() : null;
$oauth = class_exists('\AKSRT\Auth\OAuth') ? \AKSRT\Auth\OAuth::get_instance() : null;
$oauth_data = $oauth ? $oauth->get_frontend_bindings_data($user_id) : ['bindings' => [], 'available' => []];
$binding_name_map = [
'github' => 'GitHub',
@@ -25,7 +25,7 @@ if ($show_wallet || $show_credits) :
<a class="uc-asset-mini__card flex1" href="<?php echo esc_url($assets_url); ?>">
<div class="uc-asset-mini__label muted-2-color em09"><?php esc_html_e('余额', 'aksrt'); ?><i class="ml6 fa fa-angle-right em12" aria-hidden="true"></i></div>
<div class="flex jsb ac">
<span class="font-bold c-blue-2"><?php echo esc_html(class_exists('AKSRT_Balance') ? AKSRT_Balance::format($wallet) : number_format_i18n($wallet, 2)); ?></span>
<span class="font-bold c-blue-2"><?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($wallet) : number_format_i18n($wallet, 2)); ?></span>
<i class="fas fa-wallet em14 c-blue-2" aria-hidden="true"></i>
</div>
</a>
+8
View File
@@ -0,0 +1,8 @@
<?php
/**
* Creator revenue class lives at AKSRT\Payment\CreatorRevenue (Composer).
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* AKSRT User system module hub (procedural).
*
* Loads user-parts/*; keeps historical path for bootstrap.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
require_once __DIR__ . '/user-parts/template-registry.php';
require_once __DIR__ . '/user-parts/urls.php';
require_once __DIR__ . '/user-parts/routing.php';
require_once __DIR__ . '/user-parts/account-ajax.php';
@@ -29,11 +29,11 @@ function aksrt_get_user_notifications(int $user_id = 0): array {
$items = [];
$email_verified = true;
if (class_exists('AKSRT_Auth_Service')) {
$email_verified = AKSRT_Auth_Service::user_is_email_verified($user_id);
if (class_exists('\AKSRT\Auth\Service')) {
$email_verified = \AKSRT\Auth\Service::user_is_email_verified($user_id);
}
if (!$email_verified && (!class_exists('AKSRT_Settings') || AKSRT_Settings::notification_enabled('verify_email'))) {
if (!$email_verified && (!class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::notification_enabled('verify_email'))) {
$items[] = [
'type' => 'verify_email',
'title' => __('邮箱待验证', 'aksrt'),
@@ -49,7 +49,7 @@ function aksrt_get_user_notifications(int $user_id = 0): array {
'status' => 'hold',
]);
if ($pending_comments > 0 && (!class_exists('AKSRT_Settings') || AKSRT_Settings::notification_enabled('pending_comments'))) {
if ($pending_comments > 0 && (!class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::notification_enabled('pending_comments'))) {
$items[] = [
'type' => 'pending_comments',
'title' => __('评论待审核', 'aksrt'),
@@ -99,7 +99,7 @@ function aksrt_get_user_inbox_notifications(int $user_id = 0): array {
if ($user_id <= 0) return [];
global $wpdb;
$table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('notification') : '';
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
if ($table === '') {
$items = get_user_meta($user_id, 'aksrt_notifications', true);
return is_array($items) ? array_values($items) : [];
@@ -171,12 +171,12 @@ if (!function_exists('aksrt_cleanup_notifications')) :
function aksrt_cleanup_notifications(): void {
global $wpdb;
$table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('notification') : '';
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
if ($table === '') {
return;
}
$settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_notification_settings() : [
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_notification_settings() : [
'read_retention_days' => 30,
'unread_retention_days' => 180,
'max_per_user' => 200,
@@ -237,7 +237,7 @@ if (!function_exists('aksrt_write_user_inbox_notifications')) :
function aksrt_write_user_inbox_notifications(int $user_id, array $items): void {
if ($user_id <= 0) return;
global $wpdb;
$table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('notification') : '';
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
if ($table === '') {
update_user_meta($user_id, 'aksrt_notifications', array_values(array_slice($items, 0, 50)));
return;
@@ -265,12 +265,12 @@ if (!function_exists('aksrt_add_user_notification')) :
function aksrt_add_user_notification(int $user_id, array $payload): void {
if ($user_id <= 0) return;
$type = sanitize_key((string) ($payload['type'] ?? 'notice'));
if (class_exists('AKSRT_Settings') && !AKSRT_Settings::notification_enabled($type)) {
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::notification_enabled($type)) {
return;
}
global $wpdb;
$table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('notification') : '';
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
$created_at = (string) ($payload['created_at'] ?? current_time('mysql', true));
if ($table === '') {
@@ -306,7 +306,7 @@ if (!function_exists('aksrt_mark_user_notification_read')) :
function aksrt_mark_user_notification_read(int $user_id, string $notification_id = '', bool $mark_all = false): void {
if ($user_id <= 0) return;
global $wpdb;
$table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('notification') : '';
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
if ($table === '') {
$items = aksrt_get_user_inbox_notifications($user_id);
foreach ($items as &$item) {
@@ -345,7 +345,7 @@ if (!function_exists('aksrt_delete_user_notification')) :
function aksrt_delete_user_notification(int $user_id, string $notification_id): void {
if ($user_id <= 0 || $notification_id === '') return;
global $wpdb;
$table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('notification') : '';
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
if ($table === '') {
$items = aksrt_get_user_inbox_notifications($user_id);
$items = array_values(array_filter($items, static function ($item) use ($notification_id) {
@@ -366,7 +366,7 @@ function aksrt_delete_user_notifications(int $user_id, array $notification_ids):
if (empty($ids)) return;
global $wpdb;
$table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('notification') : '';
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
if ($table === '') {
$items = aksrt_get_user_inbox_notifications($user_id);
$items = array_values(array_filter($items, static function ($item) use ($ids) {
@@ -401,12 +401,12 @@ function aksrt_get_user_tab_badge_count(int $user_id = 0): int {
if ($user_id <= 0) {
return 0;
}
if (class_exists('AKSRT_Settings') && !AKSRT_Settings::notification_user_badge_enabled()) {
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::notification_user_badge_enabled()) {
return 0;
}
$count = aksrt_get_user_unread_notification_count($user_id);
if (class_exists('AKSRT_Settings') && AKSRT_Settings::notification_badge_include_stateful()) {
if (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::notification_badge_include_stateful()) {
$count += aksrt_get_user_notification_count($user_id);
}
return $count;
@@ -195,8 +195,8 @@ add_action('wp_ajax_aksrt_send_email_code', function () {
$current_user->display_name,
$code
);
$sent = class_exists( 'AKSRT_Settings' )
? AKSRT_Settings::send_event_email(
$sent = class_exists( '\AKSRT\Settings\Settings' )
? \AKSRT\Settings\Settings::send_event_email(
'change_code', $target_email, $default_subject, $default_content,
[ '{username}' => $current_user->display_name, '{site_name}' => $site_name, '{code}' => $code ]
)
@@ -345,8 +345,8 @@ add_action('wp_ajax_aksrt_change_email', function () {
$current_user->display_name,
$new_email
);
if ( class_exists( 'AKSRT_Settings' ) ) {
AKSRT_Settings::send_event_email(
if ( class_exists( '\AKSRT\Settings\Settings' ) ) {
\AKSRT\Settings\Settings::send_event_email(
'change_notice', $old_email, $default_subject, $default_content,
[ '{username}' => $current_user->display_name, '{site_name}' => $site_name, '{new_email}' => $new_email ]
);
@@ -364,11 +364,11 @@ add_action('wp_ajax_aksrt_change_email', function () {
$verify_url = '';
$verify_message = '';
if ( class_exists( 'AKSRT_Settings' ) && class_exists( 'AKSRT_Auth_Service' )
&& AKSRT_Settings::registration_requires_email_verification() ) {
if ( class_exists( '\AKSRT\Settings\Settings' ) && class_exists( '\AKSRT\Auth\Service' )
&& \AKSRT\Settings\Settings::registration_requires_email_verification() ) {
update_user_meta( $user_id, 'aksrt_email_verified', 0 );
// 用户对自身的 edit_user 权限映射到 'read',因此 admin_send_verification 会通过权限校验。
$verify_result = AKSRT_Auth_Service::admin_send_verification( $user_id, $user_id );
$verify_result = \AKSRT\Auth\Service::admin_send_verification( $user_id, $user_id );
if ( ! empty( $verify_result['success'] ) ) {
$verify_url = function_exists('aksrt_get_verify_email_url') ? aksrt_get_verify_email_url( $user_id ) : '';
$verify_message = __( '请前往新邮箱完成验证,否则下次登录将被拦截。', 'aksrt' );
@@ -261,7 +261,7 @@ function aksrt_get_verify_email_url(int $user_id = 0, array $args = []): string
endif;
// Notifications live in the same user/ domain; bootstrap also loads it.
if (!class_exists('AKSRT_User_Notifications', false) && file_exists(__DIR__ . '/class-aksrt-user-notifications.php')) {
require_once __DIR__ . '/class-aksrt-user-notifications.php';
if (!class_exists('AKSRT_User_Notifications', false) /* procedural module */ && file_exists(dirname(__DIR__) . '/user-notifications.php')) {
require_once dirname(__DIR__) . '/user-notifications.php';
}
@@ -11,49 +11,49 @@ defined('ABSPATH') || exit;
* Register custom widgets.
*/
function aksrt_register_widgets() {
register_widget('AKSRT_About_Widget');
register_widget('AKSRT_Categories_Widget');
register_widget('AKSRT_Tag_Cloud_Widget');
register_widget('AKSRT_Hot_Posts_Widget');
register_widget('AKSRT_Tab_Posts_Widget');
register_widget('AKSRT_Category_Block_Widget');
register_widget('AKSRT_Category_Tabs_Widget');
register_widget('AKSRT_Category_Recommend_Widget');
register_widget('\AKSRT\Widgets\AboutWidget');
register_widget('\AKSRT\Widgets\CategoriesWidget');
register_widget('\AKSRT\Widgets\TagCloudWidget');
register_widget('\AKSRT\Widgets\HotPostsWidget');
register_widget('\AKSRT\Widgets\TabPostsWidget');
register_widget('\AKSRT\Widgets\CategoryBlockWidget');
register_widget('\AKSRT\Widgets\CategoryTabsWidget');
register_widget('\AKSRT\Widgets\CategoryRecommendWidget');
// 第一批通用 widget
register_widget('AKSRT_Search_Widget');
register_widget('AKSRT_Notice_Widget');
register_widget('AKSRT_Recent_Comments_Widget');
register_widget('AKSRT_Friend_Links_Widget');
register_widget('AKSRT_Icon_Cards_Widget');
register_widget('AKSRT_Buttons_Widget');
register_widget('AKSRT_Custom_HTML_Gap_Widget');
register_widget('\AKSRT\Widgets\SearchWidget');
register_widget('\AKSRT\Widgets\NoticeWidget');
register_widget('\AKSRT\Widgets\RecentCommentsWidget');
register_widget('\AKSRT\Widgets\FriendLinksWidget');
register_widget('\AKSRT\Widgets\IconCardsWidget');
register_widget('\AKSRT\Widgets\ButtonsWidget');
register_widget('\AKSRT\Widgets\CustomHtmlGapWidget');
// 公告跑马灯
register_widget('AKSRT_Widget_Announcement');
register_widget('\AKSRT\Widgets\WidgetAnnouncement');
// 用户卡片
register_widget('AKSRT_Widget_User_Card');
register_widget('\AKSRT\Widgets\WidgetUserCard');
// 用户排行榜
register_widget('AKSRT_Widget_User_Ranking');
register_widget('\AKSRT\Widgets\WidgetUserRanking');
// 图文封面卡片
register_widget('AKSRT_Widget_Cover_Cards');
register_widget('\AKSRT\Widgets\WidgetCoverCards');
// 视频播放器
register_widget('AKSRT_Widget_Video_Player');
register_widget('\AKSRT\Widgets\WidgetVideoPlayer');
// 语言切换器
register_widget('AKSRT_Widget_Lang_Switch');
register_widget('\AKSRT\Widgets\WidgetLangSwitch');
// 一言轮播
register_widget('AKSRT_Widget_Yiyan');
register_widget('\AKSRT\Widgets\WidgetYiyan');
// Shop product widgets (§6.9)
register_widget('AKSRT_Widget_Product_List');
register_widget('AKSRT_Widget_Product_Oneline');
register_widget('AKSRT_Widget_Product_Tab');
register_widget('\AKSRT\Widgets\WidgetProductList');
register_widget('\AKSRT\Widgets\WidgetProductOneline');
register_widget('\AKSRT\Widgets\WidgetProductTab');
aksrt_maybe_repair_sidebar_blog_widgets();
}
+2 -2
View File
@@ -9,8 +9,8 @@ defined('ABSPATH') || exit;
get_header();
$page_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_post_page_settings()
$page_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_post_page_settings()
: ['reading_progress' => false, 'lightbox' => true];
$page_id = get_queried_object_id();
$page_content_style = get_post_meta($page_id, 'page_content_style', true);
+6 -6
View File
@@ -26,14 +26,14 @@ $search_placeholder = function_exists('aksrt_get_search_placeholder') ? aksrt_ge
$search_type = $search_state['type'];
$search_type_options = !empty($search_state['types']) && is_array($search_state['types']) ? $search_state['types'] : ['post' => __('文章', 'aksrt')];
$hot_keywords = function_exists('aksrt_get_search_hot_keywords') ? aksrt_get_search_hot_keywords() : [];
$filter_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_post_filter_settings()
$filter_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_post_filter_settings()
: ['enabled' => false, 'categories' => true, 'tags' => false, 'sort' => true];
$list_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_post_list_style_settings()
$list_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_post_list_style_settings()
: ['render_mode' => 'card', 'card_style' => 'standard'];
$other_page_settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_other_page_settings()
$other_page_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_other_page_settings()
: ['page_search_sidebar' => true];
$popular_categories = get_categories([
'taxonomy' => 'category',
+5 -213
View File
@@ -1,217 +1,9 @@
<?php
/**
* Script to replace method bodies with delegation stubs in class-aksrt-forum.php
* Obsolete one-off script (pre-PSR-4). Forum class is now AKSRT\Forum\Forum under src/AKSRT/.
*
* @package AKSRT
*/
$file = __DIR__ . '/inc/classes/forum/class-aksrt-forum.php';
$content = file_get_contents($file);
if ($content === false) {
echo "ERROR: Cannot read file\n";
exit(1);
}
/**
* Replace a method body with a one-liner delegation.
* Finds the method signature, then locates the matching closing brace.
*/
function replace_method(string $content, string $signature, string $body): string {
$pos = strpos($content, $signature);
if ($pos === false) {
echo "WARNING: Could not find: $signature\n";
return $content;
}
// Find the opening brace of the method (first { after the signature)
$open_brace = strpos($content, '{', $pos + strlen($signature));
if ($open_brace === false) {
$open_brace = strpos($content, '{', $pos);
if ($open_brace === false) {
echo "WARNING: Could not find opening brace for: $signature\n";
return $content;
}
}
// Find matching closing brace by counting brace depth
$depth = 1;
$i = $open_brace + 1;
$len = strlen($content);
$in_string_single = false;
$in_string_double = false;
$in_line_comment = false;
$in_block_comment = false;
while ($i < $len && $depth > 0) {
$ch = $content[$i];
$next = ($i + 1 < $len) ? $content[$i + 1] : '';
if ($in_line_comment) {
if ($ch === "\n") $in_line_comment = false;
$i++;
continue;
}
if ($in_block_comment) {
if ($ch === '*' && $next === '/') { $in_block_comment = false; $i += 2; continue; }
$i++;
continue;
}
if ($in_string_single) {
if ($ch === '\\') { $i += 2; continue; }
if ($ch === "'") $in_string_single = false;
$i++;
continue;
}
if ($in_string_double) {
if ($ch === '\\') { $i += 2; continue; }
if ($ch === '"') $in_string_double = false;
$i++;
continue;
}
if ($ch === '/' && $next === '/') { $in_line_comment = true; $i += 2; continue; }
if ($ch === '/' && $next === '*') { $in_block_comment = true; $i += 2; continue; }
if ($ch === "'") { $in_string_single = true; $i++; continue; }
if ($ch === '"') { $in_string_double = true; $i++; continue; }
if ($ch === '{') $depth++;
elseif ($ch === '}') $depth--;
$i++;
}
if ($depth !== 0) {
echo "WARNING: Could not find matching closing brace for: $signature\n";
return $content;
}
$close_brace = $i - 1;
// Get indentation of the method
$line_start = strrpos(substr($content, 0, $pos), "\n");
if ($line_start === false) $line_start = 0;
else $line_start++;
$indent = '';
for ($j = $line_start; $j < $pos; $j++) {
if ($content[$j] === ' ' || $content[$j] === "\t") $indent .= $content[$j];
else break;
}
// Replace from open_brace to close_brace (inclusive)
$replacement = "{\n" . $indent . " " . $body . "\n" . $indent . "}";
$content = substr($content, 0, $open_brace) . $replacement . substr($content, $close_brace + 1);
return $content;
}
// --- DRAFT SERVICE METHODS ---
$content = replace_method($content,
'public function publish_draft(int $user_id, int $draft_id, array $data)',
'return $this->draft_service()->publish_draft($user_id, $draft_id, $data);');
$content = replace_method($content,
'public function ajax_delete_draft(): void',
'$this->draft_service()->ajax_delete_draft();');
$content = replace_method($content,
'public function ajax_load_draft(): void',
'$this->draft_service()->ajax_load_draft();');
$content = replace_method($content,
'public function ajax_save_draft(): void',
'$this->draft_service()->ajax_save_draft();');
$content = replace_method($content,
'public function load_draft_data(int $user_id, int $draft_id): ?array',
'return $this->draft_service()->load_draft_data($user_id, $draft_id);');
$content = replace_method($content,
'public function delete_draft(int $user_id, int $draft_id): bool',
'return $this->draft_service()->delete_draft($user_id, $draft_id);');
$content = replace_method($content,
'public function get_user_drafts(int $user_id, int $limit = 20): array',
'return $this->draft_service()->get_user_drafts($user_id, $limit);');
$content = replace_method($content,
'public function get_user_draft_count(int $user_id): int',
'return $this->draft_service()->get_user_draft_count($user_id);');
$content = replace_method($content,
'public function save_draft(int $user_id, array $data)',
'return $this->draft_service()->save_draft($user_id, $data);');
// --- COMMENT SERVICE METHODS ---
$content = replace_method($content,
'public function get_commenter_badge(int $user_id, int $topic_id): ?array',
'return $this->comment_service()->get_commenter_badge($user_id, $topic_id);');
$content = replace_method($content,
'public function is_hot_comment(int $comment_id): bool',
'return $this->comment_service()->is_hot_comment($comment_id);');
$content = replace_method($content,
'public function maybe_mark_hot_comment(int $comment_id): bool',
'return $this->comment_service()->maybe_mark_hot_comment($comment_id);');
$content = replace_method($content,
'public function set_comment_topping(int $comment_id, int $level): bool',
'return $this->comment_service()->set_comment_topping($comment_id, $level);');
$sig_forum_comments = "public function get_forum_comments(int \$topic_id, string \$sort = 'newest', bool \$author_only = false, int \$page = 1, int \$per_page = 30): array";
$content = replace_method($content, $sig_forum_comments,
'return $this->comment_service()->get_forum_comments($topic_id, $sort, $author_only, $page, $per_page);');
$content = replace_method($content,
'public function get_adopted_comment_id(int $topic_id): int',
'return $this->comment_service()->get_adopted_comment_id($topic_id);');
$content = replace_method($content,
'public function adopt_answer(int $topic_id, int $comment_id, int $operator_id)',
'return $this->comment_service()->adopt_answer($topic_id, $comment_id, $operator_id);');
$content = replace_method($content,
'public function render_forum_comments(array $comments, int $topic_id, int $adopted_id = 0): void',
'$this->comment_service()->render_forum_comments($comments, $topic_id, $adopted_id);');
$content = replace_method($content,
'public function ajax_comment_topping(): void',
'$this->comment_service()->ajax_comment_topping();');
$content = replace_method($content,
'public function ajax_forum_comments(): void',
'$this->comment_service()->ajax_forum_comments();');
// --- SCORE/NOTIFICATION SERVICE METHODS ---
$content = replace_method($content,
'public function on_forum_comment_posted(int $comment_id, $approved, array $commentdata = []): void',
'$this->score_service()->on_forum_comment_posted($comment_id, $approved, $commentdata);');
$content = replace_method($content,
'public function notify_topic_scored(int $topic_id, int $scorer_id, int $amount): void',
'$this->score_service()->notify_topic_scored($topic_id, $scorer_id, $amount);');
$content = replace_method($content,
'public function notify_topic_reply(int $topic_id, int $commenter_id): void',
'$this->score_service()->notify_topic_reply($topic_id, $commenter_id);');
$content = replace_method($content,
'public function notify_moderation_result(int $topic_id, string $action, int $operator_id): void',
'$this->score_service()->notify_moderation_result($topic_id, $action, $operator_id);');
$content = replace_method($content,
'public function notify_topic_pending(int $topic_id, int $author_id): void',
'$this->score_service()->notify_topic_pending($topic_id, $author_id);');
$content = replace_method($content,
'private function notify(int $user_id, string $type, string $content, array $data = []): void',
'$this->score_service()->notify($user_id, $type, $content, $data);');
// --- Write result ---
$result = file_put_contents($file, $content);
if ($result === false) {
echo "ERROR: Cannot write file\n";
exit(1);
}
echo "SUCCESS: File updated. New size: " . strlen($content) . " bytes\n";
echo "Line count: " . (substr_count($content, "\n") + 1) . "\n";
fwrite(STDERR, "slim-forum.php is obsolete after the PSR-4 migration.\n");
exit(1);
@@ -1,15 +1,13 @@
<?php
/**
* AKSRT Admin — AI Controller
*
* REST for AI connection config + SEO/writing generation.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
class AIController extends ControllerBase {
private static $instance = null;
@@ -72,14 +70,14 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
if (current_user_can('edit_posts')) {
return true;
}
if (class_exists('AKSRT_Front_Submit')) {
return (bool) AKSRT_Front_Submit::get_instance()->can_submit();
if (class_exists('\AKSRT\Core\FrontSubmit')) {
return (bool) \AKSRT\Core\FrontSubmit::get_instance()->can_submit();
}
return false;
}
public function get_status(): WP_REST_Response {
if (!class_exists('AKSRT_AI')) {
public function get_status(): \WP_REST_Response {
if (!class_exists('\AKSRT\Ai\AI')) {
return $this->success(['data' => [
'enabled' => false,
'provider' => 'none',
@@ -89,11 +87,11 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
]]);
}
return $this->success(['data' => AKSRT_AI::get_instance()->get_status()]);
return $this->success(['data' => \AKSRT\Ai\AI::get_instance()->get_status()]);
}
public function update_settings(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_AI')) {
public function update_settings(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Ai\AI')) {
return $this->error(__('AI 模块未加载', 'aksrt'), 500);
}
@@ -128,11 +126,11 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
}
}
$success = AKSRT_AI::get_instance()->update_config($config);
$success = \AKSRT\Ai\AI::get_instance()->update_config($config);
if ($success) {
return $this->success([
'message' => __('AI 设置已保存', 'aksrt'),
'data' => AKSRT_AI::get_instance()->get_status(),
'data' => \AKSRT\Ai\AI::get_instance()->get_status(),
]);
}
return $this->error(__('保存失败', 'aksrt'));
@@ -141,8 +139,8 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /ai/seo-generate — 从 post/term 实体生成 SEO 三字段。
*/
public function seo_generate(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_AI_SEO')) {
public function seo_generate(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Ai\AISEO')) {
return $this->error(__('AI SEO 模块未加载', 'aksrt'), 500);
}
@@ -164,7 +162,7 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
}
}
$result = AKSRT_AI_SEO::get_instance()->generate_fields($type, $id);
$result = \AKSRT\Ai\AISEO::get_instance()->generate_fields($type, $id);
if (empty($result['success'])) {
return $this->error((string) ($result['message'] ?? __('生成失败', 'aksrt')));
}
@@ -172,8 +170,8 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
return $this->success(['data' => $result['data']]);
}
public function seo_suggest(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_AI_SEO')) {
public function seo_suggest(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Ai\AISEO')) {
return $this->error(__('AI SEO 模块未加载', 'aksrt'), 500);
}
@@ -190,7 +188,7 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
return $this->error(__('标题不能为空', 'aksrt'));
}
$result = AKSRT_AI_SEO::get_instance()->suggest($title, $content);
$result = \AKSRT\Ai\AISEO::get_instance()->suggest($title, $content);
if (!empty($result['success'])) {
return $this->success(['data' => $result['data']]);
}
@@ -198,8 +196,8 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
return $this->error((string) ($result['message'] ?? __('生成失败', 'aksrt')));
}
public function summary_suggest(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_AI') || !class_exists('AKSRT_AI_Prompt')) {
public function summary_suggest(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Ai\AI') || !class_exists('\AKSRT\Ai\AIPrompt')) {
return $this->error(__('AI 模块未加载', 'aksrt'), 500);
}
@@ -223,7 +221,7 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
return $this->error(__('内容不能为空,请先在编辑器填写正文后再生成摘要', 'aksrt'), 422);
}
$ai = AKSRT_AI::get_instance();
$ai = \AKSRT\Ai\AI::get_instance();
if (!$ai->is_available()) {
return $this->error(
__('AI 服务未启用或未配置。请到「扩展 → AI 辅助」启用并填写 API Key(或配置 WordPress AI Connectors)。', 'aksrt'),
@@ -232,7 +230,7 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
}
// Prefer excerpt-oriented prompt when title is present.
$prompt_builder = AKSRT_AI_Prompt::get_instance();
$prompt_builder = \AKSRT\Ai\AIPrompt::get_instance();
if ($title !== '' && method_exists($prompt_builder, 'build_excerpt_prompt')) {
$prompt = $prompt_builder->build_excerpt_prompt($title, $content);
} else {
@@ -278,8 +276,8 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
return $this->error($message, $status);
}
public function tags_suggest(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_AI') || !class_exists('AKSRT_AI_Prompt')) {
public function tags_suggest(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Ai\AI') || !class_exists('\AKSRT\Ai\AIPrompt')) {
return $this->error(__('AI 模块未加载', 'aksrt'), 500);
}
@@ -291,8 +289,8 @@ class AKSRT_Admin_AI_Controller extends AKSRT_Admin_Controller_Base {
return $this->error(__('标题或内容不能为空', 'aksrt'));
}
$prompt = AKSRT_AI_Prompt::get_instance()->build_tags_prompt($title, $content);
$result = AKSRT_AI::get_instance()->generate_text($prompt, [
$prompt = \AKSRT\Ai\AIPrompt::get_instance()->build_tags_prompt($title, $content);
$result = \AKSRT\Ai\AI::get_instance()->generate_text($prompt, [
'max_tokens' => 300,
'temperature' => 0.5,
]);
@@ -1,18 +1,13 @@
<?php
/**
* AKSRT Theme Admin
*
* Admin SPA container + legacy REST compatibility façade.
* New domain routes live in inc/classes/admin/* controllers, while this class
* remains the orchestrator and keeps only shell/bootstrap and public AJAX
* helpers that are intentionally centralized.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin {
class Admin {
private static $instance = null;
private const PAGE_SLUG = 'aksrt-settings';
@@ -154,7 +149,7 @@ class AKSRT_Admin {
return ['index.js unreadable'];
}
if (!preg_match_all('/\\.\\/([A-Za-z0-9_.-]+\\.js)/', $src, $matches)) {
if (!preg_match_all('/\.\/([A-Za-z0-9_.-]+\.js)/', $src, $matches)) {
return [];
}
@@ -177,20 +172,20 @@ class AKSRT_Admin {
public function register_rest_routes(): void {
$controllers = [
'AKSRT_Admin_Global_Controller',
'AKSRT_Admin_Page_Display_Controller',
'AKSRT_Admin_Post_List_Controller',
'AKSRT_Admin_Permissions_Controller',
'AKSRT_Admin_User_Controller',
'AKSRT_Admin_Payment_Controller',
'AKSRT_Admin_Tools_Controller',
'AKSRT_Admin_Import_Export_Controller',
'AKSRT_Admin_Shop_Controller',
'AKSRT_Admin_Forum_Controller',
'AKSRT_Admin_Extension_Controller',
'AKSRT_Admin_Comment_Controller',
'AKSRT_Admin_Message_Controller',
'AKSRT_Admin_AI_Controller',
'GlobalController',
'PageDisplayController',
'PostListController',
'PermissionsController',
'UserController',
'PaymentController',
'ToolsController',
'ImportExportController',
'ShopController',
'ForumController',
'ExtensionController',
'CommentController',
'MessageController',
'AIController',
];
foreach ($controllers as $class_name) {
@@ -319,7 +314,7 @@ class AKSRT_Admin {
$query_vars['post_type'] = 'post';
}
$query = new WP_Query($query_vars);
$query = new \WP_Query($query_vars);
ob_start();
if (function_exists('aksrt_render_post_list')) {
aksrt_render_post_list($query, $render_config, true);
@@ -1,15 +1,13 @@
<?php
/**
* Admin REST Controller — Comments
*
* Provides REST endpoints for comment management under aksrt/v1/comments.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Comment_Controller extends AKSRT_Admin_Controller_Base {
class CommentController extends ControllerBase {
private static $instance = null;
@@ -103,7 +101,7 @@ class AKSRT_Admin_Comment_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /comments — List comments with filtering.
*/
public function list_comments(WP_REST_Request $request): WP_REST_Response {
public function list_comments(\WP_REST_Request $request): \WP_REST_Response {
$args = [
'number' => min(100, (int) $request->get_param('per_page')),
'offset' => ((int) $request->get_param('page') - 1) * (int) $request->get_param('per_page'),
@@ -165,7 +163,7 @@ class AKSRT_Admin_Comment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /comments — Create a comment.
*/
public function create_comment(WP_REST_Request $request): WP_REST_Response {
public function create_comment(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
$post_id = (int) $request->get_param('post_id');
$content = trim((string) $request->get_param('content'));
@@ -200,7 +198,7 @@ class AKSRT_Admin_Comment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /comments/{id}/status — Approve/unapprove/spam/trash.
*/
public function update_comment_status(WP_REST_Request $request): WP_REST_Response {
public function update_comment_status(\WP_REST_Request $request): \WP_REST_Response {
$comment_id = (int) $request->get_param('id');
$new_status = $request->get_param('status');
$comment = get_comment($comment_id);
@@ -233,7 +231,7 @@ class AKSRT_Admin_Comment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /comments/{id} — Edit comment content.
*/
public function update_comment(WP_REST_Request $request): WP_REST_Response {
public function update_comment(\WP_REST_Request $request): \WP_REST_Response {
$comment_id = (int) $request->get_param('id');
$content = trim((string) $request->get_param('content'));
$comment = get_comment($comment_id);
@@ -258,7 +256,7 @@ class AKSRT_Admin_Comment_Controller extends AKSRT_Admin_Controller_Base {
/**
* DELETE /comments/{id} — Delete a comment.
*/
public function delete_comment(WP_REST_Request $request): WP_REST_Response {
public function delete_comment(\WP_REST_Request $request): \WP_REST_Response {
$comment_id = (int) $request->get_param('id');
$comment = get_comment($comment_id);
@@ -277,7 +275,7 @@ class AKSRT_Admin_Comment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /comments/bulk — Bulk action on comments.
*/
public function bulk_action(WP_REST_Request $request): WP_REST_Response {
public function bulk_action(\WP_REST_Request $request): \WP_REST_Response {
$body = $request->get_json_params();
$ids = array_map('absint', $body['ids'] ?? []);
$action = sanitize_text_field($body['action'] ?? '');
@@ -325,7 +323,7 @@ class AKSRT_Admin_Comment_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /comments/post/{post_id} — Public: list comments for a post with nesting.
*/
public function get_post_comments(WP_REST_Request $request): WP_REST_Response {
public function get_post_comments(\WP_REST_Request $request): \WP_REST_Response {
$post_id = (int) $request->get_param('post_id');
$page = max(1, (int) $request->get_param('page'));
$per_page = min(50, max(1, (int) $request->get_param('per_page')));
@@ -1,19 +1,16 @@
<?php
/**
* AKSRT Admin Controller Base
*
* 所有后台业务域控制器的基类。
* 提供通用的权限检查、响应格式化、设置读写等基础设施。
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
abstract class AKSRT_Admin_Controller_Base {
abstract class ControllerBase {
/**
* REST API namespace (shared with AKSRT_Admin).
* REST API namespace (shared with Admin).
*/
const API_NAMESPACE = 'aksrt/v1';
@@ -33,15 +30,15 @@ abstract class AKSRT_Admin_Controller_Base {
/**
* Create a standard success response.
*/
protected function success($data = [], int $status = 200): WP_REST_Response {
return new WP_REST_Response(array_merge(['success' => true], $data), $status);
protected function success($data = [], int $status = 200): \WP_REST_Response {
return new \WP_REST_Response(array_merge(['success' => true], $data), $status);
}
/**
* Create a standard error response.
*/
protected function error(string $message, int $status = 400): WP_REST_Response {
return new WP_REST_Response([
protected function error(string $message, int $status = 400): \WP_REST_Response {
return new \WP_REST_Response([
'success' => false,
'message' => $message,
], $status);
@@ -50,7 +47,7 @@ abstract class AKSRT_Admin_Controller_Base {
/**
* Read JSON request body safely.
*/
protected function get_json_params(WP_REST_Request $request): array {
protected function get_json_params(\WP_REST_Request $request): array {
$params = $request->get_json_params();
return is_array($params) ? $params : [];
}
@@ -102,7 +99,7 @@ abstract class AKSRT_Admin_Controller_Base {
protected function register_section_routes(string $route_slug, string $domain): void {
register_rest_route(self::API_NAMESPACE, '/settings/' . $route_slug . '/(?P<section>[a-z0-9_-]+)', [
'methods' => 'GET',
'callback' => function (WP_REST_Request $request) use ($domain) {
'callback' => function (\WP_REST_Request $request) use ($domain) {
return $this->get_section_settings($request, $domain);
},
'permission_callback' => [$this, 'check_permission'],
@@ -110,15 +107,15 @@ abstract class AKSRT_Admin_Controller_Base {
register_rest_route(self::API_NAMESPACE, '/settings/' . $route_slug . '/(?P<section>[a-z0-9_-]+)', [
'methods' => 'POST',
'callback' => function (WP_REST_Request $request) use ($domain) {
'callback' => function (\WP_REST_Request $request) use ($domain) {
return $this->save_section_settings($request, $domain);
},
'permission_callback' => [$this, 'check_permission'],
]);
}
protected function get_section_settings(WP_REST_Request $request, string $domain): WP_REST_Response {
$provider = AKSRT_Admin_Schema_Provider::get_instance();
protected function get_section_settings(\WP_REST_Request $request, string $domain): \WP_REST_Response {
$provider = SchemaProvider::get_instance();
$section = (string) $request->get_param('section');
$schema = $provider->get_section_schema($domain, $section);
@@ -137,8 +134,8 @@ abstract class AKSRT_Admin_Controller_Base {
]);
}
protected function save_section_settings(WP_REST_Request $request, string $domain): WP_REST_Response {
$provider = AKSRT_Admin_Schema_Provider::get_instance();
protected function save_section_settings(\WP_REST_Request $request, string $domain): \WP_REST_Response {
$provider = SchemaProvider::get_instance();
$section = (string) $request->get_param('section');
$schema = $provider->get_section_schema($domain, $section);
@@ -1,16 +1,13 @@
<?php
/**
* AKSRT Admin — Extension Controller
*
* Owns REST routes for the "扩展&增强" domain.
* Aggregates real service status from SMS, WeChat, Captcha, IP Geo, Content Audit, Search Push.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
class ExtensionController extends ControllerBase {
private static $instance = null;
private $admin;
@@ -20,7 +17,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
return self::$instance;
}
public function set_admin(AKSRT_Admin $admin): void {
public function set_admin(Admin $admin): void {
$this->admin = $admin;
}
@@ -78,7 +75,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /extensions/overview — real extension status aggregation.
*/
public function get_overview(): WP_REST_Response {
public function get_overview(): \WP_REST_Response {
$services = $this->collect_service_statuses();
$installed = 0;
@@ -111,7 +108,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function get_docs_stats(): WP_REST_Response {
public function get_docs_stats(): \WP_REST_Response {
return $this->success([
'data' => [
'total' => 0,
@@ -124,7 +121,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /docs/search — search document pages by keyword.
*/
public function search_docs(WP_REST_Request $request): WP_REST_Response {
public function search_docs(\WP_REST_Request $request): \WP_REST_Response {
return $this->success([
'data' => [
'results' => [],
@@ -136,7 +133,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /settings/extensions — aggregated extension service status.
*/
public function get_extensions_status(): WP_REST_Response {
public function get_extensions_status(): \WP_REST_Response {
$services = $this->collect_service_statuses();
$flat = [];
@@ -157,9 +154,9 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /settings/security — security settings summary with real service status.
*/
public function get_security_settings(): WP_REST_Response {
public function get_security_settings(): \WP_REST_Response {
$services = $this->collect_service_statuses();
$settings = AKSRT_Settings::get_all();
$settings = \AKSRT\Settings\Settings::get_all();
$email_gate_enabled = true;
if (defined('AKSRT_NO_EMAIL_GATE') && AKSRT_NO_EMAIL_GATE) {
@@ -169,7 +166,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
$captcha = function_exists('aksrt_get_captcha_status_summary')
? aksrt_get_captcha_status_summary()
: ['enabled' => false, 'provider' => '', 'configured' => false, 'scenes' => []];
$features = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_cms_features() : [];
$features = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_cms_features() : [];
$scenes = is_array($captcha['scenes'] ?? null) ? $captcha['scenes'] : [];
$risk_switches = [
@@ -206,7 +203,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /settings/security — save risk switches.
*/
public function save_security_settings(WP_REST_Request $request): WP_REST_Response {
public function save_security_settings(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$risk_switches = $params['risk_switches'] ?? [];
@@ -223,7 +220,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
$sanitized = $this->sanitize_fields($risk_switches, $allowed);
// Merge into main settings
$all = AKSRT_Settings::get_all();
$all = \AKSRT\Settings\Settings::get_all();
foreach ($sanitized as $key => $val) {
$all[$key] = $val;
}
@@ -239,7 +236,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /security/audit-log — recent security audit entries.
*/
public function get_audit_log(): WP_REST_Response {
public function get_audit_log(): \WP_REST_Response {
global $wpdb;
$limit = 20;
@@ -293,7 +290,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
* Admin tests force a live lookup (skip enable-gate + cache) so operators can
* verify credentials before flipping the runtime switch.
*/
public function test_ip_geo(WP_REST_Request $request): WP_REST_Response {
public function test_ip_geo(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$ip = trim((string) ($params['ip'] ?? ''));
@@ -301,11 +298,11 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
return $this->error(__('请输入有效的 IP 地址', 'aksrt'), 422);
}
if (!class_exists('AKSRT_IP_Geo')) {
if (!class_exists('\AKSRT\Extensions\IPGeo')) {
return $this->error(__('IP 归属地服务不可用', 'aksrt'), 500);
}
$geo = AKSRT_IP_Geo::get_instance();
$geo = \AKSRT\Extensions\IPGeo::get_instance();
$status = $geo->get_status();
$result = $geo->lookup($ip, true);
@@ -355,7 +352,7 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
* Admin tests force a live provider call (skip enable gates + failure allow policy)
* so operators can verify credentials before flipping runtime switches.
*/
public function test_content_audit(WP_REST_Request $request): WP_REST_Response {
public function test_content_audit(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$text = trim((string) ($params['text'] ?? ''));
@@ -363,11 +360,11 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
return $this->error(__('请输入要测试的文本内容', 'aksrt'), 422);
}
if (!class_exists('AKSRT_Content_Audit')) {
if (!class_exists('\AKSRT\Extensions\ContentAudit')) {
return $this->error(__('内容审核服务不可用', 'aksrt'), 500);
}
$audit = AKSRT_Content_Audit::get_instance();
$audit = \AKSRT\Extensions\ContentAudit::get_instance();
$status = $audit->get_status();
$result = $audit->audit_text($text, true);
@@ -444,15 +441,15 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
$services = [];
// SMS
if (class_exists('AKSRT_SMS')) {
$services['sms'] = AKSRT_SMS::get_instance()->get_provider_status();
if (class_exists('\AKSRT\Sms\SMS')) {
$services['sms'] = \AKSRT\Sms\SMS::get_instance()->get_provider_status();
} else {
$services['sms'] = ['enabled' => false, 'provider' => 'none', 'configured' => false, 'available' => false, 'verified' => false, 'transport' => '', 'missing_fields' => []];
}
// WeChat
if (class_exists('AKSRT_WeChat_Notify')) {
$services['wechat'] = AKSRT_WeChat_Notify::get_instance()->get_status();
if (class_exists('\AKSRT\Payment\WeChatNotify')) {
$services['wechat'] = \AKSRT\Payment\WeChatNotify::get_instance()->get_status();
} else {
$services['wechat'] = ['enabled' => false, 'provider' => '', 'configured' => false, 'available' => false, 'verified' => false, 'transport' => '', 'missing_fields' => []];
}
@@ -473,22 +470,22 @@ class AKSRT_Admin_Extension_Controller extends AKSRT_Admin_Controller_Base {
];
// IP Geo
if (class_exists('AKSRT_IP_Geo')) {
$services['ip_geo'] = AKSRT_IP_Geo::get_instance()->get_status();
if (class_exists('\AKSRT\Extensions\IPGeo')) {
$services['ip_geo'] = \AKSRT\Extensions\IPGeo::get_instance()->get_status();
} else {
$services['ip_geo'] = ['enabled' => false, 'provider' => '', 'configured' => false, 'available' => false, 'verified' => false, 'transport' => '', 'missing_fields' => []];
}
// Content Audit
if (class_exists('AKSRT_Content_Audit')) {
$services['audit'] = AKSRT_Content_Audit::get_instance()->get_status();
if (class_exists('\AKSRT\Extensions\ContentAudit')) {
$services['audit'] = \AKSRT\Extensions\ContentAudit::get_instance()->get_status();
} else {
$services['audit'] = ['enabled' => false, 'provider' => '', 'configured' => false, 'available' => false, 'verified' => false, 'transport' => '', 'missing_fields' => []];
}
// Search Push
if (class_exists('AKSRT_Search_Push')) {
$services['push'] = AKSRT_Search_Push::get_instance()->get_status();
if (class_exists('\AKSRT\Extensions\SearchPush')) {
$services['push'] = \AKSRT\Extensions\SearchPush::get_instance()->get_status();
} else {
$services['push'] = ['enabled' => false, 'provider' => '', 'configured' => false, 'available' => false, 'verified' => false, 'transport' => '', 'missing_fields' => []];
}
@@ -1,15 +1,15 @@
<?php
/**
* Forum REST controller.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
use AKSRT_Admin_Forum_Controller_Part_1;
use AKSRT_Admin_Forum_Controller_Part_2;
class ForumController extends ControllerBase {
use ForumControllerPart1;
use ForumControllerPart2;
private static $instance = null;
@@ -23,7 +23,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
return self::$instance;
}
public function set_admin(AKSRT_Admin $admin): void {
public function set_admin(Admin $admin): void {
$this->admin = $admin;
}
@@ -227,7 +227,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function get_overview(): WP_REST_Response {
public function get_overview(): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->success(['data' => ['stats' => [], 'boards' => [], 'recent_topics' => [], 'pending_applications' => []]]);
@@ -236,7 +236,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
$pending_topics = $forum->get_topic_list([
'limit' => 6,
'status' => 'pending',
'review_status' => AKSRT_Forum::REVIEW_PENDING,
'review_status' => \AKSRT\Forum\Forum::REVIEW_PENDING,
'viewer_user_id' => get_current_user_id(),
'include_hidden' => true,
]);
@@ -246,12 +246,12 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
'stats' => $forum->get_stats(),
'boards' => array_slice($forum->get_boards(), 0, 6),
'pending_topics' => $pending_topics['items'],
'pending_applications' => array_slice($forum->get_moderator_application_list(['status' => AKSRT_Forum::APPLICATION_PENDING]), 0, 6),
'pending_applications' => array_slice($forum->get_moderator_application_list(['status' => \AKSRT\Forum\Forum::APPLICATION_PENDING]), 0, 6),
],
]);
}
public function get_boards(): WP_REST_Response {
public function get_boards(): \WP_REST_Response {
$forum = $this->get_forum_service();
$items = $forum ? $forum->get_boards() : [];
@@ -263,7 +263,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function create_board(WP_REST_Request $request): WP_REST_Response {
public function create_board(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -286,7 +286,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
], 201);
}
public function update_board(WP_REST_Request $request): WP_REST_Response {
public function update_board(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -305,7 +305,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
return $this->success(['message' => __('版块已更新', 'aksrt')]);
}
public function delete_board(WP_REST_Request $request): WP_REST_Response {
public function delete_board(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -324,7 +324,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
return $this->success(['message' => __('版块已删除', 'aksrt')]);
}
public function reorder_boards(WP_REST_Request $request): WP_REST_Response {
public function reorder_boards(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -345,7 +345,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
// §7.0 Plate CPT handlers
// ================================================================
public function get_plates(WP_REST_Request $request): WP_REST_Response {
public function get_plates(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->success(['data' => ['items' => [], 'total' => 0]]);
@@ -371,7 +371,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function get_plate(WP_REST_Request $request): WP_REST_Response {
public function get_plate(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -386,7 +386,7 @@ class AKSRT_Admin_Forum_Controller extends AKSRT_Admin_Controller_Base {
return $this->success(['data' => $plate]);
}
public function create_plate(WP_REST_Request $request): WP_REST_Response {
public function create_plate(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -1,9 +1,15 @@
<?php
/**
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
trait AKSRT_Admin_Forum_Controller_Part_1 {
trait ForumControllerPart1 {
public function update_plate(WP_REST_Request $request): WP_REST_Response {
public function update_plate(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -20,7 +26,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
return $this->success(['message' => __('版块已更新', 'aksrt')]);
}
public function delete_plate(WP_REST_Request $request): WP_REST_Response {
public function delete_plate(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -39,7 +45,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
return $this->success(['message' => __('版块已删除', 'aksrt')]);
}
public function reorder_plates(WP_REST_Request $request): WP_REST_Response {
public function reorder_plates(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -56,7 +62,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
return $this->success(['message' => __('排序已更新', 'aksrt')]);
}
public function toggle_follow_plate(WP_REST_Request $request): WP_REST_Response {
public function toggle_follow_plate(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -69,7 +75,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
return $this->success($result);
}
public function get_plate_categories(): WP_REST_Response {
public function get_plate_categories(): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->success(['data' => []]);
@@ -78,7 +84,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
return $this->success(['data' => $forum->get_plate_categories()]);
}
public function get_sorted_plates(WP_REST_Request $request): WP_REST_Response {
public function get_sorted_plates(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->success(['data' => []]);
@@ -91,7 +97,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
return $this->success(['data' => $forum->get_sorted_plates($orderby, $order, $limit)]);
}
public function get_topics(WP_REST_Request $request): WP_REST_Response {
public function get_topics(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->success(['data' => ['items' => [], 'total' => 0, 'page' => 1, 'total_pages' => 1]]);
@@ -133,7 +139,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
]);
}
public function get_topic_detail(WP_REST_Request $request): WP_REST_Response {
public function get_topic_detail(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -149,7 +155,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
]);
}
public function moderate_topic(WP_REST_Request $request): WP_REST_Response {
public function moderate_topic(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -174,7 +180,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
]);
}
public function vote_topic(WP_REST_Request $request): WP_REST_Response {
public function vote_topic(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -202,7 +208,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
/**
* Legacy admin moderation endpoint kept for compatibility.
*/
public function update_topic_legacy(WP_REST_Request $request): WP_REST_Response {
public function update_topic_legacy(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$topic_id = (int) ($params['topic_id'] ?? 0);
if ($topic_id <= 0) {
@@ -235,7 +241,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
return $this->success(['message' => __('治理状态已更新', 'aksrt')]);
}
public function get_moderators(): WP_REST_Response {
public function get_moderators(): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->success(['data' => ['boards' => []]]);
@@ -261,7 +267,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
return $this->success(['data' => ['boards' => $result]]);
}
public function update_moderators(WP_REST_Request $request): WP_REST_Response {
public function update_moderators(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -303,7 +309,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
]);
}
public function change_moderator_role(WP_REST_Request $request): WP_REST_Response {
public function change_moderator_role(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -331,7 +337,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
return $this->success(['message' => __('角色已更新', 'aksrt')]);
}
public function apply_moderator(WP_REST_Request $request): WP_REST_Response {
public function apply_moderator(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -353,7 +359,7 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
]);
}
public function get_moderator_applications(WP_REST_Request $request): WP_REST_Response {
public function get_moderator_applications(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->success(['data' => ['items' => [], 'total' => 0]]);
@@ -373,9 +379,9 @@ trait AKSRT_Admin_Forum_Controller_Part_1 {
'boards' => $forum->get_boards(),
'status' => [
['label' => __('全部', 'aksrt'), 'value' => ''],
['label' => __('待处理', 'aksrt'), 'value' => AKSRT_Forum::APPLICATION_PENDING],
['label' => __('已通过', 'aksrt'), 'value' => AKSRT_Forum::APPLICATION_APPROVED],
['label' => __('已拒绝', 'aksrt'), 'value' => AKSRT_Forum::APPLICATION_REJECTED],
['label' => __('待处理', 'aksrt'), 'value' => \AKSRT\Forum\Forum::APPLICATION_PENDING],
['label' => __('已通过', 'aksrt'), 'value' => \AKSRT\Forum\Forum::APPLICATION_APPROVED],
['label' => __('已拒绝', 'aksrt'), 'value' => \AKSRT\Forum\Forum::APPLICATION_REJECTED],
],
],
],
@@ -1,10 +1,16 @@
<?php
/**
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
trait AKSRT_Admin_Forum_Controller_Part_2 {
trait ForumControllerPart2 {
public function review_moderator_application(WP_REST_Request $request): WP_REST_Response {
public function review_moderator_application(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -26,7 +32,7 @@ trait AKSRT_Admin_Forum_Controller_Part_2 {
]);
}
public function toggle_favorite(WP_REST_Request $request): WP_REST_Response {
public function toggle_favorite(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -42,7 +48,7 @@ trait AKSRT_Admin_Forum_Controller_Part_2 {
return $this->success($result);
}
public function score_topic(WP_REST_Request $request): WP_REST_Response {
public function score_topic(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -61,7 +67,7 @@ trait AKSRT_Admin_Forum_Controller_Part_2 {
return $this->success($result);
}
public function adopt_answer(WP_REST_Request $request): WP_REST_Response {
public function adopt_answer(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -84,11 +90,11 @@ trait AKSRT_Admin_Forum_Controller_Part_2 {
return is_user_logged_in();
}
private function get_forum_service(): ?AKSRT_Forum {
return class_exists('AKSRT_Forum') ? AKSRT_Forum::get_instance() : null;
private function get_forum_service(): ?\AKSRT\Forum\Forum {
return class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
}
public function frontend_create_plate(WP_REST_Request $request): WP_REST_Response {
public function frontend_create_plate(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -121,7 +127,7 @@ trait AKSRT_Admin_Forum_Controller_Part_2 {
return $this->success($result);
}
public function frontend_update_plate(WP_REST_Request $request): WP_REST_Response {
public function frontend_update_plate(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -156,7 +162,7 @@ trait AKSRT_Admin_Forum_Controller_Part_2 {
return $this->success($result);
}
public function frontend_delete_plate(WP_REST_Request $request): WP_REST_Response {
public function frontend_delete_plate(\WP_REST_Request $request): \WP_REST_Response {
$forum = $this->get_forum_service();
if (!$forum) {
return $this->error(__('论坛系统未启用', 'aksrt'));
@@ -1,20 +1,16 @@
<?php
/**
* AKSRT Admin — Global & Functions Controller
*
* Handles REST routes for the "全局&功能" domain:
* SEO, email/SMTP, footer, floating buttons, footer tabbar,
* friend links, CMS features, homepage settings, category recommend.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
use AKSRT_Admin_Global_Controller_Part_1;
use AKSRT_Admin_Global_Controller_Part_2;
use AKSRT_Admin_Homepage_Settings_Rest;
class GlobalController extends ControllerBase {
use GlobalControllerPart1;
use GlobalControllerPart2;
use HomepageSettingsRest;
private static $instance = null;
@@ -178,9 +174,9 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function rest_handle_cms_features(WP_REST_Request $request): WP_REST_Response {
public function rest_handle_cms_features(\WP_REST_Request $request): \WP_REST_Response {
if ($request->get_method() === 'GET') {
return $this->success(['cms_features' => AKSRT_Settings::get_cms_features()]);
return $this->success(['cms_features' => \AKSRT\Settings\Settings::get_cms_features()]);
}
$params = $this->get_json_params($request);
@@ -192,18 +188,18 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
'search_include_resource' => 'bool',
];
$sanitized = $this->sanitize_fields($params, $allowed);
$settings = AKSRT_Settings::get_all();
$settings = \AKSRT\Settings\Settings::get_all();
$settings['cms_features'] = array_merge(
is_array($settings['cms_features'] ?? null) ? $settings['cms_features'] : [],
$sanitized
);
update_option('aksrt_settings', $settings);
AKSRT_Settings::flush_settings_cache();
\AKSRT\Settings\Settings::flush_settings_cache();
return $this->success(['message' => 'CMS 功能已保存', 'cms_features' => AKSRT_Settings::get_cms_features()]);
return $this->success(['message' => 'CMS 功能已保存', 'cms_features' => \AKSRT\Settings\Settings::get_cms_features()]);
}
public function rest_handle_mail(WP_REST_Request $request): WP_REST_Response {
public function rest_handle_mail(\WP_REST_Request $request): \WP_REST_Response {
$option_key = 'aksrt_mail_config';
if ($request->get_method() === 'GET') {
@@ -227,7 +223,7 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
return $this->success(['message' => '邮件配置已保存', 'code' => 'success']);
}
public function rest_test_mail(WP_REST_Request $request): WP_REST_Response {
public function rest_test_mail(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$to = sanitize_email($params['to'] ?? '');
if (!is_email($to)) {
@@ -241,7 +237,7 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
return $this->error(__('邮件发送失败,请检查 SMTP 配置', 'aksrt'));
}
public function rest_homepage_tab_posts(WP_REST_Request $request): WP_REST_Response {
public function rest_homepage_tab_posts(\WP_REST_Request $request): \WP_REST_Response {
$term_id = (int) $request->get_param('term_id');
$page = max(1, (int) $request->get_param('page'));
$per_page = min(50, max(1, (int) $request->get_param('per_page')));
@@ -275,16 +271,16 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
]];
}
$exclude_ids = class_exists('AKSRT_Settings')
? AKSRT_Settings::home_exclude_post_ids()
$exclude_ids = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::home_exclude_post_ids()
: [];
if (!empty($exclude_ids)) {
$args['post__not_in'] = $exclude_ids;
}
if ($panel === 'latest' || $term_id <= 0) {
$exclude_cat_ids = class_exists('AKSRT_Settings')
? AKSRT_Settings::home_exclude_category_ids()
$exclude_cat_ids = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::home_exclude_category_ids()
: [];
if (!empty($exclude_cat_ids)) {
$args['category__not_in'] = $exclude_cat_ids;
@@ -299,7 +295,7 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
$args['order'] = 'DESC';
}
$query = new WP_Query($args);
$query = new \WP_Query($args);
$mode = in_array($view_mode, ['card', 'list'], true) ? $view_mode : '';
$html = '';
@@ -338,11 +334,11 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function rest_archive_posts(WP_REST_Request $request): WP_REST_Response {
public function rest_archive_posts(\WP_REST_Request $request): \WP_REST_Response {
return $this->rest_homepage_tab_posts($request);
}
public function rest_homepage_categories(): WP_REST_Response {
public function rest_homepage_categories(): \WP_REST_Response {
$data = [];
$cats = get_categories(['hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC']);
@@ -383,7 +379,7 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
return $this->success(['data' => $data]);
}
public function rest_handle_friend_links(WP_REST_Request $request): WP_REST_Response {
public function rest_handle_friend_links(\WP_REST_Request $request): \WP_REST_Response {
if ($request->get_method() === 'GET') {
$links = aksrt_get_friend_links();
return rest_ensure_response(['code' => 'success', 'data' => $links]);
@@ -409,7 +405,7 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
return rest_ensure_response(['code' => 'success', 'data' => $new_link, 'message' => __('Friend link added.', 'aksrt')]);
}
public function rest_delete_friend_link(WP_REST_Request $request): WP_REST_Response {
public function rest_delete_friend_link(\WP_REST_Request $request): \WP_REST_Response {
$id = $request->get_param('id');
$links = get_option('aksrt_friend_links', []);
$links = array_filter($links, function ($link) use ($id) {
@@ -420,10 +416,10 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
return rest_ensure_response(['code' => 'success', 'message' => __('Friend link deleted.', 'aksrt')]);
}
public function rest_reorder_friend_links(WP_REST_Request $request): WP_REST_Response {
public function rest_reorder_friend_links(\WP_REST_Request $request): \WP_REST_Response {
$ordered_ids = $request->get_param('ids');
if (!is_array($ordered_ids)) {
return new WP_REST_Response(['code' => 'error', 'message' => __('参数错误', 'aksrt')], 400);
return new \WP_REST_Response(['code' => 'error', 'message' => __('参数错误', 'aksrt')], 400);
}
$links = get_option('aksrt_friend_links', []);
$order_map = array_flip($ordered_ids);
@@ -439,7 +435,7 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
return rest_ensure_response(['code' => 'success', 'message' => __('Order saved.', 'aksrt')]);
}
public function rest_handle_footer_settings(WP_REST_Request $request): WP_REST_Response {
public function rest_handle_footer_settings(\WP_REST_Request $request): \WP_REST_Response {
if ($request->get_method() === 'GET') {
$footer = get_option('aksrt_footer_settings', []);
$defaults = [
@@ -575,10 +571,10 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
return $clean;
}
public function rest_handle_footer_tabbar(WP_REST_Request $request): WP_REST_Response {
public function rest_handle_footer_tabbar(\WP_REST_Request $request): \WP_REST_Response {
if ($request->get_method() === 'GET') {
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_footer_tabbar_settings()
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_footer_tabbar_settings()
: ['enabled' => true, 'scroll_hide' => false, 'scroll_down_hide' => true, 'items' => []];
return rest_ensure_response(['code' => 'success', 'data' => $settings]);
}
@@ -588,7 +584,7 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
$max_items = max(3, min(7, (int) ($params['max_items'] ?? 5)));
if (count($items) > $max_items) {
return new WP_REST_Response([
return new \WP_REST_Response([
'code' => 'error',
'message' => sprintf(__('Footer tabbar supports at most %d items.', 'aksrt'), $max_items),
], 400);
@@ -613,8 +609,8 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
];
update_option('aksrt_footer_tabbar', $tabbar);
if (class_exists('AKSRT_Settings')) {
AKSRT_Settings::flush_settings_cache();
if (class_exists('\AKSRT\Settings\Settings')) {
\AKSRT\Settings\Settings::flush_settings_cache();
}
return rest_ensure_response(['code' => 'success', 'message' => __('Footer tabbar settings saved.', 'aksrt')]);
@@ -1,18 +1,24 @@
<?php
/**
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
trait AKSRT_Admin_Global_Controller_Part_1 {
trait GlobalControllerPart1 {
public function rest_reorder_footer_tabbar(WP_REST_Request $request): WP_REST_Response {
public function rest_reorder_footer_tabbar(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$ordered_ids = $params['ids'] ?? [];
if (!is_array($ordered_ids)) {
return new WP_REST_Response(['code' => 'error', 'message' => __('参数错误', 'aksrt')], 400);
return new \WP_REST_Response(['code' => 'error', 'message' => __('参数错误', 'aksrt')], 400);
}
if (count($ordered_ids) > 5) {
return new WP_REST_Response(['code' => 'error', 'message' => __('Footer tabbar supports at most 5 items.', 'aksrt')], 400);
return new \WP_REST_Response(['code' => 'error', 'message' => __('Footer tabbar supports at most 5 items.', 'aksrt')], 400);
}
$tabbar = get_option('aksrt_footer_tabbar', []);
@@ -85,10 +91,10 @@ trait AKSRT_Admin_Global_Controller_Part_1 {
];
}
public function rest_handle_floating_buttons(WP_REST_Request $request): WP_REST_Response {
public function rest_handle_floating_buttons(\WP_REST_Request $request): \WP_REST_Response {
if ($request->get_method() === 'GET') {
$settings = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_floating_buttons_settings()
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_floating_buttons_settings()
: [
'enabled' => true,
'style' => 'round',
@@ -138,19 +144,19 @@ trait AKSRT_Admin_Global_Controller_Part_1 {
update_option('aksrt_floating_buttons', $settings);
if (class_exists('AKSRT_Settings')) {
AKSRT_Settings::flush_settings_cache();
if (class_exists('\AKSRT\Settings\Settings')) {
\AKSRT\Settings\Settings::flush_settings_cache();
}
return rest_ensure_response(['code' => 'success', 'message' => __('Floating button settings saved.', 'aksrt')]);
}
public function rest_reorder_floating_buttons(WP_REST_Request $request): WP_REST_Response {
public function rest_reorder_floating_buttons(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$ordered_ids = $params['ids'] ?? [];
if (!is_array($ordered_ids)) {
return new WP_REST_Response(['code' => 'error', 'message' => __('参数错误', 'aksrt')], 400);
return new \WP_REST_Response(['code' => 'error', 'message' => __('参数错误', 'aksrt')], 400);
}
$settings = get_option('aksrt_floating_buttons', []);
@@ -171,8 +177,8 @@ trait AKSRT_Admin_Global_Controller_Part_1 {
$settings['items'] = $items;
update_option('aksrt_floating_buttons', $settings);
if (class_exists('AKSRT_Settings')) {
AKSRT_Settings::flush_settings_cache();
if (class_exists('\AKSRT\Settings\Settings')) {
\AKSRT\Settings\Settings::flush_settings_cache();
}
return rest_ensure_response(['code' => 'success', 'message' => __('Order saved.', 'aksrt')]);
@@ -1,11 +1,17 @@
<?php
/**
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
trait AKSRT_Admin_Global_Controller_Part_2 {
trait GlobalControllerPart2 {
public function rest_handle_category_recommend(WP_REST_Request $request): WP_REST_Response {
public function rest_handle_category_recommend(\WP_REST_Request $request): \WP_REST_Response {
if ($request->get_method() === 'GET') {
$settings = AKSRT_Settings::get_category_recommend_settings();
$settings = \AKSRT\Settings\Settings::get_category_recommend_settings();
return rest_ensure_response(['code' => 'success', 'data' => $settings]);
}
@@ -25,12 +31,12 @@ trait AKSRT_Admin_Global_Controller_Part_2 {
'category_recommend_show_more_link' => !empty($params['category_recommend_show_more_link']),
];
update_option('aksrt_category_recommend', $settings);
AKSRT_Settings::flush_category_recommend_cache();
\AKSRT\Settings\Settings::flush_category_recommend_cache();
return rest_ensure_response(['code' => 'success', 'message' => __('Category recommendation settings saved.', 'aksrt')]);
}
public function rest_get_categories(WP_REST_Request $request): WP_REST_Response {
public function rest_get_categories(\WP_REST_Request $request): \WP_REST_Response {
$categories = get_categories([
'orderby' => 'count',
'order' => 'DESC',
@@ -45,7 +51,7 @@ trait AKSRT_Admin_Global_Controller_Part_2 {
'count' => (int) $cat->count,
'description' => $cat->description,
'cover_id' => (int) get_term_meta($cat->term_id, 'aksrt_category_cover_id', true),
'cover_url' => AKSRT_Settings::get_category_cover_url((int) $cat->term_id),
'cover_url' => \AKSRT\Settings\Settings::get_category_cover_url((int) $cat->term_id),
'recommend_desc' => (string) get_term_meta($cat->term_id, 'aksrt_category_recommend_desc', true),
];
}, $categories);
@@ -53,7 +59,7 @@ trait AKSRT_Admin_Global_Controller_Part_2 {
return rest_ensure_response(['code' => 'success', 'data' => array_values($data)]);
}
public function rest_search_users(WP_REST_Request $request): WP_REST_Response {
public function rest_search_users(\WP_REST_Request $request): \WP_REST_Response {
$search = (string) $request->get_param('search');
$number = max(1, min(50, (int) $request->get_param('number')));
@@ -80,11 +86,11 @@ trait AKSRT_Admin_Global_Controller_Part_2 {
return rest_ensure_response(['code' => 'success', 'data' => array_values($data)]);
}
public function rest_update_category_meta(WP_REST_Request $request): WP_REST_Response {
public function rest_update_category_meta(\WP_REST_Request $request): \WP_REST_Response {
$id = (int) $request->get_param('id');
$term = get_term($id, 'category');
if (!$term || is_wp_error($term)) {
return new WP_REST_Response(['code' => 'error', 'message' => __('Category does not exist.', 'aksrt')], 404);
return new \WP_REST_Response(['code' => 'error', 'message' => __('Category does not exist.', 'aksrt')], 404);
}
$params = $this->get_json_params($request);
@@ -103,7 +109,7 @@ trait AKSRT_Admin_Global_Controller_Part_2 {
delete_term_meta($id, 'aksrt_category_recommend_desc');
}
AKSRT_Settings::flush_category_recommend_cache();
\AKSRT\Settings\Settings::flush_category_recommend_cache();
return rest_ensure_response(['code' => 'success', 'message' => __('分类元数据已保存', 'aksrt')]);
}
@@ -1,32 +1,21 @@
<?php
/**
* Homepage settings REST — Zibll-aligned storage keys for the main list / tabs contract.
*
* Canonical keys (aligned with Zibll option IDs):
* - home_posts_list_s
* - home_list1_orderby_s
* - home_list1_orderby_option
* - index_list_title
* - home_exclude_posts
* - home_exclude_cats
* - home_lists
*
* AKSRT-only presentation keys remain optional (card style, multi-thumb, content model).
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
trait AKSRT_Admin_Homepage_Settings_Rest {
trait HomepageSettingsRest {
public function rest_handle_homepage_settings(WP_REST_Request $request): WP_REST_Response {
public function rest_handle_homepage_settings(\WP_REST_Request $request): \WP_REST_Response {
$option_key = 'aksrt_settings';
if ($request->get_method() === 'GET') {
return rest_ensure_response([
'code' => 'success',
'data' => AKSRT_Settings_Home_Cms::get_homepage_fixed_settings(),
'data' => \AKSRT\Settings\HomeCms::get_homepage_fixed_settings(),
]);
}
@@ -38,7 +27,7 @@ trait AKSRT_Admin_Homepage_Settings_Rest {
$params = [];
}
$allowed_sorts = AKSRT_Settings_Home_Cms::homepage_allowed_sorts();
$allowed_sorts = \AKSRT\Settings\HomeCms::homepage_allowed_sorts();
$settings = [];
// --- Zibll main list contract ---
@@ -198,8 +187,8 @@ trait AKSRT_Admin_Homepage_Settings_Rest {
}
update_option($option_key, $current);
if (class_exists('AKSRT_Settings')) {
AKSRT_Settings::flush_settings_cache();
if (class_exists('\AKSRT\Settings\Settings')) {
\AKSRT\Settings\Settings::flush_settings_cache();
}
update_option('aksrt_homepage_schema_version', gmdate('Y-m-d'));
delete_transient('aksrt_homepage_cached_images');
@@ -208,7 +197,7 @@ trait AKSRT_Admin_Homepage_Settings_Rest {
return rest_ensure_response([
'code' => 'success',
'message' => __('首页设置已保存', 'aksrt'),
'data' => AKSRT_Settings_Home_Cms::get_homepage_fixed_settings(),
'data' => \AKSRT\Settings\HomeCms::get_homepage_fixed_settings(),
]);
}
@@ -1,18 +1,15 @@
<?php
/**
* AKSRT Admin — Import/Export Controller
*
* Handles REST routes for settings export, import, section reset,
* and health diagnostics.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
use AKSRT_Admin_Import_Export_Controller_Part_1;
use AKSRT_Admin_Import_Export_Controller_Part_2;
class ImportExportController extends ControllerBase {
use ImportExportControllerPart1;
use ImportExportControllerPart2;
private static $instance = null;
@@ -167,8 +164,8 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
/**
* Export all AKSRT settings as a JSON-serializable array.
*/
public function rest_export_settings(WP_REST_Request $request): WP_REST_Response {
$schema_provider = AKSRT_Admin_Schema_Provider::get_instance();
public function rest_export_settings(\WP_REST_Request $request): \WP_REST_Response {
$schema_provider = SchemaProvider::get_instance();
$domains = $schema_provider->get_domain_keys();
$export = [
@@ -185,7 +182,7 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
}
// Also export standalone options from the registry
$standalone_keys = AKSRT_Settings::STANDALONE_OPTION_KEYS;
$standalone_keys = \AKSRT\Settings\Settings::STANDALONE_OPTION_KEYS;
$export['standalone'] = [];
foreach ($standalone_keys as $key) {
@@ -204,7 +201,7 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
* Request body: { domains: { domain: { data: {...} } }, standalone: { key: value } }
* Optional: { dry_run: true } to validate without saving.
*/
public function rest_import_settings(WP_REST_Request $request): WP_REST_Response {
public function rest_import_settings(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$dry_run = !empty($params['dry_run']);
@@ -212,7 +209,7 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
return $this->error('没有可导入的数据');
}
$schema_provider = AKSRT_Admin_Schema_Provider::get_instance();
$schema_provider = SchemaProvider::get_instance();
$results = [];
// Import domain settings
@@ -263,7 +260,7 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
}
if (!$dry_run) {
AKSRT_Settings::flush_settings_cache();
\AKSRT\Settings\Settings::flush_settings_cache();
}
return $this->success([
@@ -275,9 +272,9 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
/**
* Reset a domain's settings to defaults.
*/
public function rest_reset_domain(WP_REST_Request $request): WP_REST_Response {
public function rest_reset_domain(\WP_REST_Request $request): \WP_REST_Response {
$domain = $request->get_param('domain');
$schema_provider = AKSRT_Admin_Schema_Provider::get_instance();
$schema_provider = SchemaProvider::get_instance();
if (!in_array($domain, $schema_provider->get_domain_keys(), true)) {
return $this->error('未知的设置域: ' . esc_html($domain), 404);
@@ -296,8 +293,8 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function rest_reset_all(WP_REST_Request $request): WP_REST_Response {
$schema_provider = AKSRT_Admin_Schema_Provider::get_instance();
public function rest_reset_all(\WP_REST_Request $request): \WP_REST_Response {
$schema_provider = SchemaProvider::get_instance();
$backup = $this->create_backup_record('reset_all', __('重置全部前快照', 'aksrt'));
$this->persist_setting_backup($backup);
@@ -305,7 +302,7 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
$schema_provider->reset_to_defaults($domain);
}
AKSRT_Settings::flush_settings_cache();
\AKSRT\Settings\Settings::flush_settings_cache();
return $this->success([
'message' => __('全部 schema 托管设置已重置为默认值', 'aksrt'),
@@ -318,7 +315,7 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
/**
* Health check — returns system diagnostics.
*/
public function rest_health_check(WP_REST_Request $request): WP_REST_Response {
public function rest_health_check(\WP_REST_Request $request): \WP_REST_Response {
global $wpdb;
$checks = [];
@@ -375,7 +372,7 @@ class AKSRT_Admin_Import_Export_Controller extends AKSRT_Admin_Controller_Base {
];
// Avatar source
$avatar_source = AKSRT_Settings::get_all()['avatar_source'] ?? 'cn.cravatar.com';
$avatar_source = \AKSRT\Settings\Settings::get_all()['avatar_source'] ?? 'cn.cravatar.com';
$checks['avatar_source'] = [
'label' => '头像服务',
'value' => $avatar_source,
@@ -1,14 +1,20 @@
<?php
/**
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
trait AKSRT_Admin_Import_Export_Controller_Part_1 {
trait ImportExportControllerPart1 {
/**
* Get the schema definition for a domain (for frontend introspection).
*/
public function rest_get_schema(WP_REST_Request $request): WP_REST_Response {
public function rest_get_schema(\WP_REST_Request $request): \WP_REST_Response {
$domain = $request->get_param('domain');
$schema_provider = AKSRT_Admin_Schema_Provider::get_instance();
$schema_provider = SchemaProvider::get_instance();
$schema = $schema_provider->get_schema($domain);
if (!$schema) {
@@ -18,15 +24,15 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
return $this->success(['schema' => $schema]);
}
public function rest_get_schema_section(WP_REST_Request $request): WP_REST_Response {
public function rest_get_schema_section(\WP_REST_Request $request): \WP_REST_Response {
return $this->get_section_settings($request, (string) $request->get_param('domain'));
}
public function rest_save_schema_section(WP_REST_Request $request): WP_REST_Response {
public function rest_save_schema_section(\WP_REST_Request $request): \WP_REST_Response {
return $this->save_section_settings($request, (string) $request->get_param('domain'));
}
public function list_setting_backups(WP_REST_Request $request): WP_REST_Response {
public function list_setting_backups(\WP_REST_Request $request): \WP_REST_Response {
$backups = get_option('aksrt_settings_backups', []);
if (!is_array($backups)) {
$backups = [];
@@ -44,7 +50,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
]);
}
public function create_setting_backup(WP_REST_Request $request): WP_REST_Response {
public function create_setting_backup(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$type = sanitize_key((string) ($params['type'] ?? 'manual'));
$label = sanitize_text_field((string) ($params['label'] ?? ''));
@@ -63,7 +69,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
]);
}
public function restore_setting_backup(WP_REST_Request $request): WP_REST_Response {
public function restore_setting_backup(\WP_REST_Request $request): \WP_REST_Response {
$id = (int) $request->get_param('id');
$backups = get_option('aksrt_settings_backups', []);
if (!is_array($backups)) {
@@ -85,7 +91,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
$payload = $target['payload'];
$domains = $payload['domains'] ?? [];
$standalone = $payload['standalone'] ?? [];
$provider = AKSRT_Admin_Schema_Provider::get_instance();
$provider = SchemaProvider::get_instance();
foreach ($domains as $domain => $domainPayload) {
$data = $domainPayload['data'] ?? $domainPayload;
@@ -100,7 +106,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
}
}
AKSRT_Settings::flush_settings_cache();
\AKSRT\Settings\Settings::flush_settings_cache();
return $this->success([
'message' => __('设置已从快照恢复', 'aksrt'),
@@ -110,7 +116,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
]);
}
public function delete_setting_backup(WP_REST_Request $request): WP_REST_Response {
public function delete_setting_backup(\WP_REST_Request $request): \WP_REST_Response {
$id = (int) $request->get_param('id');
$backups = get_option('aksrt_settings_backups', []);
if (!is_array($backups)) {
@@ -145,7 +151,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
/**
* GET /widgets/export — Export current widget configuration.
*/
public function export_widgets(WP_REST_Request $request): WP_REST_Response {
public function export_widgets(\WP_REST_Request $request): \WP_REST_Response {
$sidebars_widgets = get_option('sidebars_widgets', []);
$widget_options = $this->collect_widget_options();
@@ -162,7 +168,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
/**
* POST /widgets/import — Import widget configuration.
*/
public function import_widgets(WP_REST_Request $request): WP_REST_Response {
public function import_widgets(\WP_REST_Request $request): \WP_REST_Response {
$params = $request->get_json_params() ?? [];
$sidebars = $params['sidebars_widgets'] ?? null;
$options = $params['widget_options'] ?? null;
@@ -201,7 +207,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
/**
* GET /widgets/templates — List saved widget templates.
*/
public function list_widget_templates(WP_REST_Request $request): WP_REST_Response {
public function list_widget_templates(\WP_REST_Request $request): \WP_REST_Response {
$templates = get_option('aksrt_widget_templates', []);
return $this->success(['data' => ['templates' => $templates]]);
}
@@ -209,7 +215,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
/**
* POST /widgets/templates — Save current layout as a named template.
*/
public function save_widget_template(WP_REST_Request $request): WP_REST_Response {
public function save_widget_template(\WP_REST_Request $request): \WP_REST_Response {
$params = $request->get_json_params() ?? [];
$name = sanitize_text_field((string) ($params['name'] ?? ''));
if (!$name) {
@@ -234,7 +240,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
/**
* POST /widgets/templates/{id}/apply — Apply a saved template.
*/
public function apply_widget_template(WP_REST_Request $request): WP_REST_Response {
public function apply_widget_template(\WP_REST_Request $request): \WP_REST_Response {
$id = (int) $request->get_param('id');
$templates = get_option('aksrt_widget_templates', []);
@@ -268,7 +274,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_1 {
/**
* DELETE /widgets/templates/{id} — Delete a saved template.
*/
public function delete_widget_template(WP_REST_Request $request): WP_REST_Response {
public function delete_widget_template(\WP_REST_Request $request): \WP_REST_Response {
$id = (int) $request->get_param('id');
$templates = get_option('aksrt_widget_templates', []);
@@ -1,11 +1,17 @@
<?php
/**
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
trait AKSRT_Admin_Import_Export_Controller_Part_2 {
trait ImportExportControllerPart2 {
private function get_backup_schedule_settings(): array {
$provider = AKSRT_Admin_Schema_Provider::get_instance();
$provider = SchemaProvider::get_instance();
$settings = $provider->read_settings('tools', 'backup');
$frequency = sanitize_key((string) ($settings['backup_frequency'] ?? 'weekly'));
$allowed = ['daily', 'weekly', 'monthly'];
@@ -20,7 +26,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_2 {
}
private function build_settings_backup(string $type, string $label = ''): array {
$schema_provider = AKSRT_Admin_Schema_Provider::get_instance();
$schema_provider = SchemaProvider::get_instance();
$domains = $schema_provider->get_domain_keys();
$payload = [
@@ -37,7 +43,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_2 {
];
}
foreach (AKSRT_Settings::STANDALONE_OPTION_KEYS as $key) {
foreach (\AKSRT\Settings\Settings::STANDALONE_OPTION_KEYS as $key) {
$value = get_option($key);
if ($value !== false) {
$payload['standalone'][$key] = $value;
@@ -54,7 +60,7 @@ trait AKSRT_Admin_Import_Export_Controller_Part_2 {
}
private function trim_setting_backups(array $backups): array {
$retain = (int) (AKSRT_Settings::get_value('backup_retain', 7));
$retain = (int) (\AKSRT\Settings\Settings::get_value('backup_retain', 7));
$retain = max(3, min(20, $retain));
if (count($backups) <= $retain) {
@@ -1,16 +1,13 @@
<?php
/**
* Admin REST Controller — Messages & Conversations
*
* Provides REST endpoints for notifications and private messages
* under aksrt/v1/messages and aksrt/v1/conversations.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Message_Controller extends AKSRT_Admin_Controller_Base {
class MessageController extends ControllerBase {
private static $instance = null;
@@ -107,17 +104,17 @@ class AKSRT_Admin_Message_Controller extends AKSRT_Admin_Controller_Base {
// ── Notification handlers ──
public function list_notifications(WP_REST_Request $request): WP_REST_Response {
public function list_notifications(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
$type = $request->get_param('type');
$per_page = min(100, (int) $request->get_param('per_page'));
$page = max(1, (int) $request->get_param('page'));
if (!class_exists('AKSRT_Message')) {
if (!class_exists('\AKSRT\Messages\Message')) {
return $this->success(['data' => [], 'total' => 0]);
}
$msg = AKSRT_Message::get_instance();
$msg = \AKSRT\Messages\Message::get_instance();
$args = [
'limit' => $per_page,
'offset' => ($page - 1) * $per_page,
@@ -135,59 +132,59 @@ class AKSRT_Admin_Message_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function get_unread_count(WP_REST_Request $request): WP_REST_Response {
public function get_unread_count(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
if (!class_exists('AKSRT_Message')) {
if (!class_exists('\AKSRT\Messages\Message')) {
return $this->success(['data' => ['unread' => 0]]);
}
$count = AKSRT_Message::get_instance()->get_unread_count($user_id);
$count = \AKSRT\Messages\Message::get_instance()->get_unread_count($user_id);
return $this->success(['data' => ['unread' => $count]]);
}
public function mark_read(WP_REST_Request $request): WP_REST_Response {
public function mark_read(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
$id = (string) $request->get_param('id');
if (!class_exists('AKSRT_Message')) {
if (!class_exists('\AKSRT\Messages\Message')) {
return $this->error('not_available', '消息系统未启用。', 501);
}
$result = AKSRT_Message::get_instance()->mark_read($user_id, $id);
$result = \AKSRT\Messages\Message::get_instance()->mark_read($user_id, $id);
return $this->success(['data' => ['success' => $result]]);
}
public function mark_all_read(WP_REST_Request $request): WP_REST_Response {
public function mark_all_read(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
if (!class_exists('AKSRT_Message')) {
if (!class_exists('\AKSRT\Messages\Message')) {
return $this->error('not_available', '消息系统未启用。', 501);
}
$result = AKSRT_Message::get_instance()->mark_all_read($user_id);
$result = \AKSRT\Messages\Message::get_instance()->mark_all_read($user_id);
return $this->success(['data' => ['success' => $result]]);
}
// ── Conversation handlers ──
public function list_conversations(WP_REST_Request $request): WP_REST_Response {
public function list_conversations(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
$limit = min(50, (int) $request->get_param('limit'));
if (!class_exists('AKSRT_Private_Message')) {
if (!class_exists('\AKSRT\Messages\PrivateMessage')) {
return $this->success(['data' => []]);
}
$conversations = AKSRT_Private_Message::get_instance()->get_conversations($user_id, $limit);
$conversations = \AKSRT\Messages\PrivateMessage::get_instance()->get_conversations($user_id, $limit);
return $this->success(['data' => $conversations]);
}
public function get_thread(WP_REST_Request $request): WP_REST_Response {
public function get_thread(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
$conv_id = (int) $request->get_param('id');
$page = max(1, (int) $request->get_param('page'));
$per_page = min(50, (int) $request->get_param('per_page'));
if (!class_exists('AKSRT_Private_Message')) {
if (!class_exists('\AKSRT\Messages\PrivateMessage')) {
return $this->error('not_available', '私信系统未启用。', 501);
}
$result = AKSRT_Private_Message::get_instance()->get_thread($conv_id, $user_id, $page, $per_page);
$result = \AKSRT\Messages\PrivateMessage::get_instance()->get_thread($conv_id, $user_id, $page, $per_page);
if (is_wp_error($result)) {
return $this->error('thread_error', $result->get_error_message(), 403);
}
@@ -195,7 +192,7 @@ class AKSRT_Admin_Message_Controller extends AKSRT_Admin_Controller_Base {
return $this->success(['data' => $result]);
}
public function send_message(WP_REST_Request $request): WP_REST_Response {
public function send_message(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
$conv_id = (int) $request->get_param('id');
$content = trim((string) $request->get_param('content'));
@@ -204,11 +201,11 @@ class AKSRT_Admin_Message_Controller extends AKSRT_Admin_Controller_Base {
return $this->error('content_required', '消息内容不能为空。', 400);
}
if (!class_exists('AKSRT_Private_Message')) {
if (!class_exists('\AKSRT\Messages\PrivateMessage')) {
return $this->error('not_available', '私信系统未启用。', 501);
}
$result = AKSRT_Private_Message::get_instance()->send($conv_id, $user_id, $content);
$result = \AKSRT\Messages\PrivateMessage::get_instance()->send($conv_id, $user_id, $content);
if (!$result['success']) {
return $this->error('send_failed', $result['message'] ?? '发送失败。', 500);
}
@@ -216,7 +213,7 @@ class AKSRT_Admin_Message_Controller extends AKSRT_Admin_Controller_Base {
return $this->success(['data' => $result]);
}
public function get_or_create_conversation(WP_REST_Request $request): WP_REST_Response {
public function get_or_create_conversation(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
$other_id = (int) $request->get_param('user_id');
@@ -224,11 +221,11 @@ class AKSRT_Admin_Message_Controller extends AKSRT_Admin_Controller_Base {
return $this->error('self_message', '不能与自己创建对话。', 400);
}
if (!class_exists('AKSRT_Private_Message')) {
if (!class_exists('\AKSRT\Messages\PrivateMessage')) {
return $this->error('not_available', '私信系统未启用。', 501);
}
$conv_id = AKSRT_Private_Message::get_instance()->get_or_create_conversation($user_id, $other_id);
$conv_id = \AKSRT\Messages\PrivateMessage::get_instance()->get_or_create_conversation($user_id, $other_id);
if (is_wp_error($conv_id)) {
return $this->error('create_failed', $conv_id->get_error_message(), 500);
}
@@ -236,15 +233,15 @@ class AKSRT_Admin_Message_Controller extends AKSRT_Admin_Controller_Base {
return $this->success(['data' => ['conversation_id' => $conv_id]]);
}
public function mark_conversation_read(WP_REST_Request $request): WP_REST_Response {
public function mark_conversation_read(\WP_REST_Request $request): \WP_REST_Response {
$user_id = get_current_user_id();
$conv_id = (int) $request->get_param('id');
if (!class_exists('AKSRT_Private_Message')) {
if (!class_exists('\AKSRT\Messages\PrivateMessage')) {
return $this->error('not_available', '私信系统未启用。', 501);
}
AKSRT_Private_Message::get_instance()->mark_conversation_read($conv_id, $user_id);
\AKSRT\Messages\PrivateMessage::get_instance()->mark_conversation_read($conv_id, $user_id);
return $this->success(['data' => ['success' => true]]);
}
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: AKSRT_Admin_Pay_After_Sale.
*
* Extracted from AKSRT_Admin_Pay_Menus.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_After_Sale {
class PayAfterSale {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_after_sale';
@@ -42,13 +40,13 @@ class AKSRT_Admin_Pay_After_Sale {
check_admin_referer($nonce_action);
$ok = false;
if ($order_number !== '' && class_exists('AKSRT_After_Sale')) {
if ($order_number !== '' && class_exists('\AKSRT\Payment\AfterSale')) {
$user_id = isset($_POST['user_id']) ? (int) $_POST['user_id'] : 0;
if ($user_id <= 0 && class_exists('AKSRT_Order_Repository')) {
$order = AKSRT_Order_Repository::get_instance()->get($order_number);
if ($user_id <= 0 && class_exists('\AKSRT\Payment\OrderRepository')) {
$order = \AKSRT\Payment\OrderRepository::get_instance()->get($order_number);
$user_id = (int) ($order['user_id'] ?? 0);
}
$id = AKSRT_After_Sale::get_instance()->create([
$id = \AKSRT\Payment\AfterSale::get_instance()->create([
'order_number' => $order_number,
'user_id' => $user_id,
'type' => sanitize_key((string) wp_unslash($_POST['type'] ?? 'refund')),
@@ -75,7 +73,7 @@ class AKSRT_Admin_Pay_After_Sale {
$this->ensure_cap();
$this->render_header(__('售后管理', 'aksrt'));
if (!class_exists('AKSRT_After_Sale')) {
if (!class_exists('\AKSRT\Payment\AfterSale')) {
echo '<div class="notice notice-error"><p>' . esc_html__('售后模块未初始化。', 'aksrt') . '</p></div>';
$this->render_footer();
return;
@@ -89,7 +87,7 @@ class AKSRT_Admin_Pay_After_Sale {
}
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
$svc = AKSRT_After_Sale::get_instance();
$svc = \AKSRT\Payment\AfterSale::get_instance();
$stats = $svc->get_stats();
$status_options = $this->after_sale_status_options(true);
$type_options = $this->after_sale_type_options(true);
@@ -223,8 +221,8 @@ class AKSRT_Admin_Pay_After_Sale {
check_admin_referer('aksrt_pay_update_after_sale_' . $id);
$ok = false;
if ($id > 0 && $new_status !== '' && class_exists('AKSRT_After_Sale')) {
$ok = AKSRT_After_Sale::get_instance()->update_status($id, $new_status, get_current_user_id(), $note);
if ($id > 0 && $new_status !== '' && class_exists('\AKSRT\Payment\AfterSale')) {
$ok = \AKSRT\Payment\AfterSale::get_instance()->update_status($id, $new_status, get_current_user_id(), $note);
}
wp_safe_redirect($this->page_url('aksrt_after_sale', ['aksrt_pay_msg' => $ok ? 'after_sale_updated' : 'after_sale_failed']));
exit;
@@ -239,8 +237,8 @@ class AKSRT_Admin_Pay_After_Sale {
check_admin_referer('aksrt_pay_after_sale_action_' . $id);
$ok = false;
if ($id > 0 && class_exists('AKSRT_After_Sale')) {
$svc = AKSRT_After_Sale::get_instance();
if ($id > 0 && class_exists('\AKSRT\Payment\AfterSale')) {
$svc = \AKSRT\Payment\AfterSale::get_instance();
$operator_id = get_current_user_id();
if ($as_action === 'approve') {
$ok = $svc->merchant_approve($id, $operator_id);
@@ -263,8 +261,8 @@ class AKSRT_Admin_Pay_After_Sale {
if ($include_all) {
$options[''] = __('全部状态', 'aksrt');
}
if (class_exists('AKSRT_After_Sale')) {
foreach (AKSRT_After_Sale::get_status_options() as $item) {
if (class_exists('\AKSRT\Payment\AfterSale')) {
foreach (\AKSRT\Payment\AfterSale::get_status_options() as $item) {
$value = (string) ($item['value'] ?? '');
if ($value === '') {
continue;
@@ -294,8 +292,8 @@ class AKSRT_Admin_Pay_After_Sale {
'exchange' => __('换货', 'aksrt'),
'repair' => __('维修', 'aksrt'),
];
if (class_exists('AKSRT_After_Sale')) {
foreach (AKSRT_After_Sale::get_type_options() as $item) {
if (class_exists('\AKSRT\Payment\AfterSale')) {
foreach (\AKSRT\Payment\AfterSale::get_type_options() as $item) {
$value = (string) ($item['value'] ?? '');
if ($value === '') {
continue;
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: AKSRT_Admin_Pay_Charge_Cards.
*
* Extracted from AKSRT_Admin_Pay_Menus.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Charge_Cards {
class PayChargeCards {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_charge_cards';
@@ -35,7 +33,7 @@ class AKSRT_Admin_Pay_Charge_Cards {
$this->ensure_cap();
$this->render_header(__('卡密管理', 'aksrt'));
if (!class_exists('AKSRT_Charge_Card')) {
if (!class_exists('\AKSRT\Payment\ChargeCard')) {
echo '<div class="notice notice-error"><p>' . esc_html__('卡密模块未初始化。', 'aksrt') . '</p></div>';
$this->render_footer();
return;
@@ -46,7 +44,7 @@ class AKSRT_Admin_Pay_Charge_Cards {
$search = isset($_GET['s']) ? sanitize_text_field((string) wp_unslash($_GET['s'])) : '';
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
$svc = AKSRT_Charge_Card::get_instance();
$svc = \AKSRT\Payment\ChargeCard::get_instance();
$stats = $svc->get_stats();
$type_labels = [
'balance' => __('余额', 'aksrt'),
@@ -229,8 +227,8 @@ class AKSRT_Admin_Pay_Charge_Cards {
check_admin_referer('aksrt_pay_disable_charge_card_' . $id);
$ok = false;
if ($id > 0 && class_exists('AKSRT_Charge_Card')) {
$ok = AKSRT_Charge_Card::get_instance()->disable($id);
if ($id > 0 && class_exists('\AKSRT\Payment\ChargeCard')) {
$ok = \AKSRT\Payment\ChargeCard::get_instance()->disable($id);
}
wp_safe_redirect($this->page_url('aksrt_charge_cards', [
@@ -245,7 +243,7 @@ class AKSRT_Admin_Pay_Charge_Cards {
}
check_admin_referer('aksrt_pay_batch_charge_cards');
if (!class_exists('AKSRT_Charge_Card')) {
if (!class_exists('\AKSRT\Payment\ChargeCard')) {
wp_safe_redirect($this->page_url('aksrt_charge_cards', ['aksrt_pay_msg' => 'card_batch_failed']));
exit;
}
@@ -280,7 +278,7 @@ class AKSRT_Admin_Pay_Charge_Cards {
$meta['days'] = $days;
}
$codes = AKSRT_Charge_Card::get_instance()->batch_create($type, $meta, $count, $length, $prefix, $expires, $note);
$codes = \AKSRT\Payment\ChargeCard::get_instance()->batch_create($type, $meta, $count, $length, $prefix, $expires, $note);
$ok = !empty($codes);
if ($ok) {
set_transient('aksrt_pay_card_codes_' . get_current_user_id(), $codes, 10 * MINUTE_IN_SECONDS);
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: coupon list / create / batch / edit (product_scope).
*
* Extracted from AKSRT_Admin_Pay_Menus to keep pay-menus shell smaller.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Coupons {
class PayCoupons {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_coupons';
@@ -38,13 +36,13 @@ class AKSRT_Admin_Pay_Coupons {
$this->ensure_cap();
$this->render_header(__('优惠码', 'aksrt'));
if (!class_exists('AKSRT_Coupon')) {
if (!class_exists('\AKSRT\Payment\Coupon')) {
echo '<div class="notice notice-error"><p>' . esc_html__('优惠码模块未初始化。', 'aksrt') . '</p></div>';
$this->render_footer();
return;
}
$svc = AKSRT_Coupon::get_instance();
$svc = \AKSRT\Payment\Coupon::get_instance();
$edit_id = isset($_GET['edit_id']) ? (int) $_GET['edit_id'] : 0;
$edit_row = $edit_id > 0 ? $svc->get($edit_id) : null;
@@ -169,7 +167,7 @@ class AKSRT_Admin_Pay_Coupons {
}
}
private function render_list(AKSRT_Coupon $svc): void {
private function render_list(\AKSRT\Payment\Coupon $svc): void {
$status = isset($_GET['status']) ? sanitize_key((string) wp_unslash($_GET['status'])) : '';
$search = isset($_GET['s']) ? sanitize_text_field((string) wp_unslash($_GET['s'])) : '';
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
@@ -253,8 +251,8 @@ class AKSRT_Admin_Pay_Coupons {
check_admin_referer('aksrt_pay_create_coupon');
$ok = false;
if (class_exists('AKSRT_Coupon')) {
$id = AKSRT_Coupon::get_instance()->create([
if (class_exists('\AKSRT\Payment\Coupon')) {
$id = \AKSRT\Payment\Coupon::get_instance()->create([
'code' => sanitize_text_field((string) wp_unslash($_POST['code'] ?? '')),
'type' => sanitize_key((string) wp_unslash($_POST['type'] ?? 'fixed')),
'value' => (float) ($_POST['value'] ?? 0),
@@ -280,8 +278,8 @@ class AKSRT_Admin_Pay_Coupons {
$ok = false;
$created = 0;
$codes = [];
if (class_exists('AKSRT_Coupon')) {
$result = AKSRT_Coupon::get_instance()->batch_create([
if (class_exists('\AKSRT\Payment\Coupon')) {
$result = \AKSRT\Payment\Coupon::get_instance()->batch_create([
'type' => sanitize_key((string) wp_unslash($_POST['type'] ?? 'fixed')),
'value' => (float) ($_POST['value'] ?? 0),
'min_amount' => (float) ($_POST['min_amount'] ?? 0),
@@ -314,8 +312,8 @@ class AKSRT_Admin_Pay_Coupons {
check_admin_referer('aksrt_pay_update_coupon_' . $id);
$ok = false;
if ($id > 0 && class_exists('AKSRT_Coupon')) {
$ok = AKSRT_Coupon::get_instance()->update($id, [
if ($id > 0 && class_exists('\AKSRT\Payment\Coupon')) {
$ok = \AKSRT\Payment\Coupon::get_instance()->update($id, [
'type' => sanitize_key((string) wp_unslash($_POST['type'] ?? 'fixed')),
'value' => (float) ($_POST['value'] ?? 0),
'min_amount' => (float) ($_POST['min_amount'] ?? 0),
@@ -339,7 +337,7 @@ class AKSRT_Admin_Pay_Coupons {
}
$id = isset($_POST['coupon_id']) ? (int) $_POST['coupon_id'] : 0;
check_admin_referer('aksrt_pay_disable_coupon_' . $id);
$ok = $id > 0 && class_exists('AKSRT_Coupon') && AKSRT_Coupon::get_instance()->disable($id);
$ok = $id > 0 && class_exists('\AKSRT\Payment\Coupon') && \AKSRT\Payment\Coupon::get_instance()->disable($id);
wp_safe_redirect($this->page_url(['aksrt_pay_msg' => $ok ? 'coupon_disabled' : 'coupon_failed']));
exit;
}
@@ -350,7 +348,7 @@ class AKSRT_Admin_Pay_Coupons {
}
$id = isset($_POST['coupon_id']) ? (int) $_POST['coupon_id'] : 0;
check_admin_referer('aksrt_pay_enable_coupon_' . $id);
$ok = $id > 0 && class_exists('AKSRT_Coupon') && AKSRT_Coupon::get_instance()->enable($id);
$ok = $id > 0 && class_exists('\AKSRT\Payment\Coupon') && \AKSRT\Payment\Coupon::get_instance()->enable($id);
wp_safe_redirect($this->page_url(['aksrt_pay_msg' => $ok ? 'coupon_enabled' : 'coupon_failed']));
exit;
}
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: resource download token/log browser (zibll paydown log parity, best-effort).
*
* Source: {prefix}aksrt_dl_token (issued tokens; used rows kept ~7 days by cleanup).
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Download_Logs {
class PayDownloadLogs {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_download_logs';
@@ -31,12 +29,12 @@ class AKSRT_Admin_Pay_Download_Logs {
$this->ensure_cap();
echo '<div class="wrap"><h1>' . esc_html__('下载记录', 'aksrt') . '</h1>';
if (!class_exists('AKSRT_DB_Migrator')) {
if (!class_exists('\AKSRT\Core\DBMigrator')) {
echo '<div class="notice notice-error"><p>' . esc_html__('数据库服务不可用。', 'aksrt') . '</p></div></div>';
return;
}
$table = AKSRT_DB_Migrator::table('dl_token');
$table = \AKSRT\Core\DBMigrator::table('dl_token');
if ($table === '') {
echo '<div class="notice notice-error"><p>' . esc_html__('下载令牌表未初始化。', 'aksrt') . '</p></div></div>';
return;
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: AKSRT_Admin_Pay_Income.
*
* Extracted from AKSRT_Admin_Pay_Menus.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Income {
class PayIncome {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_income';
@@ -34,7 +32,7 @@ class AKSRT_Admin_Pay_Income {
$this->ensure_cap();
$this->render_header(__('创作分成', 'aksrt'));
if (!class_exists('AKSRT_Revenue')) {
if (!class_exists('\AKSRT\Payment\Revenue')) {
echo '<div class="notice notice-error"><p>' . esc_html__('分成模块未初始化。', 'aksrt') . '</p></div>';
$this->render_footer();
return;
@@ -44,7 +42,7 @@ class AKSRT_Admin_Pay_Income {
$user_id = isset($_GET['user_id']) ? max(0, (int) $_GET['user_id']) : 0;
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
$svc = AKSRT_Revenue::get_instance();
$svc = \AKSRT\Payment\Revenue::get_instance();
$stats = $user_id > 0 ? $svc->get_stats($user_id) : $svc->get_stats();
echo '<p>' . esc_html(sprintf(
@@ -124,7 +122,7 @@ class AKSRT_Admin_Pay_Income {
}
$id = isset($_POST['revenue_id']) ? (int) $_POST['revenue_id'] : 0;
check_admin_referer('aksrt_pay_settle_income_' . $id);
$ok = $id > 0 && class_exists('AKSRT_Revenue') && AKSRT_Revenue::get_instance()->settle($id);
$ok = $id > 0 && class_exists('\AKSRT\Payment\Revenue') && \AKSRT\Payment\Revenue::get_instance()->settle($id);
wp_safe_redirect($this->page_url('aksrt_income', ['aksrt_pay_msg' => $ok ? 'income_settled' : 'income_failed']));
exit;
}
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin menus shell for payment / order ops (zibll zibpay-style).
*
* Domain pages live in dedicated AKSRT_Admin_Pay_* classes.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Menus {
class PayMenus {
public const CAPABILITY = 'manage_options';
public const MENU_SLUG = 'aksrt_pay';
@@ -47,8 +45,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_orders',
'title' => __('订单', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_Orders')) {
AKSRT_Admin_Pay_Orders::get_instance()->render_orders_page();
if (class_exists('PayOrders')) {
PayOrders::get_instance()->render_orders_page();
return;
}
wp_die(esc_html__('订单模块未初始化。', 'aksrt'));
@@ -58,8 +56,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_pay_products',
'title' => __('付费文章', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_Products')) {
AKSRT_Admin_Pay_Products::get_instance()->render_products_page();
if (class_exists('PayProducts')) {
PayProducts::get_instance()->render_products_page();
return;
}
wp_die(esc_html__('付费文章模块未初始化。', 'aksrt'));
@@ -69,8 +67,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_download_logs',
'title' => __('下载记录', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_Download_Logs')) {
AKSRT_Admin_Pay_Download_Logs::get_instance()->render_page();
if (class_exists('PayDownloadLogs')) {
PayDownloadLogs::get_instance()->render_page();
return;
}
wp_die(esc_html__('下载记录模块未初始化。', 'aksrt'));
@@ -80,8 +78,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_shipping',
'title' => __('发货及物流', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_Shipping')) {
AKSRT_Admin_Pay_Shipping::get_instance()->render_shipping_page();
if (class_exists('PayShipping')) {
PayShipping::get_instance()->render_shipping_page();
return;
}
wp_die(esc_html__('物流模块未初始化。', 'aksrt'));
@@ -91,8 +89,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_after_sale',
'title' => __('售后管理', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_After_Sale')) {
AKSRT_Admin_Pay_After_Sale::get_instance()->render_after_sale_page();
if (class_exists('PayAfterSale')) {
PayAfterSale::get_instance()->render_after_sale_page();
return;
}
wp_die(esc_html__('售后模块未初始化。', 'aksrt'));
@@ -102,8 +100,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_coupons',
'title' => __('优惠码', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_Coupons')) {
AKSRT_Admin_Pay_Coupons::get_instance()->render_page();
if (class_exists('PayCoupons')) {
PayCoupons::get_instance()->render_page();
return;
}
wp_die(esc_html__('优惠码模块未初始化。', 'aksrt'));
@@ -113,8 +111,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_charge_cards',
'title' => __('卡密管理', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_Charge_Cards')) {
AKSRT_Admin_Pay_Charge_Cards::get_instance()->render_charge_cards_page();
if (class_exists('PayChargeCards')) {
PayChargeCards::get_instance()->render_charge_cards_page();
return;
}
wp_die(esc_html__('卡密模块未初始化。', 'aksrt'));
@@ -124,8 +122,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_income',
'title' => __('创作分成', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_Income')) {
AKSRT_Admin_Pay_Income::get_instance()->render_income_page();
if (class_exists('PayIncome')) {
PayIncome::get_instance()->render_income_page();
return;
}
wp_die(esc_html__('分成模块未初始化。', 'aksrt'));
@@ -135,8 +133,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_rebate',
'title' => __('推广返佣', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_Rebate')) {
AKSRT_Admin_Pay_Rebate::get_instance()->render_rebate_page();
if (class_exists('PayRebate')) {
PayRebate::get_instance()->render_rebate_page();
return;
}
wp_die(esc_html__('返佣模块未初始化。', 'aksrt'));
@@ -146,8 +144,8 @@ class AKSRT_Admin_Pay_Menus {
'slug' => 'aksrt_withdraw',
'title' => __('提现审核', 'aksrt'),
'callback' => static function (): void {
if (class_exists('AKSRT_Admin_Pay_Withdrawals')) {
AKSRT_Admin_Pay_Withdrawals::get_instance()->render_withdrawals_page();
if (class_exists('PayWithdrawals')) {
PayWithdrawals::get_instance()->render_withdrawals_page();
return;
}
wp_die(esc_html__('提现模块未初始化。', 'aksrt'));
@@ -190,8 +188,8 @@ class AKSRT_Admin_Pay_Menus {
$page = isset($_GET['page']) ? sanitize_key((string) wp_unslash($_GET['page'])) : '';
if ($page !== 'aksrt_withdraw' && class_exists('AKSRT_Withdrawal')) {
$pending = (int) AKSRT_Withdrawal::get_instance()->get_count(['status' => AKSRT_Withdrawal::STATUS_PENDING]);
if ($page !== 'aksrt_withdraw' && class_exists('\AKSRT\Payment\Withdrawal')) {
$pending = (int) \AKSRT\Payment\Withdrawal::get_instance()->get_count(['status' => \AKSRT\Payment\Withdrawal::STATUS_PENDING]);
if ($pending > 0) {
$url = admin_url('admin.php?page=aksrt_withdraw&status=pending');
echo '<div class="notice notice-info is-dismissible">';
@@ -206,8 +204,8 @@ class AKSRT_Admin_Pay_Menus {
}
}
if ($page !== 'aksrt_after_sale' && class_exists('AKSRT_After_Sale')) {
$as_stats = AKSRT_After_Sale::get_instance()->get_stats();
if ($page !== 'aksrt_after_sale' && class_exists('\AKSRT\Payment\AfterSale')) {
$as_stats = \AKSRT\Payment\AfterSale::get_instance()->get_stats();
$pending_as = (int) ($as_stats['pending'] ?? 0);
if ($pending_as > 0) {
$url = admin_url('admin.php?page=aksrt_after_sale&status=pending');
@@ -247,22 +245,22 @@ class AKSRT_Admin_Pay_Menus {
$this->ensure_cap();
$this->render_header(__('支付中心', 'aksrt'));
$order_stats = class_exists('AKSRT_Order_Repository')
? AKSRT_Order_Repository::get_instance()->get_stats()
$order_stats = class_exists('\AKSRT\Payment\OrderRepository')
? \AKSRT\Payment\OrderRepository::get_instance()->get_stats()
: [];
$withdraw_stats = class_exists('AKSRT_Withdrawal')
? AKSRT_Withdrawal::get_instance()->get_stats()
$withdraw_stats = class_exists('\AKSRT\Payment\Withdrawal')
? \AKSRT\Payment\Withdrawal::get_instance()->get_stats()
: [];
$card_stats = class_exists('AKSRT_Charge_Card')
? AKSRT_Charge_Card::get_instance()->get_stats()
$card_stats = class_exists('\AKSRT\Payment\ChargeCard')
? \AKSRT\Payment\ChargeCard::get_instance()->get_stats()
: [];
echo '<p class="description">' . esc_html__('运营数据入口(对齐 zibll 商城中心)。配置项仍在 AKSRT 主题设置 SPA。', 'aksrt') . '</p>';
echo '<div class="aksrt-pay-stats" style="display:flex;flex-wrap:wrap;gap:16px;margin:20px 0;">';
$pending_ship = 0;
if (class_exists('AKSRT_Order_Repository')) {
$pending_ship = (int) (AKSRT_Order_Repository::get_instance()->get_pending_shipment_orders(['limit' => 1])['total'] ?? 0);
if (class_exists('\AKSRT\Payment\OrderRepository')) {
$pending_ship = (int) (\AKSRT\Payment\OrderRepository::get_instance()->get_pending_shipment_orders(['limit' => 1])['total'] ?? 0);
}
$this->stat_card(__('订单总数', 'aksrt'), (string) (int) ($order_stats['total'] ?? 0), $this->page_url('aksrt_orders'));
$this->stat_card(__('待支付', 'aksrt'), (string) (int) ($order_stats['pending'] ?? 0), $this->page_url('aksrt_orders', ['status' => 'pending']));
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: AKSRT_Admin_Pay_Orders.
*
* Extracted from AKSRT_Admin_Pay_Menus.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Orders {
class PayOrders {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_orders';
@@ -37,7 +35,7 @@ class AKSRT_Admin_Pay_Orders {
$this->ensure_cap();
$this->render_header(__('订单', 'aksrt'));
if (!class_exists('AKSRT_Order_Repository')) {
if (!class_exists('\AKSRT\Payment\OrderRepository')) {
echo '<div class="notice notice-error"><p>' . esc_html__('订单服务不可用。', 'aksrt') . '</p></div>';
$this->render_footer();
return;
@@ -59,7 +57,7 @@ class AKSRT_Admin_Pay_Orders {
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
$repo = AKSRT_Order_Repository::get_instance();
$repo = \AKSRT\Payment\OrderRepository::get_instance();
$args = [
'limit' => $per_page,
'offset' => ($page_num - 1) * $per_page,
@@ -83,8 +81,8 @@ class AKSRT_Admin_Pay_Orders {
$items = $repo->get_orders_admin($args, $search);
$total = $repo->get_orders_count($args, $search);
$pages = max(1, (int) ceil($total / $per_page));
$labels = class_exists('AKSRT_Domain_Model')
? AKSRT_Domain_Model::order_status_labels()
$labels = class_exists('\AKSRT\Core\DomainModel')
? \AKSRT\Core\DomainModel::order_status_labels()
: [];
// Type tabs (zibll order subsubsub parity).
@@ -269,7 +267,7 @@ class AKSRT_Admin_Pay_Orders {
}
private function render_order_detail_page(string $order_number): void {
$repo = AKSRT_Order_Repository::get_instance();
$repo = \AKSRT\Payment\OrderRepository::get_instance();
$order = $repo->get($order_number);
if (!$order) {
echo '<div class="notice notice-error"><p>' . esc_html__('订单不存在。', 'aksrt') . '</p></div>';
@@ -277,8 +275,8 @@ class AKSRT_Admin_Pay_Orders {
return;
}
$labels = class_exists('AKSRT_Domain_Model')
? AKSRT_Domain_Model::order_status_labels()
$labels = class_exists('\AKSRT\Core\DomainModel')
? \AKSRT\Core\DomainModel::order_status_labels()
: [];
$context = $repo->get_admin_order_context($order_number);
$user_id = (int) ($order['user_id'] ?? 0);
@@ -291,11 +289,11 @@ class AKSRT_Admin_Pay_Orders {
$admin_note = (string) $order['note'];
}
$shipping_items = class_exists('AKSRT_Shipping')
? AKSRT_Shipping::get_instance()->get_by_order($order_number)
$shipping_items = class_exists('\AKSRT\Payment\Shipping')
? \AKSRT\Payment\Shipping::get_instance()->get_by_order($order_number)
: [];
$after_sale = class_exists('AKSRT_After_Sale')
? (AKSRT_After_Sale::get_instance()->get_list(['order_number' => $order_number, 'limit' => 20])['items'] ?? [])
$after_sale = class_exists('\AKSRT\Payment\AfterSale')
? (\AKSRT\Payment\AfterSale::get_instance()->get_list(['order_number' => $order_number, 'limit' => 20])['items'] ?? [])
: [];
echo '<p><a class="button" href="' . esc_url($this->page_url('aksrt_orders')) . '">&larr; ' . esc_html__('返回订单列表', 'aksrt') . '</a></p>';
@@ -440,8 +438,8 @@ class AKSRT_Admin_Pay_Orders {
check_admin_referer('aksrt_pay_update_order_status_' . $order_number);
$ok = false;
if ($order_number !== '' && $new_status !== '' && class_exists('AKSRT_Order_Repository')) {
$ok = AKSRT_Order_Repository::get_instance()->update_status($order_number, $new_status, ['force' => true]);
if ($order_number !== '' && $new_status !== '' && class_exists('\AKSRT\Payment\OrderRepository')) {
$ok = \AKSRT\Payment\OrderRepository::get_instance()->update_status($order_number, $new_status, ['force' => true]);
}
$args = ['aksrt_pay_msg' => $ok ? 'order_updated' : 'order_failed'];
@@ -464,8 +462,8 @@ class AKSRT_Admin_Pay_Orders {
check_admin_referer('aksrt_pay_update_order_note_' . $order_number);
$ok = false;
if ($order_number !== '' && class_exists('AKSRT_Order_Repository')) {
$ok = AKSRT_Order_Repository::get_instance()->update_admin_note($order_number, $admin_note);
if ($order_number !== '' && class_exists('\AKSRT\Payment\OrderRepository')) {
$ok = \AKSRT\Payment\OrderRepository::get_instance()->update_admin_note($order_number, $admin_note);
}
wp_safe_redirect($this->page_url('aksrt_orders', [
@@ -482,8 +480,8 @@ class AKSRT_Admin_Pay_Orders {
check_admin_referer('aksrt_pay_clear_closed_orders');
$days = isset($_POST['days']) ? max(1, min(3650, (int) $_POST['days'])) : 14;
$deleted = 0;
if (class_exists('AKSRT_Order_Repository')) {
$deleted = AKSRT_Order_Repository::get_instance()->clear_closed_orders($days);
if (class_exists('\AKSRT\Payment\OrderRepository')) {
$deleted = \AKSRT\Payment\OrderRepository::get_instance()->clear_closed_orders($days);
}
wp_safe_redirect($this->page_url('aksrt_orders', [
'aksrt_pay_msg' => $deleted > 0 ? 'orders_cleared' : 'orders_clear_empty',
@@ -499,12 +497,12 @@ class AKSRT_Admin_Pay_Orders {
$order_number = isset($_POST['order_number']) ? sanitize_text_field((string) wp_unslash($_POST['order_number'])) : '';
check_admin_referer('aksrt_pay_delete_order_' . $order_number);
$ok = false;
if ($order_number !== '' && class_exists('AKSRT_Order_Repository')) {
$order = AKSRT_Order_Repository::get_instance()->get($order_number);
if ($order_number !== '' && class_exists('\AKSRT\Payment\OrderRepository')) {
$order = \AKSRT\Payment\OrderRepository::get_instance()->get($order_number);
$status = is_array($order) ? (string) ($order['status'] ?? '') : '';
// Only allow hard-delete of closed/expired rows (safety).
if (in_array($status, ['cancelled', 'expired'], true)) {
$ok = AKSRT_Order_Repository::get_instance()->delete_order($order_number);
$ok = \AKSRT\Payment\OrderRepository::get_instance()->delete_order($order_number);
}
}
wp_safe_redirect($this->page_url('aksrt_orders', [
@@ -514,15 +512,15 @@ class AKSRT_Admin_Pay_Orders {
}
private function shipping_status_options(bool $include_all = false): array {
if (class_exists('AKSRT_Admin_Pay_Shipping')) {
return AKSRT_Admin_Pay_Shipping::get_instance()->shipping_status_options_public($include_all);
if (class_exists('PayShipping')) {
return PayShipping::get_instance()->shipping_status_options_public($include_all);
}
return $include_all ? ['' => __('全部状态', 'aksrt')] : [];
}
private function after_sale_type_options(bool $include_all = false): array {
if (class_exists('AKSRT_Admin_Pay_After_Sale')) {
return AKSRT_Admin_Pay_After_Sale::get_instance()->after_sale_type_options_public($include_all);
if (class_exists('PayAfterSale')) {
return PayAfterSale::get_instance()->after_sale_type_options_public($include_all);
}
return $include_all ? ['' => __('全部类型', 'aksrt')] : [
'refund' => __('仅退款', 'aksrt'),
@@ -530,8 +528,8 @@ class AKSRT_Admin_Pay_Orders {
}
private function render_carrier_field(string $selected = ''): void {
if (class_exists('AKSRT_Admin_Pay_Shipping')) {
AKSRT_Admin_Pay_Shipping::get_instance()->render_carrier_field_public($selected);
if (class_exists('PayShipping')) {
PayShipping::get_instance()->render_carrier_field_public($selected);
return;
}
echo '<input type="text" name="carrier" value="' . esc_attr($selected) . '" required />';
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: paid content sales report (zibll zibpay_product_page parity).
*
* Lists content posts with pay config / resource orders — not shop_product CPT.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Products {
class PayProducts {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_pay_products';
@@ -31,7 +29,7 @@ class AKSRT_Admin_Pay_Products {
$this->ensure_cap();
$this->render_header(__('付费文章', 'aksrt'));
if (!class_exists('AKSRT_Order_Repository') || !class_exists('AKSRT_Domain_Model')) {
if (!class_exists('\AKSRT\Payment\OrderRepository') || !class_exists('\AKSRT\Core\DomainModel')) {
echo '<div class="notice notice-error"><p>' . esc_html__('订单服务不可用。', 'aksrt') . '</p></div>';
$this->render_footer();
return;
@@ -42,8 +40,8 @@ class AKSRT_Admin_Pay_Products {
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
$type_labels = AKSRT_Domain_Model::pay_type_labels();
unset($type_labels[AKSRT_Domain_Model::PAY_TYPE_NO]);
$type_labels = \AKSRT\Core\DomainModel::pay_type_labels();
unset($type_labels[\AKSRT\Core\DomainModel::PAY_TYPE_NO]);
$query = $this->query_paid_posts([
'pay_type' => $pay_type,
@@ -57,13 +55,13 @@ class AKSRT_Admin_Pay_Products {
$pages = max(1, (int) ceil($total / $per_page));
$sales_map = [];
if ($posts && class_exists('AKSRT_Order_Repository')) {
if ($posts && class_exists('\AKSRT\Payment\OrderRepository')) {
$ids = array_map(static function ($p) {
return (int) $p->ID;
}, $posts);
$sales_map = AKSRT_Order_Repository::get_instance()->get_content_sales_map(
$sales_map = \AKSRT\Payment\OrderRepository::get_instance()->get_content_sales_map(
$ids,
AKSRT_Domain_Model::ORDER_PRODUCT_RESOURCE
\AKSRT\Core\DomainModel::ORDER_PRODUCT_RESOURCE
);
}
@@ -90,7 +88,7 @@ class AKSRT_Admin_Pay_Products {
foreach ($posts as $post) {
$post_id = (int) $post->ID;
$meta = function_exists('aksrt_get_pay_meta') ? aksrt_get_pay_meta($post) : [];
$pt = AKSRT_Domain_Model::normalize_pay_type((string) ($meta['pay_type'] ?? AKSRT_Domain_Model::PAY_TYPE_NO));
$pt = \AKSRT\Core\DomainModel::normalize_pay_type((string) ($meta['pay_type'] ?? \AKSRT\Core\DomainModel::PAY_TYPE_NO));
$pt_label = $type_labels[$pt] ?? $pt;
$modo = (($meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0';
$modo_label = $modo === 'points' ? __('积分', 'aksrt') : __('现金', 'aksrt');
@@ -107,7 +105,7 @@ class AKSRT_Admin_Pay_Products {
$db_sales = (int) ($sales['sales_count'] ?? 0);
$avg = (float) ($sales['avg_amount'] ?? 0);
$revenue = (float) ($sales['revenue'] ?? 0);
$meta_sales = (int) get_post_meta($post_id, AKSRT_Domain_Model::RESOURCE_SALES_VOLUME_KEY, true);
$meta_sales = (int) get_post_meta($post_id, \AKSRT\Core\DomainModel::RESOURCE_SALES_VOLUME_KEY, true);
$edit_url = get_edit_post_link($post_id, 'raw');
$title = get_the_title($post_id);
@@ -116,7 +114,7 @@ class AKSRT_Admin_Pay_Products {
}
$orders_url = $this->page_url('aksrt_orders', [
'product_type' => AKSRT_Domain_Model::ORDER_PRODUCT_RESOURCE,
'product_type' => \AKSRT\Core\DomainModel::ORDER_PRODUCT_RESOURCE,
'product_id' => $post_id,
]);
@@ -141,7 +139,7 @@ class AKSRT_Admin_Pay_Products {
echo '<a class="button button-small" href="' . esc_url($edit_url) . '">' . esc_html__('编辑', 'aksrt') . '</a>';
}
echo '<a class="button button-small" href="' . esc_url($orders_url) . '">' . esc_html__('订单', 'aksrt') . '</a>';
if ($pt === AKSRT_Domain_Model::PAY_TYPE_DOWNLOAD) {
if ($pt === \AKSRT\Core\DomainModel::PAY_TYPE_DOWNLOAD) {
$dl_url = $this->page_url('aksrt_download_logs', ['post_id' => $post_id]);
echo '<a class="button button-small" href="' . esc_url($dl_url) . '">' . esc_html__('下载记录', 'aksrt') . '</a>';
}
@@ -160,7 +158,7 @@ class AKSRT_Admin_Pay_Products {
/**
* @param array{pay_type?:string,search?:string,page?:int,per_page?:int} $args
* @return array{posts: WP_Post[], total: int}
* @return array{posts: \WP_Post[], total: int}
*/
private function query_paid_posts(array $args): array {
$pay_type = sanitize_key((string) ($args['pay_type'] ?? ''));
@@ -171,22 +169,22 @@ class AKSRT_Admin_Pay_Products {
$meta_query = [
'relation' => 'AND',
[
'key' => AKSRT_Domain_Model::PAY_META_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_META_KEY,
'compare' => 'EXISTS',
],
];
// Prefer denormalized type key when present; still exclude "no".
if ($pay_type !== '' && $pay_type !== AKSRT_Domain_Model::PAY_TYPE_NO) {
if ($pay_type !== '' && $pay_type !== \AKSRT\Core\DomainModel::PAY_TYPE_NO) {
$meta_query[] = [
'relation' => 'OR',
[
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_TYPE_KEY,
'value' => $pay_type,
'compare' => '=',
],
[
'key' => AKSRT_Domain_Model::PAY_META_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_META_KEY,
'value' => '"pay_type";s:' . strlen($pay_type) . ':"' . $pay_type . '"',
'compare' => 'LIKE',
],
@@ -195,12 +193,12 @@ class AKSRT_Admin_Pay_Products {
$meta_query[] = [
'relation' => 'OR',
[
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
'value' => AKSRT_Domain_Model::PAY_TYPE_NO,
'key' => \AKSRT\Core\DomainModel::PAY_TYPE_KEY,
'value' => \AKSRT\Core\DomainModel::PAY_TYPE_NO,
'compare' => '!=',
],
[
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
'key' => \AKSRT\Core\DomainModel::PAY_TYPE_KEY,
'compare' => 'NOT EXISTS',
],
];
@@ -228,10 +226,10 @@ class AKSRT_Admin_Pay_Products {
}
}
$q = new WP_Query($q_args);
$q = new \WP_Query($q_args);
$posts = [];
foreach ($q->posts as $post) {
if (!($post instanceof WP_Post)) {
if (!($post instanceof \WP_Post)) {
continue;
}
// Drop posts whose pay bag is effectively free/no.
@@ -240,7 +238,7 @@ class AKSRT_Admin_Pay_Products {
}
if ($pay_type !== '' && function_exists('aksrt_get_pay_meta')) {
$meta = aksrt_get_pay_meta($post);
$pt = AKSRT_Domain_Model::normalize_pay_type((string) ($meta['pay_type'] ?? ''));
$pt = \AKSRT\Core\DomainModel::normalize_pay_type((string) ($meta['pay_type'] ?? ''));
if ($pt !== $pay_type) {
continue;
}
@@ -266,15 +264,15 @@ class AKSRT_Admin_Pay_Products {
/**
* Fallback: posts that already have paid resource orders.
*
* @return array{posts: WP_Post[], total: int}
* @return array{posts: \WP_Post[], total: int}
*/
private function posts_from_order_summary(int $limit, int $offset): array {
if (!class_exists('AKSRT_Order_Repository')) {
if (!class_exists('\AKSRT\Payment\OrderRepository')) {
return ['posts' => [], 'total' => 0];
}
$summary = AKSRT_Order_Repository::get_instance()->get_content_sales_summary([
'product_type' => AKSRT_Domain_Model::ORDER_PRODUCT_RESOURCE,
$summary = \AKSRT\Payment\OrderRepository::get_instance()->get_content_sales_summary([
'product_type' => \AKSRT\Core\DomainModel::ORDER_PRODUCT_RESOURCE,
'limit' => $limit,
'offset' => $offset,
'orderby' => 'sales_count',
@@ -285,7 +283,7 @@ class AKSRT_Admin_Pay_Products {
foreach ($summary['items'] as $item) {
$pid = (int) ($item['product_id'] ?? 0);
$post = $pid > 0 ? get_post($pid) : null;
if ($post instanceof WP_Post && $post->post_type === 'post') {
if ($post instanceof \WP_Post && $post->post_type === 'post') {
$posts[] = $post;
}
}
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: AKSRT_Admin_Pay_Rebate.
*
* Extracted from AKSRT_Admin_Pay_Menus.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Rebate {
class PayRebate {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_rebate';
@@ -35,7 +33,7 @@ class AKSRT_Admin_Pay_Rebate {
$this->ensure_cap();
$this->render_header(__('推广返佣', 'aksrt'));
if (!class_exists('AKSRT_Rebate')) {
if (!class_exists('\AKSRT\Payment\Rebate')) {
echo '<div class="notice notice-error"><p>' . esc_html__('返佣模块未初始化。', 'aksrt') . '</p></div>';
$this->render_footer();
return;
@@ -45,7 +43,7 @@ class AKSRT_Admin_Pay_Rebate {
$user_id = isset($_GET['user_id']) ? max(0, (int) $_GET['user_id']) : (isset($_GET['referrer_id']) ? max(0, (int) $_GET['referrer_id']) : 0);
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
$svc = AKSRT_Rebate::get_instance();
$svc = \AKSRT\Payment\Rebate::get_instance();
$stats = $svc->get_stats();
echo '<p>' . esc_html(sprintf(
@@ -131,7 +129,7 @@ class AKSRT_Admin_Pay_Rebate {
}
$id = isset($_POST['rebate_id']) ? (int) $_POST['rebate_id'] : 0;
check_admin_referer('aksrt_pay_settle_rebate_' . $id);
$ok = $id > 0 && class_exists('AKSRT_Rebate') && AKSRT_Rebate::get_instance()->settle($id);
$ok = $id > 0 && class_exists('\AKSRT\Payment\Rebate') && \AKSRT\Payment\Rebate::get_instance()->settle($id);
wp_safe_redirect($this->page_url('aksrt_rebate', ['aksrt_pay_msg' => $ok ? 'rebate_settled' : 'rebate_failed']));
exit;
}
@@ -142,7 +140,7 @@ class AKSRT_Admin_Pay_Rebate {
}
$id = isset($_POST['rebate_id']) ? (int) $_POST['rebate_id'] : 0;
check_admin_referer('aksrt_pay_cancel_rebate_' . $id);
$ok = $id > 0 && class_exists('AKSRT_Rebate') && AKSRT_Rebate::get_instance()->cancel($id);
$ok = $id > 0 && class_exists('\AKSRT\Payment\Rebate') && \AKSRT\Payment\Rebate::get_instance()->cancel($id);
wp_safe_redirect($this->page_url('aksrt_rebate', ['aksrt_pay_msg' => $ok ? 'rebate_cancelled' : 'rebate_failed']));
exit;
}
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: AKSRT_Admin_Pay_Shipping.
*
* Extracted from AKSRT_Admin_Pay_Menus.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Shipping {
class PayShipping {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_shipping';
@@ -36,7 +34,7 @@ class AKSRT_Admin_Pay_Shipping {
$this->ensure_cap();
$this->render_header(__('发货及物流', 'aksrt'));
if (!class_exists('AKSRT_Shipping')) {
if (!class_exists('\AKSRT\Payment\Shipping')) {
echo '<div class="notice notice-error"><p>' . esc_html__('物流模块未初始化。', 'aksrt') . '</p></div>';
$this->render_footer();
return;
@@ -50,13 +48,13 @@ class AKSRT_Admin_Pay_Shipping {
$search = isset($_GET['s']) ? sanitize_text_field((string) wp_unslash($_GET['s'])) : '';
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
$svc = AKSRT_Shipping::get_instance();
$svc = \AKSRT\Payment\Shipping::get_instance();
$stats = $svc->get_stats();
$status_options = $this->shipping_status_options(true);
$pending_total = 0;
if (class_exists('AKSRT_Order_Repository')) {
$pending_total = (int) (AKSRT_Order_Repository::get_instance()->get_pending_shipment_orders(['limit' => 1, 'search' => ''])['total'] ?? 0);
if (class_exists('\AKSRT\Payment\OrderRepository')) {
$pending_total = (int) (\AKSRT\Payment\OrderRepository::get_instance()->get_pending_shipment_orders(['limit' => 1, 'search' => ''])['total'] ?? 0);
}
echo '<p>' . esc_html(sprintf(
@@ -183,7 +181,7 @@ class AKSRT_Admin_Pay_Shipping {
}
private function render_pending_shipment_board(string $search, int $page_num, int $per_page): void {
if (!class_exists('AKSRT_Order_Repository')) {
if (!class_exists('\AKSRT\Payment\OrderRepository')) {
echo '<div class="notice notice-error"><p>' . esc_html__('订单服务不可用。', 'aksrt') . '</p></div>';
return;
}
@@ -195,7 +193,7 @@ class AKSRT_Admin_Pay_Shipping {
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
echo '</form>';
$result = AKSRT_Order_Repository::get_instance()->get_pending_shipment_orders([
$result = \AKSRT\Payment\OrderRepository::get_instance()->get_pending_shipment_orders([
'search' => $search,
'limit' => $per_page,
'offset' => ($page_num - 1) * $per_page,
@@ -203,8 +201,8 @@ class AKSRT_Admin_Pay_Shipping {
$items = $result['items'] ?? [];
$total = (int) ($result['total'] ?? 0);
$pages = max(1, (int) ($result['max_pages'] ?? 1));
$labels = class_exists('AKSRT_Domain_Model')
? AKSRT_Domain_Model::order_status_labels()
$labels = class_exists('\AKSRT\Core\DomainModel')
? \AKSRT\Core\DomainModel::order_status_labels()
: [];
echo '<table class="wp-list-table widefat fixed striped"><thead><tr>';
@@ -261,8 +259,8 @@ class AKSRT_Admin_Pay_Shipping {
check_admin_referer('aksrt_pay_update_shipping_' . $id);
$ok = false;
if ($id > 0 && $new_status !== '' && class_exists('AKSRT_Shipping')) {
$ok = AKSRT_Shipping::get_instance()->update_status($id, $new_status, $note, get_current_user_id());
if ($id > 0 && $new_status !== '' && class_exists('\AKSRT\Payment\Shipping')) {
$ok = \AKSRT\Payment\Shipping::get_instance()->update_status($id, $new_status, $note, get_current_user_id());
}
$redirect_order = isset($_POST['redirect_order']) ? sanitize_text_field((string) wp_unslash($_POST['redirect_order'])) : '';
@@ -291,8 +289,8 @@ class AKSRT_Admin_Pay_Shipping {
$ok = false;
$order_number = '';
if ($id > 0 && class_exists('AKSRT_Shipping')) {
$svc = AKSRT_Shipping::get_instance();
if ($id > 0 && class_exists('\AKSRT\Payment\Shipping')) {
$svc = \AKSRT\Payment\Shipping::get_instance();
$record = $svc->get($id);
$order_number = is_array($record) ? (string) ($record['order_number'] ?? '') : '';
$result = $svc->query_express($id, $force);
@@ -318,14 +316,14 @@ class AKSRT_Admin_Pay_Shipping {
check_admin_referer($nonce_action);
$ok = false;
if ($order_number !== '' && class_exists('AKSRT_Shipping')) {
if (class_exists('AKSRT_Order_Repository')) {
$order = AKSRT_Order_Repository::get_instance()->get($order_number);
if ($order_number !== '' && class_exists('\AKSRT\Payment\Shipping')) {
if (class_exists('\AKSRT\Payment\OrderRepository')) {
$order = \AKSRT\Payment\OrderRepository::get_instance()->get($order_number);
if (!$order) {
$this->redirect_shipping_create_result(false, $order_number, $redirect_page);
}
}
$id = AKSRT_Shipping::get_instance()->create([
$id = \AKSRT\Payment\Shipping::get_instance()->create([
'order_number' => $order_number,
'carrier' => sanitize_text_field((string) wp_unslash($_POST['carrier'] ?? '')),
'tracking_no' => sanitize_text_field((string) wp_unslash($_POST['tracking_no'] ?? '')),
@@ -372,8 +370,8 @@ class AKSRT_Admin_Pay_Shipping {
if ($include_all) {
$options[''] = __('全部状态', 'aksrt');
}
if (class_exists('AKSRT_Shipping')) {
foreach (AKSRT_Shipping::get_status_options() as $item) {
if (class_exists('\AKSRT\Payment\Shipping')) {
foreach (\AKSRT\Payment\Shipping::get_status_options() as $item) {
$value = (string) ($item['value'] ?? '');
if ($value === '') {
continue;
@@ -397,8 +395,8 @@ class AKSRT_Admin_Pay_Shipping {
private function render_carrier_field(string $selected = ''): void {
$options = [];
if (class_exists('AKSRT_Shipping')) {
foreach (AKSRT_Shipping::get_carrier_options() as $item) {
if (class_exists('\AKSRT\Payment\Shipping')) {
foreach (\AKSRT\Payment\Shipping::get_carrier_options() as $item) {
$value = (string) ($item['value'] ?? '');
$label = (string) ($item['label'] ?? $value);
if ($value !== '') {
@@ -422,11 +420,11 @@ class AKSRT_Admin_Pay_Shipping {
echo '<input type="text" name="carrier" value="' . esc_attr($selected) . '" required placeholder="SF/YTO/..." />';
}
private function render_express_timeline_panel(int $shipping_id): void {
if ($shipping_id <= 0 || !class_exists('AKSRT_Shipping')) {
if ($shipping_id <= 0 || !class_exists('\AKSRT\Payment\Shipping')) {
echo '<p>' . esc_html__('无法加载物流轨迹。', 'aksrt') . '</p>';
return;
}
$svc = AKSRT_Shipping::get_instance();
$svc = \AKSRT\Payment\Shipping::get_instance();
// Prefer cached data; do not force remote query on pure view.
$timeline = $svc->build_express_timeline($shipping_id);
$record = $svc->get($shipping_id);
@@ -1,15 +1,13 @@
<?php
/**
* Native WP admin: AKSRT_Admin_Pay_Withdrawals.
*
* Extracted from AKSRT_Admin_Pay_Menus.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Pay_Withdrawals {
class PayWithdrawals {
public const CAPABILITY = 'manage_options';
public const PAGE_SLUG = 'aksrt_withdraw';
@@ -34,7 +32,7 @@ class AKSRT_Admin_Pay_Withdrawals {
$this->ensure_cap();
$this->render_header(__('提现审核', 'aksrt'));
if (!class_exists('AKSRT_Withdrawal')) {
if (!class_exists('\AKSRT\Payment\Withdrawal')) {
echo '<div class="notice notice-error"><p>' . esc_html__('提现模块未初始化。', 'aksrt') . '</p></div>';
$this->render_footer();
return;
@@ -43,7 +41,7 @@ class AKSRT_Admin_Pay_Withdrawals {
$status = isset($_GET['status']) ? sanitize_key((string) wp_unslash($_GET['status'])) : '';
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
$svc = AKSRT_Withdrawal::get_instance();
$svc = \AKSRT\Payment\Withdrawal::get_instance();
$stats = $svc->get_stats();
echo '<p>' . esc_html(sprintf(
@@ -184,8 +182,8 @@ class AKSRT_Admin_Pay_Withdrawals {
check_admin_referer('aksrt_pay_update_withdrawal_' . $id);
$msg = 'withdraw_failed';
if ($id > 0 && $new_status !== '' && class_exists('AKSRT_Withdrawal')) {
$result = AKSRT_Withdrawal::get_instance()->process_status_change($id, $new_status, $note);
if ($id > 0 && $new_status !== '' && class_exists('\AKSRT\Payment\Withdrawal')) {
$result = \AKSRT\Payment\Withdrawal::get_instance()->process_status_change($id, $new_status, $note);
if (!is_wp_error($result) && $result) {
$msg = 'withdraw_updated';
} elseif (is_wp_error($result) && $result->get_error_code() === 'aksrt_balance') {
@@ -1,13 +1,13 @@
<?php
/**
* Native users.php submenus for governance ops (zibll-aligned).
*
* @package AKSRT
*/
namespace AKSRT\Admin\Native;
defined('ABSPATH') || exit;
class AKSRT_Admin_Users_Menus {
class UsersMenus {
public const CAPABILITY = 'manage_options';
@@ -95,8 +95,8 @@ class AKSRT_Admin_Users_Menus {
}
}
if ($page !== 'aksrt_user_ban' && class_exists('AKSRT_Report_Center')) {
$pending_reports = (int) AKSRT_Report_Center::get_instance()->get_pending_count();
if ($page !== 'aksrt_user_ban' && class_exists('\AKSRT\Messages\ReportCenter')) {
$pending_reports = (int) \AKSRT\Messages\ReportCenter::get_instance()->get_pending_count();
if ($pending_reports > 0) {
$url = admin_url('users.php?page=aksrt_user_ban&tab=reports&status=pending');
echo '<div class="notice notice-info is-dismissible"><h3>' . esc_html__('举报待处理', 'aksrt') . '</h3>';
@@ -170,7 +170,7 @@ class AKSRT_Admin_Users_Menus {
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 30;
$offset = ($page_num - 1) * $per_page;
$table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('notification') : '';
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('notification') : '';
if ($table === '') {
echo '<div class="notice notice-warning"><p>' . esc_html__('通知表不可用。', 'aksrt') . '</p></div></div>';
@@ -224,8 +224,8 @@ class AKSRT_Admin_Users_Menus {
}
$ok = false;
if ($content !== '' && class_exists('AKSRT_Message')) {
$ok = AKSRT_Message::get_instance()->send($user_id, 'system', $content, ['title' => $title !== '' ? $title : $content]);
if ($content !== '' && class_exists('\AKSRT\Messages\Message')) {
$ok = \AKSRT\Messages\Message::get_instance()->send($user_id, 'system', $content, ['title' => $title !== '' ? $title : $content]);
}
$this->redirect('aksrt_messages', $ok ? 'message_sent' : 'message_failed');
}
@@ -315,7 +315,7 @@ class AKSRT_Admin_Users_Menus {
if (!$rows) {
echo '<tr><td colspan="3">' . esc_html__('暂无用户邀请码', 'aksrt') . '</td></tr>';
}
$invite_table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('invite') : '';
$invite_table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('invite') : '';
foreach ((array) $rows as $row) {
$user_id = (int) ($row['user_id'] ?? 0);
$user = $user_id > 0 ? get_userdata($user_id) : null;
@@ -589,12 +589,12 @@ class AKSRT_Admin_Users_Menus {
}
private function render_reports_tab(): void {
if (!class_exists('AKSRT_Report_Center')) {
if (!class_exists('\AKSRT\Messages\ReportCenter')) {
echo '<div class="notice notice-error"><p>' . esc_html__('举报中心未初始化。', 'aksrt') . '</p></div>';
return;
}
$status = isset($_GET['status']) ? sanitize_key((string) wp_unslash($_GET['status'])) : 'pending';
$svc = AKSRT_Report_Center::get_instance();
$svc = \AKSRT\Messages\ReportCenter::get_instance();
$counts = $svc->get_status_counts();
echo '<p>' . esc_html(sprintf(
@@ -650,11 +650,11 @@ class AKSRT_Admin_Users_Menus {
}
private function render_restrictions_tab(): void {
if (!class_exists('AKSRT_User_Restriction')) {
if (!class_exists('\AKSRT\User\Restriction')) {
echo '<div class="notice notice-error"><p>' . esc_html__('限制模块未初始化。', 'aksrt') . '</p></div>';
return;
}
$svc = AKSRT_User_Restriction::get_instance();
$svc = \AKSRT\User\Restriction::get_instance();
$stats = $svc->get_stats();
echo '<p>' . esc_html(sprintf(
/* translators: 1 total 2 active 3 banned */
@@ -684,7 +684,7 @@ class AKSRT_Admin_Users_Menus {
echo '</form>';
global $wpdb;
$table = class_exists('AKSRT_DB_Migrator') ? AKSRT_DB_Migrator::table('user_restriction') : '';
$table = class_exists('\AKSRT\Core\DBMigrator') ? \AKSRT\Core\DBMigrator::table('user_restriction') : '';
if ($table === '') {
echo '<div class="notice notice-warning"><p>' . esc_html__('限制表不可用。', 'aksrt') . '</p></div>';
return;
@@ -725,7 +725,7 @@ class AKSRT_Admin_Users_Menus {
$new_status = isset($_POST['new_status']) ? sanitize_key((string) wp_unslash($_POST['new_status'])) : '';
$note = isset($_POST['note']) ? sanitize_textarea_field((string) wp_unslash($_POST['note'])) : '';
check_admin_referer('aksrt_users_update_report_' . $id);
$ok = $id > 0 && class_exists('AKSRT_Report_Center') && AKSRT_Report_Center::get_instance()->update_status($id, $new_status, $note);
$ok = $id > 0 && class_exists('\AKSRT\Messages\ReportCenter') && \AKSRT\Messages\ReportCenter::get_instance()->update_status($id, $new_status, $note);
$this->redirect('aksrt_user_ban', $ok ? 'report_updated' : 'report_failed', ['tab' => 'reports']);
}
@@ -739,8 +739,8 @@ class AKSRT_Admin_Users_Menus {
$scope = isset($_POST['scope']) ? sanitize_key((string) wp_unslash($_POST['scope'])) : 'global';
$reason = isset($_POST['reason']) ? sanitize_text_field((string) wp_unslash($_POST['reason'])) : '';
$ok = false;
if ($user_id > 0 && $reason !== '' && class_exists('AKSRT_User_Restriction')) {
$result = AKSRT_User_Restriction::get_instance()->restrict($user_id, $type, $reason, $scope, '', get_current_user_id());
if ($user_id > 0 && $reason !== '' && class_exists('\AKSRT\User\Restriction')) {
$result = \AKSRT\User\Restriction::get_instance()->restrict($user_id, $type, $reason, $scope, '', get_current_user_id());
$ok = !empty($result['id']) || !empty($result['success']) || is_array($result);
}
$this->redirect('aksrt_user_ban', $ok ? 'restriction_added' : 'restriction_failed', ['tab' => 'restrictions']);
@@ -752,7 +752,7 @@ class AKSRT_Admin_Users_Menus {
}
$id = isset($_POST['restriction_id']) ? (int) $_POST['restriction_id'] : 0;
check_admin_referer('aksrt_users_remove_restriction_' . $id);
$ok = $id > 0 && class_exists('AKSRT_User_Restriction') && AKSRT_User_Restriction::get_instance()->remove_restriction($id);
$ok = $id > 0 && class_exists('\AKSRT\User\Restriction') && \AKSRT\User\Restriction::get_instance()->remove_restriction($id);
$this->redirect('aksrt_user_ban', $ok ? 'restriction_removed' : 'restriction_failed', ['tab' => 'restrictions']);
}
@@ -1,16 +1,13 @@
<?php
/**
* AKSRT Admin — Page Display Controller
*
* Handles REST routes for the "页面&显示" domain:
* Header components, banners, and homepage visual modules.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Page_Display_Controller extends AKSRT_Admin_Controller_Base {
class PageDisplayController extends ControllerBase {
private static $instance = null;
private $admin;
@@ -20,7 +17,7 @@ class AKSRT_Admin_Page_Display_Controller extends AKSRT_Admin_Controller_Base {
return self::$instance;
}
public function set_admin(AKSRT_Admin $admin): void {
public function set_admin(Admin $admin): void {
$this->admin = $admin;
}
@@ -70,7 +67,7 @@ class AKSRT_Admin_Page_Display_Controller extends AKSRT_Admin_Controller_Base {
];
}
public function rest_get_banners(WP_REST_Request $request): WP_REST_Response {
public function rest_get_banners(\WP_REST_Request $request): \WP_REST_Response {
$kind = $this->normalize_banner_kind($request->get_param('kind') ?: 'hero');
$args = [
'post_type' => 'aksrt_banner',
@@ -109,7 +106,7 @@ class AKSRT_Admin_Page_Display_Controller extends AKSRT_Admin_Controller_Base {
return rest_ensure_response(['code' => 'success', 'data' => $banners]);
}
public function rest_create_banner(WP_REST_Request $request): WP_REST_Response {
public function rest_create_banner(\WP_REST_Request $request): \WP_REST_Response {
$params = $this->get_json_params($request);
$kind = $this->normalize_banner_kind($params['kind'] ?? 'hero');
$title = sanitize_text_field($params['title'] ?? '');
@@ -122,7 +119,7 @@ class AKSRT_Admin_Page_Display_Controller extends AKSRT_Admin_Controller_Base {
]);
if (is_wp_error($post_id)) {
return new WP_REST_Response(['code' => 'error', 'message' => $post_id->get_error_message()], 400);
return new \WP_REST_Response(['code' => 'error', 'message' => $post_id->get_error_message()], 400);
}
update_post_meta($post_id, '_image_url', esc_url_raw($params['image_url'] ?? ''));
@@ -147,10 +144,10 @@ class AKSRT_Admin_Page_Display_Controller extends AKSRT_Admin_Controller_Base {
return rest_ensure_response(['code' => 'success', 'data' => ['id' => $post_id], 'message' => __('幻灯片已创建', 'aksrt')]);
}
public function rest_handle_banner_item(WP_REST_Request $request): WP_REST_Response {
public function rest_handle_banner_item(\WP_REST_Request $request): \WP_REST_Response {
$id = absint($request['id']);
if (!$id || get_post_type($id) !== 'aksrt_banner') {
return new WP_REST_Response(['code' => 'not_found', 'message' => __('幻灯片不存在', 'aksrt')], 404);
return new \WP_REST_Response(['code' => 'not_found', 'message' => __('幻灯片不存在', 'aksrt')], 404);
}
if ($request->get_method() === 'DELETE') {
@@ -200,4 +197,3 @@ class AKSRT_Admin_Page_Display_Controller extends AKSRT_Admin_Controller_Base {
return rest_ensure_response(['code' => 'success', 'message' => __('幻灯片已更新', 'aksrt')]);
}
}
@@ -1,15 +1,13 @@
<?php
/**
* AKSRT Admin — Payment Controller
*
* Owns section-level REST routes for the "支付&付费" domain.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
class PaymentController extends ControllerBase {
private static $instance = null;
@@ -118,17 +116,17 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function rest_payment_overview(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Settings')) {
public function rest_payment_overview(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Settings\Settings')) {
return $this->error('设置模块未初始化', 500);
}
$paid = AKSRT_Settings::get_paid_content_settings();
$recharge = AKSRT_Settings::get_payment_recharge_settings();
$vip = AKSRT_Settings::get_payment_vip_settings();
$revenue = AKSRT_Settings::get_payment_revenue_settings();
$affiliate = AKSRT_Settings::get_payment_affiliate_settings();
$gateway = AKSRT_Settings::get_payment_gateway_settings();
$paid = \AKSRT\Settings\Settings::get_paid_content_settings();
$recharge = \AKSRT\Settings\Settings::get_payment_recharge_settings();
$vip = \AKSRT\Settings\Settings::get_payment_vip_settings();
$revenue = \AKSRT\Settings\Settings::get_payment_revenue_settings();
$affiliate = \AKSRT\Settings\Settings::get_payment_affiliate_settings();
$gateway = \AKSRT\Settings\Settings::get_payment_gateway_settings();
return $this->success([
'data' => [
@@ -138,7 +136,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
'revenue' => $revenue,
'affiliate' => $affiliate,
'gateway' => $gateway,
'currency_name' => AKSRT_Settings::get_currency_name(),
'currency_name' => \AKSRT\Settings\Settings::get_currency_name(),
],
]);
}
@@ -146,15 +144,15 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /payment/revenue — revenue stats with optional time-series
*/
public function get_revenue(WP_REST_Request $request): WP_REST_Response {
public function get_revenue(\WP_REST_Request $request): \WP_REST_Response {
$revenue_stats = ['total' => 0, 'pending' => 0, 'settled' => 0, 'count' => 0];
if (class_exists('AKSRT_Revenue')) {
$revenue_stats = AKSRT_Revenue::get_instance()->get_stats();
if (class_exists('\AKSRT\Payment\Revenue')) {
$revenue_stats = \AKSRT\Payment\Revenue::get_instance()->get_stats();
}
$withdrawal_stats = ['total' => 0, 'pending' => 0, 'completed' => 0, 'total_paid' => 0];
if (class_exists('AKSRT_Withdrawal')) {
$withdrawal_stats = AKSRT_Withdrawal::get_instance()->get_stats();
if (class_exists('\AKSRT\Payment\Withdrawal')) {
$withdrawal_stats = \AKSRT\Payment\Withdrawal::get_instance()->get_stats();
}
$response = [
@@ -173,7 +171,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* Build revenue time-series data.
*/
private function get_revenue_time_series(WP_REST_Request $request): array {
private function get_revenue_time_series(\WP_REST_Request $request): array {
global $wpdb;
$prefix = $wpdb->prefix;
@@ -228,8 +226,8 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /payment/withdrawals — 提现列表,统一 page + per_page 分页
*/
public function get_withdrawals(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Withdrawal')) {
public function get_withdrawals(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\Withdrawal')) {
return $this->success(['data' => ['items' => [], 'total' => 0, 'page' => 1, 'total_pages' => 1, 'stats' => []]]);
}
@@ -237,14 +235,14 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
$page = max(1, (int) $request->get_param('page'));
$per_page = max(1, min(50, (int) $request->get_param('per_page'))) ?: 20;
$items = AKSRT_Withdrawal::get_instance()->get_all([
$items = \AKSRT\Payment\Withdrawal::get_instance()->get_all([
'status' => $status,
'limit' => $per_page,
'offset' => ($page - 1) * $per_page,
]);
$total = AKSRT_Withdrawal::get_instance()->get_count(['status' => $status]);
$stats = AKSRT_Withdrawal::get_instance()->get_stats();
$total = \AKSRT\Payment\Withdrawal::get_instance()->get_count(['status' => $status]);
$stats = \AKSRT\Payment\Withdrawal::get_instance()->get_stats();
return $this->success([
'data' => [
@@ -260,8 +258,8 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /payment/withdrawals/{id} — 更新提现状态
*/
public function update_withdrawal_status(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Withdrawal')) {
public function update_withdrawal_status(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\Withdrawal')) {
return $this->error('提现模块未初始化', 500);
}
@@ -279,7 +277,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
return $this->error('无效的提现 ID');
}
$success = AKSRT_Withdrawal::get_instance()->update_status($id, $new_status, $note);
$success = \AKSRT\Payment\Withdrawal::get_instance()->update_status($id, $new_status, $note);
if ($success) {
return $this->success(['message' => __('提现状态已更新', 'aksrt')]);
@@ -294,14 +292,14 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /payment/charge-cards — 充值卡列表
*/
public function get_charge_cards(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Charge_Card')) {
public function get_charge_cards(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\ChargeCard')) {
return $this->success(['data' => ['items' => [], 'total' => 0, 'page' => 1, 'max_pages' => 1]]);
}
global $wpdb;
$table = AKSRT_DB_Migrator::table('charge_card');
$table = \AKSRT\Core\DBMigrator::table('charge_card');
$page = max(1, (int) ($request->get_param('page') ?: 1));
$per_page = max(1, min(100, (int) ($request->get_param('per_page') ?: 20)));
$status = sanitize_key((string) $request->get_param('status'));
@@ -348,7 +346,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
$total = count($items);
$offset = ($page - 1) * $per_page;
$stats = AKSRT_Charge_Card::get_instance()->get_stats();
$stats = \AKSRT\Payment\ChargeCard::get_instance()->get_stats();
return $this->success([
'data' => [
@@ -374,8 +372,8 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /payment/charge-cards — 创建充值卡
*/
public function create_charge_card(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Charge_Card')) {
public function create_charge_card(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\ChargeCard')) {
return $this->error('充值卡系统未启用', 500);
}
@@ -389,7 +387,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
return $this->error('卡密不能为空');
}
$id = AKSRT_Charge_Card::get_instance()->create(array_merge($params, [
$id = \AKSRT\Payment\ChargeCard::get_instance()->create(array_merge($params, [
'type' => $type,
'password' => $password,
]));
@@ -407,8 +405,8 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /payment/charge-cards/batch — 批量生成充值卡
*/
public function batch_create_charge_cards(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Charge_Card')) {
public function batch_create_charge_cards(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\ChargeCard')) {
return $this->error('充值卡系统未启用', 500);
}
@@ -437,7 +435,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
return $this->error('积分卡积分必须大于 0');
}
$codes = AKSRT_Charge_Card::get_instance()->batch_create(
$codes = \AKSRT\Payment\ChargeCard::get_instance()->batch_create(
$type,
$meta_fields,
$count,
@@ -456,8 +454,8 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /payment/charge-cards/{id}/disable — 禁用充值卡
*/
public function disable_charge_card(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Charge_Card')) {
public function disable_charge_card(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\ChargeCard')) {
return $this->error('充值卡系统未启用', 500);
}
@@ -466,7 +464,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
return $this->error('参数无效');
}
$success = AKSRT_Charge_Card::get_instance()->disable($id);
$success = \AKSRT\Payment\ChargeCard::get_instance()->disable($id);
if ($success) {
return $this->success(['message' => __('充值卡已禁用', 'aksrt')]);
@@ -474,11 +472,11 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
return $this->error(__('操作失败', 'aksrt'));
}
public function get_charge_card_detail(WP_REST_Request $request): WP_REST_Response {
public function get_charge_card_detail(\WP_REST_Request $request): \WP_REST_Response {
global $wpdb;
$id = (int) $request->get_param('id');
$table = AKSRT_DB_Migrator::table('charge_card');
$table = \AKSRT\Core\DBMigrator::table('charge_card');
if ($id <= 0 || !$table) {
return $this->error(__('充值卡不存在', 'aksrt'), 404);
@@ -503,14 +501,14 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* GET /payment/rebate/log — 返佣记录列表
*/
public function get_rebate_list(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Rebate')) {
public function get_rebate_list(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\Rebate')) {
return $this->success(['data' => ['items' => [], 'total' => 0, 'page' => 1, 'max_pages' => 1]]);
}
global $wpdb;
$table = AKSRT_DB_Migrator::table('rebate_log');
$table = \AKSRT\Core\DBMigrator::table('rebate_log');
$page = max(1, (int) ($request->get_param('page') ?: 1));
$per_page = max(1, min(100, (int) ($request->get_param('per_page') ?: 20)));
$status = sanitize_key((string) $request->get_param('status'));
@@ -564,7 +562,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
$total = count($items);
$offset = ($page - 1) * $per_page;
$stats = AKSRT_Rebate::get_instance()->get_stats();
$stats = \AKSRT\Payment\Rebate::get_instance()->get_stats();
return $this->success([
'data' => [
@@ -594,8 +592,8 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /payment/rebate/{id}/settle — 结算返佣
*/
public function settle_rebate(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Rebate')) {
public function settle_rebate(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\Rebate')) {
return $this->error('返佣系统未启用', 500);
}
@@ -606,7 +604,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
return $this->error('参数无效');
}
$success = AKSRT_Rebate::get_instance()->settle($id);
$success = \AKSRT\Payment\Rebate::get_instance()->settle($id);
if ($success) {
$this->append_rebate_process_log($id, 'settled', $note);
@@ -618,8 +616,8 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
/**
* POST /payment/rebate/{id}/cancel — 取消返佣
*/
public function cancel_rebate(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Rebate')) {
public function cancel_rebate(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\Rebate')) {
return $this->error('返佣系统未启用', 500);
}
@@ -630,7 +628,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
return $this->error('参数无效');
}
$success = AKSRT_Rebate::get_instance()->cancel($id);
$success = \AKSRT\Payment\Rebate::get_instance()->cancel($id);
if ($success) {
$this->append_rebate_process_log($id, 'cancelled', $note);
@@ -639,11 +637,11 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
return $this->error(__('操作失败', 'aksrt'));
}
public function get_rebate_detail(WP_REST_Request $request): WP_REST_Response {
public function get_rebate_detail(\WP_REST_Request $request): \WP_REST_Response {
global $wpdb;
$id = (int) $request->get_param('id');
$table = AKSRT_DB_Migrator::table('rebate_log');
$table = \AKSRT\Core\DBMigrator::table('rebate_log');
if ($id <= 0 || !$table) {
return $this->error(__('返佣记录不存在', 'aksrt'), 404);
@@ -715,7 +713,7 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
'expires_at' => (string) ($row['expires_at'] ?? ''),
'created_at' => (string) ($row['created_at'] ?? ''),
'note' => (string) ($row['note'] ?? ''),
'used_by_user' => $user instanceof WP_User ? [
'used_by_user' => $user instanceof \WP_User ? [
'id' => (int) $user->ID,
'display_name' => $user->display_name,
'email' => $user->user_email,
@@ -753,12 +751,12 @@ class AKSRT_Admin_Payment_Controller extends AKSRT_Admin_Controller_Base {
'settled_at' => (string) ($row['settled_at'] ?? ''),
'note' => (string) ($row['note'] ?? ''),
'history_count' => count($this->get_rebate_process_log((int) ($row['id'] ?? 0))),
'user' => $user instanceof WP_User ? [
'user' => $user instanceof \WP_User ? [
'id' => (int) $user->ID,
'display_name' => $user->display_name,
'email' => $user->user_email,
] : null,
'source_user' => $source_user instanceof WP_User ? [
'source_user' => $source_user instanceof \WP_User ? [
'id' => (int) $source_user->ID,
'display_name' => $source_user->display_name,
'email' => $source_user->user_email,
@@ -1,19 +1,13 @@
<?php
/**
* AKSRT Admin — Permissions Controller
*
* Owns REST routes for the "功能&权限" domain:
* Captcha, moderation, user permissions.
*
* Previously these routes were registered under the User Controller.
* This controller provides proper domain separation.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Permissions_Controller extends AKSRT_Admin_Controller_Base {
class PermissionsController extends ControllerBase {
private static $instance = null;
@@ -37,14 +31,14 @@ class AKSRT_Admin_Permissions_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function get_capabilities(): WP_REST_Response {
if (!class_exists('AKSRT_Settings')) {
public function get_capabilities(): \WP_REST_Response {
if (!class_exists('\AKSRT\Settings\Settings')) {
return $this->error(__('能力矩阵模块不可用', 'aksrt'), 500);
}
$caps = AKSRT_Settings::get_user_capabilities();
$defs = AKSRT_Settings::cap_definitions();
$columns = AKSRT_Settings::cap_role_columns();
$caps = \AKSRT\Settings\Settings::get_user_capabilities();
$defs = \AKSRT\Settings\Settings::cap_definitions();
$columns = \AKSRT\Settings\Settings::cap_role_columns();
return $this->success([
'data' => [
@@ -59,8 +53,8 @@ class AKSRT_Admin_Permissions_Controller extends AKSRT_Admin_Controller_Base {
]);
}
public function save_capabilities(WP_REST_Request $request): WP_REST_Response {
if (!class_exists('AKSRT_Settings')) {
public function save_capabilities(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Settings\Settings')) {
return $this->error(__('能力矩阵模块不可用', 'aksrt'), 500);
}
@@ -71,8 +65,8 @@ class AKSRT_Admin_Permissions_Controller extends AKSRT_Admin_Controller_Base {
return $this->error(__('无效的能力矩阵数据', 'aksrt'), 422);
}
$defs = AKSRT_Settings::cap_definitions();
$columns = AKSRT_Settings::cap_role_columns();
$defs = \AKSRT\Settings\Settings::cap_definitions();
$columns = \AKSRT\Settings\Settings::cap_role_columns();
$clean = [];
foreach ($defs as $cap_id => $def) {
@@ -90,10 +84,10 @@ class AKSRT_Admin_Permissions_Controller extends AKSRT_Admin_Controller_Base {
}
}
$all = AKSRT_Settings::get_all();
$all = \AKSRT\Settings\Settings::get_all();
$all['user_caps'] = $clean;
update_option('aksrt_settings', $all);
AKSRT_Settings::flush_settings_cache();
\AKSRT\Settings\Settings::flush_settings_cache();
return $this->success([
'message' => __('能力矩阵已保存', 'aksrt'),
@@ -1,15 +1,13 @@
<?php
/**
* AKSRT Admin — Post List Controller
*
* Owns section-level REST routes for the "文章&列表" domain.
*
* @package AKSRT
*/
namespace AKSRT\Admin;
defined('ABSPATH') || exit;
class AKSRT_Admin_Post_List_Controller extends AKSRT_Admin_Controller_Base {
class PostListController extends ControllerBase {
private static $instance = null;
@@ -1,13 +1,13 @@
<?php
/**
* AKSRT_Admin_Schema_Global schema builder.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Schema;
defined('ABSPATH') || exit;
class AKSRT_Admin_Schema_Global {
class GlobalSchema {
public static function build(): array {
return [
@@ -1,16 +1,13 @@
<?php
/**
* Post list — "list" section schema (Zibll-aligned field contract).
*
* Storage keys mirror Zibll option IDs where the admin list section is the source of truth.
* Runtime maps them into render modes; no legacy key fallbacks.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Schema\PostList;
defined('ABSPATH') || exit;
class AKSRT_Admin_Schema_Post_List_List {
class SchemaPostListList {
public static function build(): array {
return [
@@ -0,0 +1,25 @@
<?php
/**
* @package AKSRT
*/
namespace AKSRT\Admin\Schema;
defined('ABSPATH') || exit;
class SchemaExtensions {
public static function build(): array {
return [
'domain' => 'extensions',
'title' => '扩展&增强',
'sections' => [
'ip' => SchemaExtensionsIP::build(),
'audit' => SchemaExtensionsAudit::build(),
'push' => SchemaExtensionsPush::build(),
'security' => SchemaExtensionsSecurity::build(),
'docs-mode' => SchemaExtensionsDocsMode::build(),
],
];
}
}
@@ -1,13 +1,13 @@
<?php
/**
* AKSRT_Admin_Schema_Extensions_Audit section schema.
*
* @package AKSRT
*/
namespace AKSRT\Admin\Schema;
defined('ABSPATH') || exit;
class AKSRT_Admin_Schema_Extensions_Audit {
class SchemaExtensionsAudit {
public static function build(): array {
return [

Some files were not shown because too many files have changed in this diff Show More