WC_Email::send
Send an email.
Метод класса: WC_Email{}
Хуки из метода
Возвращает
bool. 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 11.1.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 );
if ( ! is_bool( $return ) ) {
$original_type = gettype( $return );
$return = is_scalar( $return ) ? wc_string_to_bool( (string) $return ) : false;
wc_doing_it_wrong(
__METHOD__,
sprintf(
'The callback registered to the woocommerce_mail_callback filter should return a boolean; %s returned.',
$original_type
),
'11.1.0'
);
}
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;
}