Skip to content

Commit

Permalink
REST API: Add the missing 'site_icon_url' to the index (#42957)
Browse files Browse the repository at this point in the history
* REST API: Add the missing 'site_icon_url' to the index
* Add backport note
  • Loading branch information
Mamaduka authored and priethor committed Aug 5, 2022
1 parent 93e056e commit 2b857a3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/compat/wordpress-6.1/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,21 @@ function gutenberg_register_gutenberg_rest_block_patterns() {
$block_patterns->register_routes();
}
add_action( 'rest_api_init', 'gutenberg_register_gutenberg_rest_block_patterns', 100 );

/**
* Exposes the site logo URL through the WordPress REST API.
*
* This is used for fetching this information when user has no rights
* to update settings.
*
* Note: Backports into wp-includes/rest-api/class-wp-rest-server.php file.
*
* @param WP_REST_Response $response REST API response.
* @return WP_REST_Response $response REST API response.
*/
function gutenberg_add_site_icon_url_to_index( WP_REST_Response $response ) {
$response->data['site_icon_url'] = get_site_icon_url();

return $response;
}
add_action( 'rest_index', 'gutenberg_add_site_icon_url_to_index' );

0 comments on commit 2b857a3

Please sign in to comment.