Command Palette: Proper handling of page/post links in all themes#53718
Merged
Command Palette: Proper handling of page/post links in all themes#53718
Conversation
|
Size Change: +20 B (0%) Total Size: 1.51 MB
ℹ️ View Unchanged
|
d05f4ee to
a294e1d
Compare
a294e1d to
a51f111
Compare
ntsekouras
approved these changes
Aug 21, 2023
Contributor
ntsekouras
left a comment
There was a problem hiding this comment.
Thank you! This LGTM!
Not related to this PR, when I tested with WP 6.2 the is_block_theme prop from useIsBlockBasedTheme hook is not present. It was added directly in core for 6.3. Since we support one more WP version though and we should add it in GB too. I've opened a PR for that.
|
Flaky tests detected in 9295a46. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5926204937
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Should be able to close #52154, #52847
Related to #53123
What?
This PR fixes the following two issues in the command palette:
In the classic theme and the hybrid theme, accessing a searched page would take you to the Site Editor which you do not have permission to access.
Screencast
1901407c5505b05e994882595b0f7ab5.mp4
In all themes, accessing a searched post takes you to a page where the Site Editor does not exist.
Screencast
fa4b34bf18b43350c6b5517e66c8fd14.mp4
Why?
For pages, you should go to the Pages menu in the Site Editor for block themes and to the normal edit page for non-block themes.
For posts, you should go to the normal edit page regardless of the theme type, as it is not currently implemented in the Site Editor.
How?
These commands are controlled by the
getNavigationCommandLoaderPerPostType()function. This function handles all posts, pages, templates, and template parts, and therefore contains various conditions based on post type.I have split it into two functions to simplify the process:
getNavigationCommandLoaderPerPostType(): commands for posts and pagesgetNavigationCommandLoaderPerTemplate(): commands for templates and template partsAnd in each of these functions, I added processing according to the theme type.
Testing Instructions
Go to
localhost:8889/wp-admin, open the Command Palette in each theme, and check the following:Block Theme (Twenty Twenty Three)
hello: should move to the edit post pageprivacy: should move to the edit page of the Site Editor404: should move to the template page of the Site Editorheader: should move to the template part page of the Site EditorHybrid Theme (Emptyhybrid)
hello: should move to the edit post pageprivacy: should move to the edit post page404: the command results should not be displayedheader: should move to the template part of the Site EditorClassic Theme (Twenty Twenty One)
hello: should move to the edit post pageprivacy: should move to the edit post page404: the command results should not be displayedheader: the command results should not be displayed