From 47b1d50afd13a76a649b07bd66ceecd137a0d64e Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 4 Aug 2022 13:25:16 +0400 Subject: [PATCH] REST API: Add the missing 'site_icon_url' to the index (#42957) * REST API: Add the missing 'site_icon_url' to the index * Add backport note --- lib/compat/wordpress-6.1/rest-api.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/compat/wordpress-6.1/rest-api.php b/lib/compat/wordpress-6.1/rest-api.php index 4ba0b328857b8..88b6d3bbb9a4d 100644 --- a/lib/compat/wordpress-6.1/rest-api.php +++ b/lib/compat/wordpress-6.1/rest-api.php @@ -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' );