mirror of
https://github.com/flextype/flextype.git
synced 2025-08-10 15:14:20 +02:00
feat(shortcodes): update logic for setting enabled
, affected all shortcodes #564
This commit is contained in:
@@ -87,12 +87,15 @@ final class Shortcodes
|
||||
}
|
||||
|
||||
foreach ($shortcodes as $shortcode) {
|
||||
if (! isset($shortcode['path'])) {
|
||||
if (! isset($shortcode['enabled'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $shortcode['enabled']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! file_exists(ROOT_DIR . $shortcode['path'])) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -12,8 +12,12 @@ namespace Flextype\Parsers\Shortcodes;
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
// Shortcode: [content_fetch id="content-id" field="field-name" default="default-value"]
|
||||
if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.content.enabled')) {
|
||||
parsers()->shortcodes()->addHandler('content_fetch', static function (ShortcodeInterface $s) {
|
||||
return arrays(content()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default'));
|
||||
});
|
||||
}
|
||||
parsers()->shortcodes()->addHandler('content_fetch', static function (ShortcodeInterface $s) {
|
||||
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.content.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return arrays(content()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default'));
|
||||
});
|
||||
|
||||
|
@@ -12,8 +12,12 @@ namespace Flextype\Parsers\Shortcodes;
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
// Shortcode: [media_files_fetch id="media-id" field="field-name" default="default-value"]
|
||||
if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.media.enabled')) {
|
||||
parsers()->shortcodes()->addHandler('media_files_fetch', static function (ShortcodeInterface $s) {
|
||||
return arrays(flextype('media')->files()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default'));
|
||||
});
|
||||
}
|
||||
parsers()->shortcodes()->addHandler('media_files_fetch', static function (ShortcodeInterface $s) {
|
||||
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.media.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return arrays(flextype('media')->files()->fetch($s->getParameter('id')))->get($s->getParameter('field'), $s->getParameter('default'));
|
||||
});
|
||||
|
||||
|
@@ -14,10 +14,9 @@ use Thunder\Shortcode\Events;
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
// Shortcode: [raw]
|
||||
if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.raw.enabled')) {
|
||||
parsers()->shortcodes()->addHandler('raw', static function (ShortcodeInterface $s) {
|
||||
return $s->getContent();
|
||||
});
|
||||
parsers()->shortcodes()->addHandler('raw', static function (ShortcodeInterface $s) {
|
||||
return $s->getContent();
|
||||
});
|
||||
|
||||
parsers()->shortcodes()->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['raw']));
|
||||
|
||||
parsers()->shortcodes()->addEventHandler(Events::FILTER_SHORTCODES, new FilterRawEventHandler(['raw']));
|
||||
}
|
||||
|
@@ -12,8 +12,11 @@ namespace Flextype\Parsers\Shortcodes;
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
|
||||
// Shortcode: [registry_get name="item-name" default="default-value"]
|
||||
if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.registry.enabled')) {
|
||||
parsers()->shortcodes()->addHandler('registry_get', static function (ShortcodeInterface $s) {
|
||||
return registry()->get($s->getParameter('name'), $s->getParameter('default'));
|
||||
});
|
||||
}
|
||||
parsers()->shortcodes()->addHandler('registry_get', static function (ShortcodeInterface $s) {
|
||||
|
||||
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.registry.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return registry()->get($s->getParameter('name'), $s->getParameter('default'));
|
||||
});
|
@@ -13,12 +13,15 @@ use Slim\Http\Environment;
|
||||
use Slim\Http\Uri;
|
||||
|
||||
// Shortcode: [url]
|
||||
if (registry()->get('flextype.settings.parsers.shortcodes.shortcodes.url.enabled')) {
|
||||
parsers()->shortcodes()->addHandler('url', static function () {
|
||||
if (registry()->has('flextype.settings.url') && registry()->get('flextype.settings.url') !== '') {
|
||||
return registry()->get('flextype.settings.url');
|
||||
}
|
||||
parsers()->shortcodes()->addHandler('url', static function () {
|
||||
|
||||
if (!registry()->get('flextype.settings.parsers.shortcodes.shortcodes.url.enabled')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return app()->getBasePath();
|
||||
});
|
||||
}
|
||||
if (registry()->has('flextype.settings.url') && registry()->get('flextype.settings.url') !== '') {
|
||||
return registry()->get('flextype.settings.url');
|
||||
}
|
||||
|
||||
return app()->getBasePath();
|
||||
});
|
||||
|
Reference in New Issue
Block a user