Insert unique ID, permalink and title in Disqus JS code
This avoids thread splitting, duplication, and other problems in Disqus, as discussed at: https://help.disqus.com/customer/en/portal/articles/2158629 Signed-off-by: ADTC <send2adtc@gmail.com>
This commit is contained in:
parent
c5dde14783
commit
ad3ee5608f
@ -98,6 +98,30 @@ class pluginDisqus extends Plugin {
|
||||
|
||||
public function siteBodyEnd()
|
||||
{
|
||||
global $Page, $Post, $Url, $posts;
|
||||
|
||||
switch($Url->whereAmI())
|
||||
{
|
||||
case 'post':
|
||||
$absolutePermalink = $Post->permalink(true);
|
||||
$uniqueId = $Post->uniqueId();
|
||||
$disqusTitle = $Post->title();
|
||||
break;
|
||||
case 'page':
|
||||
$absolutePermalink = $Page->permalink(true);
|
||||
$uniqueId = $Page->uniqueId();
|
||||
$disqusTitle = $Page->title();
|
||||
break;
|
||||
|
||||
default:
|
||||
// Homepage - use the first post
|
||||
if(isset($posts[0])) {
|
||||
$absolutePermalink = $posts[0]->permalink(true);
|
||||
$uniqueId = $posts[0]->uniqueId();
|
||||
$disqusTitle = $posts[0]->title();
|
||||
}
|
||||
}
|
||||
|
||||
if( $this->enable ) {
|
||||
|
||||
$html = '
|
||||
@ -105,6 +129,12 @@ class pluginDisqus extends Plugin {
|
||||
|
||||
var disqus_shortname = "'.$this->getDbField('shortname').'";
|
||||
|
||||
var disqus_config = function () {
|
||||
this.page.url = "'.$absolutePermalink.'";
|
||||
this.page.identifier = "'.$uniqueId.'";
|
||||
this.page.title = "'.$disqusTitle.'";
|
||||
};
|
||||
|
||||
(function() {
|
||||
var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
|
||||
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
|
||||
|
Loading…
x
Reference in New Issue
Block a user