diff --git a/WPML_OptionsManager.php b/WPML_OptionsManager.php index b22d3833..e65c4a4a 100644 --- a/WPML_OptionsManager.php +++ b/WPML_OptionsManager.php @@ -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, ...) diff --git a/inc/redux/WPML_Redux_Framework_config.php b/inc/redux/WPML_Redux_Framework_config.php index ff49c7a3..967df145 100644 --- a/inc/redux/WPML_Redux_Framework_config.php +++ b/inc/redux/WPML_Redux_Framework_config.php @@ -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', @@ -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.