You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.1 KiB

<?php namespace Sensory5\Shortcode;
use App;
use Str;
use Html;
use Event;
use System\Classes\PluginBase;
use Illuminate\Foundation\AliasLoader;
use Sensory5\Shortcode\Models\Settings;
/**
* Shortcode Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'Shortcode',
'description' => 'Shortcode integration for OctoberCMS.',
'author' => 'Sensory 5',
'icon' => 'icon-code'
];
}
/**
* Register service provider, Twig extensions, and alias facade.
*/
public function boot()
{
// Service provider
App::register('\Sensory5\Shortcode\Classes\ServiceProvider');
// Register alias
$alias = AliasLoader::getInstance();
$alias->alias('Shortcode', '\Sensory5\Shortcode\Classes\Facade');
// Enable shortcodes on all pages if requested
if (Settings::get('enable_on_render', false))
{
Event::listen('cms.page.postprocess', function($controller, $url, $page, $dataHolder) {
$dataHolder->content = \Shortcode::parse($dataHolder->content);
});
}
}
/**
* Register twig filters
*/
public function registerMarkupTags()
{
return [
'filters' => [ 'shortcode' => ['\Shortcode', 'parse'] ],
'functions' => ['shortcode' => ['\Shortcode', 'parse'] ]
];
}
/**
* Register backend settings
*/
public function registerSettings()
{
return [
'settings' => [
'label' => 'Shortcode Settings',
'description' => 'Manage shortcode settings',
'category' => 'Shortcodes',
'icon' => 'icon-code',
'class' => 'Sensory5\Shortcode\Models\Settings',
'order' => 600,
'keywords' => 'shortcode shortcodes'
]
];
}
}