| | |
| | | <?php |
| | | namespace JVBase\managers; |
| | | |
| | | use Exception; |
| | | use JVBase\Instance; |
| | | use JVBase\integrations\services\Cloudflare; |
| | | use JVBase\meta\Form; |
| | |
| | | 'From ' . $yesterday |
| | | ); |
| | | |
| | | $content .= Emails::getInstance()->spacer(20); |
| | | $content .= Emails::getInstance()->spacer(); |
| | | $content .= Emails::getInstance()->h2('New Referrals'); |
| | | |
| | | // Build list of referrals |
| | |
| | | Emails::getInstance()->stat($from_user->referral_count, 'Total Referrals'), |
| | | Emails::getInstance()->stat($from_user->treated_count, 'Treated') |
| | | ]; |
| | | $cardContent .= Emails::getInstance()->grid($stats, 2); |
| | | $cardContent .= Emails::getInstance()->grid($stats); |
| | | |
| | | $content .= Emails::getInstance()->card($cardContent); |
| | | $rank++; |
| | |
| | | */ |
| | | protected function generateCSV(array $referrals): string |
| | | { |
| | | $cache = Cache::for('referralCSV', null, HOUR_IN_SECONDS); |
| | | $cache = Cache::for('referralCSV'); |
| | | return $cache->remember( |
| | | 'csv', |
| | | function () use ($referrals) { |
| | |
| | | } |
| | | |
| | | // Check if code is unique |
| | | if ($this->isCodeTaken($code, $user_id)) { |
| | | if ($this->isCodeTaken($code)) { |
| | | add_action('user_profile_update_errors', function($errors) { |
| | | $errors->add('referral_code_taken', |
| | | 'This referral code is already in use.'); |
| | |
| | | * Display user's referral code and share options |
| | | * Use in templates or dashboard with: echo jvbReferralShareWidget(); |
| | | * |
| | | * @return string HTML output |
| | | * @return array HTML output |
| | | */ |
| | | public function outputShareWidget(array $actions):array |
| | | { |
| | |
| | | Cloudflare::getInstance()->renderTurnstile(); |
| | | $turnstile = ob_get_clean(); |
| | | |
| | | $reward_text = $this->getRewardText(true); |
| | | $reward_text = $this->getRewardText(); |
| | | |
| | | // Pre-fill code if from referral link |
| | | $prefill_code = $_GET['ref'] ?? ''; |
| | |
| | | * Add referral settings subpage to admin menu |
| | | * Add referral settings subpage to admin menu |
| | | * |
| | | * @param array $subpages |
| | | * @return array |
| | | * @return void |
| | | */ |
| | | public static function addSubpage():void |
| | | { |
| | |
| | | 'message' => 'Referral settings saved successfully!' |
| | | ]; |
| | | |
| | | } catch (\Exception $e) { |
| | | } catch (Exception $e) { |
| | | return [ |
| | | 'success' => false, |
| | | 'message' => 'Failed to save settings: ' . $e->getMessage() |