CARVIEW |
Select Language
HTTP/2 200
server: nginx
date: Sat, 11 Oct 2025 13:32:39 GMT
content-type: text/html;charset=utf-8
vary: Accept-Encoding
etag: W/"anonymous/Mon, 27 Mar 2017 07:08:54 GMT/c65c8aa382cb83d56d776e9128cff5f5"
cache-control: must-revalidate
alt-svc: h3=":443"; ma=86400
x-nc: MISS
content-encoding: gzip
Changeset 40336 – WordPress Trac
Changeset 40336
- Timestamp:
- 03/27/2017 07:08:54 AM (9 years ago)
- Author:
- swissspidy
- Message:
-
REST API: Add
gmt_offset
andtimezone_string
to the base/wp-json
response.
The site's current timezone offset is an important piece of information for any REST API client that needs to manipulate dates. It has not been
previously available.
Expose both the
gmt_offset
(the site's current offset from UTC in hours) andtimezone_string
(which also provides information about daylight
savings time) via the "site info" endpoint (the base/wp-json
response).
Also update the
wp-api-generated.js
fixture file with the changes to the default API responses.
Props sagarkbhatt.
Fixes #39854.
Merges [40238] to the 4.7 branch.
- Location:
- branches/4.7
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
branches/4.7/src/wp-includes/rest-api/class-wp-rest-server.php
r39278 r40336 1011 1011 // General site data. 1012 1012 $available = array( 1013 'name' => get_option( 'blogname' ), 1014 'description' => get_option( 'blogdescription' ), 1015 'url' => get_option( 'siteurl' ), 1016 'home' => home_url(), 1017 'namespaces' => array_keys( $this->namespaces ), 1018 'authentication' => array(), 1019 'routes' => $this->get_data_for_routes( $this->get_routes(), $request['context'] ), 1013 'name' => get_option( 'blogname' ), 1014 'description' => get_option( 'blogdescription' ), 1015 'url' => get_option( 'siteurl' ), 1016 'home' => home_url(), 1017 'gmt_offset' => get_option( 'gmt_offset' ), 1018 'timezone_string' => get_option( 'timezone_string' ), 1019 'namespaces' => array_keys( $this->namespaces ), 1020 'authentication' => array(), 1021 'routes' => $this->get_data_for_routes( $this->get_routes(), $request['context'] ), 1020 1022 ); 1021 1023 -
branches/4.7/tests/phpunit/tests/rest-api/rest-server.php
r38947 r40336 647 647 $this->assertArrayHasKey( 'url', $data ); 648 648 $this->assertArrayHasKey( 'home', $data ); 649 $this->assertArrayHasKey( 'gmt_offset', $data ); 650 $this->assertArrayHasKey( 'timezone_string', $data ); 649 651 $this->assertArrayHasKey( 'namespaces', $data ); 650 652 $this->assertArrayHasKey( 'authentication', $data ); -
branches/4.7/tests/qunit/fixtures/wp-api-generated.js
r40137 r40336 11 11 "url": "https://example.org", 12 12 "home": "https://example.org", 13 "gmt_offset": "0", 14 "timezone_string": "", 13 15 "namespaces": [ 14 16 "oembed/1.0",
Note: See TracChangeset
for help on using the changeset viewer.