Skip to content

Commit

Permalink
Remove broken site editor redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Feb 27, 2023
1 parent 88e3406 commit 29b1bbd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 35 deletions.
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

0 comments on commit 29b1bbd

Please sign in to comment.