Rewrite: Redirect attachment URLs when their slug changes.

Using the same logic that we use to redirect posts when their slug changes, we can provide the same functionality for attachments. Attachment pages are posts, too.

Props swissspdy.

Fixes #34043.



git-svn-id: https://develop.svn.wordpress.org/trunk@34685 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2015-09-29 04:57:02 +00:00
parent 0ab0525691
commit 070b65dcfc
4 changed files with 48 additions and 15 deletions
@@ -121,6 +121,19 @@ class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase {
wp_old_slug_redirect();
$this->assertNull( $this->old_slug_redirect_url );
$this->assertQueryTrue( 'is_attachment', 'is_singular', 'is_single' );
$old_permalink = get_attachment_link( $attachment_id );
wp_update_post( array(
'ID' => $attachment_id,
'post_name' => 'the-attachment',
) );
$permalink = user_trailingslashit( trailingslashit( get_permalink( $this->post_id ) ) . 'the-attachment' );
$this->go_to( $old_permalink );
wp_old_slug_redirect();
$this->assertEquals( $permalink, $this->old_slug_redirect_url );
}
public function test_old_slug_redirect_paged() {