0 ) { return sprintf( /* translators: 1: site name, 2: critical count */ __( '[Keepwatch] %1$s: %2$d critical issue(s)', 'keepwatch' ), $site, $summary['critical'] ); } if ( $summary['recommended'] > 0 ) { return sprintf( /* translators: 1: site name, 2: recommended count */ __( '[Keepwatch] %1$s: %2$d recommended fix(es)', 'keepwatch' ), $site, $summary['recommended'] ); } return sprintf( /* translators: %s: site name */ __( '[Keepwatch] %s: all checks passed', 'keepwatch' ), $site ); } /** * Plain-text body. * * @param array $groups Grouped results. * @param array{good: int, recommended: int, critical: int} $summary Counts. */ public static function body( array $groups, array $summary ): string { $labels = Menu::group_labels(); $lines = array( sprintf( /* translators: 1: critical count, 2: recommended count, 3: passed count */ __( 'Keepwatch weekly summary — critical: %1$d, recommended: %2$d, passed: %3$d', 'keepwatch' ), $summary['critical'], $summary['recommended'], $summary['good'] ), '', ); $open = 0; foreach ( $groups as $group => $results ) { $group_lines = array(); foreach ( $results as $result ) { if ( Result::GOOD === $result->status ) { continue; } ++$open; $prefix = Result::CRITICAL === $result->status ? '[!]' : '[-]'; $group_lines[] = $prefix . ' ' . $result->label; if ( '' !== $result->description ) { $group_lines[] = ' ' . $result->description; } } if ( array() === $group_lines ) { continue; } $heading = isset( $labels[ $group ] ) ? $labels[ $group ] : $group; $lines[] = '== ' . $heading . ' =='; foreach ( $group_lines as $line ) { $lines[] = $line; } $lines[] = ''; } if ( 0 === $open ) { $lines[] = __( 'Everything looks good this week.', 'keepwatch' ); $lines[] = ''; } $lines[] = sprintf( /* translators: %s: dashboard URL */ __( 'Open Keepwatch: %s', 'keepwatch' ), admin_url( 'tools.php?page=' . Menu::SLUG ) ); $lines[] = __( 'You can turn this email off under Tools > Keepwatch > Email alerts.', 'keepwatch' ); return implode( "\n", $lines ); } }