wp/wp-admin/js/set-post-thumbnail.js
author ymh <ymh.work@gmail.com>
Tue, 15 Dec 2020 13:49:49 +0100
changeset 16 a86126ab1dd4
parent 9 177826044cd9
permissions -rw-r--r--
update enmi-conf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     1
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     2
 * @output wp-admin/js/set-post-thumbnail.js
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     3
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     4
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
     5
/* global ajaxurl, post_id, alert */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     6
/* exported WPSetAsThumbnail */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     7
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     8
window.WPSetAsThumbnail = function( id, nonce ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
	var $link = jQuery('a#wp-post-thumbnail-' + id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    11
	$link.text( wp.i18n.__( 'Saving…' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
	jQuery.post(ajaxurl, {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    13
		action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	}, function(str){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
		var win = window.dialogArguments || opener || parent || top;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    16
		$link.text( wp.i18n.__( 'Use as featured image' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
		if ( str == '0' ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    18
			alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
			jQuery('a.wp-post-thumbnail').show();
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    21
			$link.text( wp.i18n.__( 'Done' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
			$link.fadeOut( 2000 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
			win.WPSetThumbnailID(id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
			win.WPSetThumbnailHTML(str);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
	);
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    28
};