Skip to content

Commit

Permalink
Fixed date formats
Browse files Browse the repository at this point in the history
  • Loading branch information
No3x committed Jul 31, 2016
1 parent 8fb984b commit 38c7abc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 6 additions & 3 deletions WPML_OptionsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,23 @@ public function getSetting($settingName, $default = null) {
* @return string datetime format string
*/
public function getDateTimeFormatString() {
// default database like format
$format = 'Y-m-d G:i:s';
$date_format = get_option( 'date_format' );
$time_format = get_option( 'time_format' );
// get option or change to user friendly format as the options maybe not set at all
$date_format = empty( $date_format ) ? 'F j, Y' : $date_format;
$time_format = empty( $time_format ) ? 'g:i a' : $time_format;
if ( $this->getSetting( 'datetimeformat-use-wordpress', false) == true )
$timeFormat = $date_format . " " . $time_format;
return $timeFormat;
// Overwrite with defined values or default
$format = $date_format . " " . $time_format;
return $format;
}

public function getOptionNamePrefix() {
return $this->getClassnameWithoutNamespace() . '_';
}


/**
* Define your options meta data here as an array, where each element in the array
* @return array of key=>display-name and/or key=>array(display-name, choice1, choice2, ...)
Expand Down
11 changes: 10 additions & 1 deletion inc/redux/WPML_Redux_Framework_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function setSections() {
'id' => 'datetimeformat-use-wordpress',
'type' => 'switch',
'title' => __('WordPress Date Time Format', 'wpml' ),
'subtitle' => __( sprintf("Use format from WordPress settings (%s)", date_i18n( apply_filters( 'wpml_get_date_time_format', '' ), current_time( 'timestamp' ) ) ), 'wpml'),
'subtitle' => __( sprintf("Use format from WordPress settings (%s)", date_i18n( $this->wordpress_default_format(), current_time( 'timestamp' ) ) ), 'wpml'),
'default' => 0,
'on' => 'Enabled',
'off' => 'Disabled',
Expand Down Expand Up @@ -345,6 +345,15 @@ public function setSections() {
);
}

public function wordpress_default_format()
{
$date_format = get_option( 'date_format' );
$time_format = get_option( 'time_format' );
$date_format = empty( $date_format ) ? 'F j, Y' : $date_format;
$time_format = empty( $time_format ) ? 'g:i a' : $time_format;
return "{$date_format} {$time_format}";
}

public function setHelpTabs() {

// Custom page help tabs, displayed using the help API. Tabs are shown in order of definition.
Expand Down

0 comments on commit 38c7abc

Please sign in to comment.