From 2127b1bdd73ecd2423e443992da4b442f5a3c1a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 04 Feb 2026 21:19:25 +0000
Subject: [PATCH] =Major overhaul of MetaManager.php -> Meta.php and RestRouteManager.php -> Rest.php. Seems to work for JakeVan

---
 inc/managers/ReferralManager.php |  389 +++++++++++++++++++++++++++----------------------------
 1 files changed, 190 insertions(+), 199 deletions(-)

diff --git a/inc/managers/ReferralManager.php b/inc/managers/ReferralManager.php
index 2f7468a..e6a4517 100644
--- a/inc/managers/ReferralManager.php
+++ b/inc/managers/ReferralManager.php
@@ -3,7 +3,7 @@
 
 use JVBase\managers\MagicLinkManager;
 use JVBase\integrations\Cloudflare;
-use JVBase\meta\MetaForm;
+use JVBase\meta\Form;
 use JVBase\ui\CRUDSkeleton;
 use JVBase\ui\Tabs;
 use JVBase\utility\Features;
@@ -24,7 +24,9 @@
 {
 	protected $wpdb;
 	protected MagicLinkManager $magic_link;
-	protected CacheManager $cache;
+	protected Cache $cache;
+	protected Cache $requestCache;
+	protected Cache $statsCache;
 	protected string $referrals_table;
 	protected ?int $referralPage = null;
 	protected string $rewards_table;
@@ -48,7 +50,10 @@
 	{
 		global $wpdb;
 		$this->wpdb = $wpdb;
-		$this->cache = CacheManager::for('referrals', WEEK_IN_SECONDS);
+		$this->cache = Cache::for('referrals', WEEK_IN_SECONDS);
+		$this->requestCache = Cache::for('referral_requests', WEEK_IN_SECONDS)->connect('referrals', true);
+		$this->statsCache = Cache::for('referral_stats', WEEK_IN_SECONDS)->connect('referrals', true);
+
 		$this->referrals_table = $wpdb->prefix . BASE . 'referrals';
 		$this->rewards_table = $wpdb->prefix . BASE . 'referral_rewards';
 
@@ -142,11 +147,17 @@
 		];
 
 		if (Features::hasIntegration('cloudflare') && JVB()->connect('cloudflare')->isSetUp()) {
-			$requirements[] = 'cloudflare-turnstile';
+			JVB()->connect('cloudflare')->enqueueTurnstileScripts();
 		}
 		if (is_singular(BASE.'dash')) {
 			$requirements[] = 'jvb-form';
 			$requirements[] = 'jvb-view';
+
+			wp_enqueue_script('jvb-referral-admin',
+			JVB_URL.'assets/js/min/referralAdmin.min.js',
+			['jvb-referral'],
+			'1.0.0',
+			true);
 		}
 		wp_enqueue_script(
 			'jvb-referral',
@@ -349,7 +360,7 @@
 		}
 
 		// Clear caches
-		$this->cache->clear();
+		$this->cache->flush();
 
 		// Fire action for tracking
 		do_action('jvb_referral_processed', $user_id, $referrer->ID, $referral_code);
@@ -513,19 +524,19 @@
 	 */
 	public function getUserReferrals(int $user_id, array $args = []): array
 	{
-		return $this->cache->remember(
-			$user_id,
+		$defaults = [
+			'status' => 'all',
+			'limit' => 100,
+			'offset' => 0,
+			'orderby' => 'referred_at',
+			'order' => 'DESC'
+		];
+
+		$args = wp_parse_args($args, $defaults);
+
+		return $this->requestCache->remember(
+			$this->requestCache->generateKey(array_merge(['user'=>$user_id], $args)),
 			function() use ($user_id, $args) {
-				$defaults = [
-					'status' => 'all',
-					'limit' => 100,
-					'offset' => 0,
-					'orderby' => 'referred_at',
-					'order' => 'DESC'
-				];
-
-				$args = wp_parse_args($args, $defaults);
-
 				$where = $this->wpdb->prepare("WHERE referrer_id = %d", $user_id);
 
 				if ($args['status'] !== 'all') {
@@ -569,37 +580,33 @@
 	 */
 	public function getUserStats(int $user_id): array
 	{
-		$cache_key = 'stats_' . $user_id;
-		$cached = $this->cache->get($cache_key);
-
-		if ($cached !== false) {
-			return $cached;
-		}
-
-		$stats = $this->wpdb->get_row($this->wpdb->prepare(
-			"SELECT
+		return $this->statsCache->remember(
+			$user_id,
+			function() use ($user_id) {
+				$stats = $this->wpdb->get_row($this->wpdb->prepare(
+					"SELECT
 			COUNT(*) as code_used,
 			SUM(CASE WHEN status IN ('consulted', 'treated') THEN 1 ELSE 0 END) as consultations,
 			SUM(CASE WHEN status = 'treated' THEN 1 ELSE 0 END) as treatments,
 			SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) as pending
 		FROM {$this->referrals_table}
 		WHERE referrer_id = %d",
-			$user_id
-		), ARRAY_A);
+					$user_id
+				), ARRAY_A);
 
-		// Get total rewards earned (available + redeemed)
-		$rewards = $this->wpdb->get_var($this->wpdb->prepare(
-			"SELECT SUM(amount)
+				// Get total rewards earned (available + redeemed)
+				$rewards = $this->wpdb->get_var($this->wpdb->prepare(
+					"SELECT SUM(amount)
 		FROM {$this->rewards_table}
 		WHERE user_id = %d AND reward_type = 'referrer'",
-			$user_id
-		));
+					$user_id
+				));
 
-		$stats['total_rewards'] = floatval($rewards ?? 0);
-		$stats['user_id'] = $user_id;
-		$this->cache->set($cache_key, $stats, HOUR_IN_SECONDS);
-
-		return $stats;
+				$stats['total_rewards'] = floatval($rewards ?? 0);
+				$stats['user_id'] = $user_id;
+				return $stats;
+			}
+		);
 	}
 
 	/**
@@ -611,20 +618,23 @@
 	 */
 	public function getTopReferrers(int $limit = 10, string $period = 'all'): array
 	{
-		$where = '';
+		return $this->statsCache->remember(
+			$this->statsCache->generateKey(['limit'=>$limit, 'period' => $period]),
+			function() use ($limit, $period) {
+				$where = '';
 
-		if ($period !== 'all') {
-			$date_where = match($period) {
-				'day' => "referred_at >= DATE_SUB(NOW(), INTERVAL 1 DAY)",
-				'week' => "referred_at >= DATE_SUB(NOW(), INTERVAL 1 WEEK)",
-				'month' => "referred_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH)",
-				default => "1=1"
-			};
+				if ($period !== 'all') {
+					$date_where = match($period) {
+						'day' => "referred_at >= DATE_SUB(NOW(), INTERVAL 1 DAY)",
+						'week' => "referred_at >= DATE_SUB(NOW(), INTERVAL 1 WEEK)",
+						'month' => "referred_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH)",
+						default => "1=1"
+					};
 
-			$where = "WHERE {$date_where}";
-		}
+					$where = "WHERE {$date_where}";
+				}
 
-		$query = "SELECT
+				$query = "SELECT
                     referrer_id,
                     COUNT(*) as referral_count,
                     SUM(CASE WHEN status = 'treated' THEN 1 ELSE 0 END) as treated_count
@@ -634,16 +644,19 @@
                   ORDER BY referral_count DESC
                   LIMIT {$limit}";
 
-		$results = $this->wpdb->get_results($query);
+				$results = $this->wpdb->get_results($query);
 
-		// Enrich with user data
-		foreach ($results as &$result) {
-			$user = get_user_by('ID', $result->referrer_id);
-			$result->user_name = $user ? $user->display_name : 'Unknown';
-			$result->user_email = $user ? $user->user_email : '';
-		}
+				// Enrich with user data
+				foreach ($results as &$result) {
+					$user = get_user_by('ID', $result->referrer_id);
+					$result->user_name = $user ? $user->display_name : 'Unknown';
+					$result->user_email = $user ? $user->user_email : '';
+				}
 
-		return $results;
+				return $results;
+			}
+		);
+
 	}
 
 	/**
@@ -653,11 +666,8 @@
 	{
 		$yesterday = date('Y-m-d', strtotime('-1 day'));
 
-		// Get new referrals from yesterday
 		$new_referrals = $this->wpdb->get_results($this->wpdb->prepare(
-			"SELECT
-            r.*,
-            u.display_name as referrer_name
+			"SELECT r.*, u.display_name as referrer_name
         FROM {$this->referrals_table} r
         JOIN {$this->wpdb->users} u ON r.referrer_id = u.ID
         WHERE DATE(r.referred_at) = %s
@@ -665,48 +675,46 @@
 			$yesterday
 		));
 
-		// Only send if there's at least 1 new referral
 		if (empty($new_referrals)) {
 			return;
 		}
 
-		// Build email content
-		$content = '<h2>Daily Referral Report</h2>';
-		$content .= '<p><strong>' . count($new_referrals) . '</strong> new referral' .
-			(count($new_referrals) !== 1 ? 's' : '') . ' yesterday (' . $yesterday . ')</p>';
+		$content = JVB()->email()->h1('Daily Referral Report');
+		$content .= JVB()->email()->stat(
+			count($new_referrals),
+			count($new_referrals) === 1 ? 'New Referral' : 'New Referrals',
+			'From ' . $yesterday
+		);
 
-		$content .= '<table style="width:100%; border-collapse: collapse; margin: 20px 0;">';
-		$content .= '<thead><tr style="background: #f5f5f5;">';
-		$content .= '<th style="padding: 10px; text-align: left; border: 1px solid #ddd;">Referee</th>';
-		$content .= '<th style="padding: 10px; text-align: left; border: 1px solid #ddd;">Email</th>';
-		$content .= '<th style="padding: 10px; text-align: left; border: 1px solid #ddd;">Referrer</th>';
-		$content .= '<th style="padding: 10px; text-align: left; border: 1px solid #ddd;">Code</th>';
-		$content .= '</tr></thead><tbody>';
+		$content .= JVB()->email()->spacer(20);
+		$content .= JVB()->email()->h2('New Referrals');
 
+		// Build list of referrals
 		foreach ($new_referrals as $ref) {
-			$content .= '<tr>';
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html($ref->referee_name));
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html($ref->referee_email));
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html($ref->referrer_name));
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html($ref->referral_code));
-			$content .= '</tr>';
+			$cardContent = sprintf(
+				'<p><strong>%s</strong> (%s)</p>',
+				esc_html($ref->referee_name),
+				esc_html($ref->referee_email)
+			);
+			$cardContent .= sprintf(
+				'<p style="font-size:13px;color:%s;">Referred by: %s | Code: %s</p>',
+				JVB()->email()->colours['dark-200'],
+				esc_html($ref->referrer_name),
+				JVB()->email()->badge($ref->referral_code, 'info')
+			);
+
+			$content .= JVB()->email()->card($cardContent);
 		}
 
-		$content .= '</tbody></table>';
-
-		// Get admin email
 		$to = get_option('admin_email');
-		$subject = sprintf('[%s] %d New Referral%s',
+		$subject = sprintf(
+			'[%s] %d New Referral%s',
 			get_bloginfo('name'),
 			count($new_referrals),
-			count($new_referrals) !== 1 ? 's' : '');
+			count($new_referrals) !== 1 ? 's' : ''
+		);
 
-
-		JVB()->email()->sendEmail($to, $subject, $content);
+		JVB()->email()->sendEmail($to, $subject, $content, 'DAILY REPORT');
 	}
 
 	/**
@@ -717,19 +725,50 @@
 		$top_referrers = $this->getTopReferrers(10, 'week');
 		$total_referrals = $this->wpdb->get_var(
 			"SELECT COUNT(*) FROM {$this->referrals_table}
-             WHERE referred_at >= DATE_SUB(NOW(), INTERVAL 1 WEEK)"
+         WHERE referred_at >= DATE_SUB(NOW(), INTERVAL 1 WEEK)"
 		);
 
 		if ($total_referrals == 0) {
 			return;
 		}
 
+		$content = JVB()->email()->h1('Weekly Referral Summary');
+		$content .= JVB()->email()->stat(
+			$total_referrals,
+			'Total Referrals',
+			'This week'
+		);
+
+		$content .= JVB()->email()->spacer(30);
+		$content .= JVB()->email()->h2('Top 10 Referrers');
+
+		// Leaderboard style
+		$rank = 1;
+		foreach ($top_referrers as $referrer) {
+			$rankBadge = $rank <= 3
+				? JVB()->email()->badge('#' . $rank, $rank === 1 ? 'success' : 'info')
+				: '<span style="font-weight:600;color:' . JVB()->email()->colours['dark-200'] . ';">#' . $rank . '</span>';
+
+			$cardContent = sprintf(
+				'<p>%s <strong>%s</strong></p>',
+				$rankBadge,
+				esc_html($referrer->user_name)
+			);
+
+			$stats = [
+				JVB()->email()->stat($referrer->referral_count, 'Total Referrals'),
+				JVB()->email()->stat($referrer->treated_count, 'Treated')
+			];
+			$cardContent .= JVB()->email()->grid($stats, 2);
+
+			$content .= JVB()->email()->card($cardContent);
+			$rank++;
+		}
+
 		$to = get_option('admin_email');
 		$subject = '[' . get_bloginfo('name') . '] Weekly Referral Summary - ' . date('F j, Y');
 
-		$message = $this->generateWeeklyReportEmail($top_referrers, $total_referrals);
-
-		JVB()->email()->sendEmail($to, $subject, $message);
+		JVB()->email()->sendEmail($to, $subject, $content, 'WEEKLY SUMMARY');
 	}
 
 	/**
@@ -740,69 +779,30 @@
 	 */
 	protected function generateCSV(array $referrals): string
 	{
-		$csv = "Referred By,Referee Name,Referee Email,Referee Phone,Referral Code,Status,Referred At,Treated At\n";
+		$cache = Cache::for('referralCSV', HOUR_IN_SECONDS)->connect('referrals');
+		return $cache->remember(
+			'csv',
+			function () use ($referrals) {
+				$csv = "Referred By,Referee Name,Referee Email,Referee Phone,Referral Code,Status,Referred At,Treated At\n";
 
-		foreach ($referrals as $referral) {
-			$csv .= sprintf(
-				'"%s","%s","%s","%s","%s","%s","%s","%s"' . "\n",
-				$referral->referrer_name ?? 'Unknown',
-				$referral->referee_name,
-				$referral->referee_email,
-				$referral->referee_phone,
-				$referral->referral_code,
-				$referral->status,
-				$referral->referred_at,
-				$referral->treated_at ?? 'Not yet'
-			);
-		}
+				foreach ($referrals as $referral) {
+					$csv .= sprintf(
+						'"%s","%s","%s","%s","%s","%s","%s","%s"' . "\n",
+						$referral->referrer_name ?? 'Unknown',
+						$referral->referee_name,
+						$referral->referee_email,
+						$referral->referee_phone,
+						$referral->referral_code,
+						$referral->status,
+						$referral->referred_at,
+						$referral->treated_at ?? 'Not yet'
+					);
+				}
 
-		return $csv;
-	}
-
-	/**
-	 * Generate HTML email for daily report
-	 *
-	 * @param array $referrals
-	 * @param string $period
-	 * @return string
-	 */
-	protected function generateReportEmail(array $referrals, string $period): string
-	{
-		$count = count($referrals);
-
-		$content = sprintf('<p>You have <strong>%d new referral%s</strong> today.</p>',
-			$count,
-			$count !== 1 ? 's' : ''
+				return $csv;
+			}
 		);
 
-		$content .= '<table style="width:100%; border-collapse: collapse; margin: 20px 0;">';
-		$content .= '<thead><tr style="background: #f5f5f5; text-align: left;">';
-		$content .= '<th style="padding: 10px; border: 1px solid #ddd;">Referred By</th>';
-		$content .= '<th style="padding: 10px; border: 1px solid #ddd;">New User</th>';
-		$content .= '<th style="padding: 10px; border: 1px solid #ddd;">Email</th>';
-		$content .= '<th style="padding: 10px; border: 1px solid #ddd;">Status</th>';
-		$content .= '<th style="padding: 10px; border: 1px solid #ddd;">Time</th>';
-		$content .= '</tr></thead><tbody>';
-
-		foreach ($referrals as $referral) {
-			$content .= '<tr>';
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html($referral->referrer_name ?? 'Unknown'));
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html($referral->referee_name));
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html($referral->referee_email));
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html(ucfirst($referral->status)));
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html(date('g:i A', strtotime($referral->referred_at))));
-			$content .= '</tr>';
-		}
-
-		$content .= '</tbody></table>';
-		$content .= '<p><small>See attached CSV for full details.</small></p>';
-
-		return jvbGetEmailTemplate($content, 'Daily Referral Report');
 	}
 
 	/**
@@ -820,31 +820,22 @@
 			$total_referrals !== 1 ? 's' : ''
 		);
 
-		$content .= '<h3>Top 10 Referrers This Week</h3>';
-		$content .= '<table style="width:100%; border-collapse: collapse; margin: 20px 0;">';
-		$content .= '<thead><tr style="background: #f5f5f5; text-align: left;">';
-		$content .= '<th style="padding: 10px; border: 1px solid #ddd;">Rank</th>';
-		$content .= '<th style="padding: 10px; border: 1px solid #ddd;">User</th>';
-		$content .= '<th style="padding: 10px; border: 1px solid #ddd;">Total Referrals</th>';
-		$content .= '<th style="padding: 10px; border: 1px solid #ddd;">Treated</th>';
-		$content .= '</tr></thead><tbody>';
-
+		$referrers = [];
 		$rank = 1;
 		foreach ($top_referrers as $referrer) {
-			$content .= '<tr>';
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%d</td>', $rank++);
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%s</td>',
-				esc_html($referrer->user_name));
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%d</td>',
-				$referrer->referral_count);
-			$content .= sprintf('<td style="padding: 10px; border: 1px solid #ddd;">%d</td>',
-				$referrer->treated_count);
-			$content .= '</tr>';
+			$referrers[] = [
+				'label' => '#' . $rank++ . ' - ' . esc_html($referrer->user_name),
+				'value' => sprintf(
+					'<strong>Total Referrals:</strong> %d | <strong>Treated:</strong> %d',
+					$referrer->referral_count,
+					$referrer->treated_count
+				)
+			];
 		}
 
-		$content .= '</tbody></table>';
+		$content .= JVB()->email()->table($referrers, 'Top 10 Referrers This Week');
 
-		return jvbGetEmailTemplate($content, 'Weekly Referral Summary');
+		return $content;
 	}
 
 	/**
@@ -1060,7 +1051,6 @@
 		JVB()->connect('cloudflare')->renderTurnstile();
 		$turnstile = ob_get_clean();
 
-		$meta = new MetaForm();
 		$reward_text = $this->getRewardText(true);
 
 		// Pre-fill code if from referral link
@@ -1079,21 +1069,21 @@
 	<form id="referral-code-form">
 				'.jvbFormStatus(). '
     <input type="hidden" name="user_select" value="' . esc_attr(get_option(BASE.'referral_role','client')) . '">
-    ' .$meta->return('referral_name', null, [
+    ' .Form::render('referral_name', null, [
 				'required'	=> true,
 				'type'		=> 'text',
 				'label'		=> 'Your Name',
 				'placeholder'=> 'Mister Meeseeks',
 				'autocomplete'=>'name'
 			]).
-			$meta->return('referral_email', null, [
+			Form::render('referral_email', null, [
 				'required'	=> true,
 				'type'		=> 'email',
 				'label'		=> 'Your Email',
 				'placeholder'=> 'look@me.com',
 				'autocomplete'=> 'email'
 			]).
-			$meta->return('referral_code', $prefill_code, [
+			Form::render('referral_code', null, $prefill_code, [
 				'required'	=> true,
 				'type'		=> 'text',
 				'label'		=> 'Referral Code',
@@ -1102,6 +1092,7 @@
 				'autocomplete'=>'off',
 				'data-referrer' => $referrer_name
 			]).'
+				'.$turnstile.'
 				<button type="button" class="button-secondary check-code-btn">
 					'.jvbIcon('check-circle', ['size' => 16]).' Verify Code
 				</button>
@@ -1113,7 +1104,6 @@
 				<p class="helper-text">
 					We\'ll send you a link to complete your registration.
 				</p>
-				'.$turnstile.'
 			</form>
 			<div class="success-content" hidden>
 				<h3>Check Your Email!</h3>
@@ -1122,7 +1112,7 @@
 			</div>';
 
 		$loginForm = '<form id="login-form">
-	'.jvbFormStatus().$meta->return('login_email', null, [
+	'.jvbFormStatus().Form::render('login_email', null, [
 				'required'	=> true,
 				'type'		=> 'email',
 				'label'		=> 'Your Email',
@@ -1232,8 +1222,9 @@
 			<h4>Your Referral Link</h4>
 			<div class="copy-group row btw nowrap">
 				<code id="referral-link" class="copy-target"><?= esc_url($share_url) ?></code>
-				<button type="button" class="copy-btn" data-target="referral-link" aria-label="Copy referral link">
-					<?php echo jvbIcon('copy', ['size' => 16]); ?>
+				<button type="button" class="copy-btn" data-target="referral-link" title="Copy referral link">
+					<?= jvbIcon('copy'); ?>
+					<?= jvbIcon('check-circle'); ?>
 				</button>
 			</div>
 			<p class="hint">Quickest and easiest: autofills your code.</p>
@@ -1242,8 +1233,9 @@
 			<h4>Your Code</h4>
 			<div class="copy-group row btw nowrap">
 				<code id="referral-code" class="copy-target"><?= esc_html($referral_code) ?></code>
-				<button type="button" class="copy-btn" data-target="referral-code" aria-label="Copy referral code">
-					<?php echo jvbIcon('copy', ['size' => 16]); ?>
+				<button type="button" class="copy-btn" data-target="referral-code" title="Copy referral code">
+					<?= jvbIcon('copy'); ?>
+					<?= jvbIcon('check-circle'); ?>
 				</button>
 			</div>
 			<p class="hint">Manually copy and paste the code</p>
@@ -2476,20 +2468,20 @@
 
 		<!-- Referral Code Card -->
 		<div class="card">
-			<h3>Share Code</h3>
-			<div class="row btw nowrap">
-				<code class="code"><?= esc_html($referral_code) ?></code>
-				<button class="button copy-btn" data-code="<?= esc_attr($referral_code) ?>">
-					Copy Code
-				</button>
-			</div>
 			<h3>Share Link</h3>
 			<div class="row btw nowrap">
-				<code class="share-link">
-					<?= home_url('/?ref=' . $referral_code) ?>
-				</code>
-				<button class="button copy-btn" data-code="<?= home_url('/?ref=' . $referral_code) ?>">
-					Copy Link
+				<code id="referral-link" class="copy-target"><?= home_url('/?ref=' . $referral_code) ?></code>
+				<button type="button" class="copy-btn" data-target="referral-link" title="Copy referral link">
+					<?= jvbIcon('copy'); ?>
+					<?= jvbIcon('check-circle'); ?>
+				</button>
+			</div>
+			<h3>Share Code</h3>
+			<div class="row btw nowrap">
+				<code id="referral-code" class="copy-target"><?= esc_html($referral_code) ?></code>
+				<button type="button" class="copy-btn" data-target="referral-code" title="Copy referral code">
+					<?= jvbIcon('copy'); ?>
+					<?= jvbIcon('check-circle'); ?>
 				</button>
 			</div>
 		</div>
@@ -2498,7 +2490,6 @@
 			<p>Or, if you prefer, enter your friends name(s) and email(s), and we'll send off some emails.</p>
 			<p><small>(No data is stored. Your friends will get an email from our email.)</small></p>
 			<?php
-			$meta = new MetaForm();
 			$invite = [
 				'type' => 'tag_list',
 				'label' => 'Invite Your Friends',
@@ -2535,14 +2526,14 @@
 					'hint'		=> 'We\'ll add your code and a link automatically.'
 				]
 			];
-			$meta->render('invite', [], $invite);
+			echo Form::render('invite', null, $invite);
 			?>
 			<details>
 				<summary class="icon icon-caret-down">Customize Message</summary>
 				<?php
 				foreach ($fields as $fieldName => $field) {
 					$value = (array_key_exists('value', $field)) ? $field['value'] : [];
-					$meta->render($fieldName, $value, $field);
+					echo Form::render($fieldName, $value, $field);
 				}
 				?>
 			</details>
@@ -2812,7 +2803,7 @@
 		$referrer_first_name = $referrer ? strtok($referrer->display_name, ' ') : 'Your friend';
 
 		// Get reward text
-		$reward_text = $this->getRewardText(false); // Just "20% off" or "$25 off"
+		$reward_text = $this->getRewardText(); // Just "20% off" or "$25 off"
 
 		$booking_url = apply_filters('jvb_referral_booking_url', home_url('/contact'));
 		$estimate_url = apply_filters('jvb_referral_estimate_url', home_url('/estimate'));

--
Gitblit v1.10.0