| @@ -74,31 +74,35 @@ | ||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if ($block['type'] == 'button') { |
| 77 | 77 | return (string)App::make('view')->make('email.Default._button', [ |
| 78 | - 'link' => Arr::get($block['options'], 'link'), | |
| 79 | - 'btnText' => $block['content'] | |
| 78 | + 'link' => Arr::get($block['options'], 'link'), | |
| 79 | + 'btnText' => $block['content'], | |
| 80 | + 'linkColor' => Utility::getThemeColor(), | |
| 81 | + 'btnTextColor' => Utility::getThemeColor('theme_button_text') | |
| 80 | 82 | ]); |
| 81 | 83 | } |
| 82 | 84 | |
| 83 | 85 | if ($block['type'] == 'boxed_content') { |
| 84 | 86 | return (string)App::make('view')->make('email.Default._user_box_content', [ |
| 85 | - 'user_name' => $block['options']['user']->display_name, | |
| 87 | + 'user_name' => $block['options']['user']->getPublicDisplayName(), | |
| 86 | 88 | 'user_avatar' => !(empty($block['options']['user']->xprofile->avatar)) ? $block['options']['user']->xprofile->avatar : $block['options']['user']->photo, |
| 87 | 89 | 'content' => $block['content'], |
| 88 | 90 | 'permalink' => $block['options']['permalink'], |
| 89 | - 'post_content' => $block['options']['post_content'] | |
| 91 | + 'post_content' => $block['options']['post_content'], | |
| 92 | + 'linkColor' => Utility::getThemeColor() | |
| 90 | 93 | ]); |
| 91 | 94 | } |
| 92 | 95 | |
| 93 | 96 | if ($block['type'] == 'post_boxed_content') { |
| 94 | 97 | return (string)App::make('view')->make('email.Default._user_post_content', [ |
| 95 | - 'user_name' => $block['options']['user']->display_name, | |
| 98 | + 'user_name' => $block['options']['user']->getPublicDisplayName(), | |
| 96 | 99 | 'user_avatar' => !(empty($block['options']['user']->xprofile->avatar)) ? $block['options']['user']->xprofile->avatar : $block['options']['user']->photo, |
| 97 | 100 | 'content' => $block['content'], |
| 98 | 101 | 'title' => Arr::get($block['options'], 'title'), |
| 99 | 102 | 'permalink' => $block['options']['permalink'], |
| 100 | - 'space_name' => $block['options']['space_name'] | |
| 103 | + 'space_name' => $block['options']['space_name'], | |
| 104 | + 'linkColor' => Utility::getThemeColor() | |
| 101 | 105 | ]); |
| 102 | 106 | } |
| 103 | 107 | |
| 104 | 108 | if ($block['type'] == 'html_content') { |
| @@ -152,10 +156,12 @@ | ||
| 152 | 156 | } |
| 153 | 157 | |
| 154 | 158 | $generalSettings = Helper::generalSettings(); |
| 155 | 159 | |
| 160 | + $themeColor = Utility::getThemeColor(); | |
| 161 | + | |
| 156 | 162 | $replaces = [ |
| 157 | - '{{site_name_with_url}}' => '<a target="_blank" href="' . Helper::baseUrl('/') . '">' . Arr::get($generalSettings, 'site_title') . '</a>', | |
| 163 | + '{{site_name_with_url}}' => '<a target="_blank" href="' . Helper::baseUrl('/') . '" style="color: ' . esc_attr($themeColor) . '; text-decoration: none;">' . Arr::get($generalSettings, 'site_title') . '</a>', | |
| 158 | 164 | '{{site_name}}' => Arr::get($generalSettings, 'site_title') |
| 159 | 165 | ]; |
| 160 | 166 | |
| 161 | 167 | $footerTextHtml = str_replace(array_keys($replaces), array_values($replaces), $footerTextHtml); |
| @@ -160,9 +166,9 @@ | ||
| 160 | 166 | |
| 161 | 167 | $footerTextHtml = str_replace(array_keys($replaces), array_values($replaces), $footerTextHtml); |
| 162 | 168 | |
| 163 | 169 | // find pattern like this: {{manage_email_notification_url|Manage Your Email Notifications Preference}} |
| 164 | - $footerTextHtml = preg_replace_callback('/{{(.*?)\|(.*?)}}/', function ($matches) use ($withPlaceHolder) { | |
| 170 | + $footerTextHtml = preg_replace_callback('/{{(.*?)\|(.*?)}}/', function ($matches) use ($withPlaceHolder, $themeColor) { | |
| 165 | 171 | $match1 = $matches[1]; |
| 166 | 172 | if ($match1 != 'manage_email_notification_url') { |
| 167 | 173 | return $matches[0]; |
| 168 | 174 | } |
| @@ -173,9 +179,9 @@ | ||
| 173 | 179 | $url = Helper::baseUrl('fcom_route?route=user_notification_settings&auth=yes'); |
| 174 | 180 | } |
| 175 | 181 | |
| 176 | 182 | $text = $matches[2]; |
| 177 | - return '<a target="_blank" rel="noopener noreferrer" href="' . $url . '">' . $text . '</a>'; | |
| 183 | + return '<a target="_blank" rel="noopener noreferrer" style="color: ' . esc_attr($themeColor) . '; text-decoration: underline;" href="' . $url . '">' . $text . '</a>'; | |
| 178 | 184 | }, $footerTextHtml); |
| 179 | 185 | |
| 180 | 186 | $this->addFooterLine('paragraph', $footerTextHtml); |
| 181 | 187 | |
| @@ -214,8 +220,19 @@ | ||
| 214 | 220 | if ($this->headingBlocks) { |
| 215 | 221 | $data['headingContent'] = $this->complileHeadingBlocks(); |
| 216 | 222 | } |
| 217 | 223 | |
| 218 | - return (string)App::make('view')->make('email.template', $data); | |
| 224 | + $html = (string)App::make('view')->make('email.template', $data); | |
| 225 | + | |
| 226 | + // Inline the <head><style> rules onto each element so they survive clients and | |
| 227 | + // log viewers that strip the document head (Outlook, FluentSMTP's DOMPurify | |
| 228 | + // preview). @media/:hover rules can't be inlined and are kept in a <style> tag. | |
| 229 | + try { | |
| 230 | + $html = (new Emogrifier\Emogrifier($html))->emogrify(); | |
| 231 | + } catch (\Throwable $e) { | |
| 232 | + // Fall back to the un-inlined HTML; the <head><style> still covers Gmail. | |
| 233 | + } | |
| 234 | + | |
| 235 | + return $html; | |
| 219 | 236 | } |
| 220 | 237 | |
| 221 | 238 | } |