Email_Abstract::get_headers( array $headers = array() )
Get email headers.
Contents
Parameters
- $headers
-
(array) (Optional) The email headers.
Default value: array()
Return
(string)
Source
File: src/Tickets/Emails/Email_Abstract.php
public function get_headers( $headers = [] ): array {
$from_email = $this->get_from_email();
$from_name = $this->get_from_name();
// Enforce headers array.
if ( ! is_array( $headers ) ) {
$headers = explode( "\r\n", $headers );
}
// Add From name/email to headers if no headers set yet and we have a valid From email address.
if ( empty( $headers ) && ! empty( $from_name ) && ! empty( $from_email ) && is_email( $from_email ) ) {
$from_email = filter_var( $from_email, FILTER_SANITIZE_EMAIL );
$headers[] = sprintf(
'From: %1$s <%2$s>',
stripcslashes( $from_name ),
$from_email
);
$headers[] = sprintf(
'Reply-To: %s',
$from_email
);
}
// Enforce text/html content type header.
if ( ! in_array( 'Content-type: text/html', $headers, true ) || ! in_array( 'Content-type: text/html; charset=utf-8', $headers, true ) ) {
$headers[] = 'Content-type: text/html; charset=utf-8';
}
/**
* Filter the headers.
*
* @since 5.5.9
*
* @param array $headers The headers.
* @param string $id The email ID.
* @param Email_Abstract $this The email object.
*/
$headers = apply_filters( 'tec_tickets_emails_headers', $headers, $this->id, $this );
/**
* Filter the headers for the particular email.
*
* @since 5.5.10
*
* @param array $headers The headers.
* @param string $id The email ID.
* @param Email_Abstract $this The email object.
*/
$headers = apply_filters( "tec_tickets_emails_{$this->slug}_headers", $headers, $this->id, $this );
return $headers;
}
Changelog
| Version | Description |
|---|---|
| 5.5.9 | Introduced. |