Permalinks: Prevent attachment pages 404ing following [49563].
This largely reverts [49563] due to attachment pages returning 404: File not found errors when they use the `inherit` status. Permalink changes to attachment pages are retained when they are descendants of trashed or deleted posts. Props Toro_Unit, helen, johnbillion, peterwilsoncc. Fixes #51776. See #5272. Built from https://develop.svn.wordpress.org/trunk@49622 git-svn-id: http://core.svn.wordpress.org/trunk@49360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -164,7 +164,10 @@ function get_permalink( $post = 0, $leavename = false ) {
|
||||
*/
|
||||
$permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
|
||||
|
||||
if ( $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ), true ) ) {
|
||||
if (
|
||||
$permalink &&
|
||||
! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future', 'trash' ), true )
|
||||
) {
|
||||
|
||||
$category = '';
|
||||
if ( strpos( $permalink, '%category%' ) !== false ) {
|
||||
@@ -420,17 +423,6 @@ function get_attachment_link( $post = null, $leavename = false ) {
|
||||
$parent = false;
|
||||
}
|
||||
|
||||
if ( $parent ) {
|
||||
$parent_status_obj = get_post_status_object( get_post_status( $post->post_parent ) );
|
||||
if (
|
||||
! is_post_type_viewable( get_post_type( $post->post_parent ) ) ||
|
||||
$parent_status_obj->internal ||
|
||||
$parent_status_obj->protected
|
||||
) {
|
||||
$parent = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $wp_rewrite->using_permalinks() && $parent ) {
|
||||
if ( 'page' === $parent->post_type ) {
|
||||
$parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front.
|
||||
|
||||
Reference in New Issue
Block a user