-
Notifications
You must be signed in to change notification settings - Fork 3k
Editor: Update REST API preloaded paths for 6.8 #8441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor: Update REST API preloaded paths for 6.8 #8441
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
5f6cdf4
to
1b9b6c3
Compare
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mamaduka Left a few comments, but overall this looks right to me. Did a very quick performance check and can confirm that this seems to speed up the initial render of the site editor.
src/wp-admin/site-editor.php
Outdated
'/wp/v2/templates/lookup?slug=front-page', | ||
'/wp/v2/templates/lookup?slug=home', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #7695, these were only preloaded if not in the post context. Is the intention to load them always?
Sorry mate, I am a little unclear what you are asking here? Is it regarding the backport of the code you have left out for now? Presuming that's the case, I think it will need to be much the same code as both of the following URLs can be used for editing a page with the ID
The latter is used in the site editor. |
Sorry, @peterwilsoncc, that was the question. |
1b9b6c3
to
60c1caf
Compare
This should be ready for final review. |
$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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bf48f57
to
22329a9
Compare
Removed |
|
||
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 ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mamaduka probably not relevant, but just wanted to make it be sure: are we certain that the p
query var is safe? Asking as I don't see any escaping here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@audrasjb, that's a good question. I've not really explored that possibility, but I assumed it was safe because the pattern checks for numbers, and then the value is cast to an int
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's finally casted into an int
then we're all good :)
Combines the following core sync PRs: #7687 and #7695.
Gutenberg PRs:
Trac ticket: https://core.trac.wordpress.org/ticket/63050
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.