From 18e1e81dea1536436a24eee57651b3edb6c7da22 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 19b362a4ca..4e26611bb4 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 @@ class WP_REST_Server { $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 f04c266425..aa927c8b1c 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -1084,6 +1084,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { // 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 5c70e70c2b..00b6a2f834 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 = {