Ticket #20003: 20003.2.diff

File 20003.2.diff, 1.9 KB (added by ryan, 15 months ago)

Pass post id. Untested.

Line 
1Index: wp-admin/includes/ajax-actions.php
2===================================================================
3--- wp-admin/includes/ajax-actions.php  (revision 19891)
4+++ wp-admin/includes/ajax-actions.php  (working copy)
5@@ -1545,7 +1545,7 @@
6        }
7 
8        if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )
9-               wp_die( _wp_post_thumbnail_html( $thumbnail_id ) );
10+               wp_die( _wp_post_thumbnail_html( $thumbnail_id, $post_ID ) );
11        wp_die( 0 );
12 }
13 
14Index: wp-admin/includes/post.php
15===================================================================
16--- wp-admin/includes/post.php  (revision 19891)
17+++ wp-admin/includes/post.php  (working copy)
18@@ -1143,10 +1143,15 @@
19  * @since 2.9.0
20  *
21  * @param int $thumbnail_id ID of the attachment used for thumbnail
22+ * @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID
23  * @return string html
24  */
25-function _wp_post_thumbnail_html( $thumbnail_id = null ) {
26+function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) {
27        global $content_width, $_wp_additional_image_sizes, $post_ID;
28+
29+       if ( empty( $post_id ) )
30+               $post_id = $post_ID;
31+
32        $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>';
33        $content = sprintf($set_thumbnail_link, esc_html__( 'Set featured image' ));
34 
35@@ -1158,7 +1163,7 @@
36                else
37                        $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
38                if ( !empty( $thumbnail_html ) ) {
39-                       $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_ID" );
40+                       $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_id" );
41                        $content = sprintf($set_thumbnail_link, $thumbnail_html);
42                        $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>';
43                }