Skip to content
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

Site Editor: Fix template lookup preloading for non-draft pages #69400

Merged
merged 2 commits into from
Mar 4, 2025

Conversation

Mamaduka
Copy link
Member

@Mamaduka Mamaduka commented Mar 4, 2025

What?

Discovered while re-testing: WordPress/wordpress-develop#8441.

Fixes the slug for preloading page templates and adds a handler for draft pages.

Why?

The pages with draft status might not have a slug available; the client code handles this, but it was missing from the preloading logic.

Testing Instructions

  1. Open the published draft page in the Site Editor.
  2. The lookup endpoint should be correctly preloaded.

Testing Instructions for Keyboard

Same.

Screenshots or screencast

CleanShot 2025-03-04 at 11 19 57

@Mamaduka Mamaduka added [Type] Performance Related to performance efforts [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Mar 4, 2025
@Mamaduka Mamaduka self-assigned this Mar 4, 2025
@Mamaduka Mamaduka requested a review from spacedmonkey as a code owner March 4, 2025 07:16
Copy link

github-actions bot commented Mar 4, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mamaduka <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@@ -68,8 +68,8 @@ function gutenberg_block_editor_preload_paths_6_8( $paths, $context ) {
* See the call to `canUser()`, under `useGlobalStylesUserConfig()` in `packages/edit-site/src/components/use-global-styles-user-config/index.js`.
* Please ensure that the equivalent check is kept in sync with this preload path.
*/
$context = current_user_can( 'edit_theme_options' ) ? 'edit' : 'view';
$paths[] = "/wp/v2/global-styles/$global_styles_id?context=$context";
$rest_context = current_user_can( 'edit_theme_options' ) ? 'edit' : 'view';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoids overriding the $context argument.

@Mamaduka Mamaduka merged commit 6ec211a into trunk Mar 4, 2025
62 of 64 checks passed
@Mamaduka Mamaduka deleted the fix/site-editor-page-template-lookup branch March 4, 2025 17:03
@github-actions github-actions bot added this to the Gutenberg 20.5 milestone Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Performance Related to performance efforts
Projects
Development

Successfully merging this pull request may close these issues.

1 participant