WC_Email::send
Send an email.
Метод класса: WC_Email{}
Хуки из метода
Возвращает
true|false. success
Использование
$WC_Email = new WC_Email(); $WC_Email->send( $to, $subject, $message, $headers, $attachments );
- $to(строка) (обязательный)
- Email to.
- $subject(строка) (обязательный)
- Email subject.
- $message(строка) (обязательный)
- Email message.
- $headers(строка) (обязательный)
- Email headers.
- $attachments(массив) (обязательный)
- Email attachments.
Код WC_Email::send() WC Email::send WC 10.5.2
public function send( $to, $subject, $message, $headers, $attachments ) {
add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
$message = apply_filters( 'woocommerce_mail_content', $this->style_inline( $message ) );
$mail_callback = apply_filters( 'woocommerce_mail_callback', 'wp_mail', $this );
$mail_callback_params = apply_filters( 'woocommerce_mail_callback_params', array( $to, wp_specialchars_decode( $subject ), $message, $headers, $attachments ), $this );
$return = $mail_callback( ...$mail_callback_params );
remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
// Clear the AltBody (if set) so that it does not leak across to different emails.
$this->clear_alt_body_field();
/**
* Action hook fired when an email is sent.
*
* @since 5.6.0
* @param bool $return Whether the email was sent successfully.
* @param string $id Email ID.
* @param WC_Email $email WC_Email instance.
*/
do_action( 'woocommerce_email_sent', $return, (string) $this->id, $this );
return $return;
}