PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.2.11
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.2.11
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 1.2.0 1.2.1 All 156 releases
notificationx / includes / Admin / Reports / EmailTemplate.php

EmailTemplate.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar 3.2.11, at includes/Admin/Reports/EmailTemplate.php

418 lines 18.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $output = <<<NXTEMHEADER
10 <!DOCTYPE html>
11 <html lang="en">
12 <head>
13 <meta charset="UTF-8">
14 <meta name="viewport" content="width=device-width, initial-scale=1.0">
15 <title>NotificationX Email Template</title>
16 <link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet">
17 <style type="text/css">
18 .nx-email-body, .nx-wrapper-body {
19 font-size: 14px;
20 font-family: 'Roboto', sans-serif;
21 }
22 .nx-box-analytics-parent {
23 padding: 0px 25px;
24 }
25 @media screen and ( min-width: 786px ) {
26 table.nx-email-body > tbody > tr > td {
27 padding-top: 0px;
28 padding-bottom: 20px;
29 }
30 table.nx-email-body > tbody > tr > td.nx-email-header {
31 padding-top: 30px !important;
32 }
33 table.nx-email-body > tbody > tr:last-of-type > td {
34 padding-bottom: 30px !important;
35 }
36 }
37 @media screen and (max-width: 620px) {
38 table.nx-email-wrapper > tbody > tr > td, table.nx-email-body > tbody > tr > td,
39 table.nx-email-footer > tbody > tr > td {
40 padding: 15px !important;
41 }
42 table.nx-email-wrapper > tbody > tr > td.nx-email-footer-parent {
43 padding-top: 0px !important;
44 }
45
46 table.nx-email-body > tbody > tr > td.nx-box-analytics-parent {
47 padding: 5px !important;
48 }
49
50 .nx-email-body, .nx-email-footer {
51 width: 100% !important;
52 }
53 .nx-email-logo {
54 width: 100px;
55 }
56 .nx-mobile-font {
57 font-size: 12px !important;
58 line-height: 1.5;
59 }
60 .nx-box-analytics .nx-mobile-font {
61 font-size: 10px !important;
62 }
63 .nx-box-analytics > tbody > tr > td > table > tbody > tr:nth-of-type(2) td.nx-mobile-font {
64 font-size: 15px !important;
65 }
66 .nx-mobile-icon {
67 width: 15px !important
68 }
69 td#nx-no-padding {
70 padding: 0px !important;
71 }
72 }
73 </style>
74 </head>
75 <body class="nx-wrapper-body" style="background-color: #f3f7fa; margin: 0; padding: 0">
76 <table class="nx-email-wrapper" cellpadding="50" cellspacing="0" border="0" width="100%" align="center" bgcolor="#f3f7fa">
77 <tbody>
78 <tr>
79 <td>
80 <table class="nx-email-body" cellpadding="35" cellspacing="0" border="0" width="600" align="center" bgcolor="#FFF">
81 <tbody>
82 NXTEMHEADER;
83 return $output;
84 }
85
86 public function footer(){
87 $facebook = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/facebook.png' );
88 $twitter = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/twitter.png' );
89 $youtube = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/youtube.png' );
90 $web = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/web.png' );
91
92 $output = <<<NXTEMFOOTER
93 </tbody>
94 </table> <!-- /.nx-email-body -->
95 </td>
96 </tr>
97 <tr>
98 <td style="padding: 0px 0px 50px" class="nx-email-footer-parent">
99 <table class="nx-email-footer" cellpadding="0" cellspacing="0" border="0" width="600" align="center">
100 <tbody>
101 <tr>
102 <td align="center" style="padding: 0px 60px">
103 <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>
104 <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>
105 <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>
106 <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>
107 <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>
108 </td>
109 </tr>
110 </tbody>
111 </table>
112 </td>
113 </tr>
114 </tbody>
115 </table>
116 </body>
117 </html>
118 NXTEMFOOTER;
119 return $output;
120 }
121
122 public function body_header( $args = array(), $frequency = '' ){
123 $args = current( $args );
124 $logo = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/logo.png' );
125 $from_date = isset( $args['from_date'] ) ? date( 'M j, Y', strtotime( $args['from_date'] ) ) : '';
126 $to_date = isset( $args['to_date'] ) ? date( 'M j, Y', strtotime( $args['to_date'] ) ) : '';
127
128 if( empty( $from_date ) || empty( $to_date ) ) {
129 return '';
130 }
131
132 if( $frequency !== 'nx_daily' ) {
133 $to_date = "- " . $to_date;
134 } else {
135 $to_date = '';
136 }
137
138 $output = <<<NXBODYHEADER
139 <tr>
140 <td class="nx-email-header">
141 <table width="100%" cellpadding="0" cellspacing="0" align="center">
142 <tbody>
143 <tr>
144 <td align="left">
145 <a href=""><img class="nx-email-logo" style="display: block; max-width: 100%;" src="$logo" alt=""></a>
146 </td>
147 <td class="nx-mobile-font" align="right" style="font:normal 14px 'Roboto',sans-serif">
148 <font color="#848484">Your Analytics <span class="il">Report</span></font><br><font color="#444444">$from_date $to_date</font>
149 </td>
150 </tr>
151 </tbody>
152 </table>
153 </td> <!-- Header LOGO, Date Range -->
154 </tr>
155 NXBODYHEADER;
156 return $output;
157 }
158
159 public function body( $args = array(), $frequency = '' ){
160 if( empty( $args ) ) {
161 return '';
162 }
163 $body_header = $this->body_header( $args, $frequency );
164
165 $analytics_box = '';
166
167 if( is_array( $args ) ) {
168 foreach( $args as $analytics_key => $analytics_value ) {
169 $analytics_box .= $this->analytics_box( $analytics_value, $frequency );
170 }
171 }
172
173 $pro_msg = $this->pro_message();
174 $overall_promo_text = $this->promo( $args, $frequency );
175
176 $output = <<<NXTEMBODY
177 $body_header
178 $overall_promo_text
179 $analytics_box
180 $pro_msg
181 NXTEMBODY;
182 return $output;
183 }
184
185 public function template_body( $args, $frequency ){
186 $output = $this->header() . $this->body( $args, $frequency ) . $this->footer();
187 return $output;
188 }
189
190 public function promo( $args = array(), $frequency = '' ){
191 if( empty( $args ) ) {
192 return false;
193 }
194
195 $views = array_reduce( $args, function( $carry, $item ) {
196 $carry += $item['views'];
197 return $carry;
198 } );
199
200 // $last_wk_views = array_reduce( $args, function( $carry, $item ) {
201 // $carry += $item['last_views'];
202 // return $carry;
203 // } );
204
205 $clicks = array_reduce( $args, function( $carry, $item ) {
206 $carry += $item['clicks'];
207 return $carry;
208 } );
209
210 // $last_wk_clicks = array_reduce( $args, function( $carry, $item ) {
211 // $carry += $item['last_clicks'];
212 // return $carry;
213 // } );
214
215 $ctr = array_reduce( $args, function( $carry, $item ) {
216 $carry += $item['ctr'];
217 return $carry;
218 } );
219
220 $views = number_format( $views );
221 $clicks = number_format( $clicks );
222 $ctr = number_format( $ctr );
223
224 $text_lead = 'In the last 7 Days';
225
226 if( $frequency === 'nx_daily' ) {
227 $text_lead = 'Yesterday';
228 }
229
230 if( $frequency === 'nx_monthly' ) {
231 $text_lead = 'In the last month';
232 }
233 $text_lead = esc_html( $text_lead );
234
235 $output = <<<NXPROMO
236 <tr>
237 <td class="nx-mobile-font" style="line-height: 1.5;">
238 <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>
239 </td>
240 </tr> <!-- Overall Text -->
241 NXPROMO;
242 return $output;
243 }
244
245 public static function analytics_box( $args = array(), $frequency = 'nx_weekly' ){
246 if( empty( $args ) ) {
247 return false;
248 }
249
250 $type = $args['type'];
251 $title = esc_html( $args['title'] );
252 $views = number_format( $args['views'] );
253 $percentage_views = esc_html( $args['percentage_views'] );
254 $clicks = number_format( $args['clicks'] );
255 $percentage_clicks = esc_html( $args['percentage_clicks'] );
256 $ctr = number_format( $args['ctr'] );
257 $percentage_ctr = esc_html( $args['percentage_ctr'] );
258
259 $up_arrow = $v_arrow = $c_arrow = $ctr_arrow = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/nx-template-up.png' );
260 $down_arrow = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/nx-template-down.png' );
261 $v_color = $c_color = $ctr_color = '#34cf8a';
262 if( $percentage_views < 0 ) {
263 $v_color = '#ff616c';
264 $v_arrow = $down_arrow;
265 }
266 if( $percentage_clicks < 0 ) {
267 $c_color = '#ff616c';
268 $c_arrow = $down_arrow;
269 }
270 if( $percentage_ctr < 0 ) {
271 $ctr_color = '#ff616c';
272 $ctr_arrow = $down_arrow;
273 }
274
275 $percentage_views = NotificationX_Helper::nice_number( $args['percentage_views'] );
276 $percentage_clicks = NotificationX_Helper::nice_number( $args['percentage_clicks'] );
277 $percentage_ctr = NotificationX_Helper::nice_number( $args['percentage_ctr'] );
278
279 if( is_array( $type ) ) {
280 $type_name = esc_html( $type['source'] );
281 } else {
282 $type_name = esc_html( $type );
283 }
284
285 switch( $frequency ) {
286 case 'nx_weekly' :
287 $days_ago = '7 days ago';
288 break;
289 case 'nx_daily' :
290 $days_ago = '1 days ago';
291 break;
292 case 'nx_monthly' :
293 $initial_timestamp = strtotime('first day of last month', current_time('timestamp'));
294 $days_in_last_month = cal_days_in_month(CAL_GREGORIAN, date( 'm', $initial_timestamp ), date( 'Y', $initial_timestamp ));
295 $days_ago = $days_in_last_month . ' days ago';
296 break;
297 }
298
299 $days_ago = esc_html( $days_ago );
300 $v_color = esc_attr( $v_color );
301 $c_color = esc_attr( $c_color );
302 $ctr_color = esc_attr( $ctr_color );
303
304 $output = <<<NXBOXTEM
305 <tr>
306 <td class="nx-box-analytics-parent">
307 <table class="nx-box-analytics" cellspacing="10" cellpadding="0" border="0" align="center" width="100%">
308 <tbody>
309 <tr>
310 <td align="left" class="nx-mobile-font" colspan="3" style="font-size: 13px;">
311 <strong>$type_name</strong> > $title
312 </td>
313 </tr>
314 <tr>
315 <td style="border:1px solid #e5ecf2" width="33.333%">
316 <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#fff">
317 <tbody>
318 <tr>
319 <td align="center" class="nx-mobile-font" style="background-color: #e5ecf2; text-transform: uppercase; padding: 10px 0px; font-size: 14px;">
320 Total Views
321 </td>
322 </tr>
323 <tr>
324 <td class="nx-mobile-font" align="center" style="padding: 10px 5px; font-size: 26px;">
325 $views
326 </td>
327 </tr>
328 <tr>
329 <td class="nx-mobile-font" style="padding:3px 10px 10px;font:700 10px" align="center">
330 <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>
331 <br><font color="#909090">$days_ago</font>
332 </td>
333 </tr>
334 </tbody>
335 </table>
336 </td> <!-- BOX END -->
337 <td style="border:1px solid #e5ecf2;" width="33.333%">
338 <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#fff">
339 <tbody>
340 <tr>
341 <td align="center" class="nx-mobile-font" style="background-color: #e5ecf2; text-transform: uppercase; padding: 10px 0px; font-size: 14px;">
342 Total Clicks
343 </td>
344 </tr>
345 <tr>
346 <td class="nx-mobile-font" align="center" style="padding: 10px 5px; font-size: 26px;">
347 $clicks
348 </td>
349 </tr>
350 <tr>
351 <td class="nx-mobile-font" style="padding:3px 10px 10px;font:700 10px" align="center">
352 <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>
353 <br><font color="#909090">$days_ago</font>
354 </td>
355 </tr>
356 </tbody>
357 </table>
358 </td> <!-- BOX END -->
359 <td style="border:1px solid #e5ecf2" width="33.333%">
360 <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#fff">
361 <tbody>
362 <tr>
363 <td align="center" class="nx-mobile-font" style="background-color: #e5ecf2; text-transform: uppercase; padding: 10px 0px; font-size: 14px;">
364 Total CTR
365 </td>
366 </tr>
367 <tr>
368 <td class="nx-mobile-font" align="center" style="padding: 10px 5px; font-size: 26px;">
369 $ctr
370 </td>
371 </tr>
372 <tr>
373 <td class="nx-mobile-font" style="padding:3px 10px 10px;font:700 10px" align="center">
374 <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>
375 <br><font color="#909090">$days_ago</font>
376 </td>
377 </tr>
378 </tbody>
379 </table>
380 </td> <!-- BOX END -->
381 </tr>
382 </tbody>
383 </table>
384 </td>
385 </tr> <!-- Analytics BOX ROW -->
386 NXBOXTEM;
387 return $output;
388 }
389
390 public static function pro_message(){
391 $is_pro = defined( 'NOTIFICATIONX_PRO_VERSION' );
392 $graph = esc_url( NOTIFICATIONX_PUBLIC_URL . 'image/reports/graph.png' );
393 $admin_analytics_url = admin_url( 'admin.php?page=nx-analytics' );
394 if( $is_pro ) {
395 $output = <<<NXPROMSG
396 <tr>
397 <td class="nx-mobile-font nx-pro-message" align="center" style="font-size: 15px; line-height: 1.7; color: #737373;">
398 <a href="$admin_analytics_url" target="_blank"><img style="display: block; max-width: 100%; padding: 15px 0 0" src="$graph" alt="Visit Dashboard"></a>
399 <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>
400 </td>
401 </tr>
402 NXPROMSG;
403 return $output;
404 }
405
406 $output = <<<NXPROMSG
407 <tr>
408 <td class="nx-mobile-font nx-pro-message" align="center" style="font-size: 15px; line-height: 1.7; color: #737373;">
409 <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>
410 <p style="text-align: left; margin-top: 0px;">Get everything NotificationX has to offer by upgrading to a PRO plan. </p>
411 <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>
412 <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>
413 </td>
414 </tr>
415 NXPROMSG;
416 return $output;
417 }
418 }