$calling_post_id = 0;
if ( isset( $_GET['post_id'
] ) ) { $calling_post_id =
absint( $_GET['post_id'
] );
} elseif ( isset( $_POST ) &&
count( $_POST ) ) {// Like for async-upload where $_GET['post_id'] isn't set.
$calling_post_id =
$post->post_parent;
} if ( 'image' ===
$type &&
$calling_post_id &&
current_theme_supports( 'post-thumbnails',
get_post_type( $calling_post_id ) ) &&
post_type_supports( get_post_type( $calling_post_id ), 'thumbnail'
) &&
get_post_thumbnail_id( $calling_post_id ) !=
$attachment_id ) { $calling_post =
get_post( $calling_post_id );
$calling_post_type_object =
get_post_type_object( $calling_post->post_type
);
$ajax_nonce =
wp_create_nonce( "set_post_thumbnail-
$calling_post_id"
);
$thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" .
$attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"
$attachment_id\", \"
$ajax_nonce\");return false;'>" .
esc_html( $calling_post_type_object->labels->use_featured_image
) . '</a>';
} if ( ( $parsed_args['send'
] ||
$thumbnail ||
$delete ) && !
isset( $form_fields['buttons'
] ) ) { $form_fields['buttons'
] = array
( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>" .
$parsed_args['send'
] . "
$thumbnail $delete</td></tr>\n"
);
}