PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.3.3
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.3.3
3.3.3 3.3.2 3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 158 releases
← All changes | includes/Admin/Reports/EmailTemplate.php +428 -0 0.2.5.5 → 3.3.3 View file →
@@ -1,0 +1,428 @@
1 +<?php
2 +namespace NotificationX\Admin\Reports;
3 +
4 +use NotificationX\Core\Helper as NotificationX_Helper;
5 +
6 +class EmailTemplate {
7 +
8 + public function header(){
9 + // phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet -- HTML email body; wp_enqueue_style() has no effect in a mail. Audited 2026-07-16.
10 + // phpcs:ignore PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- False positive for this context: these are HTML email bodies and remote documentation/tutorial links in admin help text, not offloaded plugin assets. Audited 2026-07-16.
11 + $output = <<<NXTEMHEADER
12 +<!DOCTYPE html>
13 +<html lang="en">
14 + <head>
15 + <meta charset="UTF-8">
16 + <meta name="viewport" content="width=device-width, initial-scale=1.0">
17 + <title>NotificationX Email Template</title>
18 + <link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet">
19 + <style type="text/css">
20 + .nx-email-body, .nx-wrapper-body {
21 + font-size: 14px;
22 + font-family: 'Roboto', sans-serif;
23 + }
24 + .nx-box-analytics-parent {
25 + padding: 0px 25px;
26 + }
27 + @media screen and ( min-width: 786px ) {
28 + table.nx-email-body > tbody > tr > td {
29 + padding-top: 0px;
30 + padding-bottom: 20px;
31 + }
32 + table.nx-email-body > tbody > tr > td.nx-email-header {
33 + padding-top: 30px !important;
34 + }
35 + table.nx-email-body > tbody > tr:last-of-type > td {
36 + padding-bottom: 30px !important;
37 + }
38 + }
39 + @media screen and (max-width: 620px) {
40 + table.nx-email-wrapper > tbody > tr > td, table.nx-email-body > tbody > tr > td,
41 + table.nx-email-footer > tbody > tr > td {
42 + padding: 15px !important;
43 + }
44 + table.nx-email-wrapper > tbody > tr > td.nx-email-footer-parent {
45 + padding-top: 0px !important;
46 + }
47 +
48 + table.nx-email-body > tbody > tr > td.nx-box-analytics-parent {
49 + padding: 5px !important;
50 + }
51 +
52 + .nx-email-body, .nx-email-footer {
53 + width: 100% !important;
54 + }
55 + .nx-email-logo {
56 + width: 100px;
57 + }
58 + .nx-mobile-font {
59 + font-size: 12px !important;
60 + line-height: 1.5;
61 + }
62 + .nx-box-analytics .nx-mobile-font {
63 + font-size: 10px !important;
64 + }
65 + .nx-box-analytics > tbody > tr > td > table > tbody > tr:nth-of-type(2) td.nx-mobile-font {
66 + font-size: 15px !important;
67 + }
68 + .nx-mobile-icon {
69 + width: 15px !important
70 + }
71 + td#nx-no-padding {
72 + padding: 0px !important;
73 + }
74 + }
75 + </style>
76 + </head>
77 + <body class="nx-wrapper-body" style="background-color: #f3f7fa; margin: 0; padding: 0">
78 + <table class="nx-email-wrapper" cellpadding="50" cellspacing="0" border="0" width="100%" align="center" bgcolor="#f3f7fa">
79 + <tbody>
80 + <tr>
81 + <td>
82 + <table class="nx-email-body" cellpadding="35" cellspacing="0" border="0" width="600" align="center" bgcolor="#FFF">
83 + <tbody>
84 +NXTEMHEADER;
85 + // phpcs:enable WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
86 + return $output;
87 + }
88 +
89 + public function footer(){
90 + $facebook = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/facebook.png' );
91 + $twitter = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/twitter.png' );
92 + $youtube = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/youtube.png' );
93 + $web = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/web.png' );
94 +
95 + // phpcs:ignore PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- False positive for this context: these are HTML email bodies and remote documentation/tutorial links in admin help text, not offloaded plugin assets. Audited 2026-07-16.
96 + $output = <<<NXTEMFOOTER
97 + </tbody>
98 + </table> <!-- /.nx-email-body -->
99 + </td>
100 +</tr>
101 +<tr>
102 + <td style="padding: 0px 0px 50px" class="nx-email-footer-parent">
103 + <table class="nx-email-footer" cellpadding="0" cellspacing="0" border="0" width="600" align="center">
104 + <tbody>
105 + <tr>
106 + <td align="center" style="padding: 0px 60px">
107 + <a style="background-image: url('$facebook'); background-repeat: no-repeat; display: inline-block; width: 19px; height: 19px;" href="https://www.facebook.com/groups/NotificationX.Community" title="Join Us in Facebook" target="_blank"></a>
108 + <a style="background-image: url('$twitter'); background-repeat: no-repeat; display: inline-block; width: 19px; height: 19px;" href="https://twitter.com/NotificationX_" target="_blank" title="Follow Us"></a>
109 + <a style="background-image: url('$youtube'); background-repeat: no-repeat; display: inline-block; width: 19px; height: 19px;" href="https://www.youtube.com/wpdevelopernet" target="_blank" title="Subscribe to Get New Tutorial"></a>
110 + <a style="background-image: url('$web'); background-repeat: no-repeat; display: inline-block; width: 19px; height: 19px;" href="https://notificationx.com" target="_blank" title="Follow us On Web"></a>
111 + <p style="margin: 0; color: #737373; line-height: 1.5; margin-top: 10px;">If you have any suggestion regarding the NotificationX Analytics Report, do not hesitate to reply to this mail.</p>
112 + </td>
113 + </tr>
114 + </tbody>
115 + </table>
116 + </td>
117 +</tr>
118 +</tbody>
119 +</table>
120 +</body>
121 +</html>
122 +NXTEMFOOTER;
123 + return $output;
124 + }
125 +
126 + public function body_header( $args = array(), $frequency = '' ){
127 + $args = current( $args );
128 + $logo = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/logo.png' );
129 + $from_date = isset( $args['from_date'] ) ? gmdate( 'M j, Y', strtotime( $args['from_date'] ) ) : '';
130 + $to_date = isset( $args['to_date'] ) ? gmdate( 'M j, Y', strtotime( $args['to_date'] ) ) : '';
131 +
132 + if( empty( $from_date ) || empty( $to_date ) ) {
133 + return '';
134 + }
135 +
136 + if( $frequency !== 'nx_daily' ) {
137 + $to_date = "- " . $to_date;
138 + } else {
139 + $to_date = '';
140 + }
141 +
142 + // phpcs:ignore PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- False positive for this context: these are HTML email bodies and remote documentation/tutorial links in admin help text, not offloaded plugin assets. Audited 2026-07-16.
143 + $output = <<<NXBODYHEADER
144 +<tr>
145 + <td class="nx-email-header">
146 + <table width="100%" cellpadding="0" cellspacing="0" align="center">
147 + <tbody>
148 + <tr>
149 + <td align="left">
150 + <a href=""><img class="nx-email-logo" style="display: block; max-width: 100%;" src="$logo" alt=""></a>
151 + </td>
152 + <td class="nx-mobile-font" align="right" style="font:normal 14px 'Roboto',sans-serif">
153 + <font color="#848484">Your Analytics <span class="il">Report</span></font><br><font color="#444444">$from_date $to_date</font>
154 + </td>
155 + </tr>
156 + </tbody>
157 + </table>
158 + </td> <!-- Header LOGO, Date Range -->
159 +</tr>
160 +NXBODYHEADER;
161 + return $output;
162 + }
163 +
164 + public function body( $args = array(), $frequency = '' ){
165 + if( empty( $args ) ) {
166 + return '';
167 + }
168 + $body_header = $this->body_header( $args, $frequency );
169 +
170 + $analytics_box = '';
171 +
172 + if( is_array( $args ) ) {
173 + foreach( $args as $analytics_key => $analytics_value ) {
174 + $analytics_box .= $this->analytics_box( $analytics_value, $frequency );
175 + }
176 + }
177 +
178 + $pro_msg = $this->pro_message();
179 + $overall_promo_text = $this->promo( $args, $frequency );
180 +
181 + // phpcs:ignore PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- False positive for this context: these are HTML email bodies and remote documentation/tutorial links in admin help text, not offloaded plugin assets. Audited 2026-07-16.
182 + $output = <<<NXTEMBODY
183 +$body_header
184 +$overall_promo_text
185 +$analytics_box
186 +$pro_msg
187 +NXTEMBODY;
188 + return $output;
189 + }
190 +
191 + public function template_body( $args, $frequency ){
192 + $output = $this->header() . $this->body( $args, $frequency ) . $this->footer();
193 + return $output;
194 + }
195 +
196 + public function promo( $args = array(), $frequency = '' ){
197 + if( empty( $args ) ) {
198 + return false;
199 + }
200 +
201 + $views = array_reduce( $args, function( $carry, $item ) {
202 + $carry += $item['views'];
203 + return $carry;
204 + } );
205 +
206 + // $last_wk_views = array_reduce( $args, function( $carry, $item ) {
207 + // $carry += $item['last_views'];
208 + // return $carry;
209 + // } );
210 +
211 + $clicks = array_reduce( $args, function( $carry, $item ) {
212 + $carry += $item['clicks'];
213 + return $carry;
214 + } );
215 +
216 + // $last_wk_clicks = array_reduce( $args, function( $carry, $item ) {
217 + // $carry += $item['last_clicks'];
218 + // return $carry;
219 + // } );
220 +
221 + $ctr = array_reduce( $args, function( $carry, $item ) {
222 + $carry += $item['ctr'];
223 + return $carry;
224 + } );
225 +
226 + $views = number_format( $views );
227 + $clicks = number_format( $clicks );
228 + $ctr = number_format( $ctr );
229 +
230 + $text_lead = 'In the last 7 Days';
231 +
232 + if( $frequency === 'nx_daily' ) {
233 + $text_lead = 'Yesterday';
234 + }
235 +
236 + if( $frequency === 'nx_monthly' ) {
237 + $text_lead = 'In the last month';
238 + }
239 + $text_lead = esc_html( $text_lead );
240 +
241 + // phpcs:ignore PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- False positive for this context: these are HTML email bodies and remote documentation/tutorial links in admin help text, not offloaded plugin assets. Audited 2026-07-16.
242 + $output = <<<NXPROMO
243 +<tr>
244 + <td class="nx-mobile-font" style="line-height: 1.5;">
245 + <p style="margin: 0px; color:#555555">$text_lead NotificationX helped you have site visits of <b>$views</b>, total Click of <b>$clicks</b>, and total CTR of <b>$ctr</b></p>
246 + </td>
247 +</tr> <!-- Overall Text -->
248 +NXPROMO;
249 + return $output;
250 + }
251 +
252 + public static function analytics_box( $args = array(), $frequency = 'nx_weekly' ){
253 + if( empty( $args ) ) {
254 + return false;
255 + }
256 +
257 + $type = $args['type'];
258 + $title = esc_html( $args['title'] );
259 + $views = number_format( $args['views'] );
260 + $percentage_views = esc_html( $args['percentage_views'] );
261 + $clicks = number_format( $args['clicks'] );
262 + $percentage_clicks = esc_html( $args['percentage_clicks'] );
263 + $ctr = number_format( $args['ctr'] );
264 + $percentage_ctr = esc_html( $args['percentage_ctr'] );
265 +
266 + $up_arrow = $v_arrow = $c_arrow = $ctr_arrow = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/nx-template-up.png' );
267 + $down_arrow = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/nx-template-down.png' );
268 + $v_color = $c_color = $ctr_color = '#34cf8a';
269 + if( $percentage_views < 0 ) {
270 + $v_color = '#ff616c';
271 + $v_arrow = $down_arrow;
272 + }
273 + if( $percentage_clicks < 0 ) {
274 + $c_color = '#ff616c';
275 + $c_arrow = $down_arrow;
276 + }
277 + if( $percentage_ctr < 0 ) {
278 + $ctr_color = '#ff616c';
279 + $ctr_arrow = $down_arrow;
280 + }
281 +
282 + $percentage_views = NotificationX_Helper::nice_number( $args['percentage_views'] );
283 + $percentage_clicks = NotificationX_Helper::nice_number( $args['percentage_clicks'] );
284 + $percentage_ctr = NotificationX_Helper::nice_number( $args['percentage_ctr'] );
285 +
286 + if( is_array( $type ) ) {
287 + $type_name = esc_html( $type['source'] );
288 + } else {
289 + $type_name = esc_html( $type );
290 + }
291 +
292 + switch( $frequency ) {
293 + case 'nx_weekly' :
294 + $days_ago = '7 days ago';
295 + break;
296 + case 'nx_daily' :
297 + $days_ago = '1 days ago';
298 + break;
299 + case 'nx_monthly' :
300 + $initial_timestamp = strtotime('first day of last month', current_time('timestamp'));
301 + $days_in_last_month = cal_days_in_month(CAL_GREGORIAN, gmdate( 'm', $initial_timestamp ), gmdate( 'Y', $initial_timestamp ));
302 + $days_ago = $days_in_last_month . ' days ago';
303 + break;
304 + }
305 +
306 + $days_ago = esc_html( $days_ago );
307 + $v_color = esc_attr( $v_color );
308 + $c_color = esc_attr( $c_color );
309 + $ctr_color = esc_attr( $ctr_color );
310 +
311 + // phpcs:ignore PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- False positive for this context: these are HTML email bodies and remote documentation/tutorial links in admin help text, not offloaded plugin assets. Audited 2026-07-16.
312 + $output = <<<NXBOXTEM
313 +<tr>
314 + <td class="nx-box-analytics-parent">
315 + <table class="nx-box-analytics" cellspacing="10" cellpadding="0" border="0" align="center" width="100%">
316 + <tbody>
317 + <tr>
318 + <td align="left" class="nx-mobile-font" colspan="3" style="font-size: 13px;">
319 + <strong>$type_name</strong> > $title
320 + </td>
321 + </tr>
322 + <tr>
323 + <td style="border:1px solid #e5ecf2" width="33.333%">
324 + <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#fff">
325 + <tbody>
326 + <tr>
327 + <td align="center" class="nx-mobile-font" style="background-color: #e5ecf2; text-transform: uppercase; padding: 10px 0px; font-size: 14px;">
328 + Total Views
329 + </td>
330 + </tr>
331 + <tr>
332 + <td class="nx-mobile-font" align="center" style="padding: 10px 5px; font-size: 26px;">
333 + $views
334 + </td>
335 + </tr>
336 + <tr>
337 + <td class="nx-mobile-font" style="padding:3px 10px 10px;font:700 10px" align="center">
338 + <font color="$v_color"><img class="nx-mobile-icon" src="$v_arrow" alt="" style="padding-right:5px; width:19px; vertical-align: text-bottom;">$percentage_views%</font>
339 + <br><font color="#909090">$days_ago</font>
340 + </td>
341 + </tr>
342 + </tbody>
343 + </table>
344 + </td> <!-- BOX END -->
345 + <td style="border:1px solid #e5ecf2;" width="33.333%">
346 + <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#fff">
347 + <tbody>
348 + <tr>
349 + <td align="center" class="nx-mobile-font" style="background-color: #e5ecf2; text-transform: uppercase; padding: 10px 0px; font-size: 14px;">
350 + Total Clicks
351 + </td>
352 + </tr>
353 + <tr>
354 + <td class="nx-mobile-font" align="center" style="padding: 10px 5px; font-size: 26px;">
355 + $clicks
356 + </td>
357 + </tr>
358 + <tr>
359 + <td class="nx-mobile-font" style="padding:3px 10px 10px;font:700 10px" align="center">
360 + <font color="$c_color"><img class="nx-mobile-icon" src="$c_arrow" alt="" style="padding-right:5px; width:19px; vertical-align: text-bottom;">$percentage_clicks%</font>
361 + <br><font color="#909090">$days_ago</font>
362 + </td>
363 + </tr>
364 + </tbody>
365 + </table>
366 + </td> <!-- BOX END -->
367 + <td style="border:1px solid #e5ecf2" width="33.333%">
368 + <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#fff">
369 + <tbody>
370 + <tr>
371 + <td align="center" class="nx-mobile-font" style="background-color: #e5ecf2; text-transform: uppercase; padding: 10px 0px; font-size: 14px;">
372 + Total CTR
373 + </td>
374 + </tr>
375 + <tr>
376 + <td class="nx-mobile-font" align="center" style="padding: 10px 5px; font-size: 26px;">
377 + $ctr
378 + </td>
379 + </tr>
380 + <tr>
381 + <td class="nx-mobile-font" style="padding:3px 10px 10px;font:700 10px" align="center">
382 + <font color="$ctr_color"><img class="nx-mobile-icon" src="$ctr_arrow" alt="" style="padding-right:5px; width:19px; vertical-align: text-bottom;">$percentage_ctr%</font>
383 + <br><font color="#909090">$days_ago</font>
384 + </td>
385 + </tr>
386 + </tbody>
387 + </table>
388 + </td> <!-- BOX END -->
389 + </tr>
390 + </tbody>
391 + </table>
392 + </td>
393 +</tr> <!-- Analytics BOX ROW -->
394 +NXBOXTEM;
395 + return $output;
396 + }
397 +
398 + public static function pro_message(){
399 + $is_pro = defined( 'NOTIFICATIONX_PRO_VERSION' );
400 + $graph = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/graph.png' );
401 + $admin_analytics_url = admin_url( 'admin.php?page=nx-analytics' );
402 + if( $is_pro ) {
403 + // phpcs:ignore PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- False positive for this context: these are HTML email bodies and remote documentation/tutorial links in admin help text, not offloaded plugin assets. Audited 2026-07-16.
404 + $output = <<<NXPROMSG
405 +<tr>
406 + <td class="nx-mobile-font nx-pro-message" align="center" style="font-size: 15px; line-height: 1.7; color: #737373;">
407 + <a href="$admin_analytics_url" target="_blank"><img style="display: block; max-width: 100%; padding: 15px 0 0" src="$graph" alt="Visit Dashboard"></a>
408 + <a style="margin-top: 20px; background-color: #6125d5; color: #FFF; display: inline-block; padding: 10px 20px; text-decoration: none; border-radius: 5px;" href="$admin_analytics_url">Visit Dashboard</a>
409 + </td>
410 +</tr>
411 +NXPROMSG;
412 + return $output;
413 + }
414 +
415 + // phpcs:ignore PluginCheck.CodeAnalysis.Heredoc.NotAllowed -- False positive for this context: these are HTML email bodies and remote documentation/tutorial links in admin help text, not offloaded plugin assets. Audited 2026-07-16.
416 + $output = <<<NXPROMSG
417 +<tr>
418 + <td class="nx-mobile-font nx-pro-message" align="center" style="font-size: 15px; line-height: 1.7; color: #737373;">
419 + <p style="text-align: left; margin-top: 0px;">Resolve doubts from the minds of your users using NotificaitonX- the best Social Proof and FOMO Plugin for WordPress.</p>
420 + <p style="text-align: left; margin-top: 0px;">Get everything NotificationX has to offer by upgrading to a PRO plan. </p>
421 + <a target="_blank" href="https://notificationx.com/in/advanced-reports"><img style="display: block; max-width: 100%; padding: 15px 0 0" src="$graph" alt=""></a>
422 + <a style="margin-top: 20px; background-color: #6125d5; color: #FFF; display: inline-block; padding: 10px 20px; text-decoration: none; border-radius: 5px;" target="_blank" href="https://notificationx.com/in/advanced-reports">Get More Data</a>
423 + </td>
424 +</tr>
425 +NXPROMSG;
426 + return $output;
427 + }
428 +}