Pass post id to get_upload_iframe_src() instead of relying on a global. Props tott. fixes #20003

git-svn-id: https://develop.svn.wordpress.org/trunk@19999 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2012-02-27 19:23:03 +00:00
parent b9736c98e6
commit 5648306064
2 changed files with 6 additions and 3 deletions

View File

@ -392,10 +392,13 @@ function _media_button($title, $icon, $type, $id) {
return "<a href='" . esc_url( get_upload_iframe_src($type) ) . "' id='{$id}-add_{$type}' class='thickbox add_$type' title='" . esc_attr( $title ) . "'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' onclick='return false;' /></a>";
}
function get_upload_iframe_src( $type = null ) {
function get_upload_iframe_src( $type = null, $post_id = null ) {
global $post_ID;
$uploading_iframe_ID = (int) $post_ID;
if ( empty( $post_id ) )
$post_id = $post_ID;
$uploading_iframe_ID = (int) $post_id;
$upload_iframe_src = add_query_arg( 'post_id', $uploading_iframe_ID, admin_url('media-upload.php') );
if ( $type && 'media' != $type )

View File

@ -1152,7 +1152,7 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) {
if ( empty( $post_id ) )
$post_id = $post_ID;
$set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="' . esc_url( get_upload_iframe_src('image') ) . '" id="set-post-thumbnail" class="thickbox">%s</a></p>';
$set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="' . esc_url( get_upload_iframe_src('image', $post_id) ) . '" id="set-post-thumbnail" class="thickbox">%s</a></p>';
$content = sprintf($set_thumbnail_link, esc_html__( 'Set featured image' ));
if ( $thumbnail_id && get_post( $thumbnail_id ) ) {