From 86c6cd3cc099d2480932ede03c12cea01e625c94 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 26 Apr 2026 21:56:28 +0000
Subject: [PATCH] =Requiring files based on Site class settings
---
base/Login.php | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 162 insertions(+), 0 deletions(-)
diff --git a/base/Login.php b/base/Login.php
new file mode 100644
index 0000000..312cf47
--- /dev/null
+++ b/base/Login.php
@@ -0,0 +1,162 @@
+<?php
+namespace JVBase\base;
+/**
+ * Custom settings for the login page can be set here
+ */
+$jvbLogin = apply_filters('jvb_login', []);
+define('JVB_LOGIN', $jvbLogin);
+
+class Login {
+ protected array $login;
+ protected array $favourites = [
+ 'title' => 'Save your favourites',
+ 'description' => null,
+ 'submit' => null,
+ 'extra' => [],
+ 'footer' => '',
+ 'email' => '',
+ 'successTitle' => '',
+ 'successDescription' => []
+ ];
+ protected array $lostPassword;
+ protected array $resetPassword;
+ protected array $register;
+ protected array $logout;
+ protected array $magic;
+
+ protected array $types = ['login', 'favourites','lostPassword','resetPassword','register','logout', 'magic'];
+
+ public function __construct() {
+ $name = get_bloginfo('name');
+ $this->login = [
+ 'title' => 'Sign in',
+ 'description' => [],
+ 'submit' => 'Sign In',
+ 'extra' => [],
+ 'footer' => '',
+ 'email' => '',
+ 'successTitle' => '',
+ 'successDescription' => []
+ ];
+ $this->register = [
+ 'title' => 'Create Your Account',
+ 'description' => [],
+ 'submit' => 'Create Account',
+ 'extra' => [],
+ 'footer' => '',
+ 'email' => '['.$name.'] Finish Creating Your Account',
+ 'successTitle' => 'Success!',
+ 'successDescription' => ['See your email for next steps','(Check your spam folder if you cannot find it after a couple minutes.)']
+ ];
+
+ $this->lostPassword = [
+ 'title' => 'Reset Password',
+ 'description' => ['Forgot your password?', 'We\'ll send you a reset link to your email'],
+ 'submit' => 'Send Reset Link',
+ 'extra' => [],
+ 'footer' => '',
+ 'email' => '',
+ 'successTitle' => 'Success!',
+ 'successDescription' => ['Check your email for reset instructions']
+ ];
+ $this->resetPassword = [
+ 'title' => 'Reset Your Password',
+ 'description' => ['Enter your new password below.'],
+ 'submit' => 'Change Password',
+ 'extra' => [],
+ 'footer' => '',
+ 'email' => '',
+ 'successTitle' => '',
+ 'successDescription' => []
+ ];
+
+ $this->logout = [
+ 'title' => 'Logged out!',
+ 'description' => [''],
+ 'submit' => '',
+ 'extra' => [],
+ 'footer' => '',
+ 'email' => '',
+ 'successTitle' => '',
+ 'successDescription' => []
+ ];
+
+ $this->magic = [
+ 'title' => 'Log In with Magic Link!',
+ 'description' => ['Enter your email.','You\'ll get an email with a magic link.','Click it, and you\'re logged in!'],
+ 'submit' => jvbIcon('magic-wand').'Send Magic Link',
+ 'extra' => [],
+ 'footer' => '',
+ 'email' => '',
+ 'successTitle' => '',
+ 'successDescription' => []
+ ];
+
+
+ }
+
+ protected function checkType(string $type):bool
+ {
+ return in_array($type, $this->types);
+ }
+ public function setTitle(string $type, string $title):void
+ {
+ if (!$this->checkType($type)) {
+ return;
+ }
+ $this->$type['title'] = $title;
+ }
+ public function getTitle(string $type):string
+ {
+ if (!$this->checkType($type) ||
+ !array_key_exists('title', $this->$type)) {
+ return '';
+ }
+ return $this->$type['title'];
+ }
+
+ public function setDescription(string $type, array|string $description):void
+ {
+ if (!$this->checkType($type)) {
+ return;
+ }
+ $this->$type['description'] = $description;
+ }
+ public function getDescription(string $type):array
+ {
+ if (!$this->checkType($type) ||
+ !array_key_exists('description', $this->$type) ||
+ empty($this->$type['description'])) {
+ return [];
+ }
+ if (is_string($this->$type['description'])) {
+ return [$this->$type['description']];
+ }
+ return $this->$type['description'];
+ }
+ public function setSubmit(string $type, string $submit):void
+ {
+ if (!$this->checkType($type)) {
+ return;
+ }
+ $this->$type['submit'] = $submit;
+ }
+
+ public function getSubmit(string $type):string
+ {
+ if (!$this->checkType($type) ||
+ !array_key_exists('submit', $this->$type) ||
+ empty($this->$type['submit'])) {
+ return $this->login['submit'];
+ }
+ return $this->$type['submit'];
+ }
+
+ public function getLabels(string $type):array
+ {
+ if (!$this->checkType($type)) {
+ return [];
+ }
+ return $this->$type;
+ }
+}
--
Gitblit v1.10.0