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:
33
src/flextype/core/Parsers/Shortcodes/DateShortcode.php
Normal file
33
src/flextype/core/Parsers/Shortcodes/DateShortcode.php
Normal 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());
|
||||
});
|
Reference in New Issue
Block a user