Commit 7a7f302c77 for wordpress.org

commit 7a7f302c775e6e6b65cde8d627d1903cf8c0aa31
Author: lancewillett <lancewillett@git.wordpress.org>
Date:   Tue Dec 1 21:24:50 2026 +0000

    Build/Test Tools: Type-check the featured image AJAX handler.

    Developed in: https://github.com/WordPress/wordpress-develop/pull/16349

    Props shailu25, mukesh27.
    See #66751.

    Built from https://develop.svn.wordpress.org/trunk@65856


    git-svn-id: http://core.svn.wordpress.org/trunk@64885 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-admin/js/set-post-thumbnail.js b/wp-admin/js/set-post-thumbnail.js
index 5f5f565564..72b4ee2610 100644
--- a/wp-admin/js/set-post-thumbnail.js
+++ b/wp-admin/js/set-post-thumbnail.js
@@ -5,24 +5,50 @@
 /* global ajaxurl, post_id, alert */
 /* exported WPSetAsThumbnail */

+/**
+ * Sets the selected attachment as the post's featured image via AJAX.
+ *
+ * @param {string|number} id    Attachment ID.
+ * @param {string}        nonce Security nonce.
+ */
 window.WPSetAsThumbnail = function( id, nonce ) {
-	var $link = jQuery('a#wp-post-thumbnail-' + id);
+	if ( typeof ajaxurl !== 'string' || typeof post_id === 'undefined' ) {
+		return;
+	}
+
+	var $link = jQuery( 'a#wp-post-thumbnail-' + id );

 	$link.text( wp.i18n.__( 'Saving…' ) );
-	jQuery.post(ajaxurl, {
-		action: 'set-post-thumbnail', post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent( document.cookie )
-	}, function(str){
-		var win = window.dialogArguments || opener || parent || top;
-		$link.text( wp.i18n.__( 'Use as featured image' ) );
-		if ( str == '0' ) {
-			alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
-		} else {
-			jQuery('a.wp-post-thumbnail').show();
-			$link.text( wp.i18n.__( 'Done' ) );
-			$link.fadeOut( 2000 );
-			win.WPSetThumbnailID(id);
-			win.WPSetThumbnailHTML(str);
+	jQuery.post(
+		ajaxurl,
+		{
+			action: 'set-post-thumbnail',
+			post_id: post_id,
+			thumbnail_id: id,
+			_ajax_nonce: nonce,
+			cookie: encodeURIComponent( document.cookie )
+		},
+		/**
+		 * Handles the AJAX response after setting the post thumbnail.
+		 *
+		 * @param {string} str Response HTML or `'0'` on failure.
+		 */
+		function( str ) {
+			var win = window.dialogArguments || opener || parent || top;
+			$link.text( wp.i18n.__( 'Use as featured image' ) );
+			if ( str == '0' ) {
+				alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
+			} else {
+				jQuery( 'a.wp-post-thumbnail' ).show();
+				$link.text( wp.i18n.__( 'Done' ) );
+				$link.fadeOut( 2000 );
+				if ( win && typeof win.WPSetThumbnailID === 'function' ) {
+					win.WPSetThumbnailID( id );
+				}
+				if ( win && typeof win.WPSetThumbnailHTML === 'function' ) {
+					win.WPSetThumbnailHTML( str );
+				}
+			}
 		}
-	}
 	);
 };
diff --git a/wp-admin/js/set-post-thumbnail.min.js b/wp-admin/js/set-post-thumbnail.min.js
index 638d957408..bb35a92242 100644
--- a/wp-admin/js/set-post-thumbnail.min.js
+++ b/wp-admin/js/set-post-thumbnail.min.js
@@ -1,2 +1,2 @@
 /*! This file is auto-generated */
-window.WPSetAsThumbnail=function(n,t){var a=jQuery("a#wp-post-thumbnail-"+n);a.text(wp.i18n.__("Saving\u2026")),jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:n,_ajax_nonce:t,cookie:encodeURIComponent(document.cookie)},function(t){var e=window.dialogArguments||opener||parent||top;a.text(wp.i18n.__("Use as featured image")),"0"==t?alert(wp.i18n.__("Could not set that as the thumbnail image. Try a different attachment.")):(jQuery("a.wp-post-thumbnail").show(),a.text(wp.i18n.__("Done")),a.fadeOut(2e3),e.WPSetThumbnailID(n),e.WPSetThumbnailHTML(t))})};
\ No newline at end of file
+window.WPSetAsThumbnail=function(n,t){var a;"string"==typeof ajaxurl&&"undefined"!=typeof post_id&&((a=jQuery("a#wp-post-thumbnail-"+n)).text(wp.i18n.__("Saving\u2026")),jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:n,_ajax_nonce:t,cookie:encodeURIComponent(document.cookie)},function(t){var e=window.dialogArguments||opener||parent||top;a.text(wp.i18n.__("Use as featured image")),"0"==t?alert(wp.i18n.__("Could not set that as the thumbnail image. Try a different attachment.")):(jQuery("a.wp-post-thumbnail").show(),a.text(wp.i18n.__("Done")),a.fadeOut(2e3),e&&"function"==typeof e.WPSetThumbnailID&&e.WPSetThumbnailID(n),e&&"function"==typeof e.WPSetThumbnailHTML&&e.WPSetThumbnailHTML(t))}))};
\ No newline at end of file
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 72b70fb28d..4ef2ac5568 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.3-alpha-65855';
+$wp_version = '7.3-alpha-65856';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.