[wp-trac] [WordPress Trac] #35561: function wp_admin_canonical_url() not using configured site url when constructing canonical url link tag
WordPress Trac
noreply at wordpress.org
Tue Apr 23 13:31:11 UTC 2024
#35561: function wp_admin_canonical_url() not using configured site url when
constructing canonical url link tag
-------------------------------------------------+-------------------------
Reporter: ilude | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Administration | Version: 4.4.1
Severity: normal | Resolution:
Keywords: reporter-feedback dev-feedback has- | Focuses:
patch | administration
-------------------------------------------------+-------------------------
Comment (by jefferyto):
For those using WordPress 6.5 or newer, adding something like this to your
theme should work around this issue:
{{{#!php
<?php
function trac35561_wp_admin_canonical_url( $filtered_url ) {
$removable_query_args = wp_removable_query_args();
if ( ! empty( $removable_query_args ) ) {
$current_url = admin_url( preg_replace( '#^[^?]*/wp-
admin/#i', '', $_SERVER['REQUEST_URI'] ) );
$filtered_url = remove_query_arg( $removable_query_args,
$current_url );
}
return $filtered_url;
}
add_filter( 'wp_admin_canonical_url', 'trac35561_wp_admin_canonical_url'
);
}}}
If this works for you, please leave a comment on this ticket so that the
developers will know this issue continues to exist.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35561#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list