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
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,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();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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
@@ -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'
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,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;
|
||||
@@ -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') {
|
||||
|
||||
@@ -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'])
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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) : [];
|
||||
|
||||
@@ -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
@@ -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');
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* AKSRT Navigation Walker
|
||||
*
|
||||
* Custom walker for WordPress nav menus that adds:
|
||||
* - FA5 icons from menu item classes
|
||||
* - Badge labels from title attribute pattern [text:type]
|
||||
* - Submenu style overrides (dropdown / mega / cards)
|
||||
* - CSS class augmentation for hover effects
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class AKSRT_Nav_Walker extends Walker_Nav_Menu {
|
||||
|
||||
/**
|
||||
* @var array Decoration settings from aksrt_get_menu_decoration_settings().
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
public function __construct(array $settings = []) {
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前处理的菜单项是否为 Mega Menu 容器
|
||||
* @var bool
|
||||
*/
|
||||
private $is_mega_menu = false;
|
||||
|
||||
/**
|
||||
* Mega Menu 列数
|
||||
* @var int
|
||||
*/
|
||||
private $mega_columns = 3;
|
||||
|
||||
/**
|
||||
* Start level: open submenu with appropriate class based on style.
|
||||
*/
|
||||
public function start_lvl(&$output, $depth = 0, $args = null): void {
|
||||
$indent = str_repeat("\t", $depth);
|
||||
|
||||
if ($this->is_mega_menu && $depth === 0) {
|
||||
// Mega Menu 子菜单容器
|
||||
$output .= "\n{$indent}<ul class=\"sub-menu mega-menu__panel mega-menu__columns-{$this->mega_columns}\">\n";
|
||||
} else {
|
||||
$output .= "\n{$indent}<ul class=\"sub-menu\">\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start element: add icon, badge, and classes.
|
||||
*/
|
||||
public function start_el(&$output, $item, $depth = 0, $args = null, $id = 0): void {
|
||||
$indent = ($depth) ? str_repeat("\t", $depth) : '';
|
||||
|
||||
$classes = (array) $item->classes;
|
||||
$decoration = function_exists('aksrt_get_menu_item_decoration')
|
||||
? aksrt_get_menu_item_decoration($item)
|
||||
: ['icon' => '', 'badge_text' => '', 'badge_type' => 'new', 'submenu_style' => ''];
|
||||
|
||||
// 检测 Mega Menu 标记
|
||||
$this->is_mega_menu = false;
|
||||
$this->mega_columns = 3;
|
||||
if ($depth === 0) {
|
||||
foreach ($classes as $cls) {
|
||||
if ($cls === 'mega-menu') {
|
||||
$this->is_mega_menu = true;
|
||||
}
|
||||
if (preg_match('/^mega-menu-columns-(\d)$/', $cls, $m)) {
|
||||
$this->mega_columns = max(2, min(5, (int) $m[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build li classes
|
||||
$li_classes = ['menu-item', 'menu-item-' . $item->ID];
|
||||
if (in_array('current-menu-item', $classes, true)) {
|
||||
$li_classes[] = 'current-menu-item';
|
||||
}
|
||||
if (in_array('menu-item-has-children', $classes, true)) {
|
||||
$li_classes[] = 'menu-item-has-children';
|
||||
}
|
||||
if ($this->is_mega_menu) {
|
||||
$li_classes[] = 'mega-menu-item';
|
||||
}
|
||||
|
||||
// Add decoration classes
|
||||
$li_classes[] = 'aksrt-nav__item';
|
||||
if ($decoration['icon'] !== '' && !empty($this->settings['icon_enabled'])) {
|
||||
$li_classes[] = 'aksrt-nav__item--has-icon';
|
||||
}
|
||||
if ($decoration['badge_text'] !== '' && !empty($this->settings['badge_enabled'])) {
|
||||
$li_classes[] = 'aksrt-nav__item--has-badge';
|
||||
}
|
||||
$hover = $this->settings['hover_effect'] ?? 'underline';
|
||||
if ($hover !== 'none') {
|
||||
$li_classes[] = 'aksrt-nav__item--hover-' . $hover;
|
||||
}
|
||||
|
||||
$class_str = implode(' ', array_unique($li_classes));
|
||||
$output .= $indent . '<li class="' . esc_attr($class_str) . '" data-menu-item-id="' . (int) $item->ID . '" data-menu-depth="' . (int) $depth . '"' . (in_array('menu-item-has-children', $classes, true) ? ' data-menu-has-children="1"' : '') . '>';
|
||||
|
||||
// Build link content
|
||||
$icon_html = '';
|
||||
if ($decoration['icon'] !== '' && !empty($this->settings['icon_enabled'])) {
|
||||
$icon_html = aksrt_render_menu_icon($decoration['icon'], true);
|
||||
}
|
||||
|
||||
$badge_html = '';
|
||||
if ($decoration['badge_text'] !== '' && !empty($this->settings['badge_enabled'])) {
|
||||
$badge_html = aksrt_render_menu_badge($decoration['badge_text'], $decoration['badge_type'], true);
|
||||
}
|
||||
|
||||
// Mega Menu 子项:检查是否有描述文字(用作卡片副标题)
|
||||
$description_html = '';
|
||||
if ($this->is_mega_menu && $depth === 1 && !empty($item->description)) {
|
||||
$description_html = '<span class="mega-menu__item-desc">' . esc_html($item->description) . '</span>';
|
||||
}
|
||||
|
||||
$atts = [
|
||||
'href' => $item->url,
|
||||
'title' => $item->attr_title ?: '',
|
||||
];
|
||||
|
||||
$link_inner = $icon_html . '<span>' . esc_html($item->title) . '</span>' . $description_html . $badge_html;
|
||||
|
||||
$output .= '<a';
|
||||
foreach ($atts as $attr => $value) {
|
||||
if ('' !== $value) {
|
||||
$output .= ' ' . $attr . '="' . esc_attr($value) . '"';
|
||||
}
|
||||
}
|
||||
$output .= '>' . $link_inner . '</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* End element.
|
||||
*/
|
||||
public function end_el(&$output, $item, $depth = 0, $args = null): void {
|
||||
$output .= "</li>\n";
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user