Make WordPress Core


Ignore:
Timestamp:
02/10/2012 05:41:37 PM (13 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r19853 r19902  
    11441144 *
    11451145 * @param int $thumbnail_id ID of the attachment used for thumbnail
     1146 * @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID
    11461147 * @return string html
    11471148 */
    1148 function _wp_post_thumbnail_html( $thumbnail_id = null ) {
     1149function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) {
    11491150    global $content_width, $_wp_additional_image_sizes, $post_ID;
     1151
     1152    if ( empty( $post_id ) )
     1153        $post_id = $post_ID;
     1154
    11501155    $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>';
    11511156    $content = sprintf($set_thumbnail_link, esc_html__( 'Set featured image' ));
     
    11591164            $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
    11601165        if ( !empty( $thumbnail_html ) ) {
    1161             $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_ID" );
     1166            $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_id" );
    11621167            $content = sprintf($set_thumbnail_link, $thumbnail_html);
    11631168            $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>';
Note: See TracChangeset for help on using the changeset viewer.