Enable comments plugin only on its route

This commit is contained in:
Flavio Copes 2015-10-08 17:29:48 +02:00
parent 5790ac019e
commit 61677d06d4
1 changed files with 9 additions and 2 deletions

View File

@ -13,7 +13,7 @@ use Symfony\Component\Yaml\Yaml;
class CommentsPlugin extends Plugin
{
protected $route = 'comments';
protected $route = '/admin/comments';
/**
* @return array
@ -46,6 +46,10 @@ class CommentsPlugin extends Plugin
}
} else {
/** @var Uri $uri */
$uri = $this->grav['uri'];
//Admin
$this->enable([
'onTwigTemplatePaths' => ['onTwigAdminTemplatePaths', 0],
@ -53,6 +57,10 @@ class CommentsPlugin extends Plugin
'onDataTypeExcludeFromDataManagerPluginHook' => ['onDataTypeExcludeFromDataManagerPluginHook', 0],
]);
if (strpos($uri->path(), $this->route) === false) {
return;
}
$page = $this->grav['uri']->param('page');
$comments = $this->getLastComments($page);
@ -76,7 +84,6 @@ class CommentsPlugin extends Plugin
$email = filter_var(urldecode($post['email']), FILTER_SANITIZE_STRING);
$title = filter_var(urldecode($post['title']), FILTER_SANITIZE_STRING);
if ($this->config->get('plugins.comments.use_captcha')) {
//Validate the captcha
$recaptchaResponse = filter_var(urldecode($post['recaptchaResponse']), FILTER_SANITIZE_STRING);