mirror of
git://develop.git.wordpress.org/
synced 2025-03-22 21:09:51 +01:00
Editor: Update preload paths for post and site editor.
Some checks are pending
Cleanup Pull Requests / Clean up pull requests (push) Waiting to run
Coding Standards / PHP coding standards (push) Waiting to run
Coding Standards / JavaScript coding standards (push) Waiting to run
Coding Standards / Slack Notifications (push) Blocked by required conditions
Coding Standards / Failed workflow tasks (push) Blocked by required conditions
End-to-end Tests / Test with SCRIPT_DEBUG disabled (push) Waiting to run
End-to-end Tests / Test with SCRIPT_DEBUG enabled (push) Waiting to run
End-to-end Tests / Slack Notifications (push) Blocked by required conditions
End-to-end Tests / Failed workflow tasks (push) Blocked by required conditions
JavaScript Tests / QUnit Tests (push) Waiting to run
JavaScript Tests / Slack Notifications (push) Blocked by required conditions
JavaScript Tests / Failed workflow tasks (push) Blocked by required conditions
Performance Tests / Determine Matrix (push) Waiting to run
Performance Tests / ${{ matrix.multisite && 'Multisite' || 'Single Site' }} ${{ matrix.memcached && 'Memcached' || 'Default' }} (push) Blocked by required conditions
Performance Tests / Compare (push) Blocked by required conditions
Performance Tests / Slack Notifications (push) Blocked by required conditions
Performance Tests / Failed workflow tasks (push) Blocked by required conditions
PHP Compatibility / Check PHP compatibility (push) Waiting to run
PHP Compatibility / Slack Notifications (push) Blocked by required conditions
PHP Compatibility / Failed workflow tasks (push) Blocked by required conditions
PHPUnit Tests / PHP 7.2 (push) Waiting to run
PHPUnit Tests / PHP 7.3 (push) Waiting to run
PHPUnit Tests / PHP 7.4 (push) Waiting to run
PHPUnit Tests / PHP 8.0 (push) Waiting to run
PHPUnit Tests / PHP 8.1 (push) Waiting to run
PHPUnit Tests / PHP 8.2 (push) Waiting to run
PHPUnit Tests / PHP 8.3 (push) Waiting to run
PHPUnit Tests / PHP 8.4 (push) Waiting to run
PHPUnit Tests / html-api-html5lib-tests (push) Waiting to run
PHPUnit Tests / Slack Notifications (push) Blocked by required conditions
PHPUnit Tests / Failed workflow tasks (push) Blocked by required conditions
Test Build Processes / Core running from build (push) Waiting to run
Test Build Processes / Core running from src (push) Waiting to run
Test Build Processes / Gutenberg running from build (push) Waiting to run
Test Build Processes / Gutenberg running from src (push) Waiting to run
Test Build Processes / Slack Notifications (push) Blocked by required conditions
Test Build Processes / Failed workflow tasks (push) Blocked by required conditions
Upgrade Develop Version Tests / Build (push) Waiting to run
Upgrade Develop Version Tests / Upgrade from 4.9 (push) Blocked by required conditions
Upgrade Develop Version Tests / Upgrade from 6.5 (push) Blocked by required conditions
Upgrade Develop Version Tests / Upgrade from 6.6 (push) Blocked by required conditions
Upgrade Develop Version Tests / Upgrade from 6.7 (push) Blocked by required conditions
Upgrade Develop Version Tests / Slack Notifications (push) Blocked by required conditions
Upgrade Develop Version Tests / Failed workflow tasks (push) Blocked by required conditions
Some checks are pending
Cleanup Pull Requests / Clean up pull requests (push) Waiting to run
Coding Standards / PHP coding standards (push) Waiting to run
Coding Standards / JavaScript coding standards (push) Waiting to run
Coding Standards / Slack Notifications (push) Blocked by required conditions
Coding Standards / Failed workflow tasks (push) Blocked by required conditions
End-to-end Tests / Test with SCRIPT_DEBUG disabled (push) Waiting to run
End-to-end Tests / Test with SCRIPT_DEBUG enabled (push) Waiting to run
End-to-end Tests / Slack Notifications (push) Blocked by required conditions
End-to-end Tests / Failed workflow tasks (push) Blocked by required conditions
JavaScript Tests / QUnit Tests (push) Waiting to run
JavaScript Tests / Slack Notifications (push) Blocked by required conditions
JavaScript Tests / Failed workflow tasks (push) Blocked by required conditions
Performance Tests / Determine Matrix (push) Waiting to run
Performance Tests / ${{ matrix.multisite && 'Multisite' || 'Single Site' }} ${{ matrix.memcached && 'Memcached' || 'Default' }} (push) Blocked by required conditions
Performance Tests / Compare (push) Blocked by required conditions
Performance Tests / Slack Notifications (push) Blocked by required conditions
Performance Tests / Failed workflow tasks (push) Blocked by required conditions
PHP Compatibility / Check PHP compatibility (push) Waiting to run
PHP Compatibility / Slack Notifications (push) Blocked by required conditions
PHP Compatibility / Failed workflow tasks (push) Blocked by required conditions
PHPUnit Tests / PHP 7.2 (push) Waiting to run
PHPUnit Tests / PHP 7.3 (push) Waiting to run
PHPUnit Tests / PHP 7.4 (push) Waiting to run
PHPUnit Tests / PHP 8.0 (push) Waiting to run
PHPUnit Tests / PHP 8.1 (push) Waiting to run
PHPUnit Tests / PHP 8.2 (push) Waiting to run
PHPUnit Tests / PHP 8.3 (push) Waiting to run
PHPUnit Tests / PHP 8.4 (push) Waiting to run
PHPUnit Tests / html-api-html5lib-tests (push) Waiting to run
PHPUnit Tests / Slack Notifications (push) Blocked by required conditions
PHPUnit Tests / Failed workflow tasks (push) Blocked by required conditions
Test Build Processes / Core running from build (push) Waiting to run
Test Build Processes / Core running from src (push) Waiting to run
Test Build Processes / Gutenberg running from build (push) Waiting to run
Test Build Processes / Gutenberg running from src (push) Waiting to run
Test Build Processes / Slack Notifications (push) Blocked by required conditions
Test Build Processes / Failed workflow tasks (push) Blocked by required conditions
Upgrade Develop Version Tests / Build (push) Waiting to run
Upgrade Develop Version Tests / Upgrade from 4.9 (push) Blocked by required conditions
Upgrade Develop Version Tests / Upgrade from 6.5 (push) Blocked by required conditions
Upgrade Develop Version Tests / Upgrade from 6.6 (push) Blocked by required conditions
Upgrade Develop Version Tests / Upgrade from 6.7 (push) Blocked by required conditions
Upgrade Develop Version Tests / Slack Notifications (push) Blocked by required conditions
Upgrade Develop Version Tests / Failed workflow tasks (push) Blocked by required conditions
Preloading all blocking requests ensures that the editor canvas becomes responsive quickly and that the browser avoids unnecessary client-side requests. Props mamaduka, joemcgill, audrasjb, peterwilsoncc. Fixes #63050. git-svn-id: https://develop.svn.wordpress.org/trunk@59958 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f01ff83ac3
commit
75960402f0
@ -53,6 +53,10 @@ $rest_path = rest_get_route_for_post( $post );
|
||||
|
||||
$active_theme = get_stylesheet();
|
||||
$global_styles_endpoint_context = current_user_can( 'edit_theme_options' ) ? 'edit' : 'view';
|
||||
$template_lookup_slug = 'page' === $post->post_type ? 'page' : 'single-' . $post->post_type;
|
||||
if ( ! empty( $post->post_name ) ) {
|
||||
$template_lookup_slug .= '-' . $post->post_name;
|
||||
}
|
||||
// Preload common data.
|
||||
$preload_paths = array(
|
||||
'/wp/v2/types?context=view',
|
||||
@ -79,6 +83,32 @@ $preload_paths = array(
|
||||
* Please ensure that the equivalent check is kept in sync with this preload path.
|
||||
*/
|
||||
'/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=' . $global_styles_endpoint_context,
|
||||
// Used by getBlockPatternCategories in useBlockEditorSettings.
|
||||
'/wp/v2/block-patterns/categories',
|
||||
// @see packages/core-data/src/entities.js
|
||||
'/?_fields=' . implode(
|
||||
',',
|
||||
array(
|
||||
'description',
|
||||
'gmt_offset',
|
||||
'home',
|
||||
'name',
|
||||
'site_icon',
|
||||
'site_icon_url',
|
||||
'site_logo',
|
||||
'timezone_string',
|
||||
'url',
|
||||
'page_for_posts',
|
||||
'page_on_front',
|
||||
'show_on_front',
|
||||
)
|
||||
),
|
||||
$paths[] = add_query_arg(
|
||||
'slug',
|
||||
// @see https://github.com/WordPress/gutenberg/blob/e093fefd041eb6cc4a4e7f67b92ab54fd75c8858/packages/core-data/src/private-selectors.ts#L244-L254
|
||||
$template_lookup_slug,
|
||||
'/wp/v2/templates/lookup'
|
||||
),
|
||||
);
|
||||
|
||||
block_editor_rest_api_preload( $preload_paths, $block_editor_context );
|
||||
|
@ -139,7 +139,15 @@ foreach ( get_default_block_template_types() as $slug => $template_type ) {
|
||||
$indexed_template_types[] = $template_type;
|
||||
}
|
||||
|
||||
$block_editor_context = new WP_Block_Editor_Context( array( 'name' => 'core/edit-site' ) );
|
||||
$context_settings = array( 'name' => 'core/edit-site' );
|
||||
|
||||
if ( ! empty( $_GET['postId'] ) && is_numeric( $_GET['postId'] ) ) {
|
||||
$context_settings['post'] = get_post( (int) $_GET['postId'] );
|
||||
} elseif ( isset( $_GET['p'] ) && preg_match( '/^\/page\/(\d+)$/', $_GET['p'], $matches ) ) {
|
||||
$context_settings['post'] = get_post( (int) $matches[1] );
|
||||
}
|
||||
|
||||
$block_editor_context = new WP_Block_Editor_Context( $context_settings );
|
||||
$custom_settings = array(
|
||||
'siteUrl' => site_url(),
|
||||
'postsPerPage' => get_option( 'posts_per_page' ),
|
||||
@ -199,8 +207,48 @@ $preload_paths = array(
|
||||
),
|
||||
'GET',
|
||||
),
|
||||
'/wp/v2/settings',
|
||||
array( '/wp/v2/settings', 'OPTIONS' ),
|
||||
// Used by getBlockPatternCategories in useBlockEditorSettings.
|
||||
'/wp/v2/block-patterns/categories',
|
||||
// @see packages/core-data/src/entities.js
|
||||
'/?_fields=' . implode(
|
||||
',',
|
||||
array(
|
||||
'description',
|
||||
'gmt_offset',
|
||||
'home',
|
||||
'name',
|
||||
'site_icon',
|
||||
'site_icon_url',
|
||||
'site_logo',
|
||||
'timezone_string',
|
||||
'url',
|
||||
'page_for_posts',
|
||||
'page_on_front',
|
||||
'show_on_front',
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
if ( $block_editor_context->post ) {
|
||||
$route_for_post = rest_get_route_for_post( $block_editor_context->post );
|
||||
if ( $route_for_post ) {
|
||||
$preload_paths[] = add_query_arg( 'context', 'edit', $route_for_post );
|
||||
if ( 'page' === $block_editor_context->post->post_type ) {
|
||||
$preload_paths[] = add_query_arg(
|
||||
'slug',
|
||||
// @see https://github.com/WordPress/gutenberg/blob/e093fefd041eb6cc4a4e7f67b92ab54fd75c8858/packages/core-data/src/private-selectors.ts#L244-L254
|
||||
empty( $block_editor_context->post->post_name ) ? 'page' : 'page-' . $post->post_name,
|
||||
'/wp/v2/templates/lookup'
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$preload_paths[] = '/wp/v2/templates/lookup?slug=front-page';
|
||||
$preload_paths[] = '/wp/v2/templates/lookup?slug=home';
|
||||
}
|
||||
|
||||
block_editor_rest_api_preload( $preload_paths, $block_editor_context );
|
||||
|
||||
wp_add_inline_script(
|
||||
|
Loading…
x
Reference in New Issue
Block a user