REST API: Add `gmt_offset` and `timezone_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) and `timezone_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.

Built from https://develop.svn.wordpress.org/branches/4.7@40336


git-svn-id: http://core.svn.wordpress.org/branches/4.7@40243 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2017-03-27 07:09:41 +00:00
parent 0b6084b362
commit a56cceb25f
2 changed files with 10 additions and 8 deletions

View File

@ -1010,13 +1010,15 @@ class WP_REST_Server {
public function get_index( $request ) {
// General site data.
$available = array(
'name' => get_option( 'blogname' ),
'description' => get_option( 'blogdescription' ),
'url' => get_option( 'siteurl' ),
'home' => home_url(),
'namespaces' => array_keys( $this->namespaces ),
'authentication' => array(),
'routes' => $this->get_data_for_routes( $this->get_routes(), $request['context'] ),
'name' => get_option( 'blogname' ),
'description' => get_option( 'blogdescription' ),
'url' => get_option( 'siteurl' ),
'home' => home_url(),
'gmt_offset' => get_option( 'gmt_offset' ),
'timezone_string' => get_option( 'timezone_string' ),
'namespaces' => array_keys( $this->namespaces ),
'authentication' => array(),
'routes' => $this->get_data_for_routes( $this->get_routes(), $request['context'] ),
);
$response = new WP_REST_Response( $available );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7.4-alpha-40335';
$wp_version = '4.7.4-alpha-40336';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.