diff --git a/assets/js/src/forms/list.jsx b/assets/js/src/forms/list.jsx index 5a7820a110..fd009fc702 100644 --- a/assets/js/src/forms/list.jsx +++ b/assets/js/src/forms/list.jsx @@ -141,7 +141,7 @@ const FormList = React.createClass({ { segments } - { MailPoet.Date.full(form.created_at) } + { MailPoet.Date.format(form.created_at) } ); diff --git a/assets/js/src/newsletters/list.jsx b/assets/js/src/newsletters/list.jsx index 10803a6b88..72b3ca438e 100644 --- a/assets/js/src/newsletters/list.jsx +++ b/assets/js/src/newsletters/list.jsx @@ -148,7 +148,7 @@ define( } else { if (item.queue.status === 'scheduled') { return ( - {MailPoet.I18n.t('scheduledFor')} { item.queue.scheduled_at } + {MailPoet.I18n.t('scheduledFor')} { MailPoet.Date.format(item.queue.scheduled_at) } ) } var progressClasses = classNames( @@ -273,10 +273,10 @@ define( { statistics_column } - { MailPoet.Date.full(newsletter.created_at) } + { MailPoet.Date.format(newsletter.created_at) } - { MailPoet.Date.full(newsletter.updated_at) } + { MailPoet.Date.format(newsletter.updated_at) } ); diff --git a/assets/js/src/segments/list.jsx b/assets/js/src/segments/list.jsx index d09cf69893..2423a5b111 100644 --- a/assets/js/src/segments/list.jsx +++ b/assets/js/src/segments/list.jsx @@ -191,7 +191,7 @@ const SegmentList = React.createClass({ { parseInt(unsubscribed).toLocaleString() } - { MailPoet.Date.full(segment.created_at) } + { MailPoet.Date.format(segment.created_at) } ); diff --git a/assets/js/src/subscribers/importExport/import.js b/assets/js/src/subscribers/importExport/import.js index 9d55e7e563..5edc4a7059 100644 --- a/assets/js/src/subscribers/importExport/import.js +++ b/assets/js/src/subscribers/importExport/import.js @@ -976,7 +976,7 @@ define( data[matchedColumn] += '' - + date + ''; + + MailPoet.Date.format(date) + ''; } else { data[matchedColumn] += diff --git a/assets/js/src/subscribers/list.jsx b/assets/js/src/subscribers/list.jsx index 8686897cf5..f8017303a9 100644 --- a/assets/js/src/subscribers/list.jsx +++ b/assets/js/src/subscribers/list.jsx @@ -341,10 +341,10 @@ const SubscriberList = React.createClass({ { segments } - { MailPoet.Date.full(subscriber.created_at) } + { MailPoet.Date.format(subscriber.created_at) } - { MailPoet.Date.full(subscriber.updated_at) } + { MailPoet.Date.format(subscriber.updated_at) } ); diff --git a/lib/Twig/Functions.php b/lib/Twig/Functions.php index cc2cd4c148..df1a7c17aa 100644 --- a/lib/Twig/Functions.php +++ b/lib/Twig/Functions.php @@ -42,10 +42,20 @@ class Functions extends \Twig_Extension { 'get_option', array('is_safe' => array('all')) ), + new \Twig_SimpleFunction( + 'get_option', + 'get_option', + array('is_safe' => array('all')) + ), new \Twig_SimpleFunction( 'sending_frequency', array($this, 'getSendingFrequency'), array('is_safe' => array('all')) + ), + new \Twig_SimpleFunction( + 'wp_datetime_format', + array($this, 'getWPDateTimeFormat'), + array('is_safe' => array('all')) ) ); } @@ -86,6 +96,16 @@ class Functions extends \Twig_Extension { } } + function getWPDateTimeFormat() { + $date_format = (get_option('date_format')) ? + get_option('date_format') : + 'F j, Y'; + $time_format = (get_option('time_format')) ? + get_option('time_format') : + 'g:i a'; + return sprintf('%s %s', $date_format, $time_format); + } + function params($key = null) { $args = stripslashes_deep($_GET); if(array_key_exists($key, $args)) { @@ -93,4 +113,4 @@ class Functions extends \Twig_Extension { } return null; } -} +} \ No newline at end of file diff --git a/lib/Util/Helpers.php b/lib/Util/Helpers.php index 69afd86333..f64c08fe6d 100644 --- a/lib/Util/Helpers.php +++ b/lib/Util/Helpers.php @@ -2,77 +2,6 @@ namespace MailPoet\Util; class Helpers { - - /* - * Matches each symbol of PHP date format standard - * with jQuery equivalent codeword - * @author Tristan Jahier - */ - static function dateformat_PHP_to_jQueryUI($php_format) { - $SYMBOLS_MATCHING = array( - // Day - 'd' => 'dd', - 'D' => 'D', - 'j' => 'd', - 'l' => 'DD', - 'N' => '', - 'S' => '', - 'w' => '', - 'z' => 'o', - // Week - 'W' => '', - // Month - 'F' => 'MM', - 'm' => 'mm', - 'M' => 'M', - 'n' => 'm', - 't' => '', - // Year - 'L' => '', - 'o' => '', - 'Y' => 'yy', - 'y' => 'y', - // Time - 'a' => '', - 'A' => '', - 'B' => '', - 'g' => '', - 'G' => '', - 'h' => '', - 'H' => '', - 'i' => '', - 's' => '', - 'u' => '' - ); - $jqueryui_format = ""; - $escaping = false; - for ($i = 0; $i < strlen($php_format); $i++) { - $char = $php_format[$i]; - if($char === '\\') // PHP date format escaping character - { - $i++; - if($escaping) { - $jqueryui_format .= $php_format[$i]; - } else { - $jqueryui_format .= '\'' . $php_format[$i]; - } - $escaping = true; - } else { - if($escaping) { - $jqueryui_format .= "'"; - $escaping = false; - } - if(isset($SYMBOLS_MATCHING[$char])) { - $jqueryui_format .= $SYMBOLS_MATCHING[$char]; - } else { - $jqueryui_format .= $char; - } - } - } - - return $jqueryui_format; - } - static function getMaxPostSize($bytes = false) { $maxPostSize = ini_get('post_max_size'); if(!$bytes) return $maxPostSize; diff --git a/views/layout.html b/views/layout.html index 4ce6e20c72..e287a0252c 100644 --- a/views/layout.html +++ b/views/layout.html @@ -40,7 +40,7 @@ )%>