From 9a40ea033698ad2971c0f0a9167e61d2354e1dcd Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:05:40 +0100 Subject: [PATCH] Site Editor: preload settings requests (#66488) Co-authored-by: ellatrix Co-authored-by: Mamaduka --- backport-changelog/6.8/7687.md | 3 +++ lib/compat/wordpress-6.8/preload.php | 34 ++++++++++++++++++++++++++++ lib/load.php | 3 +++ packages/core-data/src/entities.js | 2 ++ 4 files changed, 42 insertions(+) create mode 100644 backport-changelog/6.8/7687.md create mode 100644 lib/compat/wordpress-6.8/preload.php diff --git a/backport-changelog/6.8/7687.md b/backport-changelog/6.8/7687.md new file mode 100644 index 00000000000000..f1505645df20c6 --- /dev/null +++ b/backport-changelog/6.8/7687.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/7687 + +* https://github.com/WordPress/gutenberg/pull/66488 diff --git a/lib/compat/wordpress-6.8/preload.php b/lib/compat/wordpress-6.8/preload.php new file mode 100644 index 00000000000000..5ba613e22033d4 --- /dev/null +++ b/lib/compat/wordpress-6.8/preload.php @@ -0,0 +1,34 @@ +name ) { + // Core already preloads both of these for `core/edit-post`. + $paths[] = '/wp/v2/settings'; + $paths[] = array( '/wp/v2/settings', 'OPTIONS' ); + $paths[] = '/?_fields=' . implode( + ',', + // @see packages/core-data/src/entities.js + array( + 'description', + 'gmt_offset', + 'home', + 'name', + 'site_icon', + 'site_icon_url', + 'site_logo', + 'timezone_string', + 'url', + ) + ); + } + return $paths; +} +add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_8', 10, 2 ); diff --git a/lib/load.php b/lib/load.php index 2c8a0fd0347c92..0540d4cd9efac7 100644 --- a/lib/load.php +++ b/lib/load.php @@ -116,6 +116,9 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/compat/wordpress-6.7/compat.php'; require __DIR__ . '/compat/wordpress-6.7/post-formats.php'; +// WordPress 6.8 compat. +require __DIR__ . '/compat/wordpress-6.8/preload.php'; + // Experimental features. require __DIR__ . '/experimental/block-editor-settings-mobile.php'; require __DIR__ . '/experimental/blocks.php'; diff --git a/packages/core-data/src/entities.js b/packages/core-data/src/entities.js index f73239e9afbbe5..3c10676750a2ab 100644 --- a/packages/core-data/src/entities.js +++ b/packages/core-data/src/entities.js @@ -20,6 +20,8 @@ export const rootEntitiesConfig = [ name: '__unstableBase', baseURL: '/', baseURLParams: { + // Please also change the preload path when changing this. + // @see lib/compat/wordpress-6.8/preload.php _fields: [ 'description', 'gmt_offset',