From 03db43b9a167449dd4a15065d0f7ca16108a72c3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 6 Sep 2022 14:41:08 +0000 Subject: [PATCH] REST API: Add the missing `site_icon_url` to the index. The `site_icon_url` index was supposed to ship with WordPress 5.6, but was [https://github.com/WordPress/gutenberg/pull/22952 never backported to core]. This commit backports the original PR from Gutenberg repository: * [https://github.com/WordPress/gutenberg/pull/42957 #42957: REST API: Add the missing 'site_icon_url' to the index] Follow-up to [52080]. Props Mamaduka, bernhard-reiter, TimothyBlynJacobs. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54083 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rest-api/class-wp-rest-server.php | 2 ++ tests/phpunit/tests/rest-api/rest-server.php | 1 + tests/qunit/fixtures/wp-api-generated.js | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) 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 19b362a4cae2..4e26611bb459 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -1308,6 +1308,8 @@ protected function add_site_icon_to_index( WP_REST_Response $response ) { $site_icon_id = get_option( 'site_icon', 0 ); $this->add_image_to_index( $response, $site_icon_id, 'site_icon' ); + + $response->data['site_icon_url'] = get_site_icon_url(); } /** diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php index f04c266425a1..aa927c8b1c76 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -1084,6 +1084,7 @@ public function test_get_index() { // Check site logo and icon. $this->assertArrayHasKey( 'site_logo', $data ); $this->assertArrayHasKey( 'site_icon', $data ); + $this->assertArrayHasKey( 'site_icon_url', $data ); } /** diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index 5c70e70c2bb1..00b6a2f8340d 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -10781,7 +10781,8 @@ mockedApiResponse.Schema = { } }, "site_logo": 0, - "site_icon": 0 + "site_icon": 0, + "site_icon_url": "" }; mockedApiResponse.oembed = {