Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions lib/compat/wordpress-6.0/edit-form-blocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Patches preload paths for post editor.
*
* @package gutenberg
*/

/**
* Optimizes the preload paths registered in Core (`edit-form-blocks.php`).
*
* @param array $preload_paths Preload paths to be filtered.
* @return array
*/
function optimize_preload_paths( $preload_paths ) {
// remove preload of the `/` route.
$root_index = array_search( '/', $preload_paths, true );
if ( false !== $root_index ) {
array_splice( $preload_paths, $root_index, 1 );
}

// change `/types` context from `edit` to `view` (requested in `loadPostTypeEntities`).
$types_index = array_search( '/wp/v2/types?context=edit', $preload_paths, true );
if ( false !== $types_index ) {
$preload_paths[ $types_index ] = '/wp/v2/types?context=view';
}

// start preloading `/taxonomies` in `view` context (requested in `loadTaxonomyEntities`).
$tax_index = array_search( '/wp/v2/taxonomies?per_page=-1&context=edit', $preload_paths, true );
if ( false === $tax_index ) {
array_push( $preload_paths, '/wp/v2/taxonomies?context=view' );
} else {
$preload_paths[ $tax_index ] = '/wp/v2/taxonomies?context=view';
}

// start preloading `/settings`.
$settings_index = array_search( '/wp/v2/settings', $preload_paths, true );
if ( false === $settings_index ) {
array_push( $preload_paths, '/wp/v2/settings' );
}

// modify the preload of `/users/me` to match the real request.
foreach ( $preload_paths as $user_index => $user_path ) {
if ( 0 === strpos( $user_path, '/wp/v2/users/me' ) ) {
$preload_paths[ $user_index ] = '/wp/v2/users/me';
break;
}
}

return $preload_paths;
}

add_filter( 'block_editor_rest_api_preload_paths', 'optimize_preload_paths' );
5 changes: 2 additions & 3 deletions lib/full-site-editing/edit-site-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@ static function( $classes ) {
'preload_paths' => array_merge(
array(
array( '/wp/v2/media', 'OPTIONS' ),
'/',
'/wp/v2/types?context=edit',
'/wp/v2/types?context=view',
'/wp/v2/types/wp_template?context=edit',
'/wp/v2/types/wp_template-part?context=edit',
'/wp/v2/taxonomies?context=edit',
'/wp/v2/taxonomies?context=view',
'/wp/v2/pages?context=edit',
'/wp/v2/categories?context=edit',
'/wp/v2/posts?context=edit',
Expand Down
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.0/class-wp-webfonts-provider.php';
require __DIR__ . '/compat/wordpress-6.0/class-wp-webfonts-provider-local.php';
require __DIR__ . '/compat/wordpress-6.0/webfonts.php';
require __DIR__ . '/compat/wordpress-6.0/edit-form-blocks.php';
require __DIR__ . '/compat/experimental/blocks.php';

require __DIR__ . '/blocks.php';
Expand Down
13 changes: 13 additions & 0 deletions packages/core-data/src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ export const defaultEntities = [
name: '__unstableBase',
kind: 'root',
baseURL: '/',
baseURLParams: {
_fields: [
'description',
'gmt_offset',
'home',
'name',
'site_icon',
'site_icon_url',
'site_logo',
'timezone_string',
'url',
].join( ',' ),
},
},
{
label: __( 'Site' ),
Expand Down