From ed57c386db34d8693ca75311972d0929ebe5f488 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 01 Jun 2026 22:23:19 +0000
Subject: [PATCH] =Added some more Schema classes, allowed for override of array in outputSchema for complex schema, as for timeline post types
---
inc/managers/MagicLinkManager.php | 72 ++++++++++++++++-------------------
1 files changed, 33 insertions(+), 39 deletions(-)
diff --git a/inc/managers/MagicLinkManager.php b/inc/managers/MagicLinkManager.php
index 880fe9c..c8d0a88 100644
--- a/inc/managers/MagicLinkManager.php
+++ b/inc/managers/MagicLinkManager.php
@@ -16,8 +16,8 @@
*/
class MagicLinkManager
{
- protected CacheManager $cache;
- protected CacheManager $referral_cache;
+ protected Cache $cache;
+ protected Cache $referral_cache;
// Token settings
protected int $token_expiry = 900; // 15 minutes in seconds
@@ -32,8 +32,8 @@
public function __construct()
{
- $this->cache = CacheManager::for('magic_links', $this->token_expiry);
- $this->referral_cache = CacheManager::for('referral_magic_links', 14 * DAY_IN_SECONDS);
+ $this->cache = Cache::for('magic_links', $this->token_expiry);
+ $this->referral_cache = Cache::for('referral_magic_links', 14 * DAY_IN_SECONDS);
// Hook into WordPress auth flow
add_action('template_redirect', [$this, 'handleMagicLinkClick']);
@@ -129,9 +129,9 @@
// Delete token after verification (single use)
// Check which cache it's in and delete from the correct one
if ($token_data['type'] === 'referral') {
- $this->referral_cache->delete($token);
+ $this->referral_cache->forget($token);
} else {
- $this->cache->delete($token);
+ $this->cache->forget($token);
}
return $token_data;
@@ -507,60 +507,54 @@
protected function getLoginEmailTemplate(string $name, string $magic_url): string
{
- $content = '<h2>Hey ' . esc_html($name) . '!</h2>';
- $content .= '<p>Click the button below to sign in to your account. This link expires in 15 minutes.</p>';
- $content .= JVB()->email()->button($magic_url, 'Sign In');
- $content .= '<p>Or copy and paste this link into your browser of choice:</p>';
+ $content = JVB()->email()->h2('Hey ' . esc_html($name) . '!');
+ $content .= '<p>Click the button below to sign in to your account instantly - no password needed!</p>';
+ $content .= JVB()->email()->button($magic_url, 'Sign In Now');
+ $content .= '<p>Or copy and paste this link into your browser:</p>';
$content .= JVB()->email()->link($magic_url);
- $content .= '<p>If you didn\'t request this, you can safely ignore this email. The link will expire in 15 minutes.</p>';
- $content .= JVB()->email()->signature();
-
+ $content .= JVB()->email()->divider();
+ $content .= '<p>If you didn\'t request this, you can safely ignore this email. This link expires in 15 minutes.</p>';
return $content;
}
protected function getSignupEmailTemplate(string $name, string $magic_url): string
{
- $content = '<h2>Welcome' . ($name ? ', ' . esc_html($name) : '') . '!</h2>';
- $content .= '<p>You\'re almost there! Click the button below to complete your registration and access your account.</p>';
+ $content = JVB()->email()->h2('Welcome' . ($name ? ', ' . esc_html($name) : '') . '!');
+ $content .= '<p>Click the button below to complete your registration and access your account!</p>';
$content .= JVB()->email()->button($magic_url, 'Complete Registration');
- $content .= '<p>Or copy and paste this link into your browser of choice:</p>';
+ $content .= '<p>Or copy and paste this link:</p>';
$content .= JVB()->email()->link($magic_url);
- $content .= '<p>This link expires in 15 minutes.</p>';
- $content .= JVB()->email()->signature();
-
+ $content .= JVB()->email()->spacer(10);
+ $content .= '<p><small>This link expires in 24 hours.</small></p>';
return $content;
}
protected function getReferralEmailTemplate(string $name, string $referrer_name, string $magic_url, string $reward_text, array $context): string
{
- $content = '<h2>Hey' . ($name ? ' ' . esc_html($name) : '') . '!</h2>';
- $content .= '<p><strong>' . esc_html($referrer_name) . '</strong> thinks you\'d love ' . get_bloginfo('name') . '!</p>';
+ $content = JVB()->email()->h2('Hey' . ($name ? ' ' . esc_html($name) : '') . '!');
+ $content .= sprintf(
+ '<p><strong>%s</strong> thinks you\'d love %s!</p>',
+ esc_html($referrer_name),
+ esc_html(get_bloginfo('name'))
+ );
- if (array_key_exists('message', $context) && $context['message']!== '') {
- $content .= wpautop($context['message']);
+ if (!empty($context['message'])) {
+ $content .= JVB()->email()->callout(nl2br(esc_html($context['message'])));
}
+
if ($reward_text) {
- $content .= '<p>' . esc_html($reward_text) . '</p>';
+ $content .= JVB()->email()->alert(
+ '<strong>Special Welcome Offer:</strong> ' . esc_html($reward_text),
+ 'success'
+ );
}
$content .= JVB()->email()->button($magic_url, 'Join Now');
- $content .= '<p>Or copy and paste this link into your browser of choice:</p>';
+ $content .= '<p>Or copy and paste this link:</p>';
$content .= JVB()->email()->link($magic_url);
- $content .= '<p>This link expires in 14 days.</p>';
- $content .= JVB()->email()->signature();
+ $content .= JVB()->email()->spacer(10);
+ $content .= '<p><small>This invitation expires in 14 days.</small></p>';
return $content;
}
-
- protected function getResetEmailTemplate(string $name, string $magic_url): string
- {
- $content = '<h2>Hey ' . esc_html($name) . '!</h2>';
- $content .= '<p>We received a request to reset your password. Click the button below to sign in and update your password.</p>';
- $content .= JVB()->email()->button($magic_url, 'Reset Password');
- $content .= '<p>Or copy and paste this link into your browser of choice:</p>';
- $content .= JVB()->email()->link($magic_url);
- $content .= '<p>If you didn\'t request this, you can safely ignore this email. This link expires in 15 minutes.</p>';
- $content .= JVB()->email()->signature();
- return $content;
- }
}
--
Gitblit v1.10.0