Make WordPress Core

Opened 6 weeks ago

Last modified 6 weeks ago

#63110 new defect (bug)

Site Editor: Update old URLs to new path-based URLs

Reported by: wildworks's profile wildworks Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords: good-first-bug has-patch
Focuses: Cc:

Description

Related Gutenberg issue: https://github.com/WordPress/gutenberg/issues/69584

Currently, the site editor references the p GET parameter to determine which page to show. However, there are some URLs that use old parameters (postType, path, etc)

It would be good to update these URLs to avoid unnecessary URL redirection.

From what I can see, there are three codes that need to be updated:

Change History (5)

This ticket was mentioned in PR #8514 on WordPress/wordpress-develop by @sainathpoojary.


6 weeks ago
#1

  • Keywords has-patch added

Trac ticket: #63110

#2 @sainathpoojary
6 weeks ago

Hey @wildworks,

I have updated the URL for dashboard in the PR. However, the other two instances are related to register_post_type, where the URL is used for _edit_link, which is for internal use so I’m unsure how I can reproduce this to test it.

I converted the URL as per the `_wp_get_site_editor_redirection_url function, but I'm not sure if it's correct. Could you please have a look?

From:

	$navigation_post_edit_link = 'site-editor.php?' . build_query(
		array(
			'postId'   => '%s',
			'postType' => 'wp_navigation',
			'canvas'   => 'edit',
		)
	);
	$template_edit_link = 'site-editor.php?' . build_query(
		array(
			'postType' => '%s',
			'postId'   => '%s',
			'canvas'   => 'edit',
		)
	);

To:

	$navigation_post_edit_link = 'site-editor.php?' . build_query(
		array(
			'p' => '/wp_navigation/%s',
			'canvas' => 'edit',
		)
	);
	$template_edit_link = 'site-editor.php?' . build_query(
		array(
			'p' => '/wp_template/%s',
			'canvas'   => 'edit',
		)
	);

#3 @wildworks
6 weeks ago

@sainathpoojary

I’m unsure how I can reproduce this to test it.

Template

To access the post list, temporarily run the following hook:

add_filter( 'register_post_type_args', function( $args, $post_type ) {
	if ( $post_type === 'wp_template' ) {
		$args['show_ui'] = true;
	}
	return $args;
}, 10, 2 );

#4 @sainathpoojary
6 weeks ago

Hey @wildworks,

Thanks for the detailed guidance! I followed the steps to reproduce and test the URLs. Everything seems to be working as expected. I’ve updated the PR accordingly, and it’s now ready for review. Let me know if any further changes are needed.

#5 @wildworks
6 weeks ago

@sainathpoojary Thanks for submitting a patch!

I checked your PR, and it would be a good idea to encode slashes (/) in the get parameter to %2F.

P.S. Gutenberg's JS utility (addQueryArgs()) automatically encodes URLs so no explicit encoding is needed. On the other hand, I think we would need explicit encoding in PHP.

Note: See TracTickets for help on using tickets.