Make WordPress Core


Ignore:
Timestamp:
11/17/2020 03:27:07 AM (4 years ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r49563 r49622  
    165165    $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
    166166
    167     if ( $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ), true ) ) {
     167    if (
     168        $permalink &&
     169        ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future', 'trash' ), true )
     170    ) {
    168171
    169172        $category = '';
     
    419422    if ( $parent && ! in_array( $parent->post_type, get_post_types(), true ) ) {
    420423        $parent = false;
    421     }
    422 
    423     if ( $parent ) {
    424         $parent_status_obj = get_post_status_object( get_post_status( $post->post_parent ) );
    425         if (
    426             ! is_post_type_viewable( get_post_type( $post->post_parent ) ) ||
    427             $parent_status_obj->internal ||
    428             $parent_status_obj->protected
    429         ) {
    430             $parent = false;
    431         }
    432424    }
    433425
Note: See TracChangeset for help on using the changeset viewer.