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:
kate522 committed 2026-07-17 13:29:22 +08:00
1 parent 8f349b40fb
commit aaf458af1c
404 files changed
+13602 -7705

No files matched your search

+5 -5
View File
@@ -25,8 +25,8 @@ if (function_exists('aksrt_render_post')) {
$mode = $args['mode'];␍
} elseif (function_exists('aksrt_get_post_flow') && aksrt_get_post_flow(get_the_ID()) === 'cms') {␍
$mode = 'grid-cms';␍
} elseif (class_exists('AKSRT_Settings')) {␍
$archive_layout = AKSRT_Settings::get_archive_layout();␍
} elseif (class_exists('\AKSRT\Settings\Settings')) {␍
$archive_layout = \AKSRT\Settings\Settings::get_archive_layout();␍
$mode = in_array($archive_layout, ['card', 'list', 'grid-cms'], true) ? $archive_layout : 'card';␍
}␍
␍
@@ -49,7 +49,7 @@ if (function_exists('aksrt_render_post')) {
␍
$args = isset($args) && is_array($args) ? $args : [];␍
␍
$lazy_cfg = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_lazyload_config() : ['enabled' => false, 'placeholder_url' => ''];␍
$lazy_cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_lazyload_config() : ['enabled' => false, 'placeholder_url' => ''];␍
$lazy_on = !empty($lazy_cfg['enabled']);␍
$placeholder_url = !empty($lazy_cfg['placeholder_url']) ? (string) $lazy_cfg['placeholder_url'] : (get_template_directory_uri() . '/assets/img/placeholder.svg');␍
␍
@@ -59,8 +59,8 @@ if (is_string($forced_layout) && in_array($forced_layout, ['card', 'list', 'maso
$layout = $forced_layout;␍
} elseif (function_exists('aksrt_get_post_flow') && aksrt_get_post_flow(get_the_ID()) === 'cms') {␍
$layout = 'grid-cms';␍
} elseif (class_exists('AKSRT_Settings')) {␍
$layout = AKSRT_Settings::get_archive_layout();␍
} elseif (class_exists('\AKSRT\Settings\Settings')) {␍
$layout = \AKSRT\Settings\Settings::get_archive_layout();␍
}␍
␍
$post_id = get_the_ID();␍
+2 -2
View File
@@ -3,7 +3,7 @@
* Document Chapter Navigation
*
* Shows previous/next chapter navigation at the bottom of a document page.
* Uses AKSRT_Docs_Presenter for chapter resolution.
* Uses \AKSRT\Core\DocsPresenter for chapter resolution.
*
* @package AKSRT
*/
@@ -12,7 +12,7 @@ defined('ABSPATH') || exit;
$current_id = get_the_ID();
$presenter = class_exists('AKSRT_Docs_Presenter') ? AKSRT_Docs_Presenter::get_instance() : null;
$presenter = class_exists('\AKSRT\Core\DocsPresenter') ? \AKSRT\Core\DocsPresenter::get_instance() : null;
if ($presenter) {
$nav = $presenter->get_chapter_nav($current_id);
+3 -3
View File
@@ -3,7 +3,7 @@
* Docs Mode: Sidebar Navigation
*
* 文档模式侧边栏:显示文档目录树,当前章节高亮。
* Uses AKSRT_Docs_Presenter for tree construction.
* Uses \AKSRT\Core\DocsPresenter for tree construction.
*
* @package AKSRT
*/
@@ -14,7 +14,7 @@ $current_id = get_the_ID();
$parent_id = wp_get_post_parent_id($current_id);
$root_id = $parent_id ?: $current_id;
$presenter = class_exists('AKSRT_Docs_Presenter') ? AKSRT_Docs_Presenter::get_instance() : null;
$presenter = class_exists('\AKSRT\Core\DocsPresenter') ? \AKSRT\Core\DocsPresenter::get_instance() : null;
if ($presenter) {
$doc_pages = $presenter->get_flat_tree($root_id, 3);
@@ -30,7 +30,7 @@ if ($presenter) {
$root_page = get_post($root_id);
// Quick search for docs
$doc_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_docs_mode_settings() : [];
$doc_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_docs_mode_settings() : [];
$show_search = !empty($doc_settings['toc_enabled']);
?>
<aside class="aksrt-doc-sidebar" role="navigation" aria-label="<?php esc_attr_e('文档导航', 'aksrt'); ?>">
+2 -2
View File
@@ -11,7 +11,7 @@ $page_title = get_the_title() ?: __('下载中心', 'aksrt');
$page_desc = get_the_excerpt() ?: __('浏览和下载本站提供的各类资源。', 'aksrt');
$current_filter = isset($_GET['resource_type']) ? sanitize_key((string) $_GET['resource_type']) : '';
$resource_type_labels = function_exists('aksrt_get_pay_types') ? aksrt_get_pay_types() : [];
unset($resource_type_labels[AKSRT_Domain_Model::PAY_TYPE_READING]);
unset($resource_type_labels[\AKSRT\Core\DomainModel::PAY_TYPE_READING]);
$resource_count_query = new WP_Query([
'post_type' => 'post',
@@ -20,7 +20,7 @@ $resource_count_query = new WP_Query([
'fields' => 'ids',
'meta_query' => [
[
'key' => AKSRT_Domain_Model::RESOURCE_MARKER_KEY,
'key' => \AKSRT\Core\DomainModel::RESOURCE_MARKER_KEY,
'value' => '1',
],
],
@@ -2,7 +2,7 @@
/**
* Download Permission Card
*
* Shows download status and actions from AKSRT_Download_State
* Shows download status and actions from \AKSRT\Content\DownloadState
* (Content_Visibility + cashier unlock — not per-download credits).
*
* @package AKSRT
@@ -27,8 +27,8 @@ $state = [
'need_vip' => false,
];
if (class_exists('AKSRT_Download_State')) {
$state = array_merge($state, AKSRT_Download_State::get_instance()->resolve($post_id));
if (class_exists('\AKSRT\Content\DownloadState')) {
$state = array_merge($state, \AKSRT\Content\DownloadState::get_instance()->resolve($post_id));
} elseif (function_exists('aksrt_can_download')) {
$gate = aksrt_can_download($post_id);
if (is_wp_error($gate)) {
@@ -16,7 +16,7 @@
*/
defined('ABSPATH') || exit;
if (class_exists('AKSRT_Settings') && !AKSRT_Settings::homepage_module_banner_enabled()) {
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::homepage_module_banner_enabled()) {
return;
}
@@ -24,7 +24,7 @@ $show_dates = !isset($cfg['show_dates']) || !empty($cfg['show_dates']);
if (empty($cat_ids)) return;
// 懒加载配置
$lazy_cfg = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_lazyload_config() : ['enabled' => false, 'placeholder_url' => ''];
$lazy_cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_lazyload_config() : ['enabled' => false, 'placeholder_url' => ''];
$lazy_on = !empty($lazy_cfg['enabled']);
$placeholder = $lazy_cfg['placeholder_url'] ?: (get_template_directory_uri() . '/assets/img/placeholder.svg');
@@ -35,13 +35,13 @@ foreach ($cat_ids as $idx => $cat_id) {
if (!$term || is_wp_error($term)) continue;
// 封面图
$cover_url = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_category_cover_url($cat_id)
$cover_url = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_category_cover_url($cat_id)
: $placeholder;
// 分类描述(优先 term meta 推荐描述,其次原生 description)
$desc = class_exists('AKSRT_Settings')
? AKSRT_Settings::get_category_recommend_desc($cat_id)
$desc = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_category_recommend_desc($cat_id)
: (string) $term->description;
// 5 篇最新文章
+1 -1
View File
@@ -18,7 +18,7 @@ if (!is_array($cfg)) {
$hero_banners = function_exists('aksrt_get_banners') ? aksrt_get_banners(8, 'hero') : [];
$settings = function_exists('aksrt_get_all_settings') ? aksrt_get_all_settings() : [];
$search_cfg = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_header_components_search_config() : ['show' => false, 'keywords' => [], 'categories' => [], 'type_options' => []];
$search_cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_header_components_search_config() : ['show' => false, 'keywords' => [], 'categories' => [], 'type_options' => []];
$show_search = !empty($search_cfg['show']) || !empty($cfg['with_search']);
$show_cards = !empty($settings['header_components_cards_enabled']);
$icon_cards = isset($settings['header_components_icon_cards']) ? (array) $settings['header_components_icon_cards'] : [];
+9 -9
View File
@@ -12,8 +12,8 @@ if (is_user_logged_in()) {
}
$oauth_providers = [];
if (class_exists('AKSRT_OAuth')) {
$oauth_providers = AKSRT_OAuth::get_instance()->get_auth_providers_data();
if (class_exists('\AKSRT\Auth\OAuth')) {
$oauth_providers = \AKSRT\Auth\OAuth::get_instance()->get_auth_providers_data();
}
$registration_open = true;
@@ -24,15 +24,15 @@ $invite_field_hint = '';
$invite_prefill = '';
$show_qrcode_tab = false;
if (class_exists('AKSRT_Settings')) {
$registration_open = AKSRT_Settings::registration_enabled();
if (method_exists('AKSRT_Settings', 'close_signup') && AKSRT_Settings::close_signup()) {
if (class_exists('\AKSRT\Settings\Settings')) {
$registration_open = \AKSRT\Settings\Settings::registration_enabled();
if (method_exists('\AKSRT\Settings\Settings', 'close_signup') && \AKSRT\Settings\Settings::close_signup()) {
$registration_open = false;
}
$email_verification = AKSRT_Settings::registration_requires_email_verification();
$close_signin = AKSRT_Settings::close_signin();
$email_verification = \AKSRT\Settings\Settings::registration_requires_email_verification();
$close_signin = \AKSRT\Settings\Settings::close_signin();
$invite_cfg = AKSRT_Settings::get_invite_registration_config();
$invite_cfg = \AKSRT\Settings\Settings::get_invite_registration_config();
$invite_field_mode = (string) ($invite_cfg['register_field'] ?? 'hidden');
$invite_field_hint = $invite_field_mode === 'required'
? (string) ($invite_cfg['must_desc'] ?? '')
@@ -57,7 +57,7 @@ $reset_url = function_exists('aksrt_get_reset_password_url') ? aksrt_get_reset_p
$agreement = function_exists('aksrt_get_auth_agreement_view')
? aksrt_get_auth_agreement_view()
: ['enabled' => true, 'required' => true, 'label_html' => esc_html__('我已阅读并同意用户协议', 'aksrt'), 'field_name' => 'agree_terms'];
$logo_url = class_exists('AKSRT_Settings') ? AKSRT_Settings::user_logo_url() : '';
$logo_url = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::user_logo_url() : '';
?>
<div class="aksrt-modal-auth" id="aksrt-modal-auth" aria-hidden="true" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e('登录', 'aksrt'); ?>">
+4 -4
View File
@@ -22,8 +22,8 @@ $args = is_array($args ?? null) ? $args : [];
// Resolve style: explicit args > global setting.
$ph_style = array_key_exists('style', $args) ? $args['style'] : null;
if ($ph_style === null) {
$ph_style = class_exists('AKSRT_Settings')
? (AKSRT_Settings::get_other_page_settings()['header_style'] ?? '1')
$ph_style = class_exists('\AKSRT\Settings\Settings')
? (\AKSRT\Settings\Settings::get_other_page_settings()['header_style'] ?? '1')
: '1';
}
if ($ph_style === 'not') {
@@ -42,8 +42,8 @@ $ph_extra = (string) ($args['extra'] ?? '');
// Cover image: explicit args > global setting > post thumbnail.
$ph_cover = (string) ($args['cover'] ?? '');
if ($ph_cover === '' && class_exists('AKSRT_Settings')) {
$other = AKSRT_Settings::get_other_page_settings();
if ($ph_cover === '' && class_exists('\AKSRT\Settings\Settings')) {
$other = \AKSRT\Settings\Settings::get_other_page_settings();
$ph_cover = (string) ($other['header_cover_img'] ?? '');
}
if ($ph_cover === '' && has_post_thumbnail()) {
+8 -8
View File
@@ -41,12 +41,12 @@ $gate_blocked = is_wp_error($gate);
$gate_code = $gate_blocked ? $gate->get_error_code() : '';
$gate_data = $gate_blocked ? (array) $gate->get_error_data() : [];
$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_credit' => true, 'download_captcha' => false];
$access = class_exists('AKSRT_Content_Visibility')
? AKSRT_Content_Visibility::get_post_access_state($post_id)
$access = class_exists('\AKSRT\Content\Visibility')
? \AKSRT\Content\Visibility::get_post_access_state($post_id)
: [];
$has_paid_access = !empty($access['has_paid_access']);
$priced = function_exists('aksrt_get_user_pay_price') ? aksrt_get_user_pay_price($post_id) : null;
@@ -60,7 +60,7 @@ $captcha_active = !empty($paid_settings['download_captcha']) || !empty($meta['re
if ($captcha_active && function_exists('aksrt_is_captcha_enabled_for') && !aksrt_is_captcha_enabled_for('download')) {
$captcha_active = false;
}
$balance = (int) ($gate_data['balance'] ?? (is_user_logged_in() && class_exists('AKSRT_Credits') ? AKSRT_Credits::balance(get_current_user_id()) : 0));
$balance = (int) ($gate_data['balance'] ?? (is_user_logged_in() && class_exists('\AKSRT\Credits\Credits') ? \AKSRT\Credits\Credits::balance(get_current_user_id()) : 0));
$login_url = (string) ($gate_data['login_url'] ?? wp_login_url(get_permalink($post_id)));
$vip_url = function_exists('aksrt_get_user_center_tab_url')
? aksrt_get_user_center_tab_url('credits')
@@ -134,10 +134,10 @@ $show_sales = !isset($meta['show_sales']) || !empty($meta['show_sales']);
$pay_type_badge = function_exists('aksrt_get_pay_type_badge') ? aksrt_get_pay_type_badge($pay_type) : '';
// 货币名称
$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_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'] ?? '¥');
}
$format_vip = static function (float $amount) use ($pay_modo, $currency, $cash_symbol): string {
+3 -3
View File
@@ -13,8 +13,8 @@
defined('ABSPATH') || exit;
if (class_exists('AKSRT_Settings')) {
$header_nav = AKSRT_Settings::get_header_nav_settings();
if (class_exists('\AKSRT\Settings\Settings')) {
$header_nav = \AKSRT\Settings\Settings::get_header_nav_settings();
if (empty($header_nav['search_enabled'])) {
return;
}
@@ -39,7 +39,7 @@ $search_placeholder = function_exists('aksrt_get_search_placeholder') ? aks
$search_hot_keywords = function_exists('aksrt_get_search_hot_keywords') ? aksrt_get_search_hot_keywords() : [];
$history_enabled = function_exists('aksrt_search_history_enabled') ? aksrt_search_history_enabled() : true;
$suggestions_enabled = function_exists('aksrt_search_suggestions_enabled') ? aksrt_search_suggestions_enabled() : false;
$popular_title = class_exists('AKSRT_Settings') ? AKSRT_Settings::search_popular_title() : __('热门搜索', 'aksrt');
$popular_title = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::search_popular_title() : __('热门搜索', 'aksrt');
?>
<div
id="tabbar-search-overlay"
+1 -1
View File
@@ -3,7 +3,7 @@
* Shared product card (archive / related / storefront).
*
* Expected args:
* - product: array from AKSRT_Shop::build_product_card_view()
* - product: array from \AKSRT\Shop\Shop::build_product_card_view()
* - show_sales: bool (optional)
* - sales_cfg: array (optional; used when show_sales not provided)
*
+3 -3
View File
@@ -43,7 +43,7 @@ $abs_fmt = $use_modified
$time_text = human_time_diff($rel_base, $now) . $rel_label;
$classes = trim('article-avatar ' . $extra_class);
$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() : '';
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink());
$is_self = is_user_logged_in() && get_current_user_id() === $author_id;
@@ -115,8 +115,8 @@ $is_self = is_user_logged_in() && get_current_user_id() === $author_id;
</a>
<?php else : ?>
<?php
$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'])
+1 -1
View File
@@ -18,7 +18,7 @@ extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_ext
$follow_sub = isset($_GET['follow_sub']) ? sanitize_key(wp_unslash($_GET['follow_sub'])) : 'following';
$follow_sub = in_array($follow_sub, ['following', 'followers'], true) ? $follow_sub : 'following';
$follow_instance = class_exists('AKSRT_Follow') ? AKSRT_Follow::get_instance() : null;
$follow_instance = class_exists('\AKSRT\User\Follow') ? \AKSRT\User\Follow::get_instance() : null;
$following_count = $follow_instance ? (int) $follow_instance->get_following_count((int) $user_id) : 0;
$follower_count = $follow_instance ? (int) $follow_instance->get_follower_count((int) $user_id) : 0;
$list = ['items' => [], 'total' => 0, 'total_pages' => 1];
+2 -2
View File
@@ -136,8 +136,8 @@ extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_ext
<?php
$product_page = max(1, isset($_GET['product_page']) ? (int) $_GET['product_page'] : 1);
$product_view = ['items' => [], 'total' => 0, 'max_pages' => 0];
if (class_exists('AKSRT_Shop')) {
$product_view = AKSRT_Shop::get_instance()->get_store_products((int) $user_id, $product_page, (int) $per_page);
if (class_exists('\AKSRT\Shop\Shop')) {
$product_view = \AKSRT\Shop\Shop::get_instance()->get_store_products((int) $user_id, $product_page, (int) $per_page);
}
$product_items = is_array($product_view['items'] ?? null) ? $product_view['items'] : [];
$product_max_pages = (int) ($product_view['max_pages'] ?? 0);
+3 -3
View File
@@ -47,11 +47,11 @@ $bg_url = $dashboard['background_url'] ?? '';
$is_own = !empty($dashboard['is_own_profile']);
$follower_count = (int) ($tab_counts['follow'] ?? 0);
if ($follower_count <= 0 && class_exists('AKSRT_Follow')) {
$follower_count = (int) AKSRT_Follow::get_instance()->get_follower_count($user_id);
if ($follower_count <= 0 && class_exists('\AKSRT\User\Follow')) {
$follower_count = (int) \AKSRT\User\Follow::get_instance()->get_follower_count($user_id);
}
$pm_enabled = class_exists('AKSRT_Settings') && !empty(AKSRT_Settings::private_message_settings()['enabled']);
$pm_enabled = class_exists('\AKSRT\Settings\Settings') && !empty(\AKSRT\Settings\Settings::private_message_settings()['enabled']);
$messages_url = function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '';
$pm_url = ($pm_enabled && $messages_url !== '')
? add_query_arg('msg_type', 'conversation', $messages_url)