PluginProbe
Gutenberg / 23.7.2
Gutenberg v23.7.2
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / compat / plugin / edit-site-routes-backwards-compat.php

edit-site-routes-backwards-compat.php in Gutenberg 23.7.2, at lib/compat/plugin/edit-site-routes-backwards-compat.php

45 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Backwards compatibility handling for routes used by the plugin consumers.
4 * This doesn't need to be back ported to core and will be removed after WP 6.1,
5 * to ensure that the plugin consumers have enough time to migrate to the core's
6 * route (`site-editor.php`).
7 *
8 * Allows the `theme.php` route and redirects the following routes:
9 * - `themes.php?page=gutenberg-edit-site`
10 * - `admin.php?page=gutenberg-edit-site`
11 *
12 * To `site-editor.php`.
13 *
14 * The old routes have been deprecated and removed in Gutenberg 13.7.0, but third-party
15 * consumer code might still be referencing them. In order to not break the Site Editor
16 * flows, we don't fully remove the old routes, but redirect them to the core's one.
17 *
18 * @link https://github.com/WordPress/gutenberg/pull/41306
19 *
20 * @package gutenberg
21 */
22
23 /**
24 * Allows the old routes. Without this, trying to access the old Site Editor
25 * routes results in a HTTP 403 error.
26 *
27 * Allowing the route is done by adding an wp-admin submenu page that won't be rendered.
28 */
29 function gutenberg_site_editor_menu() {
30 if ( wp_is_block_theme() ) {
31 add_submenu_page( '', '', '', 'edit_theme_options', 'gutenberg-edit-site', '__return_empty_string' );
32 }
33 }
34 add_action( 'admin_menu', 'gutenberg_site_editor_menu', 9 );
35
36 /**
37 * Does the actual redirect to the new route upon triggering of the `load-appearance_page_gutenberg-edit-site` action.
38 */
39 function gutenberg_redirect_deprecated_to_new_site_editor_page() {
40 wp_safe_redirect( 'site-editor.php' );
41 exit;
42 }
43 add_action( 'load-appearance_page_gutenberg-edit-site', 'gutenberg_redirect_deprecated_to_new_site_editor_page' );
44 add_action( 'load-admin_page_gutenberg-edit-site', 'gutenberg_redirect_deprecated_to_new_site_editor_page' );
45