代码之家  ›  专栏  ›  技术社区  ›  Roee Adler

WordPress subscribe2插件在发送电子邮件时会避开博客名称中的字符

  •  2
  • Roee Adler  · 技术社区  · 16 年前

    我在即将到来的WordPress博客中使用subscribe2插件( http://www.adlerr.com )我的博客标题是“罗伊阿德勒的博客”。发送电子邮件时,subscribe2会避开我博客标题中的撇号,电子邮件主题接收如下:

    [Roee Adler's Blog] Please confirm your request
    

    电子邮件正文为:

    Roee Adler's Blog has received a request to 
    subscribe for this email address. To complete your 
    request please click on the link below:
    ...
    

    我很自然地希望在标题和正文中包含我博客名字的“普通”未转义版本。

    我问了这个问题 doctype.com 没有成功( here's the question 但是,根据答案,我理解这可能需要修改插件的PHP代码,所以我宁愿在这里问它。

    根据我在doctype上收到的答案,我确实更改了代码的以下部分:

    function substitute($string = '') {
        if ('' == $string) {
            return;
        }
        $string = htmlspecialchars_decode(str_replace("BLOGNAME", get_option('blogname'), $string));
        $string = str_replace("BLOGLINK", get_bloginfo('url'), $string);
        $string = htmlspecialchars_decode(str_replace("TITLE", stripslashes($this->post_title), $string));
        $string = str_replace("PERMALINK", $this->permalink, $string);
    

    在上面的代码中,我添加了 htmlspecialchars_decode 用于生成blogname和title的包装器,但是电子邮件主题和正文仍然包含 ' .

    我能做些什么来解决这个问题?

    谢谢

    2 回复  |  直到 13 年前
        1
  •  3
  •   Rudd Zwolinski    16 年前

    根据 the documentation on htmlspecialchars_decode ,你需要通过 ENT_QUOTES 作为 $quote_style 要转换的参数 ' ' . 尝试设置 恩特语录 :

    function substitute($string = '') {
            if ('' == $string) {
                    return;
            }
            $string = htmlspecialchars_decode(str_replace("BLOGNAME", get_option('blogname'), $string), ENT_QUOTES);
            $string = str_replace("BLOGLINK", get_bloginfo('url'), $string);
            $string = htmlspecialchars_decode(str_replace("TITLE", stripslashes($this->post_title), $string), ENT_QUOTES);
            $string = str_replace("PERMALINK", $this->permalink, $string);
    
        2
  •  0
  •   swmcdonnell    13 年前

    WordPress将博客标题中的撇号替换为 ' 在它存储到数据库之前。如果要覆盖此项,请编辑functions.php文件并插入以下语句:

    update_option("blogname", "My Blog's Title With Apostrophe");
    

    这将强制标题与您输入的内容完全相同。在“设置”菜单中对日志标题所做的更改将无效。

    推荐文章