diff --git a/plugins/disqus/plugin.php b/plugins/disqus/plugin.php index 6682b1a0..17744110 100644 --- a/plugins/disqus/plugin.php +++ b/plugins/disqus/plugin.php @@ -2,6 +2,8 @@ class pluginDisqus extends Plugin { + private $disable; + public function init() { $this->dbFields = array( @@ -12,6 +14,34 @@ class pluginDisqus extends Plugin { ); } + function __construct() + { + parent::__construct(); + + // Disable the plugin IF ... + global $Url; + + $this->disable = false; + + if( (!$this->getDbField('enablePosts')) && ($Url->whereAmI()=='post') ) { + $this->disable = true; + } + elseif( (!$this->getDbField('enablePages')) && ($Url->whereAmI()=='page') ) { + $this->disable = true; + } + elseif( !$this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='page') ) + { + global $Page; + global $Site; + if( $Site->homePage()==$Page->key() ) { + $this->disable = true; + } + } + elseif( ($Url->whereAmI()!='post') && ($Url->whereAmI()!='page') ) { + $this->disable = true; + } + } + public function form() { global $Language; @@ -41,34 +71,38 @@ class pluginDisqus extends Plugin { public function postEnd() { - $html = ''; - if( $this->getDbField('enablePosts') ) { - $html = '
'; + if( $this->disable ) { + return false; } + + $html = '
'; return $html; } public function pageEnd() { - $html = ''; - if( $this->getDbField('enablePages') ) { - $html = '
'; + if( $this->disable ) { + return false; } + + $html = '
'; return $html; } public function siteHead() { + if( $this->disable ) { + return false; + } + $html = ''; return $html; } public function siteBodyEnd() { - global $Url; - - if( ($Url->whereAmI()!='post') && ($Url->whereAmI()!='page') ) { - return ''; + if( $this->disable ) { + return false; } $html = '