diff --git a/src/AKSRT/Ai/AI.php b/src/AKSRT/Ai/AI.php index 8c7efdb8..064f1b75 100644 --- a/src/AKSRT/Ai/AI.php +++ b/src/AKSRT/Ai/AI.php @@ -282,7 +282,7 @@ class AI { 'success' => true, 'content' => $text, ]; - } catch (Throwable $t) { + } catch (\Throwable $t) { return [ 'success' => false, 'message' => $t->getMessage() ?: __('WordPress AI Client 调用失败', 'aksrt'), diff --git a/src/AKSRT/Auth/Moderation.php b/src/AKSRT/Auth/Moderation.php index 2aa5abd9..69bfd53e 100644 --- a/src/AKSRT/Auth/Moderation.php +++ b/src/AKSRT/Auth/Moderation.php @@ -228,7 +228,7 @@ class Moderation { $decision = $this->enrich_moderation_result($decision, $commentdata); $this->remember_result($commentdata, $decision); - } catch (Exception $e) { + } catch (\Exception $e) { // Intentionally silent: keep moderation flow without writing runtime logs. } diff --git a/src/AKSRT/Content/Download.php b/src/AKSRT/Content/Download.php index 2ce960d6..47e69485 100644 --- a/src/AKSRT/Content/Download.php +++ b/src/AKSRT/Content/Download.php @@ -37,7 +37,7 @@ class Download { public function maybe_schedule_cleanup(): void { if (!wp_next_scheduled('aksrt_dl_token_cleanup')) { - $next = (new DateTimeImmutable('tomorrow 03:30', wp_timezone()))->getTimestamp(); + $next = (new \DateTimeImmutable('tomorrow 03:30', wp_timezone()))->getTimestamp(); wp_schedule_event($next, 'daily', 'aksrt_dl_token_cleanup'); } } @@ -49,8 +49,8 @@ class Download { $table = \AKSRT\Core\DBMigrator::table('dl_token'); if (!$table) return; - $now_utc = (new DateTimeImmutable('now', new DateTimeZone('UTC')))->format('Y-m-d H:i:s'); - $audit_cutoff = (new DateTimeImmutable('-7 days', new DateTimeZone('UTC')))->format('Y-m-d H:i:s'); + $now_utc = (new \DateTimeImmutable('now', new \DateTimeZone('UTC')))->format('Y-m-d H:i:s'); + $audit_cutoff = (new \DateTimeImmutable('-7 days', new \DateTimeZone('UTC')))->format('Y-m-d H:i:s'); $wpdb->query($wpdb->prepare( "DELETE FROM {$table} WHERE expires_at < %s", @@ -417,8 +417,8 @@ class Download { $ip = function_exists('aksrt_get_client_ip') ? (string) aksrt_get_client_ip() : (string) ($_SERVER['REMOTE_ADDR'] ?? ''); $ua_hash = sha1((string) ($_SERVER['HTTP_USER_AGENT'] ?? '')); - $now_utc = (new DateTimeImmutable('now', new DateTimeZone('UTC')))->format('Y-m-d H:i:s'); - $expires_utc = (new DateTimeImmutable('now', new DateTimeZone('UTC')))->modify('+' . self::TOKEN_TTL . ' seconds')->format('Y-m-d H:i:s'); + $now_utc = (new \DateTimeImmutable('now', new \DateTimeZone('UTC')))->format('Y-m-d H:i:s'); + $expires_utc = (new \DateTimeImmutable('now', new \DateTimeZone('UTC')))->modify('+' . self::TOKEN_TTL . ' seconds')->format('Y-m-d H:i:s'); $ok = $wpdb->insert( $table, diff --git a/src/AKSRT/Credits/Earn.php b/src/AKSRT/Credits/Earn.php index 3eaea3a2..848606ee 100644 --- a/src/AKSRT/Credits/Earn.php +++ b/src/AKSRT/Credits/Earn.php @@ -57,7 +57,7 @@ class Earn { if ($user_id <= 0 || !class_exists('PointsFree')) { return; } - $today = (new DateTimeImmutable('today', wp_timezone()))->format('Y-m-d'); + $today = (new \DateTimeImmutable('today', wp_timezone()))->format('Y-m-d'); $last = (string) get_user_meta($user_id, PointsFree::META_LOGIN, true); if ($last === $today) { return; diff --git a/src/AKSRT/Credits/Invite.php b/src/AKSRT/Credits/Invite.php index 5277e855..53e2f400 100644 --- a/src/AKSRT/Credits/Invite.php +++ b/src/AKSRT/Credits/Invite.php @@ -238,7 +238,7 @@ class Invite { $log_table = \AKSRT\Core\DBMigrator::table('credit_log'); if (!$log_table) return true; - $today_utc = (new DateTimeImmutable('today', wp_timezone()))->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d H:i:s'); + $today_utc = (new \DateTimeImmutable('today', wp_timezone()))->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s'); $count = (int) $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$log_table} WHERE reason = 'invite' AND ip = %s AND created_at >= %s", $ip, diff --git a/src/AKSRT/Credits/PointsFree.php b/src/AKSRT/Credits/PointsFree.php index d2310064..71b9748d 100644 --- a/src/AKSRT/Credits/PointsFree.php +++ b/src/AKSRT/Credits/PointsFree.php @@ -269,7 +269,7 @@ class PointsFree { } private static function today_key(): string { - return (new DateTimeImmutable('today', wp_timezone()))->format('Y-m-d'); + return (new \DateTimeImmutable('today', wp_timezone()))->format('Y-m-d'); } /** diff --git a/src/AKSRT/Credits/Signin.php b/src/AKSRT/Credits/Signin.php index 6fb14555..58cd1a86 100644 --- a/src/AKSRT/Credits/Signin.php +++ b/src/AKSRT/Credits/Signin.php @@ -153,7 +153,7 @@ class Signin { /** 站点时区下的今日日期 'Y-m-d' */ private function today_date(): string { - return (new DateTimeImmutable('today', wp_timezone()))->format('Y-m-d'); + return (new \DateTimeImmutable('today', wp_timezone()))->format('Y-m-d'); } /** 取签到记录 */ @@ -181,7 +181,7 @@ class Signin { $table = \AKSRT\Core\DBMigrator::table('signin_log'); if (!$table) return []; - $from_date = (new DateTimeImmutable("-{$days} days", wp_timezone()))->format('Y-m-d'); + $from_date = (new \DateTimeImmutable("-{$days} days", wp_timezone()))->format('Y-m-d'); $rows = $wpdb->get_results($wpdb->prepare( "SELECT signin_date FROM {$table} WHERE user_id = %d AND signin_date >= %s ORDER BY signin_date ASC", @@ -209,19 +209,19 @@ class Signin { if (empty($rows)) return 0; $dates = array_map(fn($r) => $r['signin_date'], $rows); - $today = new DateTimeImmutable($today_str); + $today = new \DateTimeImmutable($today_str); $tz = wp_timezone(); // 起点:若今天已签则从今天回看,否则从昨天回看 $cursor = in_array($today_str, $dates, true) ? $today - : $today->sub(new DateInterval('P1D')); + : $today->sub(new \DateInterval('P1D')); $count = 0; foreach ($dates as $d) { if ($d === $cursor->format('Y-m-d')) { $count++; - $cursor = $cursor->sub(new DateInterval('P1D')); + $cursor = $cursor->sub(new \DateInterval('P1D')); } else { break; }