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: |
|
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:
- https://github.com/WordPress/wordpress-develop/blob/ed2f2ecd3fa043eca3a064a95fcb4830b5c0765c/src/wp-admin/includes/dashboard.php#L2118
- https://github.com/WordPress/wordpress-develop/blob/ed2f2ecd3fa043eca3a064a95fcb4830b5c0765c/src/wp-includes/post.php#L339-L345
- https://github.com/WordPress/wordpress-develop/blob/ed2f2ecd3fa043eca3a064a95fcb4830b5c0765c/src/wp-includes/post.php#L511-L517
Change History (5)
This ticket was mentioned in PR #8514 on WordPress/wordpress-develop by @sainathpoojary.
6 weeks ago
#1
- Keywords has-patch added
#2
@
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
@
6 weeks ago
@sainathpoojary
I’m unsure how I can reproduce this to test it.
Navigation:
- Access http://localhost:8889/wp-admin/edit.php?post_type=wp_navigation
- Check the link of the post title
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 );
- Then, access http://localhost:8889/wp-admin/edit.php?post_type=wp_template
- Check the link of the post title
#4
@
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
@
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.
Trac ticket: #63110