equal
deleted
inserted
replaced
551 |
551 |
552 if ( is_attachment() && ! get_option( 'wp_attachment_pages_enabled' ) ) { |
552 if ( is_attachment() && ! get_option( 'wp_attachment_pages_enabled' ) ) { |
553 $attachment_id = get_query_var( 'attachment_id' ); |
553 $attachment_id = get_query_var( 'attachment_id' ); |
554 $attachment_post = get_post( $attachment_id ); |
554 $attachment_post = get_post( $attachment_id ); |
555 $attachment_parent_id = $attachment_post ? $attachment_post->post_parent : 0; |
555 $attachment_parent_id = $attachment_post ? $attachment_post->post_parent : 0; |
556 |
556 $attachment_url = wp_get_attachment_url( $attachment_id ); |
557 $attachment_url = wp_get_attachment_url( $attachment_id ); |
557 |
558 if ( $attachment_url !== $redirect_url ) { |
558 if ( $attachment_url !== $redirect_url ) { |
559 /* |
559 /* |
560 * If an attachment is attached to a post, it inherits the parent post's status. Fetch the |
560 * If an attachment is attached to a post, it inherits the parent post's status. |
561 * parent post to check its status later. |
561 * Fetch the parent post to check its status later. |
562 */ |
562 */ |
563 if ( $attachment_parent_id ) { |
563 if ( $attachment_parent_id ) { |
564 $redirect_obj = get_post( $attachment_parent_id ); |
564 $redirect_obj = get_post( $attachment_parent_id ); |
565 } |
565 } |
|
566 |
566 $redirect_url = $attachment_url; |
567 $redirect_url = $attachment_url; |
567 } |
568 } |
568 |
569 |
569 $is_attachment_redirect = true; |
570 $is_attachment_redirect = true; |
570 } |
571 } |