self::META_CONFIRM_TOKEN, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key 'meta_value' => self::hashToken( $rawToken ), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value 'number' => 1, 'fields' => 'ID', ] ); if ( [] === $users ) { return null; } return Val::int( $users[0] ); } /** * Whether the confirmation token for a user has passed its expiry, measured * against the supplied `Y-m-d H:i:s` (UTC) timestamp. A user with no stored * expiry is treated as expired (there is nothing valid to confirm). */ public static function isTokenExpired( int $userId, string $now ): bool { $expires = Val::string( get_user_meta( $userId, self::META_CONFIRM_EXPIRES, true ) ); if ( '' === $expires ) { return true; } $expiresTs = strtotime( $expires ); $nowTs = strtotime( $now ); if ( false === $expiresTs || false === $nowTs ) { return true; } return $nowTs > $expiresTs; } }