wp_mail_content_type
Позволяет изменить тип контента в письмах отправляемых через wp_mail(). Например с text/plain на text/html.
По умолчанию тип контента в WordPress равен 'text/plain'.
Использование
add_filter( 'wp_mail_content_type', 'wp_kama_mail_content_type_filter' );
/**
* Function for `wp_mail_content_type` filter-hook.
*
* @param string $content_type Default wp_mail() content type.
*
* @return string
*/
function wp_kama_mail_content_type_filter( $content_type ){
// filter...
return $content_type;
}
- $content_type(Cтрока)
Тип контента.
Может быть:
- text/plain
- text/html
- multipart/mixed
- и т.д.
Примеры
#1 Изменим тип контент письма
add_filter( 'wp_mail_content_type', 'get_content_type' );
function get_content_type() {
return 'text/plain';
}
Список изменений
| С версии 2.3.0 | Введена. |
Где вызывается хук
wp_mail_content_type
wp_mail_content_type
wp-includes/pluggable.php 519
$content_type = apply_filters( 'wp_mail_content_type', $content_type );
wp-includes/formatting.php 6182
$content_type = apply_filters( 'wp_mail_content_type', $content_type );