WordPress.org

Make WordPress Core

Ticket #17784: 17784.diff

File 17784.diff, 1.8 KB (added by kawauso, 7 years ago)
  • wp-admin/includes/media.php

     
    11921192                $thumb_url = false;
    11931193
    11941194        $post = get_post( $attachment_id );
     1195        $calling_post_id = 0;
     1196        if ( isset( $_GET['post_id'] ) )
     1197                $calling_post_id = absint( $_GET['post_id'] );
     1198        elseif ( ! empty( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set
     1199                $calling_post_id = $post->post_parent;
    11951200
    1196         $default_args = array( 'errors' => null, 'send' => $post->post_parent ? post_type_supports( get_post_type( $post->post_parent ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true );
     1201        $default_args = array( 'errors' => null, 'send' => $calling_post_id ? post_type_supports( get_post_type( $calling_post_id ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true );
    11971202        $args = wp_parse_args( $args, $default_args );
    11981203        $args = apply_filters( 'get_media_item_args', $args );
    11991204        extract( $args, EXTR_SKIP );
     
    13151320        }
    13161321
    13171322        $thumbnail = '';
    1318         $calling_post_id = 0;
    1319         if ( isset( $_GET['post_id'] ) )
    1320                 $calling_post_id = absint( $_GET['post_id'] );
    1321         elseif ( isset( $_POST ) && count( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set
    1322                 $calling_post_id = $post->post_parent;
    13231323        if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) {
    13241324                $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" );
    13251325                $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>";