[wp-trac] [WordPress Trac] #63110: Site Editor: Update old URLs to new path-based URLs
WordPress Trac
noreply at wordpress.org
Tue May 6 03:56:26 UTC 2025
#63110: Site Editor: Update old URLs to new path-based URLs
-------------------------------------------------+-------------------------
Reporter: wildworks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: good-first-bug has-patch changes- | Focuses:
requested |
-------------------------------------------------+-------------------------
Comment (by sainathpoojary):
Hey @wildworks,
I initially tried using urlencode( '/wp_navigation/%s' ), but that caused
issues when passed to sprintf(). The reason is that urlencode() outputs
%2F, and when % signs are present in the format string, sprintf() treats
them as format specifiers. So having %2F and %s in the same string led to
unexpected errors in `get_edit_post_link` function, since sprintf() tried
to interpret %2F as a format placeholder.
To fix this, I used str_replace( '/', '%%2F', '/wp_navigation/%s' ). This
escapes the % signs as %% so that sprintf() treats them as literal %,
resulting in proper URL-encoded slashes (%2F) in the final output, while
keeping %s intact for dynamic replacement.
Let me know if there’s a cleaner or preferred way to handle this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63110#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list