__( 'Today', 'statwrite' ), /* translators: %s: number of days. */ 7 => sprintf( _n( '%s day', '%s days', 7, 'statwrite' ), number_format_i18n( 7 ) ), /* translators: %s: number of days. */ 30 => sprintf( _n( '%s day', '%s days', 30, 'statwrite' ), number_format_i18n( 30 ) ), /* translators: %s: number of days. */ 90 => sprintf( _n( '%s day', '%s days', 90, 'statwrite' ), number_format_i18n( 90 ) ), ); $next = wp_next_scheduled( WPHS_Aggregator::EVENT ); $settings_url = add_query_arg( array( 'page' => 'statwrite-settings' ), admin_url( 'admin.php' ) ); $refresh_url = add_query_arg( array( 'page' => 'statwrite', 'range' => $range, 'mode' => $mode, ), admin_url( 'admin.php' ) ); $report_url = static function ( $days, $report_mode ) { return add_query_arg( array( 'page' => 'statwrite', 'range' => $days, 'mode' => $report_mode, ), admin_url( 'admin.php' ) ); }; $quality_groups = array(); $has_legacy_quality = false; $quality_tone = $quality['verified_share'] >= 80 ? 'is-good' : ( $quality['verified_share'] >= 50 ? 'is-warn' : 'is-bad' ); foreach ( $quality['groups'] as $group ) { if ( 'legacy' === $group['key'] && $group['pageviews'] > 0 ) { $has_legacy_quality = true; } if ( $group['pageviews'] > 0 || in_array( $group['key'], array( 'verified', 'nojs', 'suspect' ), true ) ) { $quality_groups[] = $group; } } /* translators: %s: time difference, for example "5 minutes". */ $last_run_text = $data['last_run'] > 0 ? sprintf( __( '%s ago', 'statwrite' ), human_time_diff( $data['last_run'], time() ) ) : __( 'No processing yet', 'statwrite' ); $token_set = ! empty( $token_set ); $overview_error = isset( $overview_error ) ? (string) $overview_error : ''; $overview_stale = ! empty( $overview_stale ); $icons = array( 'eye' => '', 'users' => '', 'activity' => '', 'clock' => '', 'bounce' => '', 'chart' => '', ); $trend = static function ( $change ) { if ( null === $change ) { echo '—'; return; } $class = $change > 0 ? 'is-up' : ( $change < 0 ? 'is-down' : 'is-flat' ); $sign = $change > 0 ? '+' : ''; echo '' . esc_html( $sign . number_format_i18n( $change, 0 ) . '%' ) . ''; }; $svg_allowed = array( 'svg' => array( 'viewbox' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true ), 'path' => array( 'd' => true ), 'circle' => array( 'cx' => true, 'cy' => true, 'r' => true ), ); $prev_avg_text = $prev['sessions'] > 0 ? WPHS_Reports::duration( $data['prev_avg_engaged'] ) : '—'; $prev_bounce_text = $prev['sessions'] > 0 ? number_format_i18n( $data['prev_bounce_rate'], 0 ) . '%' : '—'; $series = $data['series']; $n = count( $series ); $chart_peak = 0; $peak_day = null; foreach ( $series as $point ) { if ( $point['pageviews'] > $chart_peak ) { $chart_peak = $point['pageviews']; $peak_day = $point; } } $chart_max = max( 1, $chart_peak ); $chart_w = 1000; $chart_h = 240; $chart_pad = 24; $points = array(); foreach ( $series as $i => $point ) { $x = $n > 1 ? ( $i / ( $n - 1 ) ) * $chart_w : $chart_w / 2; $y = $chart_h - $chart_pad - ( ( $point['pageviews'] / $chart_max ) * ( $chart_h - 2 * $chart_pad ) ); $points[] = array( 'x' => round( $x, 2 ), 'y' => round( $y, 2 ), 'p' => $point, ); } $line_path = ''; $area_path = ''; if ( $points ) { $line_path = 'M' . $points[0]['x'] . ' ' . $points[0]['y']; foreach ( array_slice( $points, 1 ) as $point ) { $line_path .= ' L' . $point['x'] . ' ' . $point['y']; } $area_path = 'M' . $points[0]['x'] . ' ' . ( $chart_h - $chart_pad ) . ' L' . $points[0]['x'] . ' ' . $points[0]['y']; foreach ( array_slice( $points, 1 ) as $point ) { $area_path .= ' L' . $point['x'] . ' ' . $point['y']; } $last = end( $points ); $area_path .= ' L' . $last['x'] . ' ' . ( $chart_h - $chart_pad ) . ' Z'; } $grid_lines = array(); for ( $i = 0; $i <= 4; $i++ ) { $grid_lines[] = round( $chart_pad + ( $chart_h - 2 * $chart_pad ) * ( $i / 4 ), 2 ); } $step = $n > 0 ? $chart_w / $n : $chart_w; if ( $n <= 7 ) { $date_labels = array(); foreach ( $series as $point ) { $date_labels[] = substr( WPHS_Reports::day_label( $point['day'] ), 5 ); } $date_style = 'grid-template-columns:repeat(' . max( 1, $n ) . ',minmax(0,1fr))'; } else { $indexes = array( 0, (int) floor( $n * 0.25 ), (int) floor( $n * 0.5 ), (int) floor( $n * 0.75 ), $n - 1 ); $date_labels = array(); foreach ( $indexes as $index ) { $date_labels[] = substr( WPHS_Reports::day_label( $series[ $index ]['day'] ), 5 ); } $date_style = ''; } $channel_classes = array( 'search' => 'is-search', 'social' => 'is-social', 'direct' => 'is-direct', 'referral' => 'is-referral', 'paid' => 'is-paid', 'email' => 'is-email', 'campaign' => 'is-campaign', ); ?>

—

—
$point ) : ?>

0 ? esc_html( WPHS_Reports::duration( $row['avg'] ) ) : '—'; ?>

—

0 ? ( (int) $row['pv'] / (int) $t['pageviews'] ) * 100 : 0; $device_class = 'is-device-' . preg_replace( '/[^a-z]/', '', (string) $row['device'] ); ?>

0 ) : ?>