From d336f510a77b4450e8ebade964de5c9c0db2d201 Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 8 Jul 2022 15:05:27 +0300 Subject: [PATCH] feat(shortcodes): add new shortcode `url` --- src/flextype/core/Parsers/Shortcodes/UrlShortcode.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/flextype/core/Parsers/Shortcodes/UrlShortcode.php b/src/flextype/core/Parsers/Shortcodes/UrlShortcode.php index 6252b440..f6930456 100644 --- a/src/flextype/core/Parsers/Shortcodes/UrlShortcode.php +++ b/src/flextype/core/Parsers/Shortcodes/UrlShortcode.php @@ -27,6 +27,17 @@ use function Flextype\parsers; use function Flextype\registry; use function Flextype\serializers; use function Flextype\urlFor; +use function Flextype\url; + +// Shortcode: url +// Usage: (url) +parsers()->shortcodes()->addHandler('url', static function (ShortcodeInterface $s) { + if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.url.enabled')) { + return ''; + } + + return url($s->getBBCode() !== null ? $s->getBBCode() : '', $s->getParameter('prefix') !== null ? $s->getParameter('prefix') : 'base'); +}); // Shortcode: getBaseUrl // Usage: (getBaseUrl)