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.

90 lines
2.1 KiB

  1. <?php namespace Sensory5\Shortcode;
  2. use App;
  3. use Str;
  4. use Html;
  5. use Event;
  6. use System\Classes\PluginBase;
  7. use Illuminate\Foundation\AliasLoader;
  8. use Thunder\Shortcode\Shortcode\ShortcodeInterface;
  9. use Sensory5\Shortcode\Models\Settings;
  10. /**
  11. * Shortcode Plugin Information File
  12. */
  13. class Plugin extends PluginBase
  14. {
  15. /**
  16. * Returns information about this plugin.
  17. *
  18. * @return array
  19. */
  20. public function pluginDetails()
  21. {
  22. return [
  23. 'name' => 'Shortcode',
  24. 'description' => 'Shortcode integration for OctoberCMS.',
  25. 'author' => 'Sensory 5',
  26. 'icon' => 'icon-code'
  27. ];
  28. }
  29. /**
  30. * Register service provider, Twig extensions, and alias facade.
  31. */
  32. public function boot()
  33. {
  34. // Service provider
  35. App::register('\Sensory5\Shortcode\Classes\ShortcodeServiceProvider');
  36. // Register alias
  37. $alias = AliasLoader::getInstance();
  38. $alias->alias('Shortcode', '\Sensory5\Shortcode\Classes\ShortcodeFacade');
  39. // Enable shortcodes on all pages if requested
  40. if (Settings::get('enable_on_render', false))
  41. {
  42. Event::listen('cms.page.render', function($controller, $content) {
  43. return \Shortcode::parse($content);
  44. });
  45. }
  46. }
  47. /**
  48. * Register twig filters
  49. */
  50. public function registerMarkupTags()
  51. {
  52. return [
  53. 'filters' => [ 'shortcode' => ['\Shortcode', 'parse'] ],
  54. 'functions' => ['shortcode' => ['\Shortcode', 'parse'] ]
  55. ];
  56. }
  57. /**
  58. * Register backend settings
  59. */
  60. public function registerSettings()
  61. {
  62. return [
  63. 'settings' => [
  64. 'label' => 'Shortcode Settings',
  65. 'description' => 'Manage shortcode settings',
  66. 'category' => 'Shortcodes',
  67. 'icon' => 'icon-code',
  68. 'class' => 'Sensory5\Shortcode\Models\Settings',
  69. 'order' => 600,
  70. 'keywords' => 'shortcode shortcodes'
  71. ]
  72. ];
  73. }
  74. }