PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.11.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.11.0
2.11.0 2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 All 78 releases
← All changes | app/Services/Libs/DailyDigest.php +35 -13 1.0.962.11.0 View file →
@@ -8,8 +8,9 @@
8 8 use FluentCommunity\App\Models\User;
9 9 use FluentCommunity\App\Services\CustomSanitizer;
10 10 use FluentCommunity\App\Services\Helper;
11 11 use FluentCommunity\App\Services\ProfileHelper;
12 +use FluentCommunity\App\Functions\Utility;
12 13 use FluentCommunity\Framework\Support\Arr;
13 14
14 15 class DailyDigest
15 16 {
@@ -59,13 +60,16 @@
59 60 $settings = Helper::generalSettings();
60 61 $emailComposer = new \FluentCommunity\App\Services\Libs\EmailComposer();
61 62
62 63 $headingHtml = \sprintf(
64 + /* translators: %s is replaced by the title of the site */
63 65 '<h2 style="font-family: Arial, sans-serif; font-size: 20px; font-weight: bold; margin: 0; margin-bottom: 5px;">' . __('This week on %s', 'fluent-community') . '</h2>',
64 66 Arr::get($settings, 'site_title')
65 67 );
66 68
67 - $headingHtml .= '<p style="font-family: Arial, sans-serif; font-size: 12px; font-weight: normal; margin: 0; margin-bottom: 16px;">' . date('F d', strtotime($this->fromDate)) . ' - ' . date('F d, Y') . '</p>';
69 + /* translators: %1$s is replaced by the start date of the week, %2$s is replaced by the end date of the week */
70 + $headingHtml .= '<p style="font-family: Arial, sans-serif; font-size: 12px; font-weight: normal; margin: 0; margin-bottom: 16px;">' . sprintf(__('%1$s - %2$s', 'fluent-community'), date_i18n('F d', strtotime('-7 days')), date_i18n('F d, Y')) . '</p>';
71 +
68 72 $emailComposer->addBlock('html_content', $headingHtml);
69 73 $emailComposer->addBlock('paragraph', __('Here are some of the most popular posts and notifications you may have missed from the last week 🔥.', 'fluent-community'));
70 74
71 75 $popularPostsHtml = $this->getPoppularPostsHtml();
@@ -84,21 +88,36 @@
84 88 $emailComposer->addBlock('button', __('View all the notifications', 'fluent-community'), [
85 89 'link' => ProfileHelper::signUserUrlWithAuthHash(Helper::baseUrl('notifications/'), $this->user->ID)
86 90 ]);
87 91 }
92 + }
88 93
89 - }
90 - $emailComposer->setLogo(\FluentCommunity\Framework\Support\Arr::get($settings, 'logo'));
94 + $emailComposer->setDefaultLogo();
91 95
92 96 $emailComposer->setDefaultFooter();
93 97
94 98 $emailBody = $emailComposer->getHtml();
95 99
96 - return str_replace([
100 + $emailBody = str_replace([
97 101 '##email_notification_url##'
98 102 ], [
99 103 ProfileHelper::getSignedNotificationPrefUrl($this->user->ID)
100 104 ], $emailBody);
105 +
106 + $hooksSections = apply_filters('fluent_community/digest_notification/email_sections', [
107 + 'before_content' => '',
108 + 'after_content' => ''
109 + ], $this->user);
110 +
111 + if(!empty($hooksSections['before_content'])) {
112 + $emailBody = str_replace('<!--email_content_before-->', $hooksSections['before_content'], $emailBody);
113 + }
114 +
115 + if(!empty($hooksSections['after_content'])) {
116 + $emailBody = str_replace('<!--email_content_after-->', $hooksSections['after_content'], $emailBody);
117 + }
118 +
119 + return apply_filters('fluent_community/digest_email_body', $emailBody, $this->user);
101 120 }
102 121
103 122 public function willSend($hours = 20)
104 123 {
@@ -113,8 +132,9 @@
113 132 {
114 133 $settings = Helper::generalSettings();
115 134
116 135 $emailSubject = \sprintf(
136 + /* translators: %1$s is replaced by the name of the user, %2$s is replaced by the title of the site */
117 137 __('Hey %1$s, here\'s your weekly digest from %2$s', 'fluent-community'),
118 138 $this->user->display_name,
119 139 Arr::get($settings, 'site_title')
120 140 );
@@ -121,9 +141,9 @@
121 141
122 142 $notificationCount = count($this->getUnreadNotifications());
123 143
124 144 if ($notificationCount > 0) {
125 - // translators: %d is the number of unread notifications for digest email subject
145 + /* translators: %d is replaced by the number of unread notifications for digest email subject */
126 146 $emailSubject .= ' ' . \sprintf(__('(🔔%d)', 'fluent-community'), $notificationCount);
127 147 }
128 148
129 149 return apply_filters('fluent_community/digest_email_subject', $emailSubject, $this->user, $notificationCount);
@@ -173,27 +193,28 @@
173 193 $permalink = ProfileHelper::signUserUrlWithAuthHash(Helper::getUrlByJsRoute($notification->route), $this->user->ID);
174 194 $isLast = $totalCount == ($index + 1);
175 195 ?>
176 196 <tr>
177 - <td valign="top" align="left">
197 + <td valign="top">
178 198 <table class="fcom_each_item"
179 199 style="padding: 10px;<?php echo $isLast ? '' : 'border-bottom: 1px solid #dedede;'; ?>"
180 200 cellspacing="0" cellpadding="0" border="0">
181 201 <tr>
182 - <td valign="top" style="border-radius: 50%; padding: 4px; vertical-align: top;">
202 + <td valign="top" style="border-radius: 50%; padding: 4px; vertical-align: top; height: 32px; width: 32px;">
183 203 <a href="<?php echo esc_url($permalink); ?>">
184 - <img alt="<?php echo esc_html($notification->xprofile); ?>"
185 - src="<?php echo esc_url($notification->xprofile->avatar); ?>" width="32"
186 - height="32" style="border-radius: 50%; display: block;">
204 + <img alt="<?php echo esc_html($notification->xprofile ? $notification->xprofile->display_name : ''); ?>"
205 + src="<?php echo esc_url($notification->xprofile->avatar); ?>" height="32" width="32"
206 + style="border-radius: 50%; height: 32px; width: 32px; display: block;">
187 207 </a>
188 208 </td>
189 - <td style="font-family: Arial, sans-serif; font-size: 16px;color: #3c434a; padding-left: 10px; vertical-align: middle;">
209 + <td style="font-family: Arial, sans-serif; font-size: 16px;color: #3c434a; padding-left: 5px; vertical-align: middle;">
190 210 <a style="color: #3c434a; text-decoration: none;" target="_blank"
191 211 href="<?php echo esc_url($permalink); ?>">
192 - <?php echo wp_kses_post($notification->content); ?>
212 + <?php echo wp_kses_post((string) $notification->content); ?>
193 213 </a>
194 214 <p style="font-family: Arial, sans-serif; font-size: 12px; font-weight: normal; margin: 0; margin-top: 5px;">
195 - <?php echo sprintf(__('%s ago', 'fluent-community'), human_time_diff(strtotime($notification->created_at), current_time('timestamp'))); ?>
215 + <?php /* translators: %s is replaced by the time ago */ ?>
216 + <?php echo esc_html( sprintf(__('%s ago', 'fluent-community'), esc_html(human_time_diff(strtotime($notification->created_at), current_time('timestamp'))))); ?>
196 217 </p>
197 218 </td>
198 219 </tr>
199 220 </table>
@@ -242,8 +263,9 @@
242 263 'permalink' => $permalink,
243 264 'space_name' => $post->space ? $post->space->title : '',
244 265 'hide_publish' => 'yes',
245 266 'show_read_more' => 'yes',
267 + 'linkColor' => Utility::getThemeColor(),
246 268 'timestamp' => human_time_diff(strtotime($post->created_at), current_time('timestamp'))
247 269 ]);
248 270
249 271 $html .= $blockEnd;