Ticket #17784: 17784.diff
| File 17784.diff, 1.8 KB (added by kawauso, 2 years ago) |
|---|
-
wp-admin/includes/media.php
1192 1192 $thumb_url = false; 1193 1193 1194 1194 $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; 1195 1200 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 ); 1197 1202 $args = wp_parse_args( $args, $default_args ); 1198 1203 $args = apply_filters( 'get_media_item_args', $args ); 1199 1204 extract( $args, EXTR_SKIP ); … … 1315 1320 } 1316 1321 1317 1322 $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 set1322 $calling_post_id = $post->post_parent;1323 1323 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 ) { 1324 1324 $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" ); 1325 1325 $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>";
