user_email ) ) { return false; } $community = (string) Settings::get( 'community_name' ); $subject = sprintf( /* translators: 1: Community name, 2: Notification text. */ __( '[%1$s] %2$s', 'spacebay' ), wp_specialchars_decode( $community, ENT_QUOTES ), $parts['subject'] ); $html = Mailer::render( array( 'community_name' => $community, 'text' => $parts['text'], 'excerpt' => (string) ( $parts['excerpt'] ?? '' ), 'code' => (string) ( $parts['code'] ?? '' ), 'url' => (string) ( $parts['url'] ?? Portal::url() ), 'button' => (string) ( $parts['button'] ?? '' ), 'settings_url' => Portal::link( 'account/security' ), 'footer' => __( 'You receive this email because it is about your account. It is sent even when notification emails are off.', 'spacebay' ), 'brand_color' => Mailer::readable_color( (string) Settings::get( 'brand_color', '#3f22ff' ) ), 'recipient' => $user->display_name, 'logo_url' => Settings::get( 'logo_id' ) ? (string) wp_get_attachment_image_url( (int) Settings::get( 'logo_id' ), 'medium' ) : '', ) ); $headers = array( 'Content-Type: text/html; charset=UTF-8' ); $from = sanitize_email( (string) Settings::get( 'email_from_address', '' ) ); if ( $from ) { $name = str_replace( array( "\r", "\n", '"' ), '', (string) Settings::get( 'email_from_name', $community ) ); $name = '' !== $name ? $name : str_replace( array( "\r", "\n", '"' ), '', wp_specialchars_decode( $community, ENT_QUOTES ) ); $headers[] = sprintf( 'From: "%s" <%s>', $name, $from ); } /** * Filters an account email (login code, password reset, welcome) before it is sent. * * @since 1.0.0 * * @param array $email { * Email parts. * * @type string $to Recipient address. * @type string $subject Subject. * @type string $message HTML body. * @type string[] $headers Headers. * } * @param int $user_id User ID. * @param array $parts Parts the email was built from. */ $email = apply_filters( 'spacebay_account_email', array( 'to' => $user->user_email, 'subject' => $subject, 'message' => $html, 'headers' => $headers, ), (int) $user_id, $parts ); return (bool) wp_mail( $email['to'], $email['subject'], $email['message'], $email['headers'] ); } }