From 87f6a020e80de4446c35ab06fd0da72eae90f521 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin <622599+aaronjorbin@users.noreply.github.com> Date: Tue, 30 Jun 2026 16:40:22 -0500 Subject: [PATCH 1/7] Add explicit variables to fix `use strict`. Each of the variables declared at the top are included either are already used in the global scope or are prefixed. Trac Ticket: https://core.trac.wordpress.org/ticket/65515 AI Disclosure: Debugged and initial patch including tests generated with Opencode and gpt-5.5. Manually checked and adjusted to reduce the number of variables in the global scope. --- src/js/_enqueues/vendor/thickbox/thickbox.js | 13 +- tests/qunit/index.html | 5042 +++++++++++------- tests/qunit/wp-includes/js/thickbox.js | 48 + 3 files changed, 3216 insertions(+), 1887 deletions(-) create mode 100644 tests/qunit/wp-includes/js/thickbox.js diff --git a/src/js/_enqueues/vendor/thickbox/thickbox.js b/src/js/_enqueues/vendor/thickbox/thickbox.js index 2c7b7f95260fa..136dbe1668265 100644 --- a/src/js/_enqueues/vendor/thickbox/thickbox.js +++ b/src/js/_enqueues/vendor/thickbox/thickbox.js @@ -9,6 +9,9 @@ if ( typeof tb_pathToImage != 'string' ) { var tb_pathToImage = thickboxL10n.loadingAnimation; } +var imgLoader, TB_PrevCaption, TB_PrevURL, TB_PrevHTML, TB_NextCaption, TB_NextURL, + TB_NextHTML, TB_imageCount, TB_FoundURL, TB_TempArray, TB_Counter, TB_WIDTH, TB_HEIGHT; + /*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/ //on page load call tb_init @@ -117,7 +120,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic } } - imgPreloader = new Image(); + var imgPreloader = new Image(); imgPreloader.onload = function(){ imgPreloader.onload = null; @@ -201,14 +204,14 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic var queryString = url.replace(/^[^\?]+\??/,''); var params = tb_parseQuery( queryString ); + var ajaxContentW = TB_WIDTH - 30; + var ajaxContentH = TB_HEIGHT - 45; TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no parameters were added to URL TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no parameters were added to URL - ajaxContentW = TB_WIDTH - 30; - ajaxContentH = TB_HEIGHT - 45; if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window - urlNoQuery = url.split('TB_'); + var urlNoQuery = url.split('TB_'); jQuery("#TB_iframeContent").remove(); if(params['modal'] != "true"){//iframe no modal jQuery("#TB_window").append("