Make WordPress Core

Ticket #39854: 39854.2.patch

File 39854.2.patch, 1.3 KB (added by sagarkbhatt, 8 years ago)

This patch wil show gmt_offset only when context=edit

  • wp-includes/rest-api/class-wp-rest-server.php

    diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php
    index 4f5ae76..9d3f956 100644
    a b class WP_REST_Server { 
    10111011         */
    10121012        public function get_index( $request ) {
    10131013                // General site data.
     1014                $context = $request->get_param( 'context' );
     1015                $available_edit = array();
     1016                if ( 'edit' === $context && ! current_user_can( 'edit_posts' ) ) {
     1017                    return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you cannot view this resource with edit context.' ), array( 'status' => rest_authorization_required_code() ) );
     1018                }
     1019                if ( 'edit' === $context && current_user_can( 'edit_posts' ) ) {
     1020                        $available_edit['gmt_offset'] = get_option( 'gmt_offset' );
     1021                }
    10141022                $available = array(
    10151023                        'name'           => get_option( 'blogname' ),
    10161024                        'description'    => get_option( 'blogdescription' ),
    class WP_REST_Server { 
    10201028                        'authentication' => array(),
    10211029                        'routes'         => $this->get_data_for_routes( $this->get_routes(), $request['context'] ),
    10221030                );
    1023 
     1031                $available = wp_parse_args( $available, $available_edit );
    10241032                $response = new WP_REST_Response( $available );
    10251033
    10261034                $response->add_link( 'help', 'http://v2.wp-api.org/' );