5
|
1 |
/* global setPostThumbnailL10n, ajaxurl, post_id, alert */ |
|
2 |
/* exported WPSetAsThumbnail */ |
|
3 |
|
|
4 |
function WPSetAsThumbnail( id, nonce ) { |
0
|
5 |
var $link = jQuery('a#wp-post-thumbnail-' + id); |
|
6 |
|
|
7 |
$link.text( setPostThumbnailL10n.saving ); |
|
8 |
jQuery.post(ajaxurl, { |
5
|
9 |
action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie ) |
0
|
10 |
}, function(str){ |
|
11 |
var win = window.dialogArguments || opener || parent || top; |
|
12 |
$link.text( setPostThumbnailL10n.setThumbnail ); |
|
13 |
if ( str == '0' ) { |
|
14 |
alert( setPostThumbnailL10n.error ); |
|
15 |
} else { |
|
16 |
jQuery('a.wp-post-thumbnail').show(); |
|
17 |
$link.text( setPostThumbnailL10n.done ); |
|
18 |
$link.fadeOut( 2000 ); |
|
19 |
win.WPSetThumbnailID(id); |
|
20 |
win.WPSetThumbnailHTML(str); |
|
21 |
} |
|
22 |
} |
|
23 |
); |
|
24 |
} |