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:
1 parent
8f349b40fb
commit
aaf458af1c
404 files changed
+13602
-7705
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user