Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove broken site editor redirect #48283

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions lib/compat/wordpress-6.2/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,3 @@ 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 );
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ export default function useInitEditedEntityFromURL() {
useDispatch( editSiteStore );

useEffect( () => {
if (
postType &&
postId &&
// This is just a special case to support old WP versions that perform redirects.
// This code should be removed when we minimum WP version becomes 6.2.
postId !== 'none'
) {
if ( postType && postId ) {
switch ( postType ) {
case 'wp_template':
setTemplate( postId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ export function getPathFromURL( urlParams ) {
let path = urlParams?.path ?? '/';

// Compute the navigator path based on the URL params.
if (
urlParams?.postType &&
urlParams?.postId &&
// This is just a special case to support old WP versions that perform redirects.
// This code should be removed when we minimum WP version becomes 6.2.
urlParams?.postId !== 'none'
) {
if ( urlParams?.postType && urlParams?.postId ) {
switch ( urlParams.postType ) {
case 'wp_template':
case 'wp_template_part':
Expand Down