REST API - Fix fatal error due to missing get_timezone function

This commit is contained in:
Gerhard 2013-11-20 07:55:28 +02:00
parent 922406b67b
commit df5929093d
1 changed files with 25 additions and 0 deletions

View File

@ -469,6 +469,31 @@ class WC_API_Server {
return apply_filters( 'woocommerce_api_index', $available );
}
/**
* Retrieve the timezone from the db
* @since 2.1
* @return string timezone
*/
public function get_timezone() {
$current_offset = get_option('gmt_offset');
$tzstring = get_option('timezone_string');
// Remove old Etc mappings. Fallback to gmt_offset.
if ( false !== strpos( $tzstring,'Etc/GMT' ) )
$tzstring = '';
if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
$check_zone_info = false;
if ( 0 == $current_offset )
$tzstring = 'UTC+0';
elseif ($current_offset < 0)
$tzstring = 'UTC' . $current_offset;
else
$tzstring = 'UTC+' . $current_offset;
}
return $tzstring;
}
/**
* Send a HTTP status code
*