1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-06 05:07:41 +02:00

feat(shortcodes): add date shortcode

This commit is contained in:
Awilum
2022-07-11 13:44:37 +03:00
parent 3e594b6398
commit 4400657e30

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
/**
* Flextype - Hybrid Content Management System with the freedom of a headless CMS
* and with the full functionality of a traditional CMS!
*
* Copyright (c) Sergey Romanenko (https://awilum.github.io)
*
* Licensed under The MIT License.
*
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*/
namespace Flextype\Parsers\Shortcodes;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use function Flextype\expression;
use function Flextype\parsers;
use function Flextype\registry;
// Shortcode: date
// Usage: (date:'F j, Y, g:i a')
parsers()->shortcodes()->addHandler('date', static function (ShortcodeInterface $s) {
if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.date.enabled')) {
return '';
}
return date($s->getBBCode());
});