dqmfo84644 2018-04-06 22:44
浏览 97

使用联系表格7发送的电子邮件显示<a>标签代码而非格式化链接

I am using Contact Form 7 plugin with this addon "Contact Form 7 Dynamic Text Extension" which allows you to use shortcodes to add data to your emails and form elements https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/

I created a shortcode that based on the current page adds a link to a PDF file in the Autoresponder email that is sent.

function get_pdf_link( $atts ) {
    global $post;

    switch ($post->post_title) {
        case 'Agency':
            return '<a rel="nofollow" target="_blank" href="http://example.com/qcmresearch/wp-content/uploads/2018/04/Agency-Evaluation-Checklist.pdf">Download the Agency Evaluation Checklist</a>';
            break;
        case 'Signup':
            return '<a rel="nofollow" target="_blank" href="http://example.com/qcmresearch/wp-content/uploads/2018/04/signup.pdf">Download the Signup Options</a>';
            break;
        default:
            return '<a rel="nofollow" target="_blank" href="http://example.com/qcmresearch/wp-content/uploads/2018/04/Agency-Evaluation-Checklist.pdf">Download the Agency Evaluation Checklist</a>';
            break;
    }
}
add_shortcode( 'CF7_EBOOK_DOWNLOADFILE', 'get_pdf_link' );

The value from the shortcode gets added to the autoresponder email correctly but the a tag is not formatted into html and displays as code:

<a rel="nofollow" target="_blank" href="http://example.com/wp-content/uploads/2018/04/Agency-Evaluation-Checklist.pdf">Download the Agency Evaluation Checklist</a>

It should be formatted like this
Download the Agency Evaluation Checklist

I manually added the same link to the message body in Wordpress and it looked fine so there is something with the shortcode or how I added my link that is breaking the formatting.

Update: I inspected the <a> tag in developer tools @ Yahoo mail and it is wrapped in parenthesis not sure why though "<a ...>Download the Agency Evaluation</a>"

  • 写回答

1条回答 默认 最新

  • douben6670 2018-04-07 06:28
    关注

    Use html_entity_decode function:

    function get_pdf_link( $atts ) {
    global $post;
    
    switch ($post->post_title) {
        case 'Agency':
            return html_entity_decode('<a rel="nofollow" target="_blank" href="http://example.com/qcmresearch/wp-content/uploads/2018/04/Agency-Evaluation-Checklist.pdf">Download the Agency Evaluation Checklist</a>');
            break;
        case 'Signup':
            return html_entity_decode('<a rel="nofollow" target="_blank" href="http://example.com/qcmresearch/wp-content/uploads/2018/04/signup.pdf">Download the Signup Options</a>');
            break;
        default:
            return html_entity_decode('<a rel="nofollow" target="_blank" href="http://example.com/qcmresearch/wp-content/uploads/2018/04/Agency-Evaluation-Checklist.pdf">Download the Agency Evaluation Checklist</a>');
            break;
    }
    }
    add_shortcode( 'CF7_EBOOK_DOWNLOADFILE', 'get_pdf_link' );
    
    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行