From fb817a7c9675983984276ff6a3f12144cf999a7d Mon Sep 17 00:00:00 2001 From: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com> Date: Fri, 22 Jul 2022 12:12:16 -0500 Subject: [PATCH 1/7] Redirect pre-13.7 Site Editor routes to `site.editor.php` --- .../edit-site-routes-backwards-compat.php | 33 +++++++++++++++++++ lib/load.php | 1 + 2 files changed, 34 insertions(+) create mode 100644 lib/compat/wordpress-6.0/edit-site-routes-backwards-compat.php diff --git a/lib/compat/wordpress-6.0/edit-site-routes-backwards-compat.php b/lib/compat/wordpress-6.0/edit-site-routes-backwards-compat.php new file mode 100644 index 00000000000000..ecaede27b8939c --- /dev/null +++ b/lib/compat/wordpress-6.0/edit-site-routes-backwards-compat.php @@ -0,0 +1,33 @@ + Date: Tue, 26 Jul 2022 10:14:05 +0300 Subject: [PATCH 2/7] move file to different compat folder --- .../edit-site-routes-backwards-compat.php | 23 +++++++++++++------ lib/load.php | 4 +++- 2 files changed, 19 insertions(+), 8 deletions(-) rename lib/compat/{wordpress-6.0 => plugin}/edit-site-routes-backwards-compat.php (66%) diff --git a/lib/compat/wordpress-6.0/edit-site-routes-backwards-compat.php b/lib/compat/plugin/edit-site-routes-backwards-compat.php similarity index 66% rename from lib/compat/wordpress-6.0/edit-site-routes-backwards-compat.php rename to lib/compat/plugin/edit-site-routes-backwards-compat.php index ecaede27b8939c..ac6e5c12e5066a 100644 --- a/lib/compat/wordpress-6.0/edit-site-routes-backwards-compat.php +++ b/lib/compat/plugin/edit-site-routes-backwards-compat.php @@ -1,5 +1,10 @@ Date: Tue, 26 Jul 2022 10:42:34 +0300 Subject: [PATCH 3/7] update file structure docs --- lib/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/README.md b/lib/README.md index 5636d17b286a82..bbce167c72d94c 100644 --- a/lib/README.md +++ b/lib/README.md @@ -18,12 +18,13 @@ structure for its PHP code: Core in the future X.Y release, or that were previously merged to Core in the X.Y release and remain in the plugin for backwards compatibility when running the plugin on older versions of WordPress. +- `lib/compat/plugin` - Features for backwards compatibility for the plugin consumers. These files don't need to be merged to Core and should have a timeline for when they should be removed from the plugin. ## Best practices ### Prefer the `wp` prefix -For features that may be merged to Core, it's best to use a `wp_` prefix for functions or a `WP_` prefix for classes. +For features that may be merged to Core, it's best to use a `wp_` prefix for functions or a `WP_` prefix for classes. This applies to both experimental and stable features. @@ -86,7 +87,7 @@ When writing new functions and classes, it's good practice to use `! function_ex If Core has defined a symbol once and then Gutenberg defines it a second time, fatal errors will occur. -Wrapping functions and classes avoids such errors if the feature is merged to Core. +Wrapping functions and classes avoids such errors if the feature is merged to Core. #### Good @@ -122,7 +123,7 @@ Furthermore, a quick codebase search will also help you know if your new method ### Note how your feature should look when merged to Core -Developers should write a brief note about how their feature should be merged to Core, for example, which Core file or function should be patched. +Developers should write a brief note about how their feature should be merged to Core, for example, which Core file or function should be patched. Notes can be included in the doc comment. @@ -133,7 +134,7 @@ This helps future developers know what to do when merging Gutenberg features int ```php /** * Returns a navigation object for the given slug. - * + * * Should live in `wp-includes/navigation.php` when merged to Core. * * @param string $slug From b28cb67986d09aedfa7c8f574184bc57de33b13f Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Tue, 26 Jul 2022 10:44:10 +0300 Subject: [PATCH 4/7] Update lib/compat/plugin/edit-site-routes-backwards-compat.php Co-authored-by: George Mamadashvili --- lib/compat/plugin/edit-site-routes-backwards-compat.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/compat/plugin/edit-site-routes-backwards-compat.php b/lib/compat/plugin/edit-site-routes-backwards-compat.php index ac6e5c12e5066a..d5aaeeca28118b 100644 --- a/lib/compat/plugin/edit-site-routes-backwards-compat.php +++ b/lib/compat/plugin/edit-site-routes-backwards-compat.php @@ -38,5 +38,6 @@ function gutenberg_site_editor_menu() { */ 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' ); From 7d9e93a198df79c5fa20e41fa97d4b69e006c833 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 26 Jul 2022 10:53:13 +0300 Subject: [PATCH 5/7] fix empty rendered menu item --- lib/compat/plugin/edit-site-routes-backwards-compat.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/compat/plugin/edit-site-routes-backwards-compat.php b/lib/compat/plugin/edit-site-routes-backwards-compat.php index d5aaeeca28118b..1635a45ac263e7 100644 --- a/lib/compat/plugin/edit-site-routes-backwards-compat.php +++ b/lib/compat/plugin/edit-site-routes-backwards-compat.php @@ -28,7 +28,7 @@ */ 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_submenu_page( null, null, null, 'edit_theme_options', 'gutenberg-edit-site', 'gutenberg_edit_site_page' ); } } add_action( 'admin_menu', 'gutenberg_site_editor_menu', 9 ); @@ -41,3 +41,4 @@ function gutenberg_redirect_deprecated_to_new_site_editor_page() { 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' ); From 75bb8dea7ca22fbbc97c38cdc25d6ebdf5e63c7c Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Tue, 26 Jul 2022 10:57:01 +0300 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Andrei Draganescu --- lib/compat/plugin/edit-site-routes-backwards-compat.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/compat/plugin/edit-site-routes-backwards-compat.php b/lib/compat/plugin/edit-site-routes-backwards-compat.php index 1635a45ac263e7..f322541db5bd8c 100644 --- a/lib/compat/plugin/edit-site-routes-backwards-compat.php +++ b/lib/compat/plugin/edit-site-routes-backwards-compat.php @@ -5,7 +5,7 @@ * to ensure that the plugin consumers have enough time to migrate to the core's * route (`site-editor.php`). * - * Whitelists the `theme.php` route and redirects the following routes: + * Allows the `theme.php` route and redirects the following routes: * - `themes.php?page=gutenberg-edit-site` * - `admin.php?page=gutenberg-edit-site` * @@ -21,10 +21,10 @@ */ /** - * "Whitelists" the old routes. Without this, trying to access the old Site Editor - * routes result in a HTTP 403 error. + * Allows the old routes. Without this, trying to access the old Site Editor + * routes results in a HTTP 403 error. * - * The whitelist is done by adding an wp-admin submenu page that won't be rendered. + * 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() ) { From c2fccd8d24ba4903e30c15677e27370fe8a1b97f Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Tue, 26 Jul 2022 11:01:01 +0300 Subject: [PATCH 7/7] Update lib/compat/plugin/edit-site-routes-backwards-compat.php Co-authored-by: George Mamadashvili --- lib/compat/plugin/edit-site-routes-backwards-compat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/plugin/edit-site-routes-backwards-compat.php b/lib/compat/plugin/edit-site-routes-backwards-compat.php index f322541db5bd8c..44574375050698 100644 --- a/lib/compat/plugin/edit-site-routes-backwards-compat.php +++ b/lib/compat/plugin/edit-site-routes-backwards-compat.php @@ -28,7 +28,7 @@ */ function gutenberg_site_editor_menu() { if ( wp_is_block_theme() ) { - add_submenu_page( null, null, null, 'edit_theme_options', 'gutenberg-edit-site', 'gutenberg_edit_site_page' ); + add_submenu_page( null, null, null, 'edit_theme_options', 'gutenberg-edit-site', '__return_empty_string' ); } } add_action( 'admin_menu', 'gutenberg_site_editor_menu', 9 );