Canonical: redirect URLs that match an attachment masked on the wrong URL to the attachment link for the matched attachment.
Props solarissmoke. Fixes #19918. Built from https://develop.svn.wordpress.org/trunk@34272 git-svn-id: http://core.svn.wordpress.org/trunk@34236 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
48d402a395
commit
c2e1bab509
|
@ -150,9 +150,15 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
||||||
|
|
||||||
} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
|
} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
|
||||||
// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
|
// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
|
||||||
if ( is_attachment() && !empty($_GET['attachment_id']) && ! $redirect_url ) {
|
if ( is_attachment() && ! $redirect_url ) {
|
||||||
if ( $redirect_url = get_attachment_link(get_query_var('attachment_id')) )
|
if ( ! empty( $_GET['attachment_id'] ) ) {
|
||||||
$redirect['query'] = remove_query_arg('attachment_id', $redirect['query']);
|
$redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) );
|
||||||
|
if ( $redirect_url ) {
|
||||||
|
$redirect['query'] = remove_query_arg( 'attachment_id', $redirect['query'] );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$redirect_url = get_attachment_link();
|
||||||
|
}
|
||||||
} elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
|
} elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
|
||||||
if ( $redirect_url = get_permalink(get_query_var('p')) )
|
if ( $redirect_url = get_permalink(get_query_var('p')) )
|
||||||
$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
|
$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34271';
|
$wp_version = '4.4-alpha-34272';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue