| 1 |
<?php |
| 2 |
/** |
| 3 |
* General Stats Email View. |
| 4 |
* |
| 5 |
* Renders general analytics stats (sessions, visitors, bounce rate, etc.) for email reports. |
| 6 |
* |
| 7 |
* @package WP_Analytify |
| 8 |
* @version 9.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* Get compared colors for stats (text and background) based on current vs previous period. |
| 13 |
* |
| 14 |
* @param mixed $results Current period value. |
| 15 |
* @param mixed $compare_results Previous period value. |
| 16 |
* @param mixed $date_different Date difference (unused; kept for signature compatibility). |
| 17 |
* @param string $stats_for Optional. Metric key; 'bounce_rate' inverts green/red meaning. |
| 18 |
* @return array<string, string> Keys 'color' and 'bg_color' (hex). |
| 19 |
* @version 9.0.0 |
| 20 |
*/ |
| 21 |
function get_compared_colors( $results, $compare_results, $date_different, $stats_for = '' ) { |
| 22 |
|
| 23 |
// empty() treats 0, 0.0, '0', false, null, '' as empty — avoids strict === 0 missing string '0'. |
| 24 |
if ( empty( $compare_results ) || ! is_numeric( $compare_results ) ) { |
| 25 |
return array( |
| 26 |
'color' => '#000000', |
| 27 |
'bg_color' => '#ffffff', |
| 28 |
); |
| 29 |
} |
| 30 |
|
| 31 |
$compare_base = (float) $compare_results; |
| 32 |
if ( 0.0 === $compare_base ) { |
| 33 |
return array( |
| 34 |
'color' => '#000000', |
| 35 |
'bg_color' => '#ffffff', |
| 36 |
); |
| 37 |
} |
| 38 |
|
| 39 |
$current = is_numeric( $results ) ? (float) $results : 0.0; |
| 40 |
$compare = ( ( $current - $compare_base ) / $compare_base ) * 100; |
| 41 |
|
| 42 |
// Invert results for bounce rate. |
| 43 |
if ( ! empty( $stats_for ) && 'bounce_rate' === $stats_for ) { |
| 44 |
return array( |
| 45 |
'color' => $compare < 0 ? '#00c853' : '#fa5825', |
| 46 |
'bg_color' => $compare < 0 ? '#4ed98817' : '#ffffff', |
| 47 |
); |
| 48 |
} |
| 49 |
|
| 50 |
return array( |
| 51 |
'color' => $compare > 0 ? '#00c853' : '#fa5825', |
| 52 |
'bg_color' => $compare > 0 ? '#4ed98817' : '#ffffff', |
| 53 |
); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Build HTML row for comparison stats (percentage change + "X ago" label) in email. |
| 58 |
* |
| 59 |
* @param mixed $results Current period value. |
| 60 |
* @param mixed $compare_results Previous period value. |
| 61 |
* @param mixed $date_different Label for the comparison period (e.g. "7 days"); output is escaped. |
| 62 |
* @param string $stats_for Optional. Metric key; 'bounce_rate' inverts arrow/color logic. |
| 63 |
* @return string HTML fragment (table row) or empty string when compare_results is 0. |
| 64 |
* @version 9.0.0 |
| 65 |
*/ |
| 66 |
function get_compare_email_stats( $results, $compare_results, $date_different, $stats_for = '' ) { |
| 67 |
|
| 68 |
if ( empty( $compare_results ) || ! is_numeric( $compare_results ) ) { |
| 69 |
return ''; |
| 70 |
} |
| 71 |
|
| 72 |
$compare_base = (float) $compare_results; |
| 73 |
if ( 0.0 === $compare_base ) { |
| 74 |
return ''; |
| 75 |
} |
| 76 |
|
| 77 |
$current = is_numeric( $results ) ? (float) $results : 0.0; |
| 78 |
$compare_pct = ( ( $current - $compare_base ) / $compare_base ) * 100; |
| 79 |
$compare_label = number_format( $compare_pct, 2 ) . '%'; |
| 80 |
$image_name = $compare_pct > 0 ? 'analytify_green_arrow.png' : 'analytify_red_arrow.png'; |
| 81 |
$color = $compare_pct > 0 ? '#00c853' : '#fa5825'; |
| 82 |
|
| 83 |
// Invert results for bounce rate. |
| 84 |
if ( ! empty( $stats_for ) && 'bounce_rate' === $stats_for ) { |
| 85 |
$image_name = $compare_pct < 0 ? 'analytify_green_arrow_down.png' : 'analytify_red_arrow_up.png'; |
| 86 |
$color = $compare_pct < 0 ? '#00c853' : '#fa5825'; |
| 87 |
} |
| 88 |
|
| 89 |
return '<tr> |
| 90 |
<td colspan="3"> |
| 91 |
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center"> |
| 92 |
<tbody> |
| 93 |
<tr> |
| 94 |
<td valign="bottom" style="padding: 10px 10px 3px; font: 700 16px "Roboto", Arial, Helvetica, sans-serif;" align="center"><font color=" ' . esc_attr( $color ) . ' "><img src="' . esc_url( ANALYTIFY_IMAGES_PATH . $image_name ) . '" alt="' . esc_attr( $image_name ) . '" style="padding-right:10px; width:10px">' . esc_html( $compare_label ) . '</font></td> |
| 95 |
</tr> |
| 96 |
<tr> |
| 97 |
<td style="padding: 3px 10px 10px; font: 700 10px Roboto, Arial, Helvetica, sans-serif;text-transform:uppercase;" align="center"><font color="#909090">' . esc_html( $date_different ) . ' ago</font></td> |
| 98 |
</tr> |
| 99 |
</tbody> |
| 100 |
</table> |
| 101 |
</td> |
| 102 |
</tr>'; |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Generates the main stats table rows for the general-stats email (sessions, visitors, bounce rate, etc.). |
| 107 |
* |
| 108 |
* @param array<string, mixed> $current Analytify's main object (reserved for future use). |
| 109 |
* @param array<string, mixed> $stats GA stats for the current period (aggregations). |
| 110 |
* @param array<string, mixed> $old_stats GA stats from the previous period (for comparison). |
| 111 |
* @param string $date_different Human-readable comparison period label (e.g. "7 days"). |
| 112 |
* @return string HTML fragment for the email body, or empty string on failure. |
| 113 |
* @version 9.0.0 |
| 114 |
*/ |
| 115 |
function pa_email_include_general( $current, $stats, $old_stats, $date_different ) { |
| 116 |
|
| 117 |
// Sessions. |
| 118 |
$__sessions_current = $stats['aggregations']['sessions'] ?? 0; |
| 119 |
$__sessions_old = $old_stats['aggregations']['sessions'] ?? 0; |
| 120 |
|
| 121 |
// Visitors. |
| 122 |
$__total_users_current = $stats['aggregations']['totalUsers'] ?? 0; |
| 123 |
$__total_users_old = $old_stats['aggregations']['totalUsers'] ?? 0; |
| 124 |
|
| 125 |
// Bounce Rate. |
| 126 |
$__bounce_rate_current = $stats['aggregations']['bounceRate'] ?? 0; |
| 127 |
$__bounce_rate_old = $old_stats['aggregations']['bounceRate'] ?? 0; |
| 128 |
|
| 129 |
// Average time on site. |
| 130 |
$__avg_time_on_site_current = $stats['aggregations']['averageSessionDuration'] ?? 0; |
| 131 |
$__avg_time_on_site_old = $old_stats['aggregations']['averageSessionDuration'] ?? 0; |
| 132 |
|
| 133 |
// Pages/Session. |
| 134 |
$__pages_per_session_current = $stats['aggregations']['screenPageViewsPerSession'] ?? 0; |
| 135 |
$__pages_per_session_old = $old_stats['aggregations']['screenPageViewsPerSession'] ?? 0; |
| 136 |
|
| 137 |
// Page Views. |
| 138 |
$__page_views_current = $stats['aggregations']['screenPageViews'] ?? 0; |
| 139 |
$__page_views_old = $old_stats['aggregations']['screenPageViews'] ?? 0; |
| 140 |
|
| 141 |
// Engaged Sessions. |
| 142 |
$__engaged_sessions_current = $stats['aggregations']['engagedSessions'] ?? 0; |
| 143 |
$__engaged_sessions_old = $old_stats['aggregations']['engagedSessions'] ?? 0; |
| 144 |
|
| 145 |
// New visitors. |
| 146 |
$__new_visitors_current = $stats['aggregations']['newUsers'] ?? 0; |
| 147 |
$__new_visitors_old = $old_stats['aggregations']['newUsers'] ?? 0; |
| 148 |
|
| 149 |
// Total time on site. |
| 150 |
$__total_time_on_site_current = $stats['aggregations']['userEngagementDuration'] ?? 0; |
| 151 |
|
| 152 |
// Used to generate the main table. |
| 153 |
$formatted_td_stats = array( |
| 154 |
|
| 155 |
// Sessions. |
| 156 |
'sessions' => array( |
| 157 |
'label' => analytify__( 'Sessions', 'wp-analytify' ), |
| 158 |
'colors' => get_compared_colors( $__sessions_current, $__sessions_old, $date_different ), |
| 159 |
'value' => WPANALYTIFY_Utils::pretty_numbers( $__sessions_current ), |
| 160 |
'old' => $old_stats ? get_compare_email_stats( $__sessions_current, $__sessions_old, $date_different ) : '', |
| 161 |
), |
| 162 |
|
| 163 |
// Visitors. |
| 164 |
'visitors' => array( |
| 165 |
'label' => analytify__( 'Visitors', 'wp-analytify' ), |
| 166 |
'colors' => get_compared_colors( $__total_users_current, $__total_users_old, $date_different ), |
| 167 |
'value' => WPANALYTIFY_Utils::pretty_numbers( $__total_users_current ), |
| 168 |
'old' => $old_stats ? get_compare_email_stats( $__total_users_current, $__total_users_old, $date_different ) : '', |
| 169 |
), |
| 170 |
|
| 171 |
// Bounce Rate. |
| 172 |
'bounce_rate' => array( |
| 173 |
'label' => analytify__( 'Bounce Rate', 'wp-analytify' ), |
| 174 |
'colors' => get_compared_colors( $__bounce_rate_current, $__bounce_rate_old, $date_different, 'bounce_rate' ), |
| 175 |
'value' => WPANALYTIFY_Utils::fraction_to_percentage( $__bounce_rate_current ) . '%', |
| 176 |
'old' => $old_stats ? get_compare_email_stats( $__bounce_rate_current, $__bounce_rate_old, $date_different, 'bounce_rate' ) : '', |
| 177 |
), |
| 178 |
|
| 179 |
// Average time on site. |
| 180 |
'avg_time_on_site' => array( |
| 181 |
'label' => analytify__( 'Avg time on site', 'wp-analytify' ), |
| 182 |
'colors' => get_compared_colors( $__avg_time_on_site_current, $__avg_time_on_site_old, $date_different ), |
| 183 |
'value' => WPANALYTIFY_Utils::pretty_time( $__avg_time_on_site_current ), |
| 184 |
'old' => $old_stats ? get_compare_email_stats( $__avg_time_on_site_current, $__avg_time_on_site_old, $date_different ) : '', |
| 185 |
), |
| 186 |
|
| 187 |
// Pages/Session. |
| 188 |
'pages_per_session' => array( |
| 189 |
'label' => analytify__( 'Pages/Session', 'wp-analytify' ), |
| 190 |
'colors' => get_compared_colors( $__pages_per_session_current, $__pages_per_session_old, $date_different ), |
| 191 |
'value' => WPANALYTIFY_Utils::pretty_numbers( $__pages_per_session_current ), |
| 192 |
'old' => $old_stats ? get_compare_email_stats( $__pages_per_session_current, $__pages_per_session_old, $date_different ) : '', |
| 193 |
), |
| 194 |
|
| 195 |
// Page Views. |
| 196 |
'page_views' => array( |
| 197 |
'label' => analytify__( 'Page Views', 'wp-analytify' ), |
| 198 |
'colors' => get_compared_colors( $__page_views_current, $__page_views_old, $date_different ), |
| 199 |
'value' => WPANALYTIFY_Utils::pretty_numbers( $__page_views_current ), |
| 200 |
'old' => $old_stats ? get_compare_email_stats( $__page_views_current, $__page_views_old, $date_different ) : '', |
| 201 |
), |
| 202 |
|
| 203 |
// Engaged Sessions. |
| 204 |
'engaged_sessions' => array( |
| 205 |
'label' => analytify__( 'Engaged Sessions', 'wp-analytify' ), |
| 206 |
'colors' => get_compared_colors( $__engaged_sessions_current, $__engaged_sessions_old, $date_different ), |
| 207 |
'value' => WPANALYTIFY_Utils::pretty_numbers( $__engaged_sessions_current ), |
| 208 |
'old' => $old_stats ? get_compare_email_stats( $__engaged_sessions_current, $__engaged_sessions_old, $date_different ) : '', |
| 209 |
), |
| 210 |
|
| 211 |
// New visitors. |
| 212 |
'new_visitors' => array( |
| 213 |
'label' => analytify__( 'New Visitors', 'wp-analytify' ), |
| 214 |
'colors' => get_compared_colors( $__new_visitors_current, $__new_visitors_old, $date_different ), |
| 215 |
'value' => WPANALYTIFY_Utils::pretty_numbers( $__new_visitors_current ), |
| 216 |
'old' => $old_stats ? get_compare_email_stats( $__new_visitors_current, $__new_visitors_old, $date_different ) : '', |
| 217 |
), |
| 218 |
|
| 219 |
// Returning Visitors. |
| 220 |
'returning_visitors' => array( |
| 221 |
'label' => analytify__( 'Returning Visitors', 'wp-analytify' ), |
| 222 |
'colors' => get_compared_colors( $__sessions_current - $__new_visitors_current, $__sessions_old - $__new_visitors_old, $date_different ), |
| 223 |
'value' => absint( WPANALYTIFY_Utils::pretty_numbers( $__sessions_current - $__new_visitors_current ) ), |
| 224 |
'old' => $old_stats ? get_compare_email_stats( $__sessions_current - $__new_visitors_current, $__sessions_old - $__new_visitors_old, $date_different ) : '', |
| 225 |
), |
| 226 |
|
| 227 |
); |
| 228 |
|
| 229 |
ob_start(); |
| 230 |
?> |
| 231 |
<tr> |
| 232 |
<td bgcolor="#ffffff" class="session-table"> |
| 233 |
<table cellspacing="20" cellpadding="0" border="0" align="center" bgcolor="#ffffff" width="100%" class="box-table"> |
| 234 |
<tr> |
| 235 |
<td style="border: 1px solid <?php echo esc_attr( $formatted_td_stats['sessions']['colors']['color'] ); ?>; background-color: <?php echo esc_attr( $formatted_td_stats['sessions']['colors']['bg_color'] ); ?>" width="33.333%"> |
| 236 |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 237 |
<tr> |
| 238 |
<td align="center" colspan="3" |
| 239 |
style="font: 500 14px 'Roboto', Arial, Helvetica, sans-serif;padding: 16px 5px 5px; text-transform: uppercase; letter-spacing: 0.01em;"> |
| 240 |
<font color="#848484"><?php analytify_e( 'Sessions', 'wp-analytify' ); ?></font> |
| 241 |
</td> |
| 242 |
</tr> |
| 243 |
<tr> |
| 244 |
<td width="45"></td> |
| 245 |
<td align="center"> |
| 246 |
<hr style="margin:0;border:0;border-top: 1px solid #e5e5e5;" /> |
| 247 |
<td width="45"></td> |
| 248 |
</tr> |
| 249 |
<tr> |
| 250 |
<td align="center" colspan="3" |
| 251 |
style="padding: 13px 5px 10px; font: 400 24px 'Roboto', Arial, Helvetica, sans-serif;"> |
| 252 |
<font color="#444444"><?php echo wp_kses_post( $formatted_td_stats['sessions']['value'] ); ?></font> |
| 253 |
</td> |
| 254 |
</tr> |
| 255 |
<?php if ( $formatted_td_stats['sessions']['old'] ) : ?> |
| 256 |
<?php echo wp_kses_post( $formatted_td_stats['sessions']['old'] ); ?> |
| 257 |
<?php endif; ?> |
| 258 |
</table> |
| 259 |
</td> |
| 260 |
|
| 261 |
<td style="border: 1px solid <?php echo esc_attr( $formatted_td_stats['visitors']['colors']['color'] ); ?>; background-color: <?php echo esc_attr( $formatted_td_stats['visitors']['colors']['bg_color'] ); ?>" width="33.333%"> |
| 262 |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 263 |
<tr> |
| 264 |
<td align="center" colspan="3" |
| 265 |
style="font: 500 14px 'Roboto', Arial, Helvetica, sans-serif;padding: 16px 5px 5px; text-transform: uppercase; letter-spacing: 0.01em;"> |
| 266 |
<font color="#848484"><?php analytify_e( 'Visitors', 'wp-analytify' ); ?></font> |
| 267 |
</td> |
| 268 |
</tr> |
| 269 |
<tr> |
| 270 |
<td width="45"></td> |
| 271 |
<td align="center"> |
| 272 |
<hr style="margin:0;border:0;border-top: 1px solid #e5e5e5;" /> |
| 273 |
</td> |
| 274 |
<td width="45"></td> |
| 275 |
</tr> |
| 276 |
|
| 277 |
<tr> |
| 278 |
<td align="center" colspan="3" |
| 279 |
style="padding: 13px 5px 10px; font: 400 24px 'Roboto', Arial, Helvetica, sans-serif;"> |
| 280 |
<font color="#444444"><?php echo wp_kses_post( $formatted_td_stats['visitors']['value'] ); ?></font> |
| 281 |
</td> |
| 282 |
</tr> |
| 283 |
|
| 284 |
<?php if ( $formatted_td_stats['visitors']['old'] ) : ?> |
| 285 |
<?php echo wp_kses_post( $formatted_td_stats['visitors']['old'] ); ?> |
| 286 |
<?php endif; ?> |
| 287 |
|
| 288 |
</table> |
| 289 |
</td> |
| 290 |
|
| 291 |
<td style="border: 1px solid <?php echo esc_attr( $formatted_td_stats['bounce_rate']['colors']['color'] ); ?>; background-color: <?php echo esc_attr( $formatted_td_stats['bounce_rate']['colors']['bg_color'] ); ?>" width="33.333%"> |
| 292 |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 293 |
<tr> |
| 294 |
<td align="center" colspan="3" |
| 295 |
style="font: 500 14px 'Roboto', Arial, Helvetica, sans-serif;padding: 16px 5px 5px; text-transform: uppercase; letter-spacing: 0.01em;"> |
| 296 |
<font color="#848484"><?php analytify_e( 'Bounce rate', 'wp-analytify' ); ?></font> |
| 297 |
</td> |
| 298 |
</tr> |
| 299 |
<tr> |
| 300 |
<td width="45"></td> |
| 301 |
<td align="center"> |
| 302 |
<hr style="margin:0;border:0;border-top: 1px solid #e5e5e5;" /> |
| 303 |
</td> |
| 304 |
<td width="45"></td> |
| 305 |
</tr> |
| 306 |
<tr> |
| 307 |
<td align="center" colspan="3" |
| 308 |
style="padding: 13px 5px 10px; font: 400 24px 'Roboto', Arial, Helvetica, sans-serif;"><font color="#444444"><?php echo wp_kses_post( $formatted_td_stats['bounce_rate']['value'] ); ?></font></td> |
| 309 |
</tr> |
| 310 |
|
| 311 |
<?php if ( $formatted_td_stats['bounce_rate']['old'] ) : ?> |
| 312 |
<?php echo wp_kses_post( $formatted_td_stats['bounce_rate']['old'] ); ?> |
| 313 |
<?php endif; ?> |
| 314 |
|
| 315 |
</table> |
| 316 |
</td> |
| 317 |
</tr> |
| 318 |
|
| 319 |
<tr> |
| 320 |
<td style="border: 1px solid <?php echo esc_attr( $formatted_td_stats['avg_time_on_site']['colors']['color'] ); ?>; background-color: <?php echo esc_attr( $formatted_td_stats['avg_time_on_site']['colors']['bg_color'] ); ?>" width="33.333%"> |
| 321 |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 322 |
<tr> |
| 323 |
<td align="center" colspan="3" |
| 324 |
style="font: 500 14px 'Roboto', Arial, Helvetica, sans-serif;padding: 16px 5px 5px; text-transform: uppercase; letter-spacing: 0.01em;"> |
| 325 |
<font color="#848484"><?php esc_html_e( 'Avg time on site', 'wp-analytify' ); ?></font> |
| 326 |
</td> |
| 327 |
</tr> |
| 328 |
<tr> |
| 329 |
<td width="45"></td> |
| 330 |
<td align="center"> |
| 331 |
<hr style="margin:0;border:0;border-top: 1px solid #e5e5e5;" /> |
| 332 |
</td> |
| 333 |
<td width="45"></td> |
| 334 |
</tr> |
| 335 |
<tr> |
| 336 |
<td align="center" colspan="3" style="padding: 13px 5px 10px; font: 400 24px 'Roboto', Arial, Helvetica, sans-serif;"> |
| 337 |
<font color="#444444"><?php echo wp_kses_post( $formatted_td_stats['avg_time_on_site']['value'] ); ?></font> |
| 338 |
</td> |
| 339 |
</tr> |
| 340 |
|
| 341 |
<?php if ( $formatted_td_stats['avg_time_on_site']['old'] ) : ?> |
| 342 |
<?php echo wp_kses_post( $formatted_td_stats['avg_time_on_site']['old'] ); ?> |
| 343 |
<?php endif; ?> |
| 344 |
|
| 345 |
</table> |
| 346 |
</td> |
| 347 |
<td style="border: 1px solid <?php echo esc_attr( $formatted_td_stats['pages_per_session']['colors']['color'] ); ?>; background-color: <?php echo esc_attr( $formatted_td_stats['pages_per_session']['colors']['bg_color'] ); ?>" width="33.333%"> |
| 348 |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 349 |
<tr> |
| 350 |
<td align="center" colspan="3" |
| 351 |
style="font: 500 14px 'Roboto', Arial, Helvetica, sans-serif;padding: 16px 5px 5px; text-transform: uppercase; letter-spacing: 0.01em;"> |
| 352 |
<font color="#848484"><?php esc_html_e( 'Pages/Session', 'wp-analytify' ); ?></font> |
| 353 |
</td> |
| 354 |
</tr> |
| 355 |
<tr> |
| 356 |
<td width="45"></td> |
| 357 |
<td align="center"> |
| 358 |
<hr style="margin:0;border:0;border-top: 1px solid #e5e5e5;" /> |
| 359 |
</td> |
| 360 |
<td width="45"></td> |
| 361 |
</tr> |
| 362 |
<tr> |
| 363 |
<td align="center" colspan="3" |
| 364 |
style="padding: 13px 5px 10px; font: 400 24px 'Roboto', Arial, Helvetica, sans-serif;"> |
| 365 |
<font color="#444444"><?php echo wp_kses_post( $formatted_td_stats['pages_per_session']['value'] ); ?></font></td> |
| 366 |
</tr> |
| 367 |
<?php if ( $formatted_td_stats['pages_per_session']['old'] ) : ?> |
| 368 |
<?php echo wp_kses_post( $formatted_td_stats['pages_per_session']['old'] ); ?> |
| 369 |
<?php endif; ?> |
| 370 |
|
| 371 |
</table> |
| 372 |
</td> |
| 373 |
|
| 374 |
<td style="border: 1px solid <?php echo esc_attr( $formatted_td_stats['page_views']['colors']['color'] ); ?>; background-color: <?php echo esc_attr( $formatted_td_stats['page_views']['colors']['bg_color'] ); ?>" width="33.333%"> |
| 375 |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 376 |
<tr> |
| 377 |
<td align="center" colspan="3" |
| 378 |
style="font: 500 14px 'Roboto', Arial, Helvetica, sans-serif;padding: 16px 5px 5px; text-transform: uppercase; letter-spacing: 0.01em;"> |
| 379 |
<font color="#848484"><?php analytify_e( 'Page Views', 'wp-analytify' ); ?></font></td> |
| 380 |
</tr> |
| 381 |
<tr> |
| 382 |
<td width="45"></td> |
| 383 |
<td align="center"> |
| 384 |
<hr style="margin:0;border:0;border-top: 1px solid #e5e5e5;" /> |
| 385 |
</td> |
| 386 |
<td width="45"></td> |
| 387 |
</tr> |
| 388 |
<tr> |
| 389 |
<td align="center" colspan="3" |
| 390 |
style="padding: 13px 5px 10px; font: 400 24px 'Roboto', Arial, Helvetica, sans-serif;"> |
| 391 |
<font color="#444444"><?php echo wp_kses_post( $formatted_td_stats['page_views']['value'] ); ?></font></td> |
| 392 |
</tr> |
| 393 |
|
| 394 |
<?php if ( $formatted_td_stats['page_views']['old'] ) : ?> |
| 395 |
<?php echo wp_kses_post( $formatted_td_stats['page_views']['old'] ); ?> |
| 396 |
<?php endif; ?> |
| 397 |
|
| 398 |
</table> |
| 399 |
</td> |
| 400 |
</tr> |
| 401 |
<tr> |
| 402 |
<td style="border: 1px solid <?php echo esc_attr( $formatted_td_stats['engaged_sessions']['colors']['color'] ); ?>; background-color: <?php echo esc_attr( $formatted_td_stats['engaged_sessions']['colors']['bg_color'] ); ?>" width="33.333%"> |
| 403 |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 404 |
<tr> |
| 405 |
<td align="center" colspan="3" |
| 406 |
style="font: 500 14px 'Roboto', Arial, Helvetica, sans-serif;padding: 16px 5px 5px; text-transform: uppercase; letter-spacing: 0.01em;"> |
| 407 |
<font color="#848484"><?php analytify_e( 'Engaged Sessions', 'wp-analytify' ); ?></font> |
| 408 |
</td> |
| 409 |
</tr> |
| 410 |
<tr> |
| 411 |
<td width="45"></td> |
| 412 |
<td align="center"> |
| 413 |
<hr style="margin:0;border:0;border-top: 1px solid #e5e5e5;" /> |
| 414 |
</td> |
| 415 |
<td width="45"></td> |
| 416 |
</tr> |
| 417 |
<tr> |
| 418 |
<td align="center" colspan="3" |
| 419 |
style="padding: 13px 5px 10px; font: 400 24px 'Roboto', Arial, Helvetica, sans-serif;"> |
| 420 |
<font color=""><?php echo wp_kses_post( $formatted_td_stats['engaged_sessions']['value'] ); ?></font></td> |
| 421 |
</tr> |
| 422 |
|
| 423 |
<?php if ( $formatted_td_stats['engaged_sessions']['old'] ) : ?> |
| 424 |
<?php echo wp_kses_post( $formatted_td_stats['engaged_sessions']['old'] ); ?> |
| 425 |
<?php endif; ?> |
| 426 |
|
| 427 |
</table> |
| 428 |
</td> |
| 429 |
<td style="border: 1px solid <?php echo esc_attr( $formatted_td_stats['new_visitors']['colors']['color'] ); ?>; background-color: <?php echo esc_attr( $formatted_td_stats['new_visitors']['colors']['bg_color'] ); ?>" width="33.333%"> |
| 430 |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 431 |
<tr> |
| 432 |
<td align="center" colspan="3" |
| 433 |
style="font: 500 14px 'Roboto', Arial, Helvetica, sans-serif;padding: 16px 5px 5px; text-transform: uppercase; letter-spacing: 0.01em;"> |
| 434 |
<font color="#848484"><?php analytify_e( 'New Visitors', 'wp-analytify' ); ?></font> |
| 435 |
</td> |
| 436 |
</tr> |
| 437 |
<tr> |
| 438 |
<td width="45"></td> |
| 439 |
<td align="center"> |
| 440 |
<hr style="margin:0;border:0;border-top: 1px solid #e5e5e5;" /> |
| 441 |
</td> |
| 442 |
<td width="45"></td> |
| 443 |
</tr> |
| 444 |
<tr> |
| 445 |
<td align="center" colspan="3" |
| 446 |
style="padding: 13px 5px 10px; font: 400 24px 'Roboto', Arial, Helvetica, sans-serif;"> |
| 447 |
<font color=""><?php echo wp_kses_post( $formatted_td_stats['new_visitors']['value'] ); ?></font></td> |
| 448 |
</tr> |
| 449 |
|
| 450 |
<?php if ( $formatted_td_stats['new_visitors']['old'] ) : ?> |
| 451 |
<?php echo wp_kses_post( $formatted_td_stats['new_visitors']['old'] ); ?> |
| 452 |
<?php endif; ?> |
| 453 |
|
| 454 |
</table> |
| 455 |
</td> |
| 456 |
|
| 457 |
<td style="border: 1px solid <?php echo esc_attr( $formatted_td_stats['returning_visitors']['colors']['color'] ); ?>; background-color: <?php echo esc_attr( $formatted_td_stats['returning_visitors']['colors']['bg_color'] ); ?>" width="33.333%"> |
| 458 |
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 459 |
<tr> |
| 460 |
<td align="center" colspan="3" |
| 461 |
style="font: 500 14px 'Roboto', Arial, Helvetica, sans-serif;padding: 16px 5px 5px; text-transform: uppercase; letter-spacing: 0.01em;"> |
| 462 |
<font color="#848484"><?php esc_html_e( 'Returning visitors', 'wp-analytify' ); ?></font> |
| 463 |
</td> |
| 464 |
</tr> |
| 465 |
<tr> |
| 466 |
<td width="45"></td> |
| 467 |
<td align="center"> |
| 468 |
<hr style="margin:0;border:0;border-top: 1px solid #e5e5e5;" /> |
| 469 |
</td> |
| 470 |
<td width="45"></td> |
| 471 |
</tr> |
| 472 |
<tr> |
| 473 |
<td align="center" colspan="3" |
| 474 |
style="padding: 13px 5px 10px; font: 400 24px 'Roboto', Arial, Helvetica, sans-serif;"> |
| 475 |
<font color="#444444"><?php echo wp_kses_post( $formatted_td_stats['returning_visitors']['value'] ); ?></font> |
| 476 |
</td> |
| 477 |
</tr> |
| 478 |
|
| 479 |
<?php if ( $formatted_td_stats['returning_visitors']['old'] ) : ?> |
| 480 |
<?php echo wp_kses_post( $formatted_td_stats['returning_visitors']['old'] ); ?> |
| 481 |
<?php endif; ?> |
| 482 |
|
| 483 |
</table> |
| 484 |
</td> |
| 485 |
</tr> |
| 486 |
</table> |
| 487 |
</td> |
| 488 |
</tr> |
| 489 |
<tr> |
| 490 |
<td> |
| 491 |
<table cellpadding="0" cellspacing="16" border="0" width="100%" bgcolor="#f9fafa"> |
| 492 |
<tr> |
| 493 |
<td width="32" style="text-align: right;"><img src="<?php echo esc_url( ANALYTIFY_IMAGES_PATH . 'anlytify_about_icon.png' ); ?>" alt="About icon"></td> |
| 494 |
<td style="font: normal 13px 'Roboto', Arial, Helvetica, sans-serif;"><font color="#444"><?php analytify_e( 'Total time visitors spent on your site: ', 'wp-analytify' ); ?> <?php echo wp_kses_post( WPANALYTIFY_Utils::pretty_time( $__total_time_on_site_current ) ); ?></font></td> |
| 495 |
</tr> |
| 496 |
</table> |
| 497 |
</td> |
| 498 |
</tr> |
| 499 |
<tr> |
| 500 |
<td style="padding:15px;"></td> |
| 501 |
</tr> |
| 502 |
<?php if ( ! class_exists( 'WP_Analytify_Email' ) && ! class_exists( 'WP_Analytify_Addon_Email' ) ) { ?> |
| 503 |
|
| 504 |
<tr> |
| 505 |
<td valign="top" class="analytify-promo-inner-table" style="padding: 30px 45px;" bgcolor="#ffffff"> |
| 506 |
<table style="margin: 0 auto;" cellspacing="0" cellpadding="0" width="100%" align="center"> |
| 507 |
<tbody> |
| 508 |
<tr> |
| 509 |
<td valign="top" colspan="2" style="font-size: 26px; font-family: 'Roboto'; font-weight: bold; line-height: 26px; padding-bottom: 24px;" align="center" class="analytify-promo-heading"><font color="#313133"><?php analytify_e( 'Customize weekly and monthly reports' ); ?></font> </td> |
| 510 |
</tr> |
| 511 |
<tr> |
| 512 |
<td valign="top" colspan="2" style="font-size: 14px; font-family: 'Segoe UI'; font-weight: normal; line-height: 20px; padding-bottom: 15px;"><font color="#383b3d"><?php analytify_e( 'Email notifications add-on extends the Analytify Pro, and enables more control on customizing Analytics Email reports for your websites, delivers Analytics summaries straight in your inbox weekly and monthly.' ); ?></font></td> |
| 513 |
</tr> |
| 514 |
<tr> |
| 515 |
<td valign="top" class="analytify-promo-lists" width="40%"> |
| 516 |
<table cellspacing="0" cellpadding="0" width="100%" align="center"> |
| 517 |
<tbody> |
| 518 |
<tr> |
| 519 |
<td valign="top" style="padding-top: 6px; padding-right: 5px;" width="15"><img src="https://mcusercontent.com/16d94a7b1c408429988343325/images/bef57c22-a546-4d5e-b209-f028a24a1642.png" alt="<?php esc_attr_e( 'checkmark', 'wp-analytify' ); ?>"></td><td style="padding-bottom: 5px;font-size: 14px; font-family: 'Segoe UI'; font-weight: normal; line-height: 20px;"><font color="#383b3d"><?php analytify_e( 'Add your logo' ); ?></font></td> |
| 520 |
</tr> |
| 521 |
<tr> |
| 522 |
<td valign="top" style="padding-top: 6px; padding-right: 5px;" width="15"><img src="https://mcusercontent.com/16d94a7b1c408429988343325/images/bef57c22-a546-4d5e-b209-f028a24a1642.png" alt="<?php esc_attr_e( 'checkmark', 'wp-analytify' ); ?>"></td><td style="padding-bottom: 5px;font-size: 14px; font-family: 'Segoe UI'; font-weight: normal; line-height: 20px;"><font color="#383b3d"><?php analytify_e( 'Edit Email Subject' ); ?></font></td> |
| 523 |
</tr> |
| 524 |
<tr> |
| 525 |
<td valign="top" style="padding-top: 6px; padding-right: 5px;" width="15"><img src="https://mcusercontent.com/16d94a7b1c408429988343325/images/bef57c22-a546-4d5e-b209-f028a24a1642.png" alt="<?php esc_attr_e( 'checkmark', 'wp-analytify' ); ?>"></td><td style="padding-bottom: 5px;font-size: 14px; font-family: 'Segoe UI'; font-weight: normal; line-height: 20px;"><font color="#383b3d"><?php analytify_e( 'Choose your own metrics to display in reports' ); ?></font></td> |
| 526 |
</tr> |
| 527 |
</tbody> |
| 528 |
</table> |
| 529 |
</td> |
| 530 |
<td valign="top" class="analytify-promo-lists" width="52%" style="padding-left: 8%;"> |
| 531 |
<table cellspacing="0" cellpadding="0" width="100%" align="center"> |
| 532 |
<tbody> |
| 533 |
<tr> |
| 534 |
<td valign="top" style="padding-top: 6px; padding-right: 5px;" width="15"><img src="https://mcusercontent.com/16d94a7b1c408429988343325/images/bef57c22-a546-4d5e-b209-f028a24a1642.png" alt="<?php esc_attr_e( 'checkmark', 'wp-analytify' ); ?>"></td><td style="padding-bottom: 5px;font-size: 14px; font-family: 'Segoe UI'; font-weight: normal; line-height: 20px;"><font color="#383b3d"><?php analytify_e( 'Add personal note' ); ?></font></td> |
| 535 |
</tr> |
| 536 |
<tr> |
| 537 |
<td valign="top" style="padding-top: 6px; padding-right: 5px;" width="15"><img src="https://mcusercontent.com/16d94a7b1c408429988343325/images/bef57c22-a546-4d5e-b209-f028a24a1642.png" alt="checkmark"></td><td style="padding-bottom: 5px;font-size: 14px; font-family: 'Segoe UI'; font-weight: normal; line-height: 20px;"><font color="#383b3d"><?php analytify_e( 'Schedule weekly reports' ); ?></font></td> |
| 538 |
</tr> |
| 539 |
<tr> |
| 540 |
<td valign="top" style="padding-top: 6px; padding-right: 5px;" width="15"><img src="https://mcusercontent.com/16d94a7b1c408429988343325/images/bef57c22-a546-4d5e-b209-f028a24a1642.png" alt="checkmark"></td><td style="padding-bottom: 5px;font-size: 14px; font-family: 'Segoe UI'; font-weight: normal; line-height: 20px;"><font color="#383b3d"><?php analytify_e( 'Schedule monthly reports' ); ?></font></td> |
| 541 |
</tr> |
| 542 |
</tbody> |
| 543 |
</table> |
| 544 |
</td> |
| 545 |
</tr> |
| 546 |
<?php if ( class_exists( 'WP_Analytify_Pro_Base' ) ) { ?> |
| 547 |
<tr> |
| 548 |
<td valign="top" colspan="2" align="center" style="padding-top: 24px;"><a href="<?php echo esc_url( 'https://analytify.io/add-ons/email-notifications?utm_source=analytify-pro&utm_medium=email-reports&utm_content=cta&utm_campaign=addons-upgrade' ); ?>"><img src="https://mcusercontent.com/16d94a7b1c408429988343325/images/c29b00f7-b5fa-4e04-9a28-e9d77c69ba15.png" alt="<?php esc_attr_e( 'Buy Email Notifications add-on', 'wp-analytify' ); ?>"></a></td> |
| 549 |
</tr> |
| 550 |
<?php } else { ?> |
| 551 |
<tr> |
| 552 |
<td valign="top" colspan="2" align="center" style="padding-top: 24px;"><a href="<?php echo esc_url( 'https://analytify.io/add-ons/email-notifications?utm_source=analytify-lite&utm_medium=email-reports&utm_content=cta&utm_campaign=bundle-upgrade' ); ?>"><img src="https://mcusercontent.com/16d94a7b1c408429988343325/images/3c067584-abb3-4c6b-8c28-4cc265e67bfa.png" alt="<?php esc_attr_e( 'Upgrade to Analytify Pro + Email Notifications add-on bundle', 'wp-analytify' ); ?>" class="analytify-update-pro"></a></td> |
| 553 |
</tr> |
| 554 |
<?php } ?> |
| 555 |
</tbody> |
| 556 |
</table> |
| 557 |
</td> |
| 558 |
</tr> |
| 559 |
<?php |
| 560 |
} |
| 561 |
$message = ob_get_clean(); |
| 562 |
return $message ? $message : ''; |
| 563 |
} |
| 564 |
|