<?php
/*
Plugin Name: Kleor Emails
Plugin URI: https://www.kleor.com/kleor-emails/
Description: Improve the design of the emails/Améliore le design des e-mails
Version: 1.0
Author: Kleor
Author URI: https://www.kleor.com
*/

/* English:
By default, emails sent by Kleor plugins are in plain text, like the ones you receive from your friends.
If you want a more elaborate design, customize this file and place it in the "wp-content/mu-plugins" folder of your website (if there is no "mu-plugins" folder in "wp-content", create it).
You can also place it in the "wp-content/plugins" folder of your website. In this case, then activate the plugin via the "Plugins" page of WordPress.
If you need help, you can ask the Kleor Assistant AI here => https://www.kleor.com/support
You can also ask any other AI. They should be able to help you if you send them this file.
*/

/* Français :
Par défaut, les e-mails envoyés par les plugins Kleor sont en texte brut, comme ceux que vous recevez de vos amis.
Si vous souhaitez un design plus élaboré, personnalisez ce fichier et placez-le dans le dossier "wp-content/mu-plugins" de votre site (s'il n'y a pas de dossier "mu-plugins" dans "wp-content", créez-le).
Vous pouvez aussi le placer dans le dossier "wp-content/plugins" de votre site. Dans ce cas, activez ensuite le plugin via la page "Extensions" de WordPress.
Si vous avez besoin d'aide, vous pouvez demander à l'IA Kleor Assistant ici => https://www.kleor.com/support
Vous pouvez aussi demander à n'importe quelle autre IA. Elle devrait pouvoir vous aider si vous lui envoyez ce fichier.
*/

function kleor_emails_filter($array) {
/*This filter applies the design to all emails.
Ce filtre applique le design à tous les e-mails.*/
$array['body'] = make_clickable(wpautop($array['body']));
return kleor_emails_filter_html($array); }


function kleor_emails_filter_html($array) {
/*This filter applies the design to emails whose "Body" field contains at least one HTML tag.
Ce filtre applique le design aux e-mails dont le champ "Corps" contient au moins une balise HTML.*/
if ((strstr($array['body'], '</')) || (strstr($array['body'], '/>'))) {

/*Color of the central column (containing the the text of the email)
Couleur de la colonne centrale (contenant le texte de l'e-mail)*/
$color1 = '#ffffff';

/*Color of the side columns
Couleur des colonnes latérales*/
$color2 = '#e8f0f8';

/*Color of the header
Couleur de l'en-tête*/
$color3 = '#303030';

/*Color of the footer
Couleur du bas*/
$color4 = '#303030';

/*URL of the logo
URL du logo*/
$logo = '';

$array['body'] = '<!DOCTYPE html>
<html lang="fr">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="x-apple-disable-message-reformatting">
  <title>'.$array['subject'].'</title>
  <style>
    body, table, td, a { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
    table, td { border-collapse: collapse !important; }
    img { border: 0; line-height: 100%; text-decoration: none; -ms-interpolation-mode: bicubic; }
    a { text-decoration: underline; color: #0040ff; }
    a:hover { color: #e0c040; }
    h2 { color: #004080; font-size: 24px; padding-top: 12px; margin: 0; }
    p { line-height: 1.5; margin: 24px 0; }
    @media screen and (max-width: 600px) {
      .container { width: 100% !important; }
      .content { padding: 0 15px !important; }
      a { font-weight: bold; }
    }
  </style>
</head>
<body style="margin:0; padding:0; background-color:'.$color2.'; font-family:Verdana, sans-serif; font-size:16px;">
  <table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td align="center" bgcolor="'.$color2.'">
	  
        <!-- Central table/Table centrale -->
        <table role="presentation" border="0" cellpadding="0" cellspacing="0" width="600" class="container" style="max-width:600px; width:100%;">
          
          <!-- Header/En-tête -->
          <tr>
            <td align="center" bgcolor="'.$color3.'" style="padding:10px;">
              <table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <td align="left" valign="middle" style="width:240px;">
                    '.($logo == '' ? '' : '<a href="'.get_bloginfo('url').'" style="text-decoration:none; border:0;">
                      <img src="'.$logo.'" alt="'.get_bloginfo('name').'" title="'.get_bloginfo('description').'" width="240" style="display:block; max-width:100%; height:auto;">
                    </a>').'
                  </td>
                </tr>
              </table>
            </td>
          </tr>

          <!-- Content/Contenu -->
          <tr>
            <td bgcolor="'.$color1.'" class="content" style="padding:20px;">
            '.$array['body'].'
            </td>
          </tr>

          <!-- Footer/Bas -->
          <tr>
            <td align="center" bgcolor="'.$color4.'" style="padding:20px;">
              <p style="color:#ffffff; font-size:14px; margin:0;">
                <a href="'.get_bloginfo('url').'" style="color:#ffffff; text-decoration:none;">'.get_bloginfo('name').'</a> - '.get_bloginfo('description').'
              </p>
            </td>
          </tr>

          <!-- Breathing space/Espace de respiration -->
          <tr>
            <td bgcolor="'.$color2.'" height="40"></td>
          </tr>

        </table>
      </td>
    </tr>
  </table>

</body>
</html>'; }
return $array; }

/*Remove "//" from the beginning of the line below to apply the design to all emails sent by Affiliation Manager.
Supprimez "//" au début de la ligne ci-dessous pour appliquer le design à tous les e-mails envoyés par Affiliation Manager.*/
//add_filter('affiliation_mail', 'kleor_emails_filter');

/*Remove "//" from the beginning of the line below to apply the design to all emails sent by Commerce Manager.
Supprimez "//" au début de la ligne ci-dessous pour appliquer le design à tous les e-mails envoyés par Commerce Manager.*/
//add_filter('commerce_mail', 'kleor_emails_filter');

/*Remove "//" from the beginning of the line below to apply the design to all emails sent by Contact Manager.
Supprimez "//" au début de la ligne ci-dessous pour appliquer le design à tous les e-mails envoyés par Contact Manager.*/
//add_filter('contact_mail', 'kleor_emails_filter');

/*Remove "//" from the beginning of the line below to apply the design to all emails sent by Membership Manager.
Supprimez "//" au début de la ligne ci-dessous pour appliquer le design à tous les e-mails envoyés par Membership Manager.*/
//add_filter('membership_mail', 'kleor_emails_filter');

/*Remove "//" from the beginning of the line below to apply the design to all emails sent by Optin Manager.
Supprimez "//" au début de la ligne ci-dessous pour appliquer le design à tous les e-mails envoyés par Optin Manager.*/
//add_filter('optin_mail', 'kleor_emails_filter');

/*Remove "//" from the beginning of the line below to apply the design to all emails sent by Raising Manager.
Supprimez "//" au début de la ligne ci-dessous pour appliquer le design à tous les e-mails envoyés par Raising Manager.*/
//add_filter('raising_mail', 'kleor_emails_filter');