diff --git a/lib/compat/wordpress-6.2/site-editor.php b/lib/compat/wordpress-6.2/site-editor.php index b6246e49c6d11..37087fae3fb62 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 2cfde082554c4..0000000000000 --- 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 75d77f83b74fa..fb9da083390d4 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';