Jake Vanderwerf
4 days ago 5a6906f710e9333507486df3cbb545a67a040881
inc/managers/EmailManager.php
@@ -24,7 +24,7 @@
class EmailManager
{
   public array $colours = JVB_EMAIL['colours'];
   public array $colours;
   private string $title = JVB_EMAIL['content']['title'];
   private string $prefix = JVB_EMAIL['content']['subjectPrefix'];
   private string $signature = JVB_EMAIL['content']['signature'];
@@ -42,7 +42,7 @@
        $this->site_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
        $this->site_url = get_site_url();
      $this->footer = (is_array(JVB_EMAIL['content']['footer'])) ? implode('', JVB_EMAIL['content']['footer']) : JVB_EMAIL['content']['footer'];
      $this->colours = JVB_COLOURS;
        add_filter('wp_mail_content_type', [$this, 'setHtmlContentType']);
        // User registration emails
        add_filter('wp_new_user_notification_email', [$this, 'customizeNewUserEmail'], 999, 3);
@@ -756,11 +756,35 @@
      );
   }
   public function grid(array $items, int $columns = 2):string
   public function grid(array $items, int $columns = 2, string $title = '', string|array $description = '', string $after = ''):string
   {
      $width = floor(100 / $columns) - 2; // 2% gap
      $html = '<div style="display:table;width:100%;margin:20px 0;">';
      $html = '';
      if (!empty($title) || !empty($description)) {
         $html .= '<div>';
         if (!empty($title)) {
            $html .= sprintf(
               '<h2>%s</h2>',
               $title
            );
         }
         if (!empty($description)) {
            if (is_string($description)) {
               if (str_starts_with($description, '<p>')) {
                  $html .= $description;
               }else {
                  $html .= sprintf(
                     '<p>%s</p>',
                     $description
                  );
               }
            } else {
               $html .= implode('',array_map(function ($p) { return sprintf('<p>%s</p>', $p); }, $description));
            }
         }
      }
      $html .= '<div style="display:table;width:100%;margin:20px 0;">';
      foreach ($items as $index => $item) {
         if ($index > 0 && $index % $columns === 0) {
            $html .= '</div><div style="display:table;width:100%;margin:20px 0;">';
@@ -771,11 +795,16 @@
            $item
         );
      }
      $html .= '</div>';
      $html .= '</div>'.$after;
      if (!empty($title) || !empty($description)) {
         $html .= '</div>';
      }
      return $html;
   }
   public function image(string $src, string $alt = '', int $maxWidth = 600):string
   {
      return sprintf(