Merge pull request 'fix(ns): class_exists() must use FQCN after PSR-4' (#201) from fix/ns-class-exists-fqcn into main

Reviewed-on: CYL/wordpress-theme-aksrt#201
This commit is contained in:
2026-07-17 15:42:21 +08:00
40 changed files with 105 additions and 105 deletions
+10 -10
View File
@@ -45,7 +45,7 @@ class PayMenus {
'slug' => 'aksrt_orders',
'title' => __('订单', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayOrders')) {
if (class_exists('AKSRT\Admin\Native\PayOrders')) {
PayOrders::get_instance()->render_orders_page();
return;
}
@@ -56,7 +56,7 @@ class PayMenus {
'slug' => 'aksrt_pay_products',
'title' => __('付费文章', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayProducts')) {
if (class_exists('AKSRT\\Admin\\Native\\PayProducts')) {
PayProducts::get_instance()->render_products_page();
return;
}
@@ -67,7 +67,7 @@ class PayMenus {
'slug' => 'aksrt_download_logs',
'title' => __('下载记录', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayDownloadLogs')) {
if (class_exists('AKSRT\\Admin\\Native\\PayDownloadLogs')) {
PayDownloadLogs::get_instance()->render_page();
return;
}
@@ -78,7 +78,7 @@ class PayMenus {
'slug' => 'aksrt_shipping',
'title' => __('发货及物流', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayShipping')) {
if (class_exists('AKSRT\\Admin\\Native\\PayShipping')) {
PayShipping::get_instance()->render_shipping_page();
return;
}
@@ -89,7 +89,7 @@ class PayMenus {
'slug' => 'aksrt_after_sale',
'title' => __('售后管理', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayAfterSale')) {
if (class_exists('AKSRT\\Admin\\Native\\PayAfterSale')) {
PayAfterSale::get_instance()->render_after_sale_page();
return;
}
@@ -100,7 +100,7 @@ class PayMenus {
'slug' => 'aksrt_coupons',
'title' => __('优惠码', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayCoupons')) {
if (class_exists('AKSRT\\Admin\\Native\\PayCoupons')) {
PayCoupons::get_instance()->render_page();
return;
}
@@ -111,7 +111,7 @@ class PayMenus {
'slug' => 'aksrt_charge_cards',
'title' => __('卡密管理', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayChargeCards')) {
if (class_exists('AKSRT\\Admin\\Native\\PayChargeCards')) {
PayChargeCards::get_instance()->render_charge_cards_page();
return;
}
@@ -122,7 +122,7 @@ class PayMenus {
'slug' => 'aksrt_income',
'title' => __('创作分成', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayIncome')) {
if (class_exists('AKSRT\\Admin\\Native\\PayIncome')) {
PayIncome::get_instance()->render_income_page();
return;
}
@@ -133,7 +133,7 @@ class PayMenus {
'slug' => 'aksrt_rebate',
'title' => __('推广返佣', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayRebate')) {
if (class_exists('AKSRT\\Admin\\Native\\PayRebate')) {
PayRebate::get_instance()->render_rebate_page();
return;
}
@@ -144,7 +144,7 @@ class PayMenus {
'slug' => 'aksrt_withdraw',
'title' => __('提现审核', 'aksrt'),
'callback' => static function (): void {
if (class_exists('PayWithdrawals')) {
if (class_exists('AKSRT\\Admin\\Native\\PayWithdrawals')) {
PayWithdrawals::get_instance()->render_withdrawals_page();
return;
}
+3 -3
View File
@@ -512,14 +512,14 @@ class PayOrders {
}
private function shipping_status_options(bool $include_all = false): array {
if (class_exists('PayShipping')) {
if (class_exists('AKSRT\\Admin\\Native\\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('PayAfterSale')) {
if (class_exists('AKSRT\\Admin\\Native\\PayAfterSale')) {
return PayAfterSale::get_instance()->after_sale_type_options_public($include_all);
}
return $include_all ? ['' => __('全部类型', 'aksrt')] : [
@@ -528,7 +528,7 @@ class PayOrders {
}
private function render_carrier_field(string $selected = ''): void {
if (class_exists('PayShipping')) {
if (class_exists('AKSRT\\Admin\\Native\\PayShipping')) {
PayShipping::get_instance()->render_carrier_field_public($selected);
return;
}
+2 -2
View File
@@ -42,7 +42,7 @@ class AISEO {
];
}
if (!class_exists('AI') || !class_exists('AIPrompt')) {
if (!class_exists('AKSRT\\Ai\\AI') || !class_exists('AKSRT\\Ai\\AIPrompt')) {
return [
'success' => false,
'message' => __('AI 模块未加载', 'aksrt'),
@@ -115,7 +115,7 @@ class AISEO {
return ['success' => false, 'message' => __('AI SEO 功能未启用', 'aksrt')];
}
if (!class_exists('AI') || !class_exists('AIPrompt')) {
if (!class_exists('AKSRT\\Ai\\AI') || !class_exists('AKSRT\\Ai\\AIPrompt')) {
return ['success' => false, 'message' => __('AI 模块未加载', 'aksrt')];
}
+1 -1
View File
@@ -167,7 +167,7 @@ class EmailRollback {
if (count($log) > 10) $log = array_slice($log, -10);
update_user_meta($user_id, 'aksrt_email_verification_admin_log', $log);
if (class_exists('Service')) {
if (class_exists('AKSRT\\Auth\\Service')) {
Service::log_event('admin.email_rollback', [
'uid' => $user_id,
'by' => $by_admin_id ?: get_current_user_id(),
+1 -1
View File
@@ -41,7 +41,7 @@ class OAuth {
*/
public function get_auth_url(string $provider, string $action = 'login'): string {
if (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::oauth_proxy_mode() === 'client') {
if (class_exists('OAuthProxyClient')) {
if (class_exists('AKSRT\\Auth\\OAuthProxyClient')) {
return OAuthProxyClient::get_instance()->get_proxy_auth_url($provider, $action);
}
return '';
+1 -1
View File
@@ -118,7 +118,7 @@ class Download {
: ((($meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0');
$display_price = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($meta['price'] ?? 0);
$access = class_exists('Visibility')
$access = class_exists('AKSRT\\Content\\Visibility')
? Visibility::get_post_access_state($post, $uid)
: [];
+1 -1
View File
@@ -63,7 +63,7 @@ class DownloadState {
);
}
$access = class_exists('Visibility')
$access = class_exists('AKSRT\\Content\\Visibility')
? Visibility::get_post_access_state($post_id, $user_id)
: [];
$priced = function_exists('aksrt_get_user_pay_price')
+6 -6
View File
@@ -489,7 +489,7 @@ class PostMetaBox {
* Content-pay sales summary for posts list (zibll 销售数据 column parity).
*/
private function render_sales_column(int $post_id): void {
if (!function_exists('aksrt_get_pay_meta') || !class_exists('DomainModel')) {
if (!function_exists('aksrt_get_pay_meta') || !class_exists('AKSRT\\Core\\DomainModel')) {
echo '—';
return;
}
@@ -549,7 +549,7 @@ class PostMetaBox {
* Dropdown filter for content pay_type on edit.php?post_type=post.
*/
public function render_pay_type_filter(string $post_type): void {
if ($post_type !== 'post' || !class_exists('DomainModel')) {
if ($post_type !== 'post' || !class_exists('AKSRT\\Core\\DomainModel')) {
return;
}
$current = isset($_GET['aksrt_pay_type']) ? sanitize_key((string) wp_unslash($_GET['aksrt_pay_type'])) : '';
@@ -582,7 +582,7 @@ class PostMetaBox {
return;
}
$pay_type = sanitize_key((string) wp_unslash($_GET['aksrt_pay_type']));
if ($pay_type === '' || !class_exists('DomainModel')) {
if ($pay_type === '' || !class_exists('AKSRT\\Core\\DomainModel')) {
return;
}
$pay_type = DomainModel::normalize_pay_type($pay_type);
@@ -663,7 +663,7 @@ class PostMetaBox {
<select name="aksrt_bulk_pay_type" class="aksrt-bulk-pay-type">
<option value="-1"><?php esc_html_e('— 不更改 —', 'aksrt'); ?></option>
<?php
$pay_labels = class_exists('DomainModel') ? DomainModel::pay_type_labels() : [];
$pay_labels = class_exists('AKSRT\\Core\\DomainModel') ? DomainModel::pay_type_labels() : [];
foreach ($pay_labels as $k => $lab) :
?>
<option value="<?php echo esc_attr($k); ?>"><?php echo esc_html($lab); ?></option>
@@ -701,7 +701,7 @@ class PostMetaBox {
* Only non-sentinel fields are written; omit to keep existing.
*/
private function save_bulk_pay_fields(int $post_id): void {
if (!class_exists('DomainModel') || !function_exists('aksrt_get_pay_meta')) {
if (!class_exists('AKSRT\\Core\\DomainModel') || !function_exists('aksrt_get_pay_meta')) {
return;
}
if (!current_user_can('edit_post', $post_id)) {
@@ -746,7 +746,7 @@ class PostMetaBox {
update_post_meta($post_id, DomainModel::PAY_META_KEY, $meta);
update_post_meta($post_id, DomainModel::PAY_TYPE_KEY, (string) ($meta['pay_type'] ?? DomainModel::PAY_TYPE_NO));
update_post_meta($post_id, DomainModel::PAY_PRICE_KEY, (float) ($meta['price'] ?? 0));
if (class_exists('DomainModel') && method_exists('DomainModel', 'is_resource_pay_type')) {
if (class_exists('AKSRT\\Core\\DomainModel') && method_exists('AKSRT\\Core\\DomainModel', 'is_resource_pay_type')) {
update_post_meta(
$post_id,
DomainModel::RESOURCE_MARKER_KEY,
+1 -1
View File
@@ -486,7 +486,7 @@ class ResourceMetaBox {
$gallery = $this->parse_json_array($_POST['aksrt_pay_gallery'] ?? '');
// 清洗下载源
if ($downloads !== null && class_exists('Setup') && method_exists('Setup', 'sanitize_downloads_meta')) {
if ($downloads !== null && class_exists('AKSRT\\Core\\Setup') && method_exists('AKSRT\\Core\\Setup', 'sanitize_downloads_meta')) {
$downloads = Setup::sanitize_downloads_meta($downloads);
}
+2 -2
View File
@@ -260,7 +260,7 @@ class Shortcodes {
* [aksrt_archive] 文章归档
*/
public function render_archive(array $atts = [], string $content = ''): string {
if (!class_exists('Templates')) {
if (!class_exists('AKSRT\\Core\\Templates')) {
return '';
}
return Templates::get_instance()->render_archive_shortcode($atts, $content);
@@ -270,7 +270,7 @@ class Shortcodes {
* [aksrt_profile] 个人资料卡
*/
public function render_profile(array $atts = [], string $content = ''): string {
if (!class_exists('Templates')) {
if (!class_exists('AKSRT\\Core\\Templates')) {
return '';
}
return Templates::get_instance()->render_profile_shortcode($atts, $content);
+3 -3
View File
@@ -32,7 +32,7 @@ trait BalanceServiceCharge {
// Points purchase fulfill (zibll order_type=9).
if ($type === \AKSRT\Core\DomainModel::ORDER_PRODUCT_POINTS_BUY) {
if (!class_exists('Credits')) {
if (!class_exists('AKSRT\\Credits\\Credits')) {
return;
}
$note = json_decode((string) ($order['note'] ?? ''), true);
@@ -78,7 +78,7 @@ trait BalanceServiceCharge {
if ($type !== \AKSRT\Core\DomainModel::ORDER_PRODUCT_RECHARGE) {
return;
}
if (!class_exists('Balance')) {
if (!class_exists('AKSRT\\Credits\\Balance')) {
return;
}
$note = json_decode((string) ($order['note'] ?? ''), true);
@@ -140,7 +140,7 @@ trait BalanceServiceCharge {
return [
'enabled' => !empty($cfg['enabled']),
'desc' => (string) ($cfg['desc'] ?? ''),
'wallet' => class_exists('Balance') ? Balance::balance($user_id) : 0.0,
'wallet' => class_exists('AKSRT\\Credits\\Balance') ? Balance::balance($user_id) : 0.0,
'packages' => $packages,
'custom_s' => $custom_s,
'custom_limit' => $custom_limit,
+3 -3
View File
@@ -38,13 +38,13 @@ trait BalanceServicePoints {
if ($id === '') {
continue;
}
if ($id === 'balance' && !(class_exists('Balance') && Balance::enabled())) {
if ($id === 'balance' && !(class_exists('AKSRT\\Credits\\Balance') && Balance::enabled())) {
continue;
}
$methods[] = is_array($m) ? $m : ['id' => $id, 'name' => $id];
}
}
if (class_exists('Balance') && Balance::enabled()) {
if (class_exists('AKSRT\\Credits\\Balance') && Balance::enabled()) {
$has_bal = false;
foreach ($methods as $m) {
if (($m['id'] ?? '') === 'balance') {
@@ -60,7 +60,7 @@ trait BalanceServicePoints {
'enabled' => $this->points_buy_enabled(),
'desc' => (string) ($all['pay_points_desc'] ?? ''),
'rate' => $rate,
'points' => class_exists('Credits') ? Credits::balance($user_id) : 0,
'points' => class_exists('AKSRT\\Credits\\Credits') ? Credits::balance($user_id) : 0,
'packages' => $packages,
'custom_s' => $custom_s,
'custom_limit' => $custom_limit,
+7 -7
View File
@@ -93,7 +93,7 @@ trait BalanceServiceRest {
* GET charge options (packages + methods + limits).
*/
public function rest_charge_options(\WP_REST_Request $request) {
if (!class_exists('Balance') || !Balance::enabled()) {
if (!class_exists('AKSRT\\Credits\\Balance') || !Balance::enabled()) {
return new \WP_Error('aksrt_balance_disabled', __('余额功能未启用', 'aksrt'), ['status' => 403]);
}
$user_id = get_current_user_id();
@@ -109,7 +109,7 @@ trait BalanceServiceRest {
* POST create recharge order and initiate payment.
*/
public function rest_charge_create(\WP_REST_Request $request) {
if (!class_exists('Balance') || !Balance::enabled()) {
if (!class_exists('AKSRT\\Credits\\Balance') || !Balance::enabled()) {
return new \WP_Error('aksrt_balance_disabled', __('余额功能未启用', 'aksrt'), ['status' => 403]);
}
$user_id = get_current_user_id();
@@ -168,7 +168,7 @@ trait BalanceServiceRest {
if ($amount <= 0) {
return new \WP_Error('aksrt_transfer_amount', __('请输入有效金额', 'aksrt'), ['status' => 400]);
}
if (!class_exists('Balance')) {
if (!class_exists('AKSRT\\Credits\\Balance')) {
return new \WP_Error('aksrt_balance_unavailable', __('余额系统不可用', 'aksrt'), ['status' => 500]);
}
$from_bal = Balance::balance($from_id);
@@ -219,7 +219,7 @@ trait BalanceServiceRest {
if ($amount <= 0) {
return new \WP_Error('aksrt_transfer_amount', __('请输入有效积分', 'aksrt'), ['status' => 400]);
}
if (!class_exists('Credits')) {
if (!class_exists('AKSRT\\Credits\\Credits')) {
return new \WP_Error('aksrt_credits_unavailable', __('积分系统不可用', 'aksrt'), ['status' => 500]);
}
$fee_rate = max(0, min(50, (int) (\AKSRT\Settings\Settings::get_all()['points_service_charge'] ?? 0)));
@@ -286,14 +286,14 @@ trait BalanceServiceRest {
* Exchange points → cash wallet (pay_balance_exchange_*).
*/
public function rest_exchange_from_credits(\WP_REST_Request $request) {
if (!class_exists('Balance') || !Balance::enabled()) {
if (!class_exists('AKSRT\\Credits\\Balance') || !Balance::enabled()) {
return new \WP_Error('aksrt_balance_disabled', __('余额功能未启用', 'aksrt'), ['status' => 403]);
}
$cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_recharge_settings() : [];
if (empty($cfg['exchange']['enabled'])) {
return new \WP_Error('aksrt_exchange_closed', __('积分兑换余额未开启', 'aksrt'), ['status' => 403]);
}
if (!class_exists('Credits') || !\AKSRT\Settings\Settings::credits_enabled()) {
if (!class_exists('AKSRT\\Credits\\Credits') || !\AKSRT\Settings\Settings::credits_enabled()) {
return new \WP_Error('aksrt_credits_disabled', __('积分功能未启用', 'aksrt'), ['status' => 403]);
}
$params = $request->get_json_params();
@@ -380,7 +380,7 @@ trait BalanceServiceRest {
public function rest_balance_withdraw(\WP_REST_Request $request) {
if (!class_exists('Balance') || !Balance::enabled()) {
if (!class_exists('AKSRT\\Credits\\Balance') || !Balance::enabled()) {
return new \WP_Error('aksrt_balance_disabled', __('余额功能未启用', 'aksrt'), ['status' => 403]);
}
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
+10 -10
View File
@@ -39,7 +39,7 @@ class Earn {
}
public function on_user_register(int $user_id): void {
if (!class_exists('PointsFree')) {
if (!class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
PointsFree::grant($user_id, 'sign_up', 0, ['type' => 'user', 'id' => $user_id]);
@@ -54,7 +54,7 @@ class Earn {
public function on_wp_login($user_login, $user = null): void {
unset($user_login);
$user_id = $user instanceof \WP_User ? (int) $user->ID : 0;
if ($user_id <= 0 || !class_exists('PointsFree')) {
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
$today = (new \DateTimeImmutable('today', wp_timezone()))->format('Y-m-d');
@@ -81,7 +81,7 @@ class Earn {
return;
}
$user_id = (int) $post->post_author;
if ($user_id <= 0 || !class_exists('PointsFree')) {
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
if (get_post_meta($post->ID, 'aksrt_credit_post_rewarded', true)) {
@@ -118,7 +118,7 @@ class Earn {
private function reward_comment(\WP_Comment $comment): void {
$user_id = (int) $comment->user_id;
if ($user_id <= 0 || !class_exists('PointsFree')) {
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
if (get_comment_meta($comment->comment_ID, 'aksrt_credit_rewarded', true)) {
@@ -150,7 +150,7 @@ class Earn {
* @param bool $active
*/
public function on_post_liked(int $post_id, int $actor_id, bool $active): void {
if (!$active || $post_id <= 0 || !class_exists('PointsFree')) {
if (!$active || $post_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
$post = get_post($post_id);
@@ -165,7 +165,7 @@ class Earn {
}
public function on_post_favorited(int $post_id, int $actor_id, bool $active): void {
if (!$active || $post_id <= 0 || !class_exists('PointsFree')) {
if (!$active || $post_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
$post = get_post($post_id);
@@ -180,7 +180,7 @@ class Earn {
}
public function on_comment_liked(int $comment_id, int $actor_id, bool $active): void {
if (!$active || $comment_id <= 0 || !class_exists('PointsFree')) {
if (!$active || $comment_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
$comment = get_comment($comment_id);
@@ -195,14 +195,14 @@ class Earn {
}
public function on_user_followed(int $follower_id, int $following_id): void {
if ($following_id <= 0 || $follower_id === $following_id || !class_exists('PointsFree')) {
if ($following_id <= 0 || $follower_id === $following_id || !class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
PointsFree::grant($following_id, 'followed', 0, ['type' => 'user', 'id' => $follower_id]);
}
public function on_forum_topic_created(int $user_id, int $post_id): void {
if ($user_id <= 0 || !class_exists('PointsFree')) {
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
PointsFree::grant($user_id, 'bbs_posts_new', 0, ['type' => 'post', 'id' => $post_id]);
@@ -222,7 +222,7 @@ class Earn {
return;
}
$user_id = (int) $comment->user_id;
if ($user_id <= 0 || !class_exists('PointsFree')) {
if ($user_id <= 0 || !class_exists('AKSRT\\Credits\\PointsFree')) {
return;
}
if (get_comment_meta($comment_id, 'aksrt_credit_forum_reply', true)) {
+1 -1
View File
@@ -188,7 +188,7 @@ class Invite {
/** 双向发放奖励 */
private function reward_pair(int $inviter_id, int $invitee_id): void {
if (!class_exists('Credits') || !class_exists('\AKSRT\Settings\Settings')) return;
if (!class_exists('AKSRT\\Credits\\Credits') || !class_exists('\AKSRT\Settings\Settings')) return;
$invite_cfg = \AKSRT\Settings\Settings::get_invite_reward_settings();
if (empty($invite_cfg['enabled'])) return;
+1 -1
View File
@@ -82,7 +82,7 @@ class PointsFree {
* Whether free points system can run (credits enabled).
*/
public static function enabled(): bool {
return class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled() && class_exists('Credits');
return class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled() && class_exists('AKSRT\\Credits\\Credits');
}
/**
+4 -4
View File
@@ -127,16 +127,16 @@ class Signin {
do_action('aksrt_user_signed_in', $user_id);
if ($reward > 0) {
if (class_exists('PointsFree')) {
if (class_exists('AKSRT\\Credits\\PointsFree')) {
$granted = PointsFree::grant_amount($user_id, $reward, 'sign_in', ['type' => 'user', 'id' => $user_id]);
if (is_wp_error($granted)) {
if (class_exists('Credits')) {
if (class_exists('AKSRT\\Credits\\Credits')) {
Credits::add($user_id, $reward, 'signin', ['type' => 'user', 'id' => $user_id]);
}
} else {
$reward = (int) $granted;
}
} elseif (class_exists('Credits')) {
} elseif (class_exists('AKSRT\\Credits\\Credits')) {
Credits::add($user_id, $reward, 'signin', ['type' => 'user', 'id' => $user_id]);
}
}
@@ -145,7 +145,7 @@ class Signin {
'success' => true,
'streak' => $new_streak,
'reward' => $reward,
'balance' => class_exists('Credits') ? Credits::balance($user_id) : 0,
'balance' => class_exists('AKSRT\\Credits\\Credits') ? Credits::balance($user_id) : 0,
], 200);
}
+1 -1
View File
@@ -89,7 +89,7 @@ class Forum {
private function draft_service(): DraftService {
if (!$this->draft_svc) {
// Draft service is loaded by bootstrap before this class.
if (!class_exists('DraftService', false)) {
if (!class_exists('AKSRT\\Forum\\DraftService', false)) {
require_once __DIR__ . '/class-aksrt-forum-draft-service.php';
}
$this->draft_svc = new DraftService($this);
+4 -4
View File
@@ -572,7 +572,7 @@ class PlateFollowPay {
}
private function is_follow_pay_enabled(int $plate_id): bool {
if (class_exists('Forum') && method_exists('Forum', 'is_plate_follow_pay_enabled')) {
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'is_plate_follow_pay_enabled')) {
return (bool) Forum::get_instance()->is_plate_follow_pay_enabled($plate_id);
}
return (int) get_post_meta($plate_id, '_aksrt_follow_pay', true) === 1;
@@ -582,7 +582,7 @@ class PlateFollowPay {
* @return array{amount:float,modo:string,is_vip_price:bool,is_free:bool,label:string,base:float,vip_level:int}
*/
private function resolve_price(int $plate_id, int $user_id): array {
if (class_exists('Forum') && method_exists('Forum', 'resolve_plate_follow_pay_price')) {
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'resolve_plate_follow_pay_price')) {
return Forum::get_instance()->resolve_plate_follow_pay_price($plate_id, $user_id);
}
return [
@@ -604,7 +604,7 @@ class PlateFollowPay {
return function_exists('aksrt_guest_has_plate_follow_access')
&& aksrt_guest_has_plate_follow_access($plate_id);
}
if (class_exists('Forum') && method_exists('Forum', 'is_user_following_plate')) {
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'is_user_following_plate')) {
return (bool) Forum::get_instance()->is_user_following_plate($user_id, $plate_id);
}
$follow_list = get_user_meta($user_id, 'aksrt_follow_plate', true);
@@ -615,7 +615,7 @@ class PlateFollowPay {
}
private function mark_followed(int $user_id, int $plate_id): void {
if (class_exists('Forum') && method_exists('Forum', 'mark_plate_followed')) {
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'mark_plate_followed')) {
Forum::get_instance()->mark_plate_followed($user_id, $plate_id);
return;
}
+4 -4
View File
@@ -59,7 +59,7 @@ class PlateMetaBox {
$roles_map = [];
$applications = [];
if (class_exists('Forum')) {
if (class_exists('AKSRT\\Forum\\Forum')) {
$forum = Forum::get_instance();
$moderator_ids = $forum->get_plate_moderators($plate_id);
$roles_map = $forum->get_moderator_roles($plate_id);
@@ -292,7 +292,7 @@ class PlateMetaBox {
if ($status === 'pending') {
return true;
}
return class_exists('Forum') && $status === Forum::APPLICATION_PENDING;
return class_exists('AKSRT\\Forum\\Forum') && $status === Forum::APPLICATION_PENDING;
}));
if (!$pending) {
echo '<p class="description">' . esc_html__('暂无待处理申请。', 'aksrt') . '</p>';
@@ -495,7 +495,7 @@ class PlateMetaBox {
$desired[$add_id] = $add_role;
}
if (class_exists('Forum')) {
if (class_exists('AKSRT\\Forum\\Forum')) {
$forum = Forum::get_instance();
$current = $forum->get_plate_moderators($post_id);
foreach ($current as $uid) {
@@ -527,7 +527,7 @@ class PlateMetaBox {
$actions = isset($_POST['aksrt_plate_app']) && is_array($_POST['aksrt_plate_app'])
? wp_unslash($_POST['aksrt_plate_app'])
: [];
if (!$actions || !class_exists('Forum')) {
if (!$actions || !class_exists('AKSRT\\Forum\\Forum')) {
return;
}
+3 -3
View File
@@ -576,7 +576,7 @@ class TopicPay {
* @return array{amount:float,is_vip_price:bool,is_free:bool,label:string,base:float,vip_set:bool,vip_level:int}
*/
private function resolve_price(int $topic_id, int $user_id): array {
if (class_exists('Forum')) {
if (class_exists('AKSRT\\Forum\\Forum')) {
return Forum::get_instance()->resolve_topic_pay_price($topic_id, $user_id);
}
return [
@@ -594,7 +594,7 @@ class TopicPay {
if ($user_id <= 0) {
return function_exists('aksrt_guest_has_paid_access') && aksrt_guest_has_paid_access($topic_id);
}
if (class_exists('Forum')) {
if (class_exists('AKSRT\\Forum\\Forum')) {
return Forum::get_instance()->has_user_paid_topic($user_id, $topic_id);
}
if (class_exists('\AKSRT\Payment\Order')) {
@@ -608,7 +608,7 @@ class TopicPay {
}
private function mark_unlocked(int $user_id, int $topic_id): void {
if (class_exists('Forum') && method_exists('Forum', 'mark_topic_unlocked')) {
if (class_exists('AKSRT\\Forum\\Forum') && method_exists('AKSRT\\Forum\\Forum', 'mark_topic_unlocked')) {
Forum::get_instance()->mark_topic_unlocked($user_id, $topic_id);
return;
}
+1 -1
View File
@@ -184,7 +184,7 @@ class PrivateMessage {
// Create notification for the recipient
$recipient_id = $is_a ? (int) $conv['user_b'] : (int) $conv['user_a'];
if (class_exists('Message')) {
if (class_exists('AKSRT\\Messages\\Message')) {
$sender_name = '';
$sender_user = get_userdata($sender_id);
if ($sender_user) {
+3 -3
View File
@@ -137,7 +137,7 @@ class AfterSale {
$items = $wpdb->get_results($wpdb->prepare($sql, $params), ARRAY_A);
$items = array_map([$this, 'decorate_record'], (array) $items);
if ($include_order_context && !empty($items) && class_exists('OrderRepository')) {
if ($include_order_context && !empty($items) && class_exists('AKSRT\\Payment\\OrderRepository')) {
$contexts = OrderRepository::get_instance()->get_admin_order_context_map(array_column($items, 'order_number'));
foreach ($items as &$item) {
$item['order_context'] = $contexts[(string) ($item['order_number'] ?? '')] ?? [];
@@ -174,7 +174,7 @@ class AfterSale {
return null;
}
$record['order_context'] = class_exists('OrderRepository')
$record['order_context'] = class_exists('AKSRT\\Payment\\OrderRepository')
? OrderRepository::get_instance()->get_admin_order_context((string) ($record['order_number'] ?? ''))
: [];
@@ -561,7 +561,7 @@ class AfterSale {
}
private function sync_order_status(array $record, string $new_status, string $note = ''): void {
if (!class_exists('OrderRepository') || !class_exists('Order')) {
if (!class_exists('AKSRT\\Payment\\OrderRepository') || !class_exists('AKSRT\\Payment\\Order')) {
return;
}
+4 -4
View File
@@ -330,7 +330,7 @@ class ChargeCard {
if (!$this->mark_used_cas($card_id, $user_id, $order_number)) {
// Race lost.
if (class_exists('Order')) {
if (class_exists('AKSRT\\Payment\\Order')) {
Order::get_instance()->update_status($order_number, Order::STATUS_CANCELLED, [
'note' => __('卡密已被使用,订单取消', 'aksrt'),
]);
@@ -343,7 +343,7 @@ class ChargeCard {
return $fulfill;
}
if (class_exists('Order')) {
if (class_exists('AKSRT\\Payment\\Order')) {
Order::get_instance()->update_status($order_number, Order::STATUS_PAID, [
'payment_method' => 'card_pass',
'payment_transaction_id' => 'card_pass_' . $card_id,
@@ -502,7 +502,7 @@ class ChargeCard {
* @param array<string,mixed> $meta
*/
private function create_redeem_order(int $user_id, string $type, array $meta, int $card_id, string $password): string {
if (!class_exists('OrderRepository') || !class_exists('\AKSRT\Core\DomainModel')) {
if (!class_exists('AKSRT\\Payment\\OrderRepository') || !class_exists('\AKSRT\Core\DomainModel')) {
return 'CARD' . $card_id . '_' . time();
}
@@ -536,7 +536,7 @@ class ChargeCard {
'product_id' => $product_id,
'amount' => $amount,
'currency' => $currency,
'status' => class_exists('Order') ? Order::STATUS_PENDING : 'pending',
'status' => class_exists('AKSRT\\Payment\\Order') ? Order::STATUS_PENDING : 'pending',
'payment_method' => 'card_pass',
'note' => is_string($note) ? $note : '',
'expires_at' => gmdate('Y-m-d H:i:s', time() + 30 * MINUTE_IN_SECONDS),
+1 -1
View File
@@ -26,7 +26,7 @@ class CreatorRevenue {
* Whether creator revenue settlement is enabled.
*/
private function is_enabled(): bool {
if (!class_exists('Revenue') || !class_exists('\AKSRT\Settings\Settings')) {
if (!class_exists('AKSRT\\Payment\\Revenue') || !class_exists('\AKSRT\Settings\Settings')) {
return false;
}
$settings = \AKSRT\Settings\Settings::get_payment_revenue_settings();
+1 -1
View File
@@ -212,7 +212,7 @@ class Gateway {
*/
public function complete_order(string $gateway_id, array $verify): bool {
$order_number = sanitize_text_field((string) ($verify['order_number'] ?? ''));
if ($order_number === '' || !class_exists('OrderRepository')) {
if ($order_number === '' || !class_exists('AKSRT\\Payment\\OrderRepository')) {
return false;
}
+3 -3
View File
@@ -63,10 +63,10 @@ trait OrderRepositoryAdmin {
}
$resolved_order_numbers = array_keys($orders);
$shipping_map = class_exists('Shipping')
$shipping_map = class_exists('AKSRT\\Payment\\Shipping')
? Shipping::get_instance()->get_summary_map($resolved_order_numbers)
: [];
$after_sale_map = class_exists('AfterSale')
$after_sale_map = class_exists('AKSRT\\Payment\\AfterSale')
? AfterSale::get_instance()->get_summary_map($resolved_order_numbers)
: [];
@@ -509,7 +509,7 @@ trait OrderRepositoryAdmin {
'summary' => [
'order_number' => (string) ($order['order_number'] ?? ''),
'status' => $status,
'status_label' => class_exists('Order') ? (Order::get_valid_statuses()[$status] ?? $status) : $status,
'status_label' => class_exists('AKSRT\\Payment\\Order') ? (Order::get_valid_statuses()[$status] ?? $status) : $status,
'amount' => $amount,
'currency_symbol' => '¥',
'created_at' => (string) ($order['created_at'] ?? ''),
+2 -2
View File
@@ -123,7 +123,7 @@ class Shipping {
$items = $wpdb->get_results($wpdb->prepare($sql, $params), ARRAY_A);
$items = array_map([$this, 'decorate_record'], (array) $items);
if ($include_order_context && !empty($items) && class_exists('OrderRepository')) {
if ($include_order_context && !empty($items) && class_exists('AKSRT\\Payment\\OrderRepository')) {
$contexts = OrderRepository::get_instance()->get_admin_order_context_map(array_column($items, 'order_number'));
foreach ($items as &$item) {
$item['order_context'] = $contexts[(string) ($item['order_number'] ?? '')] ?? [];
@@ -172,7 +172,7 @@ class Shipping {
return null;
}
$record['order_context'] = class_exists('OrderRepository')
$record['order_context'] = class_exists('AKSRT\\Payment\\OrderRepository')
? OrderRepository::get_instance()->get_admin_order_context((string) ($record['order_number'] ?? ''))
: [];
+2 -2
View File
@@ -10,7 +10,7 @@ defined('ABSPATH') || exit;
trait ShippingPart1 {
private function send_shipping_notification(string $order_number, string $carrier, string $tracking_no, string $note = ''): void {
if (!class_exists('OrderRepository')) {
if (!class_exists('AKSRT\\Payment\\OrderRepository')) {
return;
}
@@ -117,7 +117,7 @@ trait ShippingPart1 {
}
private function sync_order_status(string $order_number, string $shipping_status, string $note = ''): void {
if ($order_number === '' || !class_exists('OrderRepository') || !class_exists('Order')) {
if ($order_number === '' || !class_exists('AKSRT\\Payment\\OrderRepository') || !class_exists('AKSRT\\Payment\\Order')) {
return;
}
+1 -1
View File
@@ -275,7 +275,7 @@ trait FacadeBulk {
*/
public static function get_post_page_settings(): array {
// Canonical assembly lives in the post-display helper (related style/source split, aliases).
if (class_exists('PostDisplay')) {
if (class_exists('AKSRT\\Settings\\PostDisplay')) {
return PostDisplay::get_post_page_settings();
}
+1 -1
View File
@@ -159,7 +159,7 @@ class CartService {
$guest = get_post_meta($product_id, '_aksrt_guest_buy', true);
if ($guest === '0' || $guest === '') {
// Fall back to inheritance chain via TermMeta
if (class_exists('TermMeta')) {
if (class_exists('AKSRT\Shop\TermMeta')) {
$resolved = TermMeta::resolve_inheritance($product_id, 'guest_buy');
if (empty($resolved)) {
return 'login_required';
+1 -1
View File
@@ -301,7 +301,7 @@ trait Part3 {
if ($pid <= 0 || $pay_price <= 0) continue;
$rebate_rate = (float) get_post_meta($pid, '_aksrt_rebate_rate', true);
if ($rebate_rate <= 0 && class_exists('TermMeta')) {
if ($rebate_rate <= 0 && class_exists('AKSRT\Shop\TermMeta')) {
$resolved = TermMeta::resolve_inheritance($pid, 'rebate');
$rebate_rate = (float) ($resolved ?: 0);
}
+1 -1
View File
@@ -275,7 +275,7 @@ class ProductReview {
$order_number = (string) ($order['order_number'] ?? '');
if ($user_id <= 0 || $order_number === '') continue;
$items = class_exists('Shop')
$items = class_exists('AKSRT\\Shop\\Shop')
? Shop::get_instance()->get_order_items($order_number)
: [];
+2 -2
View File
@@ -41,7 +41,7 @@ class ProductVariantsMetaBox {
wp_nonce_field('aksrt_product_variants_save', 'aksrt_product_variants_nonce');
$variants = [];
if (class_exists('Shop')) {
if (class_exists('AKSRT\\Shop\\Shop')) {
$variants = Shop::get_instance()->get_variants((int) $post->ID);
}
@@ -138,7 +138,7 @@ class ProductVariantsMetaBox {
if ($post->post_type !== 'aksrt_product' || !current_user_can('edit_post', $post_id)) {
return;
}
if (!class_exists('Shop')) {
if (!class_exists('AKSRT\\Shop\\Shop')) {
return;
}
+1 -1
View File
@@ -82,7 +82,7 @@ class SMSProviderAliyun implements ProviderInterface {
* @return array|\WP_Error
*/
private function request(string $access_key, string $access_secret, string $region_id, array $biz_params) {
if (!class_exists('SMSSignatureHelper')) {
if (!class_exists('AKSRT\\Sms\\SMSSignatureHelper')) {
return new \WP_Error('sms_helper_missing', '签名助手类未加载');
}
+4 -4
View File
@@ -52,13 +52,13 @@ class SMSProviderFactory {
private static function create(string $key): ?ProviderInterface {
switch ($key) {
case 'aliyun':
return class_exists('SMSProviderAliyun') ? new SMSProviderAliyun() : null;
return class_exists('AKSRT\\Sms\\SMSProviderAliyun') ? new SMSProviderAliyun() : null;
case 'tencent':
return class_exists('SMSProviderTencent') ? new SMSProviderTencent() : null;
return class_exists('AKSRT\\Sms\\SMSProviderTencent') ? new SMSProviderTencent() : null;
case 'huawei':
return class_exists('SMSProviderHuawei') ? new SMSProviderHuawei() : null;
return class_exists('AKSRT\\Sms\\SMSProviderHuawei') ? new SMSProviderHuawei() : null;
case 'custom':
return class_exists('SMSProviderCustom') ? new SMSProviderCustom() : null;
return class_exists('AKSRT\\Sms\\SMSProviderCustom') ? new SMSProviderCustom() : null;
default:
return null;
}
+1 -1
View File
@@ -473,7 +473,7 @@ class Badges {
return (float) $counts;
case 'followed':
if (class_exists('Follow')) {
if (class_exists('AKSRT\\User\\Follow')) {
return (float) Follow::get_instance()->get_follower_count($user_id);
}
return 0.0;
+3 -3
View File
@@ -31,11 +31,11 @@ class BadgesAdmin {
}
private function can_manage(): bool {
return class_exists('Badges') && Badges::can_manually_set(get_current_user_id());
return class_exists('AKSRT\\User\\Badges') && Badges::can_manually_set(get_current_user_id());
}
public function render_section(\WP_User $user): void {
if (!class_exists('Badges') || !Badges::enabled()) {
if (!class_exists('AKSRT\\User\\Badges') || !Badges::enabled()) {
return;
}
$dict = Badges::get_dictionary();
@@ -102,7 +102,7 @@ class BadgesAdmin {
if (!isset($_POST['aksrt_user_badges_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash((string) $_POST['aksrt_user_badges_nonce'])), 'aksrt_user_badges_admin')) {
return;
}
if (!class_exists('Badges') || !Badges::enabled()) {
if (!class_exists('AKSRT\\User\\Badges') || !Badges::enabled()) {
return;
}
$raw = isset($_POST['aksrt_user_badges']) ? (array) wp_unslash($_POST['aksrt_user_badges']) : [];
+2 -2
View File
@@ -161,7 +161,7 @@ class Home {
if (!empty($settings['badge']['enabled']) && !empty($settings['badge']['public_display'])) {
$limit = max(1, (int) ($settings['badge']['limit'] ?? 3));
if (class_exists('Badges')) {
if (class_exists('AKSRT\\User\\Badges')) {
$list = Badges::list_for_user($user_id, true);
$badge_count = 0;
foreach ((array) ($list['items'] ?? []) as $item) {
@@ -284,7 +284,7 @@ class Home {
if ($source === 'manual_meta') {
return max(0, (int) get_user_meta($user_id, 'aksrt_user_level', true));
}
if (class_exists('Level')) {
if (class_exists('AKSRT\\User\\Level')) {
return Level::get_level($user_id);
}
// Fallback: credits_balance thresholds (legacy) if integral class missing.
+2 -2
View File
@@ -73,7 +73,7 @@ class Metrics {
}
public static function reevaluate_medals(int $user_id): void {
if ($user_id > 0 && class_exists('Badges') && method_exists('Badges', 'auto_evaluate')) {
if ($user_id > 0 && class_exists('AKSRT\\User\\Badges') && method_exists('AKSRT\\User\\Badges', 'auto_evaluate')) {
Badges::auto_evaluate($user_id);
}
}
@@ -263,7 +263,7 @@ class Metrics {
/* ---------- level XP bridges ---------- */
private static function level_add(int $user_id, string $key): void {
if ($user_id > 0 && class_exists('Level')) {
if ($user_id > 0 && class_exists('AKSRT\\User\\Level')) {
Level::add($user_id, $key);
}
}