PluginProbe
Gutenberg / 23.7.2
Gutenberg v23.7.2
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 7.4.0 All 402 releases
gutenberg / lib / compat / wordpress-7.0 / preload.php

preload.php in Gutenberg 23.7.2, at lib/compat/wordpress-7.0/preload.php

29 lines 947 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Preload necessary resources for the editors.
5 *
6 * @param array $paths REST API paths to preload.
7 * @param WP_Block_Editor_Context $context Current block editor context
8 *
9 * @return array Filtered preload paths.
10 */
11 function gutenberg_block_editor_preload_paths_6_9( $paths, $context ) {
12 if ( 'core/edit-site' === $context->name ) {
13 // Only prefetch for the root. If we preload it for all pages and it's not used
14 // it won't be possible to invalidate.
15 // To do: perhaps purge all preloaded paths when client side navigating.
16 if ( isset( $_GET['p'] ) && '/' !== $_GET['p'] ) {
17 $paths = array_filter(
18 $paths,
19 static function ( $path ) {
20 return '/wp/v2/templates/lookup?slug=front-page' !== $path && '/wp/v2/templates/lookup?slug=home' !== $path;
21 }
22 );
23 }
24 }
25
26 return $paths;
27 }
28 add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_block_editor_preload_paths_6_9', 10, 2 );
29