Files
piratepoet/lib/Newsletter/Shortcodes/Categories/Date.php
Ján Mikláš 01bd3d036b Fix formating [date:dordinal] shortcode
[MAILPOET-2148]
2019-07-18 14:21:24 -04:00

27 lines
791 B
PHP

<?php
namespace MailPoet\Newsletter\Shortcodes\Categories;
use MailPoet\WP\Functions as WPFunctions;
class Date {
static function process(
$shortcode_details
) {
$action_mapping = [
'd' => 'd',
'dordinal' => 'jS',
'dtext' => 'l',
'm' => 'm',
'mtext' => 'F',
'y' => 'Y',
];
$wp = new WPFunctions();
if (!empty($action_mapping[$shortcode_details['action']])) {
return WPFunctions::get()->dateI18n($action_mapping[$shortcode_details['action']], $wp->currentTime('timestamp'));
}
return ($shortcode_details['action'] === 'custom' && $shortcode_details['action_argument'] === 'format') ?
WPFunctions::get()->dateI18n($shortcode_details['action_argument_value'], $wp->currentTime('timestamp')) :
false;
}
}