-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Redirect old theme_page Site Editor routes to the new site-editor.php page
#42643
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
Merged
ntsekouras
merged 7 commits into
trunk
from
add/backwards-compatibility-to-site-editor-routes
Jul 26, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fb817a7
Redirect pre-13.7 Site Editor routes to `site.editor.php`
fullofcaffeine 0b817d1
move file to different compat folder
ntsekouras 236765d
update file structure docs
ntsekouras b28cb67
Update lib/compat/plugin/edit-site-routes-backwards-compat.php
ntsekouras 7d9e93a
fix empty rendered menu item
ntsekouras 75bb8de
Apply suggestions from code review
ntsekouras c2fccd8
Update lib/compat/plugin/edit-site-routes-backwards-compat.php
ntsekouras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <?php | ||
| /** | ||
| * Backwards compatibility handling for routes used by the plugin consumers. | ||
| * This doesn't need to be back ported to core and will be removed after WP 6.1, | ||
| * to ensure that the plugin consumers have enough time to migrate to the core's | ||
| * route (`site-editor.php`). | ||
| * | ||
| * Allows the `theme.php` route and redirects the following routes: | ||
| * - `themes.php?page=gutenberg-edit-site` | ||
| * - `admin.php?page=gutenberg-edit-site` | ||
| * | ||
| * To `site-editor.php`. | ||
| * | ||
| * The old routes have been deprecated and removed in Gutenberg 13.7.0, but third-party | ||
| * consumer code might still be referencing them. In order to not break the Site Editor | ||
| * flows, we don't fully remove the old routes, but redirect them to the core's one. | ||
| * | ||
| * @see https://github.com/WordPress/gutenberg/pull/41306 | ||
| * | ||
| * @package gutenberg | ||
| */ | ||
|
|
||
| /** | ||
| * Allows the old routes. Without this, trying to access the old Site Editor | ||
| * routes results in a HTTP 403 error. | ||
| * | ||
| * Allowing the route is done by adding an wp-admin submenu page that won't be rendered. | ||
| */ | ||
| function gutenberg_site_editor_menu() { | ||
| if ( wp_is_block_theme() ) { | ||
| add_submenu_page( null, null, null, 'edit_theme_options', 'gutenberg-edit-site', '__return_empty_string' ); | ||
| } | ||
| } | ||
| add_action( 'admin_menu', 'gutenberg_site_editor_menu', 9 ); | ||
|
|
||
| /** | ||
| * Does the actual redirect to the new route upon triggering of the `load-appearance_page_gutenberg-edit-site` action. | ||
| */ | ||
| function gutenberg_redirect_deprecated_to_new_site_editor_page() { | ||
| wp_safe_redirect( 'site-editor.php' ); | ||
| exit; | ||
| } | ||
| add_action( 'load-appearance_page_gutenberg-edit-site', 'gutenberg_redirect_deprecated_to_new_site_editor_page' ); | ||
| add_action( 'load-admin_page_gutenberg-edit-site', 'gutenberg_redirect_deprecated_to_new_site_editor_page' ); | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.