From 1e749f0585dcbdacc433288c8ad0e8475ee55617 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 13 Feb 2023 13:51:48 +0100 Subject: [PATCH] Move 6.2 specific code to the right place (#48023) --- lib/compat/wordpress-6.2/site-editor.php | 21 ++++++++++++++++++ lib/compat/wordpress-6.3/site-editor.php | 27 ------------------------ lib/load.php | 3 --- 3 files changed, 21 insertions(+), 30 deletions(-) delete mode 100644 lib/compat/wordpress-6.3/site-editor.php diff --git a/lib/compat/wordpress-6.2/site-editor.php b/lib/compat/wordpress-6.2/site-editor.php index b6246e49c6d113..37087fae3fb62c 100644 --- a/lib/compat/wordpress-6.2/site-editor.php +++ b/lib/compat/wordpress-6.2/site-editor.php @@ -22,3 +22,24 @@ function gutenberg_site_editor_unset_homepage_setting( $settings, $context ) { return $settings; } add_filter( 'block_editor_settings_all', 'gutenberg_site_editor_unset_homepage_setting', 10, 2 ); + +/** + * Overrides the site editor initialization for WordPress 6.2 and cancels the redirection. + * The logic of this function is not important, we just need to remove the redirection from core. + * + * @param string $location Location. + * + * @return string Updated location. + */ +function gutenberg_prevent_site_editor_redirection( $location ) { + if ( strpos( $location, 'site-editor.php' ) !== false && strpos( $location, '?' ) !== false ) { + return add_query_arg( + array( 'postId' => 'none' ), + admin_url( 'site-editor.php' ) + ); + } + + return $location; +} + +add_filter( 'wp_redirect', 'gutenberg_prevent_site_editor_redirection', 1 ); diff --git a/lib/compat/wordpress-6.3/site-editor.php b/lib/compat/wordpress-6.3/site-editor.php deleted file mode 100644 index 2cfde082554c4e..00000000000000 --- a/lib/compat/wordpress-6.3/site-editor.php +++ /dev/null @@ -1,27 +0,0 @@ - 'none' ), - admin_url( 'site-editor.php' ) - ); - } - - return $location; -} - -add_filter( 'wp_redirect', 'gutenberg_prevent_site_editor_redirection', 1 ); diff --git a/lib/load.php b/lib/load.php index 75d77f83b74fa9..fb9da083390d43 100644 --- a/lib/load.php +++ b/lib/load.php @@ -91,9 +91,6 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/compat/wordpress-6.2/theme.php'; require __DIR__ . '/compat/wordpress-6.2/widgets.php'; -// WordPress 6.3 compat. -require __DIR__ . '/compat/wordpress-6.3/site-editor.php'; - // Experimental features. remove_action( 'plugins_loaded', '_wp_theme_json_webfonts_handler' ); // Turns off WP 6.0's stopgap handler for Webfonts API. require __DIR__ . '/experimental/block-editor-settings-mobile.php';