2018-06-27 22:30:15 -04:00
|
|
|
/**
|
|
|
|
* @output wp-admin/js/set-post-thumbnail.js
|
|
|
|
*/
|
|
|
|
|
2013-11-15 00:12:09 -05:00
|
|
|
/* global setPostThumbnailL10n, ajaxurl, post_id, alert */
|
|
|
|
/* exported WPSetAsThumbnail */
|
|
|
|
|
2018-08-19 09:33:24 -04:00
|
|
|
window.WPSetAsThumbnail = function( id, nonce ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
var $link = jQuery('a#wp-post-thumbnail-' + id);
|
|
|
|
|
|
|
|
$link.text( setPostThumbnailL10n.saving );
|
|
|
|
jQuery.post(ajaxurl, {
|
2013-11-15 00:12:09 -05:00
|
|
|
action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
|
2012-08-22 20:04:18 -04:00
|
|
|
}, function(str){
|
|
|
|
var win = window.dialogArguments || opener || parent || top;
|
2015-06-01 00:14:25 -04:00
|
|
|
$link.text( setPostThumbnailL10n.setThumbnail );
|
2012-08-22 20:04:18 -04: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 09:33:24 -04:00
|
|
|
};
|