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

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