PluginProbe
Gutenberg / 22.7.0
Gutenberg v22.7.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | lib/compat/wordpress-7.0/preload.php +31 -0 23.6.2 → 22.7.0 View file →
@@ -25,4 +25,35 @@
25 25
26 26 return $paths;
27 27 }
28 28 add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_9', 10, 2 );
29 +
30 +/**
31 + * Filters the block editor preload paths to include media processing fields.
32 + *
33 + * The packages/core-data/src/entities.js file requests additional fields
34 + * (image_sizes, image_size_threshold) on the root endpoint that are not
35 + * included in WordPress Core's default preload paths. This filter ensures
36 + * the preloaded URL matches exactly what the JavaScript requests.
37 + *
38 + * @since 20.1.0
39 + *
40 + * @param array $paths REST API paths to preload.
41 + * @return array Filtered preload paths.
42 + */
43 +function gutenberg_block_editor_preload_paths_root_fields( $paths ) {
44 + // Complete list of fields expected by packages/core-data/src/entities.js.
45 + // This must match exactly for preloading to work (same fields, same order).
46 + // @see packages/core-data/src/entities.js rootEntitiesConfig.__unstableBase
47 + $root_fields = 'description,gmt_offset,home,image_sizes,image_size_threshold,image_output_formats,jpeg_interlaced,png_interlaced,gif_interlaced,name,site_icon,site_icon_url,site_logo,timezone_string,url,page_for_posts,page_on_front,show_on_front';
48 +
49 + foreach ( $paths as $key => $path ) {
50 + if ( is_string( $path ) && str_starts_with( $path, '/?_fields=' ) ) {
51 + // Replace with the complete fields list to ensure exact match.
52 + $paths[ $key ] = '/?_fields=' . $root_fields;
53 + break;
54 + }
55 + }
56 +
57 + return $paths;
58 +}
59 +add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_root_fields' );