diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php index b7451ffc18..1a94dd3fcf 100644 --- a/wp-includes/rest-api/class-wp-rest-server.php +++ b/wp-includes/rest-api/class-wp-rest-server.php @@ -1229,6 +1229,7 @@ class WP_REST_Server { $response->add_link( 'help', 'https://developer.wordpress.org/rest-api/' ); $this->add_active_theme_link_to_index( $response ); $this->add_site_logo_to_index( $response ); + $this->add_site_icon_to_index( $response ); /** * Filters the REST API root index data. @@ -1275,6 +1276,7 @@ class WP_REST_Server { /** * Exposes the site logo through the WordPress REST API. + * * This is used for fetching this information when user has no rights * to update settings. * @@ -1283,14 +1285,47 @@ class WP_REST_Server { * @param WP_REST_Response $response REST API response. */ protected function add_site_logo_to_index( WP_REST_Response $response ) { - $site_logo_id = get_theme_mod( 'custom_logo' ); - $response->data['site_logo'] = $site_logo_id; - if ( $site_logo_id ) { + $site_logo_id = get_theme_mod( 'custom_logo', 0 ); + + $this->add_image_to_index( $response, $site_logo_id, 'site_logo' ); + } + + /** + * Exposes the site icon through the WordPress REST API. + * + * This is used for fetching this information when user has no rights + * to update settings. + * + * @since 5.9.0 + * + * @param WP_REST_Response $response REST API response. + */ + 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' ); + } + + /** + * Exposes an image through the WordPress REST API. + * This is used for fetching this information when user has no rights + * to update settings. + * + * @since 5.9.0 + * + * @param WP_REST_Response $response REST API response. + * @param int $image_id Image attachment ID. + * @param string $type Type of Image. + */ + protected function add_image_to_index( WP_REST_Response $response, $image_id, $type ) { + $response->data[ $type ] = (int) $image_id; + if ( $image_id ) { $response->add_link( 'https://api.w.org/featuredmedia', - rest_url( rest_get_route_for_post( $site_logo_id ) ), + rest_url( rest_get_route_for_post( $image_id ) ), array( 'embeddable' => true, + 'type' => $type, ) ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 2738cd67b3..d8b23e1ae4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-52079'; +$wp_version = '5.9-alpha-52080'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.