Skip to content

Commit 47b1d50

Browse files
authored
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
1 parent 220e40b commit 47b1d50

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/compat/wordpress-6.1/rest-api.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,21 @@ function gutenberg_register_gutenberg_rest_block_patterns() {
4343
$block_patterns->register_routes();
4444
}
4545
add_action( 'rest_api_init', 'gutenberg_register_gutenberg_rest_block_patterns', 100 );
46+
47+
/**
48+
* Exposes the site logo URL through the WordPress REST API.
49+
*
50+
* This is used for fetching this information when user has no rights
51+
* to update settings.
52+
*
53+
* Note: Backports into wp-includes/rest-api/class-wp-rest-server.php file.
54+
*
55+
* @param WP_REST_Response $response REST API response.
56+
* @return WP_REST_Response $response REST API response.
57+
*/
58+
function gutenberg_add_site_icon_url_to_index( WP_REST_Response $response ) {
59+
$response->data['site_icon_url'] = get_site_icon_url();
60+
61+
return $response;
62+
}
63+
add_action( 'rest_index', 'gutenberg_add_site_icon_url_to_index' );

0 commit comments

Comments
 (0)