public static function install() { $config = DI::get('Config'); // add twig function / filter if ((bool) $config->get('plugins.config.markdown.twig', false)) { Hook::attach('twigInitialized', function ($twig) { $options = ['is_safe' => ['html']]; $twig->addFunction(new \Twig_SimpleFunction('markdown', ['MarkdownPlugin', 'parseMarkdown'], $options)); $twig->addFilter(new \Twig_SimpleFilter('markdown', ['MarkdownPlugin', 'parseMarkdown'], $options)); }); } // add shortcode if ((bool) $config->get('plugins.config.markdown.shortcode', true)) { #Hook::attach('shortcodeInitialized', function($shortcode) { # $shortcode->add('markdown', ['MarkdownPlugin', 'markdownShortcode']); #}); Hook::attach('shortcodeInitialized', ['MarkdownPlugin', 'addShortcode']); } Hook::attach('renderContent', function ($content, array $attributes) { if (!in_array($attributes['format'], ['markdown', 'md'])) { return $content; } return MarkdownPlugin::parseMarkdown($content); }); }
public function install() { if ((bool) $this->config->get('plugins.config.simplecontact.twig', false)) { Hook::attach('twigInitialized', [$this, 'addTwigFunction']); } if ((bool) $this->config->get('plugins.config.simplecontact.shortcode', true)) { Hook::attach('shortcodeInitialized', [$this, 'addShortcode']); } }
/** * Initialize plugin */ public static function install() { $config = DI::get('Config'); if ((bool) $config->get('plugins.config.gist.twig', false)) { Hook::attach('twigInitialized', ['GistPlugin', 'addTwigFunction']); } if ((bool) $config->get('plugins.config.gist.shortcode', true)) { Hook::attach('shortcodeInitialized', ['GistPlugin', 'addShortcode']); } }
/** * @return array */ public function install() { if ((bool) $this->config->get('plugins.config.simplesearch.twig', false)) { Hook::attach('twigInitialized', [$this, 'addTwigFunctions']); } if ((bool) $this->config->get('plugins.config.simplesearch.shortcode', true)) { Hook::attach('shortcodeInitialized', [$this, 'addShortcodes']); } Hook::attach('pluginsInitialized', [$this, 'addPagePath']); }
/** * @return array */ public static function install() { static::$config = DI::get('Config'); if ((bool) static::$config->get('plugins.config.video.twig', false)) { Hook::attach('twigInitialized', ['VideoPlugin', 'addTwigFunctions']); } if ((bool) static::$config->get('plugins.config.video.shortcode', true)) { Hook::attach('shortcodeInitialized', ['VideoPlugin', 'addShortcodes']); } }
/** * Initialize plugin */ public static function install() { self::$config = DI::get('Config'); if ((bool) self::$config->get('plugins.config.disqus.twig', false)) { Hook::attach('twigInitialized', ['DisqusPlugin', 'twigInitialized']); } if ((bool) self::$config->get('plugins.config.disqus.shortcode', true)) { Hook::attach('shortcodeInitialized', ['DisqusPlugin', 'shortcodeInitialized']); } }
/** * @return array */ public function install() { $config = DI::get('Config'); if ((bool) $config->get('plugins.config.textile.twig', false)) { Hook::attach('twigInitialized', [$this, 'addTwigFunctionAndFilter']); } if ((bool) $config->get('plugins.config.textile.shortcode', true)) { Hook::attach('shortcodeInitialized', [$this, 'addSortcode']); } Hook::attach('renderContent', [$this, 'renderContent']); }
public static function install() { Hook::attach('pageLoaded', function ($page) { if (!empty($page->redirect)) { $url = RedirectPlugin::getUrl($page->redirect); $status = RedirectPlugin::getStatus($page->redirect); $response = new RedirectResponse($url, $status); $response->send(); } }); }
public function initTwig() { $config = DI::get('Config'); // Add custom namespace path to Imagine lib $vendorDir = $config->get('site.path') . '/../vendor'; $autoload = (require $vendorDir . '/autoload.php'); $autoload->add('Twig_', __DIR__ . '/vendor/twig/lib'); $this->twig = new Twig($config); $this->twig->init(); Di::set('Twig', $this->twig); Hook::trigger(Hook::ACTION, 'twigInitialized', $this->twig->getEnvironment()); }
public static function install() { $config = DI::get('Config'); if ((bool) $config->get('plugins.config.imagine.twig', false)) { Hook::attach('twigInitialized', ['ImaginePlugin', 'addTwigExtension']); } if ((bool) $config->get('plugins.config.imagine.shortcode', true)) { Hook::attach('shortcodeInitialized', ['ImaginePlugin', 'addShortcode']); } // Add custom namespace path to Imagine lib $vendorDir = $config->get('site.path') . '/../vendor'; $autoload = (require $vendorDir . '/autoload.php'); $autoload->add('Imagine', __DIR__ . '/vendor/lib'); }
public static function install() { // default config $defaults = DI::get('Config')->get('plugins.config.smartypants', []); static::$config = array_merge(['twig_filter' => 1, 'process_title' => 1, 'process_content' => true, 'options' => 'qDew'], $defaults); if (!empty(static::$config['twig_filter'])) { Hook::attach('twigInitialized', ['SmartypantsPlugin', 'addTwigFilter']); } if (!empty(static::$config['process_title'])) { Hook::attach('pageLoaded', ['SmartypantsPlugin', 'filterPageTitle']); } if (!empty(static::$config['process_content'])) { Hook::attach('renderContent', ['SmartypantsPlugin', 'renderContent']); } }
public function install() { $this->addDateTag(); $this->addPageTag(); $this->addSiteTag(); $this->addIncludeTag(); $this->addTwigTag(); $this->addLinkTag(); $this->addEmailTag(); $this->addTelTag(); $this->addImageTag(); $this->addFileTag(); $this->addListingTag(); $this->addBlocksTag(); Hook::trigger(Hook::ACTION, 'addShortcode', $this->shortcode); Hook::attach('renderContent', [$this, 'renderContent']); }
public function install() { $this->addDateTag(); $this->addPageTag(); $this->addSiteTag(); $this->addIncludeTag(); $this->addTwigTag(); // http://getkirby.com/docs/content/text#basic-formats $this->addLinkTag(); $this->addEmailTag(); $this->addTelTag(); $this->addImageTag(); $this->addFileTag(); $this->addListingTag(); $this->addBlocksTag(); Hook::trigger(Hook::ACTION, 'addShortcode', $this->shortcode); Hook::attach('renderContent', [$this, 'renderContent']); }
public static function install() { // config $defaults = DI::get('Config')->get('plugins.config.highlightjs', []); $config = array_merge(['stylesheets' => '@plugin/highlightjs/assets/styles/', 'javascript' => '@plugin/highlightjs/assets/highlight.pack.js', 'javascript_init' => '@plugin/highlightjs/assets/highlightjs.js', 'html' => '<pre><code class="{class}">{content}</code></pre>', 'style' => 'default'], $defaults); static::$config = $config; /** @var Herbie\Assets $assets */ $assets = DI::get('Assets'); if (false !== $config['stylesheets']) { $style = empty($config['style']) ? 'default' : $config['style']; $stylesheet = sprintf('%s/%s.css', rtrim($config['stylesheets']) . '/', $style); $assets->addCss($stylesheet); } if (false !== $config['javascript']) { $assets->addJs($config['javascript']); } if (false !== $config['javascript_init']) { $assets->addJs($config['javascript_init']); } Hook::attach('shortcodeInitialized', ['HighlightJsPlugin', 'addShortcode']); }
public static function install() { self::$templates = DI::get('Config')->get('plugins.config.grid.templates', []); Hook::attach('renderContent', ['GridPlugin', 'renderContent']); }
public static function install() { Hook::attach('twigInitialized', ['TestPlugin', 'addTwigExtension']); }
<?php use Herbie\DI; use Herbie\Hook; Hook::attach('pageLoaded', function ($page) { if (!empty($page->random)) { $menuItemCollection = DI::get('Menu\\Page\\Collection'); $excludeRoutes = empty($page->random['excludes']) ? [] : $page->random['excludes']; do { $menuItem = $menuItemCollection->getRandom(); $invalid = $menuItem->hidden == true || $menuItem->path == $page->path || in_array($menuItem->route, $excludeRoutes); } while ($invalid); if (isset($menuItem)) { $page->load($menuItem->getPath()); } } });
public function install() { Hook::attach('pluginsInitialized', [$this, 'pluginsInitialized']); Hook::attach('twigInitialized', [$this, 'addTwigFunction']); Hook::attach('outputGenerated', [$this, 'outputGenerated']); }
/** * Renders a page content segment. * @param string|int $segmentId * @param Page $page * @return string */ public function renderPageSegment($segmentId, Page $page) { if (is_null($page)) { $page = Application::getPage(); } $segment = $page->getSegment($segmentId); $segment->string = Hook::trigger(Hook::FILTER, 'renderContent', $segment->string, $page->getData()); return $segment->string; }
/** * Initialize plugin */ public static function install() { $defaults = DI::get('Config')->get('plugins.config.mathjax', []); static::$config = array_merge(['cdn_url' => 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=AM_HTMLorMML.js', 'built_in_js' => true], $defaults); Hook::attach('shortcodeInitialized', ['MathjaxPlugin', 'shortcodeInitialized']); }
public static function install() { Hook::attach('twigInitialized', ['MenuPlugin', 'addTwigFunctions']); Hook::attach('shortcodeInitialized', ['MenuPlugin', 'addShortcodes']); }