描述:
- WordPress 联系表 7;
- 使用 smtp 发送邮件;
- 表单设置:“使用 html-format”+“mail2 使用 html-format”勾选;
- 表单设置:电子邮件正文:只有一个邮件标签[计算模板];
- 解决了段落标签的问题(接收时的所有邮件标签都显示在“p”html标签内);
[calculated-template] 是一个用 html 动态填充的邮件标签,基于前端 VueJS2 处理的提交对象;
[calculated-template] 通过挂接操作“wpcf7_posted_data”填充:
add_action('wpcf7_posted_data', array('vue_handler','handle'), 1, 1);
vue_handler::handle($data) 接收 $data 数组,其中包含一些可以修改的 wpcf7 数据。$data 数组的内容:
_wpcf7 = "1166"
_wpcf7_version = "4.9.2"
_wpcf7_locale = "ru_RU"
_wpcf7_unit_tag = "wpcf7-f1166-p1167-o1"
_wpcf7_container_post = "1167"
columns-stringified = ""
fences-stringified = ""
your-name = "name"
your-email = "email@test.com"
calculated-template = ""
然后 vue_handler::handle($data) 将 html 注入到 email-tag [calculated-template] 中。
问题: 最后 [calculated-template] html-contents 呈现转义(Mailtrap.io,“HTML Source”选项卡):
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title</title>
</head>
<body>
<h1>Example Header</h1>
</body>
</html>
该片段的主要思想:打开和关闭html-tag符号“<”,“>”呈现转义:“<”,“>”;