Change Date picker to use Wordpress date format

This commit is contained in:
Tautvidas Sipavičius
2016-05-18 16:02:51 +03:00
parent 0b3a388a78
commit 91bb215e4d
4 changed files with 82 additions and 18 deletions

View File

@ -52,6 +52,16 @@ class Functions extends \Twig_Extension {
array($this, 'getSendingFrequency'),
array('is_safe' => array('all'))
),
new \Twig_SimpleFunction(
'wp_date_format',
array($this, 'getWPDateFormat'),
array('is_safe' => array('all'))
),
new \Twig_SimpleFunction(
'wp_time_format',
array($this, 'getWPTimeFormat'),
array('is_safe' => array('all'))
),
new \Twig_SimpleFunction(
'wp_datetime_format',
array($this, 'getWPDateTimeFormat'),
@ -96,14 +106,20 @@ class Functions extends \Twig_Extension {
}
}
function getWPDateTimeFormat() {
$date_format = (get_option('date_format')) ?
function getWPDateFormat() {
return (get_option('date_format')) ?
get_option('date_format') :
'F j, Y';
$time_format = (get_option('time_format')) ?
}
function getWPTimeFormat() {
return (get_option('time_format')) ?
get_option('time_format') :
'g:i a';
return sprintf('%s %s', $date_format, $time_format);
}
function getWPDateTimeFormat() {
return sprintf('%s %s', $this->getWPDateFormat(), $this->getWPTimeFormat());
}
function params($key = null) {
@ -113,4 +129,4 @@ class Functions extends \Twig_Extension {
}
return null;
}
}
}