2018-06-28 04:30:15 +02:00
|
|
|
/**
|
|
|
|
* @output wp-admin/js/set-post-thumbnail.js
|
|
|
|
*/
|
|
|
|
|
2013-11-15 06:12:09 +01:00
|
|
|
/* global setPostThumbnailL10n, ajaxurl, post_id, alert */
|
|
|
|
/* exported WPSetAsThumbnail */
|
|
|
|
|
2018-08-19 15:33:24 +02:00
|
|
|
window.WPSetAsThumbnail = function( id, nonce ) {
|
2012-08-23 02:04:18 +02:00
|
|
|
var $link = jQuery('a#wp-post-thumbnail-' + id);
|
|
|
|
|
|
|
|
$link.text( setPostThumbnailL10n.saving );
|
|
|
|
jQuery.post(ajaxurl, {
|
2013-11-15 06:12:09 +01:00
|
|
|
action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
|
2012-08-23 02:04:18 +02:00
|
|
|
}, function(str){
|
|
|
|
var win = window.dialogArguments || opener || parent || top;
|
2015-06-01 06:14:25 +02:00
|
|
|
$link.text( setPostThumbnailL10n.setThumbnail );
|
2012-08-23 02:04:18 +02:00
|
|
|
if ( str == '0' ) {
|
|
|
|
alert( setPostThumbnailL10n.error );
|
|
|
|
} else {
|
|
|
|
jQuery('a.wp-post-thumbnail').show();
|
|
|
|
$link.text( setPostThumbnailL10n.done );
|
|
|
|
$link.fadeOut( 2000 );
|
|
|
|
win.WPSetThumbnailID(id);
|
|
|
|
win.WPSetThumbnailHTML(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2018-08-19 15:33:24 +02:00
|
|
|
};
|