2010-05-18 18:08:49 -04:00
|
|
|
function WPSetAsThumbnail(id, nonce){
|
2009-12-10 03:03:26 -05:00
|
|
|
var $link = jQuery('a#wp-post-thumbnail-' + id);
|
2009-10-26 14:02:44 -04:00
|
|
|
|
|
|
|
$link.text( setPostThumbnailL10n.saving );
|
2009-10-07 18:18:09 -04:00
|
|
|
jQuery.post(ajaxurl, {
|
2010-05-18 18:08:49 -04:00
|
|
|
action:"set-post-thumbnail", post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
|
2009-10-07 18:18:09 -04:00
|
|
|
}, function(str){
|
|
|
|
var win = window.dialogArguments || opener || parent || top;
|
2009-10-26 14:02:44 -04:00
|
|
|
$link.text( setPostThumbnailL10n.setThumbnail );
|
2009-10-07 18:18:09 -04:00
|
|
|
if ( str == '0' ) {
|
|
|
|
alert( setPostThumbnailL10n.error );
|
|
|
|
} else {
|
2009-10-26 14:02:44 -04:00
|
|
|
jQuery('a.wp-post-thumbnail').show();
|
2009-12-10 02:34:32 -05:00
|
|
|
$link.text( setPostThumbnailL10n.done );
|
|
|
|
$link.fadeOut( 2000 );
|
2009-10-07 18:18:09 -04:00
|
|
|
win.WPSetThumbnailID(id);
|
|
|
|
win.WPSetThumbnailHTML(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2009-10-26 14:02:44 -04:00
|
|
|
}
|