Changeset 50956 for trunk/src/wp-admin/edit-form-blocks.php
- Timestamp:
- 05/24/2021 07:31:49 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/edit-form-blocks.php
r50776 r50956 24 24 global $post_type, $post_type_object, $post, $title, $editor_styles, $wp_meta_boxes; 25 25 26 $editor_name = 'post-editor'; 26 $editor_name = 'post-editor'; 27 $block_editor_context = new WP_Block_Editor_Context( array( 'post' => $post ) ); 27 28 28 29 // Flag that we're loading the block editor. … … 59 60 ); 60 61 61 62 /** 63 * Preload common data by specifying an array of REST API paths that will be preloaded. 64 * 65 * Filters the array of paths that will be preloaded. 66 * 67 * @since 5.0.0 68 * 69 * @param string[] $preload_paths Array of paths to preload. 70 * @param WP_Post $post Post being edited. 71 */ 72 $preload_paths = apply_filters( 'block_editor_preload_paths', $preload_paths, $post ); 73 74 /* 75 * Ensure the global $post remains the same after API data is preloaded. 76 * Because API preloading can call the_content and other filters, plugins 77 * can unexpectedly modify $post. 78 */ 79 $backup_global_post = clone $post; 80 81 $preload_data = array_reduce( 82 $preload_paths, 83 'rest_preload_api_request', 84 array() 85 ); 86 87 // Restore the global $post as it was before API preloading. 88 $post = $backup_global_post; 89 90 wp_add_inline_script( 91 'wp-api-fetch', 92 sprintf( 'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );', wp_json_encode( $preload_data ) ), 93 'after' 94 ); 62 block_editor_rest_api_preload( $preload_paths, $block_editor_context ); 95 63 96 64 wp_add_inline_script(
Note: See TracChangeset
for help on using the changeset viewer.