9
|
1 |
/** |
|
2 |
* @output wp-admin/js/set-post-thumbnail.js |
|
3 |
*/ |
|
4 |
|
16
|
5 |
/* global ajaxurl, post_id, alert */ |
5
|
6 |
/* exported WPSetAsThumbnail */ |
|
7 |
|
9
|
8 |
window.WPSetAsThumbnail = function( id, nonce ) { |
0
|
9 |
var $link = jQuery('a#wp-post-thumbnail-' + id); |
|
10 |
|
16
|
11 |
$link.text( wp.i18n.__( 'Saving…' ) ); |
0
|
12 |
jQuery.post(ajaxurl, { |
5
|
13 |
action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie ) |
0
|
14 |
}, function(str){ |
|
15 |
var win = window.dialogArguments || opener || parent || top; |
16
|
16 |
$link.text( wp.i18n.__( 'Use as featured image' ) ); |
0
|
17 |
if ( str == '0' ) { |
16
|
18 |
alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) ); |
0
|
19 |
} else { |
|
20 |
jQuery('a.wp-post-thumbnail').show(); |
16
|
21 |
$link.text( wp.i18n.__( 'Done' ) ); |
0
|
22 |
$link.fadeOut( 2000 ); |
|
23 |
win.WPSetThumbnailID(id); |
|
24 |
win.WPSetThumbnailHTML(str); |
|
25 |
} |
|
26 |
} |
|
27 |
); |
9
|
28 |
}; |