PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 3.5.2
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v3.5.2
0.9.6 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.2 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 2.0.0 2.0.1 2.1.1 2.2.1 2.3.1 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.8.0 2.9.0 3.0.1 3.0.2 3.0.3 3.1.0 3.10.0 3.11.0 3.11.1 3.2.0 3.2.1 3.3.0 3.4.0 3.5.0 3.5.1 3.5.2 3.6.1 3.7.0 3.8.0 3.8.2 3.9.0 4.0.1 4.1.0 4.1.1 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.8.0 trunk 0.10.0 0.10.1 0.11.1 0.11.2 0.3.1 0.3.2 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.5.2 0.6 0.7 0.8 0.8.2 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5
wp-mail-smtp / src / Reports / Emails / Summary.php
wp-mail-smtp / src / Reports / Emails Last commit date
Summary.php 3 years ago
Summary.php
434 lines
1 <?php
2
3 namespace WPMailSMTP\Reports\Emails;
4
5 use WPMailSMTP\Admin\Area;
6 use WPMailSMTP\Options;
7 use WPMailSMTP\Reports\Reports;
8
9 /**
10 * Class Summary. Summary report email.
11 *
12 * @since 3.0.0
13 */
14 class Summary {
15
16 /**
17 * The slug that will be used to save the option of summary report email.
18 *
19 * @since 3.0.0
20 */
21 const SETTINGS_SLUG = 'summary_report_email_disabled';
22
23 /**
24 * Whether summary report email is disabled.
25 *
26 * @since 3.0.0
27 *
28 * @return bool
29 */
30 public static function is_disabled() {
31
32 $value = Options::init()->get( 'general', self::SETTINGS_SLUG );
33
34 // If option was not already set, then plugin was updated from lower version.
35 if (
36 ( $value === '' || $value === null ) &&
37 ( is_multisite() || ! wp_mail_smtp()->is_pro() )
38 ) {
39 $value = true;
40 }
41
42 /**
43 * Filters whether summary report email is disabled.
44 *
45 * @since 3.0.0
46 *
47 * @param bool $is_disabled
48 */
49 $value = apply_filters( 'wp_mail_smtp_reports_emails_summary_is_disabled', $value );
50
51 return (bool) $value;
52 }
53
54 /**
55 * Get summary report email preview link.
56 *
57 * @since 3.0.0
58 *
59 * @return string Preview link.
60 */
61 public static function get_preview_link() {
62
63 return add_query_arg(
64 [ 'mode' => 'summary_report_email_preview' ],
65 wp_mail_smtp()->get_admin()->get_admin_page_url()
66 );
67 }
68
69 /**
70 * Send summary report email.
71 *
72 * @since 3.0.0
73 */
74 public function send() {
75
76 if ( $this->is_disabled() ) {
77 return;
78 }
79
80 $parsed_home_url = wp_parse_url( home_url() );
81 $site_domain = $parsed_home_url['host'];
82
83 if ( is_multisite() && isset( $parsed_home_url['path'] ) ) {
84 $site_domain .= $parsed_home_url['path'];
85 }
86
87 $subject = sprintf( /* translators: %s - site domain. */
88 esc_html__( 'Your Weekly WP Mail SMTP Summary for %s', 'wp-mail-smtp' ),
89 $site_domain
90 );
91
92 /**
93 * Filters the summaries email subject.
94 *
95 * @since 3.0.0
96 *
97 * @param string $subject Email subject.
98 */
99 $subject = apply_filters( 'wp_mail_smtp_reports_emails_summary_send_subject', $subject );
100
101 /**
102 * Filters the summaries recipient email address.
103 *
104 * @since 3.0.0
105 *
106 * @param string $email Recipient email address.
107 */
108 $to_email = apply_filters( 'wp_mail_smtp_reports_emails_summary_send_to', get_option( 'admin_email' ) );
109
110 add_filter( 'wp_mail_content_type', [ $this, 'set_html_content_type' ] );
111
112 wp_mail( $to_email, $subject, $this->get_content() );
113
114 remove_filter( 'wp_mail_content_type', [ $this, 'set_html_content_type' ] );
115 }
116
117 /**
118 * Get summary report email content.
119 *
120 * @since 3.0.0
121 *
122 * @return string
123 */
124 public function get_content() {
125
126 $content = $this->get_header_html();
127 $content .= $this->get_main_html();
128 $content .= $this->get_footer_html();
129
130 return $content;
131 }
132
133 /**
134 * Get summary report email header HTML.
135 *
136 * @since 3.0.0
137 *
138 * @return string
139 */
140 private function get_header_html() {
141
142 ob_start();
143 ?>
144 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
145 <html xmlns="http://www.w3.org/1999/xhtml">
146 <head>
147 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
148 <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
149 <!--[if !mso]><!-->
150 <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
151 <!--<![endif]-->
152 <meta name="color-scheme" content="light dark">
153 <meta name="supported-color-schemes" content="light dark">
154 <title><?php esc_html_e( 'WP Mail SMTP Weekly Email Summary', 'wp-mail-smtp' ); ?></title>
155 <style type="text/css">
156 <?php include wp_mail_smtp()->plugin_path . '/assets/css/emails/summary-report-email.css'; ?>
157 </style>
158 </head>
159 <body class="dark-body-bg" style="margin: 0;padding: 0;min-width: 100%;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;background: #f1f1f1;text-align: left;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;mso-line-height-rule: exactly;line-height: 140%;font-size: 14px;height: 100% !important;width: 100% !important;-webkit-font-smoothing: antialiased !important;-moz-osx-font-smoothing: grayscale !important;">
160 <table class="body dark-body-bg" border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" style="border-collapse: collapse;border-spacing: 0;padding: 0;vertical-align: top;text-align: left;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;margin: 0;min-width: 100%;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;background: #f1f1f1;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;mso-line-height-rule: exactly;line-height: 140%;font-size: 14px;height: 100% !important;width: 100%;-webkit-font-smoothing: antialiased !important;-moz-osx-font-smoothing: grayscale !important;">
161 <tr style="padding: 0;vertical-align: top;text-align: left;">
162 <td align="center" valign="top" style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 0;vertical-align: top;text-align: center;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 140%;font-size: 14px;border-collapse: collapse !important;">
163 <!-- Container -->
164 <table border="0" cellpadding="0" cellspacing="0" class="container" style="border-collapse: collapse;border-spacing: 0;padding: 0;vertical-align: top;text-align: inherit;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;width: 600px;margin: 0 auto 0 auto;">
165 <!-- Header -->
166 <tr style="padding: 0;vertical-align: top;text-align: left;">
167 <td align="center" valign="middle" class="header" style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 15px 0px;vertical-align: top;text-align: center;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 140%;font-size: 14px;border-collapse: collapse !important;">
168 <div class="light-img">
169 <img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/reports/email/wp-mail-smtp-logo' . ( wp_mail_smtp()->is_white_labeled() ? '-whitelabel' : '' ) . '.png' ); ?>" width="321" alt="<?php esc_attr_e( 'WP Mail SMTP Logo', 'wp-mail-smtp' ); ?>" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;width: 321px;max-width: 100%;clear: both;display: inline-block !important;height: auto !important;">
170 </div>
171 <!--[if !mso]><! -->
172 <div class="dark-img" style="display:none; overflow:hidden; float:left; width:0px; max-height:0px; max-width:0px; line-height:0px; visibility:hidden;" align="center">
173 <img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/reports/email/wp-mail-smtp-logo-dark' . ( wp_mail_smtp()->is_white_labeled() ? '-whitelabel' : '' ) . '.png' ); ?>" width="321" alt="<?php esc_attr_e( 'WP Mail SMTP Logo', 'wp-mail-smtp' ); ?>" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;width: 321px;max-width: 100%;clear: both;display: inline-block !important;height: auto !important;">
174 </div>
175 <!--<![endif]-->
176 </td>
177 </tr>
178 <!-- Content -->
179 <tr style="padding: 0;vertical-align: top;text-align: left;">
180 <td align="left" valign="top" class="content dark-content-bg" style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 60px;vertical-align: top;text-align: left;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 140%;font-size: 14px;background: #ffffff;border-radius: 6px;border-collapse: collapse !important;">
181 <?php
182 return ob_get_clean();
183 }
184
185 /**
186 * Get summary report email footer HTML.
187 *
188 * @since 3.0.0
189 *
190 * @return string
191 */
192 private function get_footer_html() {
193
194 $settings_link = add_query_arg(
195 [ 'tab' => 'misc' ],
196 wp_mail_smtp()->get_admin()->get_admin_page_url( Area::SLUG )
197 );
198
199 ob_start();
200 ?>
201 </td>
202 </tr>
203 <!-- Footer -->
204 <tr style="padding: 0;vertical-align: top;text-align: left;">
205 <td class="footer" align="center" valign="top" style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 30px 0px;vertical-align: top;text-align: center;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #777777;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 140%;font-size: 13px;border-collapse: collapse !important;">
206 <?php
207 echo wp_kses(
208 sprintf( /* translators: %1$s - link to a site; %2$s - link to the settings page. */
209 __( 'This email was auto-generated and sent from %1$s. Learn %2$s.', 'wp-mail-smtp' ),
210 '<a href="' . esc_url( home_url() ) . '" style="-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #72777c;font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;margin: 0;text-align: left;mso-line-height-rule: exactly;line-height: 140%;text-decoration: underline;">' . esc_html( wp_specialchars_decode( get_bloginfo( 'name' ) ) ) . '</a>',
211 '<a href="' . esc_url( $settings_link ) . '" style="-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #72777c;font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;margin: 0;text-align: left;mso-line-height-rule: exactly;line-height: 140%;text-decoration: underline;">' . esc_html__( 'how to disable it', 'wp-mail-smtp' ) . '</a>'
212 ),
213 [
214 'a' => [
215 'href' => [],
216 'style' => [],
217 ],
218 ]
219 );
220 ?>
221 </td>
222 </tr>
223 </table>
224 </td>
225 </tr>
226 </table>
227 </body>
228 </html>
229 <?php
230 return ob_get_clean();
231 }
232
233 /**
234 * Get summary report email general content HTML.
235 *
236 * @since 3.0.0
237 *
238 * @return string
239 */
240 protected function get_main_html() {
241
242 $reports = new Reports();
243
244 $upgrade_link = wp_mail_smtp()->get_upgrade_link(
245 [
246 'medium' => 'weekly-email-summary',
247 'content' => 'upgrade-to-wp-mail-smtp-pro-button',
248 ]
249 );
250
251 ob_start();
252 ?>
253 <h6 class="main-heading dark-white-color" style="margin: 0;padding: 0;color: #444444;word-wrap: normal;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: bold;mso-line-height-rule: exactly;line-height: 22px;;text-align: left;font-size: 18px;margin-bottom: 10px;">
254 <?php esc_html_e( 'Hi there,', 'wp-mail-smtp' ); ?>
255 </h6>
256 <p class="main-description dark-white-color" style="margin: 0;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;mso-line-height-rule: exactly;line-height: 19px;font-size: 16px;margin-bottom: 40px;">
257 <?php esc_html_e( 'Let’s see how many emails you’ve sent with WP Mail SMTP.', 'wp-mail-smtp' ); ?>
258 </p>
259
260 <table class="stats-totals-wrapper two" style="border-collapse: collapse;border-spacing: 0;padding: 0;vertical-align: top;text-align: left;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;width: 100%;">
261 <tr style="padding: 0;vertical-align: top;text-align: left;">
262 <td class="stats-totals-item-wrapper" style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 0px;vertical-align: top;text-align: left;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 140%;font-size: 14px;border-collapse: collapse !important;">
263 <?php
264 echo $this->get_stats_total_html( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
265 __( 'Total Emails', 'wp-mail-smtp' ),
266 'icon-email.png',
267 $reports->get_total_emails_sent(), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
268 $reports->get_total_emails_sent() - $reports->get_total_weekly_emails_sent( 'previous' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
269 '#809EB0'
270 );
271 ?>
272 </td>
273 <td class="stats-totals-item-wrapper" style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 0px;vertical-align: top;text-align: right;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 140%;font-size: 14px;border-collapse: collapse !important;">
274 <?php
275 echo $this->get_stats_total_html( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
276 __( 'Last week', 'wp-mail-smtp' ),
277 'icon-check.png',
278 $reports->get_total_weekly_emails_sent( 'now' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
279 $reports->get_total_weekly_emails_sent( 'previous' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
280 '#6AA08B'
281 );
282 ?>
283 </td>
284 </tr>
285 </table>
286
287 <div class="spacer-40" style="line-height:40px;height:40px;mso-line-height-rule:exactly;">&nbsp;</div>
288
289 <table style="border-collapse: collapse;border-spacing: 0;padding: 0;vertical-align: top;text-align: center;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;width: 100%;">
290 <tr style="padding: 0;vertical-align: top;text-align: left;">
291 <td class="dark-bg" style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;vertical-align: top;text-align: center;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 140%;font-size: 14px;border-collapse: collapse !important;background: #F8F8F8;border-radius: 4px;padding: 30px">
292 <img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/reports/icon-note.png' ); ?>" alt="<?php esc_attr_e( 'Reports', 'wp-mail-smtp' ); ?>" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;width: 75px;max-width: 100%;clear: both;display: inline-block !important;height: auto !important;" width="75">
293 <h4 class="upgrade-heading dark-white-color" style="padding: 0;color: #444444;word-wrap: normal;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: bold;mso-line-height-rule: exactly;line-height: 24px;text-align: center;font-size: 20px;margin: 20px 0;"><?php esc_attr_e( 'Want More Stats?', 'wp-mail-smtp' ); ?></h4>
294 <p class="upgrade-text" style="margin: 0;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #777777;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: center;mso-line-height-rule: exactly;line-height: 22px;font-size: 15px;margin-bottom: 20px;">
295 <?php
296 echo wp_kses(
297 __( 'Upgrade to <b>WP Mail SMTP Pro</b> and unlock <u>Email Log</u> and advanced <u>Email Reports</u>. Start measuring the success of your emails today!', 'wp-mail-smtp' ),
298 [
299 'b' => [],
300 'u' => [],
301 ]
302 );
303 ?>
304 </p>
305 <center style="width: 100%;">
306 <table style="border-collapse: collapse;border-spacing: 0;padding: 0;vertical-align: top;text-align: left;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;width: auto;">
307 <tr style="padding: 0;vertical-align: top;text-align: left;">
308 <td style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 0;vertical-align: top;text-align: left;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 100%;font-size: 14px;border-collapse: collapse !important;">
309 <table style="border-collapse: collapse;border-spacing: 0;padding: 0;vertical-align: top;text-align: left;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
310 <tr style="padding: 0;vertical-align: top;text-align: left;">
311 <td style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;vertical-align: top;text-align: center;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #ffffff;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 100%;font-size: 14px;background: #e27730;border-radius: 3px;border-collapse: collapse !important;padding: 12px 15px 12px 15px;">
312 <a href="<?php echo esc_url( $upgrade_link ); ?>" rel="noopener noreferrer" target="_blank" style="-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #ffffff;font-family: Helvetica, Arial, sans-serif;font-weight: bold;padding: 0;margin: 0;text-align: center;mso-line-height-rule: exactly;line-height: 100%;text-decoration: none;font-size: 16px;display: inline-block;">
313 <?php esc_html_e( 'Upgrade to Pro', 'wp-mail-smtp' ); ?>
314 </a>
315 </td>
316 </tr>
317 </table>
318 </td>
319 </tr>
320 </table>
321 </center>
322 </td>
323 </tr>
324 </table>
325 <?php
326 return ob_get_clean();
327 }
328
329 /**
330 * Get stats total block HTML.
331 *
332 * @since 3.0.0
333 *
334 * @param string $title Heading.
335 * @param string $icon Icon file.
336 * @param int $value Stats value.
337 * @param int $prev_value Previous period stats value.
338 * @param string $color Heading text color.
339 * @param string $wrapper_style Wrapper inline CSS styles.
340 *
341 * @return string
342 */
343 protected function get_stats_total_html( $title, $icon, $value, $prev_value, $color, $wrapper_style = '' ) {
344
345 $width = $this->get_stats_total_item_width();
346
347 $percent_change = $this->calc_percent_change( $value, $prev_value );
348
349 $images_dir_url = wp_mail_smtp()->assets_url . '/images/reports/email/';
350 $icon_width = ( $icon === 'icon-email.png' ) ? 34 : 32;
351
352 ob_start();
353 ?>
354 <table class="stats-total-item" style="border-spacing: 0;padding: 0;vertical-align: top;text-align: left;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;width: <?php echo intval( $width ); ?>px;display: inline-table;min-width:<?php echo intval( $width ); ?>px;" width="<?php echo intval( $width ); ?>">
355 <tr style="padding: 0;vertical-align: top;text-align: left;">
356 <td class="stats-total-item-inner" style="word-wrap: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;padding: 15px 5px;vertical-align: top;text-align: center;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;mso-line-height-rule: exactly;line-height: 140%;font-size: 14px;border-collapse: collapse !important; width: 100%; min-width:100%; border: 1px solid #DDDDDD;border-radius: 4px;<?php echo esc_attr( $wrapper_style ); ?>">
357 <p class="stats-total-item-icon-wrapper" style="margin: 0;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: <?php echo esc_attr( $color ); ?>;padding: 0;text-align: center;mso-line-height-rule: exactly;margin-bottom: 10px;height: 32px;">
358 <img class="stats-total-item-icon" src="<?php echo esc_url( $images_dir_url . $icon ); ?>" alt="<?php echo esc_attr( $title ); ?>" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;width: <?php echo esc_attr( $icon_width ); ?>px;height:32px;clear: both;display: inline-block;" width="<?php echo esc_attr( $icon_width ); ?>" height="32">
359 </p>
360 <p class="stats-total-item-title" style="margin: 0;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: <?php echo esc_attr( $color ); ?>;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: bold;padding: 0;text-align: center;mso-line-height-rule: exactly;line-height: 14px;font-size: 13px;margin-bottom: 11px;white-space: nowrap;">
361 <?php echo esc_html( $title ); ?>
362 </p>
363 <p class="stats-total-item-value dark-white-color" style="margin: 0 0 12px 0;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #444444;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: bold;padding: 0;text-align: center;mso-line-height-rule: exactly;line-height: 28px;font-size: 28px;">
364 <?php echo esc_html( $value ); ?>
365 </p>
366 <p class="stats-total-item-percent" style="margin: 0;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #777777;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: center;mso-line-height-rule: exactly;line-height: 14px;font-size: 14px;white-space: nowrap;">
367 <img src="<?php echo esc_url( $images_dir_url . 'icon-arrow-' . ( $percent_change['positive'] ? 'up' : 'down' ) . '.png' ); ?>" alt="<?php echo esc_attr( $title ); ?>" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;width: 12px;height: 12px;max-width: 100%;clear: both;" width="12" height="12">
368 <span style="padding-left: 1px;">
369 <!--[if mso]>&nbsp;<![endif]-->
370 <?php echo $percent_change['positive'] ? '+' : '-'; ?><?php echo esc_html( $percent_change['value'] ); ?>%
371 </span>
372 </p>
373 </td>
374 </tr>
375 </table>
376 <?php
377 return ob_get_clean();
378 }
379
380 /**
381 * Get stats total block width in px.
382 *
383 * @since 3.0.0
384 *
385 * @return int
386 */
387 protected function get_stats_total_item_width() {
388
389 return 220;
390 }
391
392 /**
393 * Calculate two numbers difference in percent.
394 *
395 * @since 3.0.0
396 *
397 * @param int $new Current value.
398 * @param int $old Previous value.
399 *
400 * @return array
401 */
402 private function calc_percent_change( $new, $old ) {
403
404 $new = intval( $new );
405 $old = intval( $old );
406
407 // Prevent divide by zero.
408 if ( $old === 0 ) {
409 $old ++;
410 $new ++;
411 }
412
413 $diff = $new - $old;
414 $percent_change = ( abs( $diff ) / $old ) * 100;
415
416 return [
417 'positive' => $diff >= 0,
418 'value' => round( $percent_change, 1 ),
419 ];
420 }
421
422 /**
423 * Set the HTML content type.
424 *
425 * @since 3.0.0
426 *
427 * @return string
428 */
429 public function set_html_content_type() {
430
431 return 'text/html';
432 }
433 }
434