First commit
This commit is contained in:
commit
b7ce57b541
10 changed files with 273 additions and 0 deletions
63
comments.php
Normal file
63
comments.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
namespace Grav\Plugin;
|
||||
|
||||
use Grav\Common\GPM\GPM;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Page\Page;
|
||||
use Grav\Common\Page\Pages;
|
||||
use Grav\Common\Plugin;
|
||||
|
||||
class CommentsPlugin extends Plugin
|
||||
{
|
||||
protected $route = 'comments';
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
'onPluginsInitialized' => ['onPluginsInitialized', 0],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable search only if url matches to the configuration.
|
||||
*/
|
||||
public function onPluginsInitialized()
|
||||
{
|
||||
if (!$this->isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->enable([
|
||||
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
|
||||
'onAdminTemplateNavPluginHook' => ['onAdminTemplateNavPluginHook', 0],
|
||||
'onDataTypeExcludeFromDataManagerPluginHook' => ['onDataTypeExcludeFromDataManagerPluginHook', 0],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add plugin templates path
|
||||
*/
|
||||
public function onTwigTemplatePaths()
|
||||
{
|
||||
$this->grav['twig']->twig_paths[] = __DIR__ . '/admin/templates';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add navigation item to the admin plugin
|
||||
*/
|
||||
public function onAdminTemplateNavPluginHook()
|
||||
{
|
||||
$this->grav['twig']->plugins_hooked_nav['PLUGIN_COMMENTS.COMMENTS'] = ['route' => $this->route, 'icon' => 'fa-file-text'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude comments from the Data Manager plugin
|
||||
*/
|
||||
public function onDataTypeExcludeFromDataManagerPluginHook()
|
||||
{
|
||||
$this->grav['admin']->dataTypesExcludedFromDataManagerPlugin[] = 'comments';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue