Disqus plugins

This commit is contained in:
dignajar 2015-08-13 22:22:26 -03:00
parent 72e377956f
commit e6b44e15b2
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,12 @@
{
"plugin-data":
{
"name": "Disqus comment system",
"description": "Disqus is a blog comment hosting service for web sites. It's necesary to register on Disqus.com before using this plugin.",
"author": "Bludit",
"email": "",
"website": "http://www.bludit.com",
"version": "0.1",
"releaseDate": "2015-08-02"
}
}

65
plugins/disqus/plugin.php Normal file
View File

@ -0,0 +1,65 @@
<?php
class pluginDisqus extends Plugin {
public function init()
{
$this->dbFields = array(
'shortname'=>''
);
}
public function form()
{
global $Language;
$html = '<div>';
$html .= '<label>Disqus shortname</label>';
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getDbField('shortname').'">';
$html .= '</div>';
return $html;
}
public function postEnd()
{
$html = '<div id="disqus_thread"></div>';
return $html;
}
public function pageEnd()
{
return $this->postEnd();
}
public function siteHead()
{
$html = '<style>#disqus_thread { margin: 20px 0 }</style>';
return $html;
}
public function siteBodyEnd()
{
global $Url;
if( ($Url->whereAmI()!='post') && ($Url->whereAmI()!='page') ) {
return '';
}
$html = '
<script type="text/javascript">
var disqus_shortname = "'.$this->getDbField('shortname').'";
(function() {
var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>';
return $html;
}
}