Initial shortcode implementation
This commit is contained in:
90
Plugin.php
Normal file
90
Plugin.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php namespace Sensory5\Shortcode;
|
||||
|
||||
use App;
|
||||
use Str;
|
||||
use Html;
|
||||
use Event;
|
||||
use System\Classes\PluginBase;
|
||||
use Illuminate\Foundation\AliasLoader;
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
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\ShortcodeServiceProvider');
|
||||
|
||||
// Register alias
|
||||
$alias = AliasLoader::getInstance();
|
||||
$alias->alias('Shortcode', '\Sensory5\Shortcode\Classes\ShortcodeFacade');
|
||||
|
||||
// Enable shortcodes on all pages if requested
|
||||
if (Settings::get('enable_on_render', false))
|
||||
{
|
||||
Event::listen('cms.page.render', function($controller, $content) {
|
||||
|
||||
return \Shortcode::parse($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'
|
||||
]
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user