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 efda2321b7..12de6c55f0 100644
a
|
b
|
class WP_REST_Server { |
1288 | 1288 | // For non-variable routes, generate links. |
1289 | 1289 | if ( strpos( $route, '{' ) === false ) { |
1290 | 1290 | $data['_links'] = array( |
1291 | | 'self' => rest_url( $route ), |
| 1291 | 'self' => array( |
| 1292 | array( |
| 1293 | 'href' => rest_url( $route ), |
| 1294 | ), |
| 1295 | ), |
1292 | 1296 | ); |
1293 | 1297 | } |
1294 | 1298 | } |
diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php
index 755f0296ea..87e46d5807 100644
a
|
b
|
class Tests_REST_Server extends WP_Test_REST_TestCase { |
1020 | 1020 | $this->assertContains( 'test/another', $namespaces ); |
1021 | 1021 | } |
1022 | 1022 | |
| 1023 | /** |
| 1024 | * @ticket 49147 |
| 1025 | */ |
| 1026 | public function test_get_data_for_non_variable_route_includes_links() { |
| 1027 | $expected = array( |
| 1028 | 'self' => array( |
| 1029 | array( 'href' => rest_url('wp/v2/posts') ), |
| 1030 | ), |
| 1031 | ); |
| 1032 | |
| 1033 | $actual = rest_get_server()->get_data_for_route( |
| 1034 | '/wp/v2/posts', |
| 1035 | array( |
| 1036 | array( |
| 1037 | 'methods' => array( 'OPTIONS' => 1 ), |
| 1038 | 'show_in_index' => true, |
| 1039 | ), |
| 1040 | ) |
| 1041 | ); |
| 1042 | |
| 1043 | $this->assertEquals( $expected, $actual['_links'] ); |
| 1044 | } |
| 1045 | |
1023 | 1046 | public function test_x_robot_tag_header_on_requests() { |
1024 | 1047 | $request = new WP_REST_Request( 'GET', '/', array() ); |
1025 | 1048 | |