From da45e59bbdd4baf7496a768b63d44b0cc82cb7c0 Mon Sep 17 00:00:00 2001 From: Rachel Baker Date: Thu, 17 Mar 2016 19:15:57 +0000 Subject: [PATCH] REST API: Add `home_url` to API index to avoid confusion with `site_url`. Confusion abound, the API index is the generic term `url` to display the `site_url`. New `home` key will display the `home_url` in the index as well. Fixes #35647. git-svn-id: https://develop.svn.wordpress.org/trunk@37031 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rest-api/class-wp-rest-server.php | 1 + tests/phpunit/tests/rest-api/rest-server.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index 9c8d257096..f795eb1086 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -945,6 +945,7 @@ class WP_REST_Server { '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'] ), diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php index 3c2c930075..534487553d 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -644,6 +644,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $this->assertArrayHasKey( 'name', $data ); $this->assertArrayHasKey( 'description', $data ); $this->assertArrayHasKey( 'url', $data ); + $this->assertArrayHasKey( 'home', $data ); $this->assertArrayHasKey( 'namespaces', $data ); $this->assertArrayHasKey( 'authentication', $data ); $this->assertArrayHasKey( 'routes', $data );