settings = $settings; } /** * Sends the notice. * * @param Profile $site Site. * @param array $run Run. * @param string $why review or held. * @return bool Whether the mail system accepted it. */ public function notify( Profile $site, array $run, $why ) { $blog = wp_specialchars_decode( (string) get_bloginfo( 'name' ), ENT_QUOTES ); $label = ReportBuilder::label( RunRepository::period( $run ), isset( $run['meta']['frequency'] ) ? (string) $run['meta']['frequency'] : '' ); $url = AdminLinks::url( AdminLinks::DELIVERIES, array( 'run' => (int) $run['id'] ) ); $checks = Readiness::problems( is_array( $run['checks'] ) ? $run['checks'] : array() ); $lines = array(); if ( 'review' === $why ) { /* translators: 1: WordPress site name, 2: report site name, 3: period. */ $subject = sprintf( __( '[%1$s] Report ready for review: %2$s · %3$s', 'turtlereport' ), $blog, $site->display_name(), $label ); /* translators: 1: report site name, 2: period. */ $lines[] = sprintf( __( 'The %2$s report for %1$s is ready. It won\'t be sent until someone approves it.', 'turtlereport' ), $site->display_name(), $label ); $lines[] = __( 'Preview it, edit the highlights and notes, then approve and send:', 'turtlereport' ) . "\n" . $url; } else { /* translators: 1: WordPress site name, 2: report site name, 3: period. */ $subject = sprintf( __( '[%1$s] Report held, data incomplete: %2$s · %3$s', 'turtlereport' ), $blog, $site->display_name(), $label ); /* translators: 1: report site name, 2: period. */ $lines[] = sprintf( __( 'The %2$s report for %1$s wasn\'t sent because some of its data couldn\'t be loaded.', 'turtlereport' ), $site->display_name(), $label ); $lines[] = __( 'Fix the problem and prepare it again, or send it anyway with a warning, here:', 'turtlereport' ) . "\n" . $url; } if ( $checks ) { $lines[] = __( 'What was found:', 'turtlereport' ) . "\n" . implode( "\n", array_map( static function ( $c ) { return '- ' . $c['message']; }, array_slice( $checks, 0, 6 ) ) ); } $lines[] = __( 'You get this because you receive TurtleReport alerts (TurtleReport → Settings).', 'turtlereport' ); return (bool) wp_mail( $this->settings->alert_recipients(), $subject, implode( "\n\n", $lines ) ); } }