WC_Email::get_headers
Get email headers.
Метод класса: WC_Email{}
Хуки из метода
Возвращает
string.
Использование
$WC_Email = new WC_Email(); $WC_Email->get_headers();
Код WC_Email::get_headers() WC Email::get headers WC 11.3.0
public function get_headers() {
$header = 'Content-Type: ' . $this->get_content_type() . "\r\n";
// For order notification emails sent to admin, always use customer's billing email as reply-to.
if ( in_array( $this->id, array( 'new_order', 'cancelled_order', 'failed_order' ), true ) ) {
if ( $this->object instanceof WC_Order ) {
$reply_to_name = EmailHeaders::sanitize_reply_to_name( $this->object->get_billing_first_name() . ' ' . $this->object->get_billing_last_name() );
$reply_to_email = sanitize_email( $this->object->get_billing_email() );
if ( '' !== $reply_to_name && is_email( $reply_to_email ) ) {
$header .= 'Reply-to: ' . $reply_to_name . ' <' . $reply_to_email . ">\r\n";
}
}
} else {
// Check if custom reply-to is enabled and configured for non-admin notification emails.
$reply_to_enabled = $this->get_reply_to_enabled();
$reply_to_address = $this->get_reply_to_address();
$reply_to_name = $this->get_reply_to_name();
if ( $reply_to_enabled && ! empty( $reply_to_address ) && is_email( $reply_to_address ) ) {
$reply_to_name = EmailHeaders::sanitize_reply_to_name( $reply_to_name );
if ( '' === $reply_to_name ) {
$reply_to_name = EmailHeaders::sanitize_reply_to_name( $this->get_from_name() );
}
$header .= 'Reply-to: ' . $reply_to_name . ' <' . $reply_to_address . ">\r\n";
} else {
$from_address = $this->get_from_address();
$from_name = EmailHeaders::sanitize_reply_to_name( $this->get_from_name() );
if ( $from_address && '' !== $from_name ) {
$header .= 'Reply-to: ' . $from_name . ' <' . $from_address . ">\r\n";
}
}
}
if ( FeaturesUtil::feature_is_enabled( 'email_improvements' ) ) {
$cc = $this->get_cc_recipient();
if ( ! empty( $cc ) ) {
$header .= 'Cc: ' . sanitize_text_field( $cc ) . "\r\n";
}
$bcc = $this->get_bcc_recipient();
if ( ! empty( $bcc ) ) {
$header .= 'Bcc: ' . sanitize_text_field( $bcc ) . "\r\n";
}
}
return apply_filters( 'woocommerce_email_headers', $header, $this->id, $this->object, $this );
}