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 / experimental / dataform-inspector-preload.php

dataform-inspector-preload.php in Gutenberg 23.7.2, at lib/experimental/dataform-inspector-preload.php

28 lines 932 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Preload paths for the DataForm-based editor inspector experiment.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * Filters the block editor preload paths.
10 *
11 * @param array $paths REST API paths to preload.
12 * @param WP_Block_Editor_Context $context Block editor context.
13 * @return array Filtered preload paths.
14 */
15 function gutenberg_dataform_inspector_preload_paths( $paths, $context ) {
16 if ( 'core/edit-post' !== $context->name || ! isset( $context->post ) ) {
17 return $paths;
18 }
19
20 // `DataFormPostSummary` requests the post type form config through
21 // `useViewConfig` with `fields: [ 'form' ]`, so the preload path must
22 // match the resulting `_fields=form` REST API request.
23 $paths[] = '/wp/v2/view-config?kind=postType&name=' . $context->post->post_type . '&_fields=form';
24
25 return $paths;
26 }
27 add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_dataform_inspector_preload_paths', 10, 2 );
28