Make WordPress Core

Ticket #42465: 42465.diff

File 42465.diff, 2.6 KB (added by schlessera, 9 years ago)

Addition of permalink_structure to wp-json, with changes to test files as required

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

    diff --git src/wp-includes/rest-api/class-wp-rest-server.php src/wp-includes/rest-api/class-wp-rest-server.php
    index c69cb4834c..d06974682a 100644
    class WP_REST_Server { 
    10171017        public function get_index( $request ) {
    10181018                // General site data.
    10191019                $available = array(
    1020                         'name'            => get_option( 'blogname' ),
    1021                         'description'     => get_option( 'blogdescription' ),
    1022                         'url'             => get_option( 'siteurl' ),
    1023                         'home'            => home_url(),
    1024                         'gmt_offset'      => get_option( 'gmt_offset' ),
    1025                         'timezone_string' => get_option( 'timezone_string' ),
    1026                         'namespaces'      => array_keys( $this->namespaces ),
    1027                         'authentication'  => array(),
    1028                         'routes'          => $this->get_data_for_routes( $this->get_routes(), $request['context'] ),
     1020                        'name'                => get_option( 'blogname' ),
     1021                        'description'         => get_option( 'blogdescription' ),
     1022                        'url'                 => get_option( 'siteurl' ),
     1023                        'home'                => home_url(),
     1024                        'gmt_offset'          => get_option( 'gmt_offset' ),
     1025                        'timezone_string'     => get_option( 'timezone_string' ),
     1026                        'permalink_structure' => get_option( 'permalink_structure' ),
     1027                        'namespaces'          => array_keys( $this->namespaces ),
     1028                        'authentication'      => array(),
     1029                        'routes'              => $this->get_data_for_routes( $this->get_routes(), $request['context'] ),
    10291030                );
    10301031
    10311032                $response = new WP_REST_Response( $available );
  • tests/phpunit/tests/rest-api/rest-server.php

    diff --git tests/phpunit/tests/rest-api/rest-server.php tests/phpunit/tests/rest-api/rest-server.php
    index cb75f4e726..37b96fdd33 100644
    class Tests_REST_Server extends WP_Test_REST_TestCase { 
    665665                $this->assertArrayHasKey( 'home', $data );
    666666                $this->assertArrayHasKey( 'gmt_offset', $data );
    667667                $this->assertArrayHasKey( 'timezone_string', $data );
     668                $this->assertArrayHasKey( 'permalink_structure', $data );
    668669                $this->assertArrayHasKey( 'namespaces', $data );
    669670                $this->assertArrayHasKey( 'authentication', $data );
    670671                $this->assertArrayHasKey( 'routes', $data );
  • tests/qunit/fixtures/wp-api-generated.js

    diff --git tests/qunit/fixtures/wp-api-generated.js tests/qunit/fixtures/wp-api-generated.js
    index 8c9684c9de..d0882f3249 100644
    mockedApiResponse.Schema = { 
    1212    "home": "http://example.org",
    1313    "gmt_offset": "0",
    1414    "timezone_string": "",
     15    "permalink_structure": false,
    1516    "namespaces": [
    1617        "oembed/1.0",
    1718        "wp/v2"