Make WordPress Core

Changeset 19902


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

Location:
trunk/wp-admin/includes
Files:
2 edited

Legend:

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

    r19897 r19902  
    15721572    if ( $thumbnail_id == '-1' ) {
    15731573        if ( delete_post_thumbnail( $post_ID ) )
    1574             wp_die( _wp_post_thumbnail_html() );
     1574            wp_die( _wp_post_thumbnail_html( null, $post_ID ) );
    15751575        else
    15761576            wp_die( 0 );
     
    15781578
    15791579    if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )
    1580         wp_die( _wp_post_thumbnail_html( $thumbnail_id ) );
     1580        wp_die( _wp_post_thumbnail_html( $thumbnail_id, $post_ID ) );
    15811581    wp_die( 0 );
    15821582}
  • 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.