Changeset 52080 for trunk/src/wp-includes/rest-api/class-wp-rest-server.php
- Timestamp:
- 11/09/2021 08:36:37 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r52068 r52080 1230 1230 $this->add_active_theme_link_to_index( $response ); 1231 1231 $this->add_site_logo_to_index( $response ); 1232 $this->add_site_icon_to_index( $response ); 1232 1233 1233 1234 /** … … 1276 1277 /** 1277 1278 * Exposes the site logo through the WordPress REST API. 1279 * 1278 1280 * This is used for fetching this information when user has no rights 1279 1281 * to update settings. … … 1284 1286 */ 1285 1287 protected function add_site_logo_to_index( WP_REST_Response $response ) { 1286 $site_logo_id = get_theme_mod( 'custom_logo' ); 1287 $response->data['site_logo'] = $site_logo_id; 1288 if ( $site_logo_id ) { 1288 $site_logo_id = get_theme_mod( 'custom_logo', 0 ); 1289 1290 $this->add_image_to_index( $response, $site_logo_id, 'site_logo' ); 1291 } 1292 1293 /** 1294 * Exposes the site icon through the WordPress REST API. 1295 * 1296 * This is used for fetching this information when user has no rights 1297 * to update settings. 1298 * 1299 * @since 5.9.0 1300 * 1301 * @param WP_REST_Response $response REST API response. 1302 */ 1303 protected function add_site_icon_to_index( WP_REST_Response $response ) { 1304 $site_icon_id = get_option( 'site_icon', 0 ); 1305 1306 $this->add_image_to_index( $response, $site_icon_id, 'site_icon' ); 1307 } 1308 1309 /** 1310 * Exposes an image through the WordPress REST API. 1311 * This is used for fetching this information when user has no rights 1312 * to update settings. 1313 * 1314 * @since 5.9.0 1315 * 1316 * @param WP_REST_Response $response REST API response. 1317 * @param int $image_id Image attachment ID. 1318 * @param string $type Type of Image. 1319 */ 1320 protected function add_image_to_index( WP_REST_Response $response, $image_id, $type ) { 1321 $response->data[ $type ] = (int) $image_id; 1322 if ( $image_id ) { 1289 1323 $response->add_link( 1290 1324 'https://api.w.org/featuredmedia', 1291 rest_url( rest_get_route_for_post( $ site_logo_id ) ),1325 rest_url( rest_get_route_for_post( $image_id ) ), 1292 1326 array( 1293 1327 'embeddable' => true, 1328 'type' => $type, 1294 1329 ) 1295 1330 );
Note: See TracChangeset
for help on using the changeset viewer.