$message Message. * @param array $config Channel config. * @return true|WP_Error */ public function send( array $message, array $config ) { $to = trim( (string) $config['recipients'] ); if ( '' === $to ) { $to = (string) get_option( 'admin_email' ); } $rows = ''; foreach ( (array) ( $message['items'] ?? array() ) as $item ) { $rows .= sprintf( '%s%s
%s', esc_html( (string) ( $item['title'] ?? '' ) ), '' !== (string) ( $item['subtitle'] ?? '' ) ? ' (' . esc_html( (string) $item['subtitle'] ) . ')' : '', esc_html( (string) ( $item['detail'] ?? '' ) ) ); } if ( ! empty( $message['more'] ) ) { /* translators: %d: number of further rows not listed. */ $rows .= '' . esc_html( sprintf( __( '…and %d more', 'profit-engine' ), (int) $message['more'] ) ) . ''; } $html = '
'; $html .= '

' . esc_html( (string) $message['title'] ) . '

'; if ( '' !== (string) ( $message['intro'] ?? '' ) ) { $html .= '

' . esc_html( (string) $message['intro'] ) . '

'; } if ( '' !== $rows ) { $html .= '' . $rows . '
'; } $html .= '

' . esc_html( (string) $message['link_label'] ) . '

'; $html .= '

' . esc_html( (string) $message['site'] ) . ' · ProfitEngine

'; $html .= '
'; $subject = sprintf( '[%s] %s', (string) $message['site'], (string) $message['title'] ); $sent = wp_mail( $to, $subject, $html, array( 'Content-Type: text/html; charset=UTF-8' ) ); return $sent ? true : new WP_Error( 'profit_engine_notification_mail', __( 'WordPress could not send the email. Check that your site can send mail (an SMTP plugin usually fixes this).', 'profit-engine' ) ); } }