-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect pre-13.7 Site Editor routes to
site.editor.php
- Loading branch information
1 parent
5d5e97a
commit fb817a7
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
lib/compat/wordpress-6.0/edit-site-routes-backwards-compat.php
This file contains 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,33 @@ | ||
<?php | ||
/** | ||
* Whitelists 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 new one. | ||
*/ | ||
|
||
/** | ||
* "Whitelists" the old routes. Without this, trying to access the old Site Editor | ||
* routes result in a HTTP 403 error. | ||
* | ||
* The whitelist 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( 'themes.php', null, null, 'edit_theme_options', 'gutenberg-edit-site', 'gutenberg_edit_site_page' ); | ||
} | ||
} | ||
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' ); | ||
} | ||
add_action( 'load-appearance_page_gutenberg-edit-site', 'gutenberg_redirect_deprecated_to_new_site_editor_page' ); |
This file contains 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