Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API: Add the missing 'site_icon_url' to the index #42957

Merged
merged 2 commits into from
Aug 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' );