Add post ID argument to _wp_post_thumbnail_html() rather than relying on a global. Post the ID from wp_ajax_set_post_thumbnail(). Props batmoo. fixes #20003
git-svn-id: https://develop.svn.wordpress.org/trunk@19902 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
917a954113
commit
99c65753a4
@ -1571,13 +1571,13 @@ function wp_ajax_set_post_thumbnail() {
|
||||
|
||||
if ( $thumbnail_id == '-1' ) {
|
||||
if ( delete_post_thumbnail( $post_ID ) )
|
||||
wp_die( _wp_post_thumbnail_html() );
|
||||
wp_die( _wp_post_thumbnail_html( null, $post_ID ) );
|
||||
else
|
||||
wp_die( 0 );
|
||||
}
|
||||
|
||||
if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )
|
||||
wp_die( _wp_post_thumbnail_html( $thumbnail_id ) );
|
||||
wp_die( _wp_post_thumbnail_html( $thumbnail_id, $post_ID ) );
|
||||
wp_die( 0 );
|
||||
}
|
||||
|
||||
|
@ -1143,10 +1143,15 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param int $thumbnail_id ID of the attachment used for thumbnail
|
||||
* @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID
|
||||
* @return string html
|
||||
*/
|
||||
function _wp_post_thumbnail_html( $thumbnail_id = null ) {
|
||||
function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) {
|
||||
global $content_width, $_wp_additional_image_sizes, $post_ID;
|
||||
|
||||
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>';
|
||||
$content = sprintf($set_thumbnail_link, esc_html__( 'Set featured image' ));
|
||||
|
||||
@ -1158,7 +1163,7 @@ function _wp_post_thumbnail_html( $thumbnail_id = null ) {
|
||||
else
|
||||
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
|
||||
if ( !empty( $thumbnail_html ) ) {
|
||||
$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_ID" );
|
||||
$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_id" );
|
||||
$content = sprintf($set_thumbnail_link, $thumbnail_html);
|
||||
$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user