Jake Vanderwerf
4 hours ago ad01a2799464e36a3954abe14f84ab82d439da53
email/_setup.php
@@ -1,42 +1,42 @@
<?php
$jvbEmail = add_filter('jvb_email', 'atat_email');
$jvbEmail = add_filter('jvb_email', 'altr_email');
function atat_email(array $defaults):array
function altr_email(array $defaults):array
{
    return [
        'colours'    => [
            'action-0'     => '#AD5B4B',
            'action-50'    => '#b7695a',
            'action-100'   => '#bf796c',
            'action-200'   => '#c78a7e',
            'secondary-0'  => '#DA993F',
            'secondary-50' => '#dea454',
            'secondary-100'   => '#e2b06a',
            'secondary-200'   => '#e6bb7f',
            'light'        => '#fdfcfc',
            'light-50'     => '#f7f4f3',
            'light-100'    => '#f0ebea',
            'light-200'    => '#eae3e2',
            'dark'         => '#503d3a',
            'dark-50'      => '#594440',
            'dark-100'     => '#624b47',
            'dark-200'     => '#6b514d',
            'action-contrast'=> '',
            'secondary-contrast'=> '',
            'action-0'     => '#c85604',
            'action-50'    => '#dc5f04',
            'action-100'   => '#f06705',
            'action-200'   => '#fa710f',
            'secondary-0'  => '#90D932',
            'secondary-50' => '#99dc43',
            'secondary-100'   => '#a3df54',
            'secondary-200'   => '#ace366',
            'light'        => '#fdf9f7',
            'light-50'     => '#fbf4ee',
            'light-100'    => '#faeee6',
            'light-200'    => '#f8e8dd',
            'dark'         => '#0d0a08',
            'dark-50'      => '#16110e',
            'dark-100'     => '#201914',
            'dark-200'     => '#292019',
            'action-contrast'=> '#c85604',
            'secondary-contrast'=> '#c85604',
        ],
        'content'    => [
            'title'           => get_bloginfo('name'),
            'subjectPrefix'      => '['.get_bloginfo('name').']',
            'signature'       => '<p>&emsp; —  ♡ Madi Mori</p>',
            'signature'       => '<p>&emsp; —  ♡ Lynsey</p>',
            'footer' => [
                '<p>&copy; ' . date('Y') . ' Tatty Soap</p>',
                '<p><a href="' . get_home_url() . '" class="text-link">Tatty Soap</a></p>'
                '<p>&copy; ' . date('Y') . ' OT with Lynsey — Edmonton Occupational Therapist.</p>',
                '<p><a href="' . get_home_url() . '" class="text-link">OT with Lynsey</a></p>'
            ]
        ],
        'types' => [
            'newUser' => [
                'subject'       => 'Welcome to Tatty Soap! Finish creating your account.',
                'subject'       => 'Welcome to OT with Lynsey! Finish creating your account.',
                'showPrefix'    => true,
            ],
            'resetPass' => [
@@ -93,197 +93,4 @@
 *          {array} $emailData, from the original filter
 *          add_filter('jvbPersonalDataExported', 'customFunction', 10, );
 *
 */
add_filter('jvbNewUserEmail', 'atat_new_user_email', 10, 2);
function atat_new_user_email(string $message, WP_User $user):string
{
    $user_login = $user->user_login;
    // Only create the password key if the user can change their password
    $key = get_password_reset_key($user);
    if (!is_wp_error($key)) {
        $reset_url = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login');
        $message = sprintf(
            '<p>Hey %s!</p>
            <p>Thanks for signing up for a Tatty Soap account.</p>
            <p><b>Login with your email: </b> %s</p>
            <p>To set your password and access your account, click the button below:</p>%s
            <p>Or copy and paste this link into your browser: %s</p>
            <p>Or go passwordless, and just sign on with a magic link.</p>
            <div class="divider"></div>
            <p>If you didn\'t create this account, just ignore this email and the link will expire.</p>',
            $user->display_name,
            $user->user_login,
            jvbMailButton($reset_url, 'Set Your Password'),
            jvbEmailLink($reset_url)
        );
    }
    return $message;
}
/*** EDMONTON INK VERSIONS: ***/
function eink_new_user_email(string $message, WP_User $user):string
{
    $user_login = $user->user_login;
    // Only create the password key if the user can change their password
    $key = get_password_reset_key($user);
    if (!is_wp_error($key)) {
        $reset_url = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login');
        $message = sprintf('<p>Hey %s!</p>', $user->first_name);
        $message .= '<p>Thanks for joining Edmonton\'s tattoo scene. Here\'s your login information:</p>';
        $message .= sprintf('<p><strong>Username:</strong> %s</p>', $user_login);
        $message .= '<p>To set your password and access your account, click the button below:</p>';
        $message .= sprintf('<p style="text-align: center;"><a href="%s" class="button">Set Your Password</a></p>', $reset_url);
        $message .= '<p>Or copy and paste this link into your browser:</p>';
        $message .= sprintf('<p style="user-select:all;">%s</p>', $reset_url);
        $message .= '<p>This link will expire in 24 hours, for security reasons.</p>';
        if (in_array('jvb_artist', array_values($user->roles))) {
            $message .= '<div class="divider"></div>';
            $message .= '<h3>NOTE:</h3>
                    <p>Once you set your password, you\'ll have access to your custom dashboard where you can:</p>
                    <ul>
                        <li>Manage your profile information</li>
                        <li>Upload tattoos/piercings, and artwork</li>
                    </ul>
                    <p>Nothing will be published until you\'ve been approved by 3 already approved artists, or the admin.</p>
                    <p>Admins check every day or three, but, if you are in a rush, you can contact us directly by replying to this email, or texting us at 825-925-9916.</p>';
        } elseif (in_array('jvb_partner', array_values($user->roles))) {
            $message .= '<div class="divider"></div>';
            $message .= '<h3>NOTE:</h3>
                    <p>Once you set your password, you\'ll have access to your custom dashboard where you can:</p>
                    <ul>
                        <li>Manage your profile information</li>
                        <li>Create offers for enthusiasts or partners or both</li>
                    </ul>
                    <p>Nothing will be published until you\'ve been approved by the admin.</p>
                    <p>Admins check every day or three, but, if you are in a rush, you can contact us directly by replying to this email, or texting us at 825-925-9916.</p>
                    <p><strong>Note:</strong>Even after approval by admin, your ability to publish depends on your karmic standing by artists. Artists each have a vote they can cast (UP or DOWN) - if your karmic score dips too far in the negative, you account is subject to reconsideration or even a ban.</p>';
        }
        $message .= '<div class="divider"></div>';
        $message .= '<p>If you didn\'t create this account, please ignore this email and the link will expire.</p>';
        $message .= sprintf('<p>Ink on, %s</p>', $user->first_name);
    }
    return $message;
}
function eink_new_user_admin_email(string $message, WP_User $user):string
{
    $message .= sprintf(
        '<p><strong>Role:</strong> %s</p>',
        str_replace(BASE, '', array_values($user->roles)[0])
    );
    return $message;
}
function eink_password_reset_email(string $message, string $user_login, WP_User $user, string $resetUrl):string
{
    return sprintf(
        '<p>Hi bud,</p>
         <p>We received a request to reset the password for an account associated with this email:</p>
         <p><strong>Username:</strong> %s</p>
         <p>If you didn\'t make this request, you can safely ignore this email and nothing will happen to your account.</p>
         <p>To reset your password, click the button below:</p>
         %s
         <p>Or copy and paste this link into your browser:</p>
         %s
         <div class="divider"></div>
         <p>This password reset link is only valid for 24 hours.</p>',
        $user_login,
        jvbMailButton($resetUrl,'Reset Password'),
        jvbEmailLink($resetUrl)
    );
}
function eink_email_change_request_email(string $message, array $oldUser, array $newUser)
{
    return sprintf(
        '<p>Hi %s,</p>
        <p>Ideally you already know this: someone asked to change your email, and here we are.</p>
        <p><strong>Old Email:</strong> %s</p>
        <p><strong>New Email:</strong> %s</p>
        <div class="divider"></div>
        <p>If this is news to you, or you did not request this - please contact us immediately. You can <a href="sms:+18258239916">text us</a> or reply to this email."></a></p>
        %s',
        $newUser['first_name'],
        $oldUser['user_email'],
        $newUser['user_email'],
        jvbMailButton(wp_login_url(), 'Log In To Your Account')
    );
}
function eink_email_changed_email(string $message, string $confirmURL):string
{
    return sprintf(
        '<p>Hey human,</p>
         <p>Seems you want to change the email associated with your account.</p>
         <p>If you really want this, please confirm this change by clicking the button below:</p>
         %s
         <p>Or copy and paste this link into your browser:</p>
         %s',
        jvbMailButton($confirmURL, 'Confirm this Email'),
        jvbEmailLink($confirmURL)
    );
}
function eink_password_changed_email(string $message, array $oldUser, array $newUser):string
{
    return sprintf(
        '<p>Hey bud,</p>
         <p>This is a confirmation email to let you know your password has successfully been changed.</p>
         <p>Ideally, you\'re expecting this email. You wanted to change your password, and this is to let you know that it\'s definitely updated.</p>
         <p>If you\'re not expecting this email, and did not change your password - please <strong>contact us immediately</strong></p>
         <p>You can <a href="sms:+18259257398">text us</a>, or reply to this email.</p>
         %s',
        jvbMailButton(wp_login_url(), 'Log In to Your Account')
    );
}
function eink_personal_data_export(string $message, string $requestType, string $confirmURL, array $emailData):string
{
    switch ($requestType) {
        case 'export_personal_data':
            $request_name = 'Export Personal Data';
            break;
        case 'remove_personal_data':
            $request_name = 'Erase Personal Data';
            break;
        default:
            $request_name = 'Data Request';
    }
    return sprintf(
        '<p>Hi privacy enthusiast,</p>
         <p>You\'re receiving this email because a request has been made to <strong>%s</strong></p>
         <p>If you\'re the one who made this request, you can confirm it by clicking the button below:</p>
         %s
         <p>Or copy and paste this link into your browser:</p>
         %s',
        $request_name,
        jvbMailButton($confirmURL, 'Confirm'),
        jvbEmailLink($confirmURL)
    );
}
function eink_personal_data_exported_email(string $message, string $downloadURL, string $expiresAt, array $emailData):string
{
    return sprintf(
        '<p>Hi again,</p>
         <p>You\'re receiving this email because you requested an export of your personal data.</p>
         <p>You can download your personal data by clicking the button below:</p>
         %s
         <p>Or you can copy and paste this link into your browser:</p>
         %s
         <div class="divider"></div>
         <p><strong>Important:</strong> For privacy and security, this link will expire at %s.</p>',
        jvbMailButton($downloadURL, 'Download Your Data'),
        jvbEmailLink($downloadURL),
        $expiresAt
    );
}
 */