From 4499858bcc257a722f6e3e225fc05b24a450e45c Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 6 Nov 2014 17:46:46 +1100 Subject: [PATCH] Fix #73 Manual offset timezone not saving --- .../settings/class-sp-settings-general.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/admin/settings/class-sp-settings-general.php b/includes/admin/settings/class-sp-settings-general.php index dbafbba1..b2f8a24e 100644 --- a/includes/admin/settings/class-sp-settings-general.php +++ b/includes/admin/settings/class-sp-settings-general.php @@ -192,8 +192,18 @@ class SP_Settings_General extends SP_Settings_Page { $settings = $this->get_settings(); SP_Admin_Settings::save_fields( $settings ); + // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. + if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) { + $_POST['gmt_offset'] = $_POST['timezone_string']; + $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', $_POST['gmt_offset'] ); + $_POST['timezone_string'] = ''; + } + if ( isset( $_POST['timezone_string'] ) ) - update_option( 'timezone_string', $_POST['timezone_string'] ); + update_option( 'timezone_string', $_POST['timezone_string'] ); + + if ( isset( $_POST['gmt_offset'] ) ) + update_option( 'gmt_offset', $_POST['gmt_offset'] ); update_option( 'sportspress_enable_frontend_css', isset( $_POST['sportspress_enable_frontend_css'] ) ? 'yes' : 'no' ); @@ -231,10 +241,10 @@ class SP_Settings_General extends SP_Settings_Page { $check_zone_info = true; // Remove old Etc mappings. Fallback to gmt_offset. - if ( false !== strpos($tzstring,'Etc/GMT') ) + if ( false !== strpos( $tzstring,'Etc/GMT' ) ) $tzstring = ''; - if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists + if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists $check_zone_info = false; if ( 0 == $current_offset ) $tzstring = 'UTC+0'; @@ -254,6 +264,7 @@ class SP_Settings_General extends SP_Settings_Page { +