Disqus plugin improves

This commit is contained in:
Diego Najar 2019-01-25 16:25:41 +01:00
parent df9d09e810
commit 06cf589021
14 changed files with 120 additions and 91 deletions

View File

@ -1,16 +0,0 @@
{
"plugin-data":
{
"name": "Disqus коментари",
"description": "Disqus коментари е услуги за уеб сайтове и блогове. Трябва да сте регистрирани в Disqus.com, преди да използвате този плъгин.",
"author": "Bludit",
"email": "",
"website": "https://github.com/dignajar/bludit-plugins",
"version": "0.6",
"releaseDate": "2015-11-13"
},
"disqus-shortname": "Disqus shortname",
"enable-disqus-on-pages": "Активиране Disqus на страници",
"enable-disqus-on-posts": "Активиране Disqus на публикации",
"enable-disqus-on-default-home-page": "Активиране Disqus на начална страница"
}

View File

@ -4,5 +4,9 @@
"name": "Disqus",
"description": "Disqus ist eine Kommentar-Plattform für Websites. Um das Plugin verwenden zu können, muss ein Konto bei <a href=\"https://disqus.com\">Disqus</a> eingerichtet werden."
},
"disqus-shortname": "Disqus shortname"
"disqus-shortname": "Disqus shortname",
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -4,5 +4,9 @@
"name": "Disqus",
"description": "Disqus ist eine Kommentar-Plattform für Websites. Um das Plugin verwenden zu können, muss ein Konto bei <a href=\"https://disqus.com\">Disqus</a> eingerichtet werden."
},
"disqus-shortname": "Disqus shortname"
"disqus-shortname": "Disqus shortname",
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -5,6 +5,8 @@
"description": "Disqus is a comment hosting service for web sites.<br>It's necessary to be registered on <a href=\"https://disqus.com\">Disqus</a> to use this service."
},
"disqus-shortname": "Disqus shortname",
"enable-disqus-on-pages": "Disqus on static",
"enable-disqus-on-posts": "Disqus on published"
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -2,7 +2,11 @@
"plugin-data":
{
"name": "Disqus",
"description": "Disqus es un servicio de comentarios online.<br>Es necesario registrarse en Disqus.com antes de utilizar este plugin."
"description": "Disqus es un servicio de comentarios online.<br>Es necesario registrarse en <a href=\"https://disqus.com\">Disqus</a> antes de utilizar este plugin."
},
"disqus-shortname": "Disqus shortname"
"disqus-shortname": "Disqus shortname",
"enable-disqus-on-pages": "Disqus en página",
"enable-disqus-on-static-pages": "Disqus en página estaticas",
"enable-disqus-on-sticky-pages": "Disqus en página sticky",
"get-the-shortname-from-the-disqus-general-settings": "Puede obtener el shortname en la página de configuración de Disqus."
}

View File

@ -5,7 +5,8 @@
"description": "Disqus est un service Web de discussion et de commentaires d'articles centralisé avec authentification unique. Il est nécessaire de sinscrire sur Disqus.com avant dutiliser ce plugin."
},
"disqus-shortname": "Votre ID Disqus",
"enable-disqus-on-pages": "Activer Disqus sur les pages",
"enable-disqus-on-posts": "Activer Disqus sur les articles",
"enable-disqus-on-default-home-page": "Activer Disqus sur la page daccueil"
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -5,6 +5,8 @@
"description": "Disqus è un servizio di hosting per i commenti sui siti web.<br>E' neccesario essere resitrati su <a href=\"https://disqus.com\">Disqus</a> per utilizzare questo servizio."
},
"disqus-shortname": "Nome Breve Disqus ",
"enable-disqus-on-pages": "Disqus su statico",
"enable-disqus-on-posts": "Disqus su pubblicato"
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -4,9 +4,9 @@
"name": "Disqus comment system",
"description": "Disqusはブログにコメント機能を提供するWebサイトです。プラグインを使用するにはDisqus.comに登録する必要があります。"
},
"disqus-shortname": "Disqusサイト名(ショートネーム)",
"enable-disqus-on-pages": "ページのDisqusを有効",
"enable-disqus-on-posts": "記事ページのDisqusを有効",
"enable-disqus-on-default-home-page": "規定のホームページのDisqusを有効"
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -4,9 +4,9 @@
"name": "Disqus commentaar systeem",
"description": "Disqus is een blog commentaar hosting service voor web sites. Het is wel nodig om jezelf te registreren op Disqus.com voordat je deze plugin kan gebruiken."
},
"disqus-shortname": "Disqus shortname",
"enable-disqus-on-pages": "Schakel Disqus in op pagina's",
"enable-disqus-on-posts": "Schakel Disqus in op posts",
"enable-disqus-on-default-home-page": "Schakel Disqus in op de startpagina"
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -5,7 +5,8 @@
"description": "System komentarzy Disqus przechowuje komentarze dla serwisów internetowych. Korzystanie z tej wtyczki wymaga rejestracji w serwisie disqus.com."
},
"disqus-shortname": "Nazwa użytkownika Disqus",
"enable-disqus-on-pages": "Włącz Disqus na wszystkich stronach",
"enable-disqus-on-posts": "Włącz Disqus we wszystkich wpisach",
"enable-disqus-on-default-home-page": "Włącz Disqus na domyślnej stronie głównej"
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -5,6 +5,8 @@
"description": "Disqus это сервис комментариев для сайтов и блогов. Необходимо быть зарегистрированным на Disqus.com перед использованием плагина."
},
"disqus-shortname": "Disqus shortname",
"enable-disqus-on-pages": "Disqus на страницах",
"enable-disqus-on-posts": "Disqus в записях"
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -4,8 +4,9 @@
"name": "Disqus Yorum Sistemi",
"description": "Disqus siteler için yorum barındırması yapan bir firmadır. Eklentiyi kullanmadan önce Disqus.com adresine kayıt olmanız gerekmektedir."
},
"disqus-shortname": "Disqus",
"enable-disqus-on-pages": "Sayfalar için Disqus'ı etkinleştir",
"enable-disqus-on-posts": "Yazılar için Disqus'ı etkinleştir",
"enable-disqus-on-default-home-page": "Geçerli ana sayfa için Disqus'ı etkinleştir"
"disqus-shortname": "Disqus shortname",
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -4,9 +4,9 @@
"name": "Система коментарів Disqus",
"description": "Disqus надає послуги хостингу коментарів для веб-сайтів. Необхідно зареєструватися на Disqus.com перед використанням цього плагіна."
},
"disqus-shortname": "Коротке ім'я в Disqus",
"enable-disqus-on-pages": "Включити Disqus на сторінках",
"enable-disqus-on-posts": "Включити Disqus у публікаціях",
"enable-disqus-on-default-home-page": "Включити Disqus на домашній сторінці"
"enable-disqus-on-pages": "Disqus on pages",
"enable-disqus-on-static-pages": "Disqus on static pages",
"enable-disqus-on-sticky-pages": "Disqus on sticky pages",
"get-the-shortname-from-the-disqus-general-settings": "Get the shortname from the Disqus general settings"
}

View File

@ -6,8 +6,9 @@ class pluginDisqus extends Plugin {
{
$this->dbFields = array(
'shortname'=>'',
'enablePages'=>false,
'enablePosts'=>true
'enablePages'=>true,
'enableStatic'=>true,
'enableSticky'=>true
);
}
@ -22,6 +23,7 @@ class pluginDisqus extends Plugin {
$html .= '<div>';
$html .= '<label>'.$L->get('disqus-shortname').'</label>';
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getValue('shortname').'">';
$html .= '<span class="tip">'.$L->get('Get the shortname from the Disqus general settings').'</span>';
$html .= '</div>';
$html .= '<div>';
@ -31,11 +33,20 @@ class pluginDisqus extends Plugin {
$html .= '<option value="false" '.($this->getValue('enablePages')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('enable-disqus-on-posts').'</label>';
$html .= '<select name="enablePosts">';
$html .= '<option value="true" '.($this->getValue('enablePosts')===true?'selected':'').'>'.$L->get('enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('enablePosts')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '<label>'.$L->get('enable-disqus-on-static-pages').'</label>';
$html .= '<select name="enableStatic">';
$html .= '<option value="true" '.($this->getValue('enableStatic')===true?'selected':'').'>'.$L->get('enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('enableStatic')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('enable-disqus-on-sticky-pages').'</label>';
$html .= '<select name="enableSticky">';
$html .= '<option value="true" '.($this->getValue('enableSticky')===true?'selected':'').'>'.$L->get('enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('enableSticky')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
@ -44,39 +55,52 @@ class pluginDisqus extends Plugin {
public function pageEnd()
{
global $content;
global $url, $page;
global $WHERE_AM_I;
if ($WHERE_AM_I==='page') {
global $page;
if ($page->published() && $this->getValue('enablePages')) {
return $this->javascript();
}
if ($page->isStatic() && $this->getValue('enableStatic')) {
return $this->javascript();
}
if ($page->sticky() && $this->getValue('enableSticky')) {
return $this->javascript();
}
}
$page = $content[0];
if (empty($page)) {
return false;
}
if ( !$url->notFound() &&
( $url->whereAmI()=='page' &&
(($this->getValue('enablePosts') && $page->published()) ||
($this->getValue('enablePages') && $page->isStatic()))
) &&
$page->allowComments() ) {
$html = '<div id="disqus_thread"></div>';
$html .= '<script type="text/javascript">
private function javascript()
{
global $page;
$pageURL = $page->permalink();
$pageID = $page->uuid();
$shortname = $this->getValue('shortname');
$code = <<<EOF
<!-- Disqus plugin -->
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = "'.$page->permalink().'";
this.page.identifier = "'.$page->uuid().'";
this.page.url = '$pageURL';
this.page.identifier = '$pageID';
};
(function() {
var d = document, s = d.createElement("script");
s.src = "https://'.$this->getValue('shortname').'.disqus.com/embed.js";
s.setAttribute("data-timestamp", +new Date());
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://$shortname.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
';
return $html;
}
return false;
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<!-- /Disqus plugin -->
EOF;
return $code;
}
}