Skip to content

Commit

Permalink
REST API: Add the missing site_icon_url to the index.
Browse files Browse the repository at this point in the history
The `site_icon_url` index was supposed to ship with WordPress 5.6, but was [WordPress/gutenberg#22952 never backported to core].

This commit backports the original PR from Gutenberg repository:
* [WordPress/gutenberg#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
  • Loading branch information
SergeyBiryukov committed Sep 6, 2022
1 parent 31fa0c8 commit 18e1e81
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/wp-includes/rest-api/class-wp-rest-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/rest-api/rest-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/qunit/fixtures/wp-api-generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -10781,7 +10781,8 @@ mockedApiResponse.Schema = {
}
},
"site_logo": 0,
"site_icon": 0
"site_icon": 0,
"site_icon_url": ""
};

mockedApiResponse.oembed = {
Expand Down

0 comments on commit 18e1e81

Please sign in to comment.