【问题标题】:Disqus Comment System [Wordpress] - Change the word "Comment"Disqus 评论系统 [Wordpress] - 更改“评论”一词
【发布时间】:2012-08-26 00:51:34
【问题描述】:

我在我的一个 wordpress 博客上安装了 Disqus 评论系统,但我希望评论编号显示为 0 而不是 0 Comments12 而不是 12 Comments。以前在 Disqus 管理员中曾经有一个外观部分,该部分曾经有一个选项来更改此输出,正如在回答 this question 时所建议的那样。但似乎 Appearance 部分已被 Disqus 删除。有没有其他方法可以实现这一点(当然,不会弄乱插件代码。)??

更新:

好吧,也查看了插件源但没有用,似乎他们正在使用 javascript 更新它。启用Reactions 后,现在返回0 comments and 0 Reactions

更新#2:

好吧,所以我终于找到了它的来源......插件基本上包括来自yoursite.disqus.com\count.js?some wierd parameterscount.js文件,js文件看起来像这样:

var DISQUSWIDGETS;

if (typeof DISQUSWIDGETS != 'undefined') {
    DISQUSWIDGETS.displayCount({"showReactions": true, "text": {"and": "and", "reactions": {"zero": "0 Reactions", "multiple": "{num} Reactions", "one": "1 Reaction"}, "comments": {"zero": "0 Comments", "multiple": "{num} Comments", "one": "1 Comment"}}, "counts": [{"reactions": 0, "uid": 1, "comments": 0}, {"reactions": 0, "uid": 0, "comments": 0}, {"reactions": 0, "uid": 3, "comments": 0}, {"reactions": 0, "uid": 2, "comments": 0}, {"reactions": 0, "uid": 4, "comments": 0}]});
}

最糟糕的是,我们甚至无法更改 js 文件中的代码,因为它托管在 disqus 本身上。

【问题讨论】:

    标签: disqus appearance


    【解决方案1】:

    您也可以“破解” Disqus 的代码。我将尝试逐步解释我所做的:

    1. 获取主disqus函数的最新文件。它应该类似于以下内容: http://disqus.com/forums/(your-site-id)/count.js
    2. 将该脚本复制到某处,您可以“美化”它以使其更具可读性。比找到并将displayCount 函数更改为您想要的任何内容:

      c.displayCount = function (a)
      {
        for (var b, c, e, g, f = 0; f < a.counts.length; f++)
        if (b = a.counts[f], c = h[b.uid]) e = b.comments === 0 ? "0 drivels" : b.comments == 1 ? "1 drivel" : "{num} drivels",
        g = e.replace("{num}", b.comments),
        a.showReactions && (e = b.reactions === 0 ? a.text.reactions.zero : b.reactions == 1 ? a.text.reactions.one : a.text.reactions.multiple, e !== "" && (g += " " + a.text.and + " " + e.replace("{num}", b.reactions))),
        c.element.innerHTML = g
      };
      

      (注意乱码;)

    3. 将整个文件保存(上传)到服务器的某个位置并记住路径

    4. 使用 Wordpress 管理编辑 Disqus 插件 - 文件 disqus-comment-system/disqus.php 并找到包含与单词 count.js 连接的 url 的行。它在文件的大约 3/4 中。截至目前,这条线看起来像这样,但将来可能会改变:

      s.src = '//' + '<?php echo DISQUS_DOMAIN; ?>/forums/' + disqus_shortname + '/count.js';
      
    5. 使此链接指向您新上传的文件,如下所示(我使用的是相对 URL):

      s.src = '/wp-include/custom/disqus-count.js';
      
    6. 保存并获利!我花了一个多小时才弄清楚这一点,所以我希望这对某人有帮助(我需要将这些信息翻译成我的母语)。这种方法的一大好处是,如果您的语言对不同的数字(除了 0、1 和更多)使用不同的单词形式,您可以编写脚本。

    【讨论】:

      【解决方案2】:

      你应该可以通过 JavaScript 隐藏它。

      类似的东西:

      node = document.getElementsByClassName("dsq-comment-count")[0].childNodes[0]
      node.nodeValue = node.nodeValue.replace("Comments", "")
      

      【讨论】:

        【解决方案3】:

        官方答案在这里:http://help.disqus.com/customer/portal/articles/565624#customizing-link-text

        1. 转到http://YOUR-SITE.disqus.com/admin/settings/?p=general

        2. 根据需要编辑评论计数链接部分。

        3. 就是这样!

        【讨论】:

          猜你喜欢
          • 2011-08-16
          • 2012-01-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-08-07
          • 2011-07-13
          • 1970-01-01
          相关资源
          最近更新 更多