fix(ns): root-qualify PHP builtins after PSR-4 move
Namespaced classes resolved DateTimeImmutable etc. under AKSRT\* (e.g. Credits\DateTimeImmutable). Prefix with \ globally.
This commit is contained in:
1 parent
0335517467
commit
da59d550ad
7 files changed
+15
-15
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user