Jake Vanderwerf
5 days ago 75a097a018a0090f5902758353c578fce4aa2a25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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;
    }
}