diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php index 9df4556ada..50e7bd9796 100644 --- a/wp-includes/rest-api/class-wp-rest-server.php +++ b/wp-includes/rest-api/class-wp-rest-server.php @@ -1273,10 +1273,23 @@ class WP_REST_Server { ); $response = new WP_REST_Response( $available ); - $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 ); + + $fields = isset( $request['_fields'] ) ? $request['_fields'] : ''; + $fields = wp_parse_list( $fields ); + if ( empty( $fields ) ) { + $fields[] = '_links'; + } + + if ( $request->has_param( '_embed' ) ) { + $fields[] = '_embedded'; + } + + if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { + $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. diff --git a/wp-includes/version.php b/wp-includes/version.php index 4fba75fd1c..9ba4c26aa1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56565'; +$wp_version = '6.4-alpha-56566'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.