From 1432f4006afde09f9e0e3005d56972092089fbaf Mon Sep 17 00:00:00 2001 From: tin Date: Fri, 4 Sep 2026 09:45:50 +0700 Subject: [PATCH 1/3] Admin: wrap remaining one-liner inline scripts in wp_print_inline_script_tag() Three raw + diff --git a/src/wp-admin/async-upload.php b/src/wp-admin/async-upload.php index 5fbdd370c5c1a..f39bbe5f57420 100644 --- a/src/wp-admin/async-upload.php +++ b/src/wp-admin/async-upload.php @@ -145,7 +145,15 @@ $_FILES['async-upload']['name'] ); - echo '\n"; + wp_print_inline_script_tag( + sprintf( + <<<'JS' +_.delay(function() {wp.a11y.speak(%s);}, 1500);jQuery( %s ).on( 'click', function() {jQuery(this).parents('div.media-item').slideUp(200, function(){jQuery(this).remove();wp.a11y.speak( wp.i18n.__( 'Error dismissed.' ) );jQuery( '#plupload-browse-button' ).trigger( 'focus' );})}); +JS, + wp_json_encode( $speak_message, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), + wp_json_encode( 'button#' . $button_unique_id ) + ) + ); exit; } diff --git a/src/wp-admin/install.php b/src/wp-admin/install.php index b6b7a08f2a5aa..c07fc16194add 100644 --- a/src/wp-admin/install.php +++ b/src/wp-admin/install.php @@ -470,17 +470,25 @@ function display_setup_form( $error = null ) { } if ( ! wp_is_mobile() ) { - ?> - - - From c41207361c35a3dbd0bd7617cd963abbe2ad5116 Mon Sep 17 00:00:00 2001 From: tin Date: Sat, 5 Sep 2026 08:45:46 +0700 Subject: [PATCH 2/3] Admin: refactor async-upload error script per review feedback Apply westonruter's suggestion from PR review: extract the inline JS into a $js_function heredoc with proper indentation and WordPress JS formatting, then pass it through sprintf( '( %s )( %s )' ) with the speak message and button selector bundled into a single wp_json_encode() object. Eliminates the sprintf placeholders inside the JS body that were flagged as a syntax error, and matches the coding standards for indentation and jQuery chaining. --- src/wp-admin/async-upload.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/async-upload.php b/src/wp-admin/async-upload.php index f39bbe5f57420..ba983b6c163f3 100644 --- a/src/wp-admin/async-upload.php +++ b/src/wp-admin/async-upload.php @@ -145,13 +145,33 @@ $_FILES['async-upload']['name'] ); + $js_function = <<<'JS' + ( { speakMessage, buttonSelector } ) => { + _.delay( function () { + wp.a11y.speak( speakMessage ); + }, 1500 ); + jQuery( buttonSelector ).on( 'click', function () { + jQuery( this ) + .parents( 'div.media-item' ) + .slideUp( 200, function () { + jQuery( this ).remove(); + wp.a11y.speak( wp.i18n.__( 'Error dismissed.' ) ); + jQuery( '#plupload-browse-button' ).trigger( 'focus' ); + } ); + } ); + } + JS; wp_print_inline_script_tag( sprintf( - <<<'JS' -_.delay(function() {wp.a11y.speak(%s);}, 1500);jQuery( %s ).on( 'click', function() {jQuery(this).parents('div.media-item').slideUp(200, function(){jQuery(this).remove();wp.a11y.speak( wp.i18n.__( 'Error dismissed.' ) );jQuery( '#plupload-browse-button' ).trigger( 'focus' );})}); -JS, - wp_json_encode( $speak_message, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), - wp_json_encode( 'button#' . $button_unique_id ) + '( %s )( %s )', + $js_function, + wp_json_encode( + array( + 'speakMessage' => $speak_message, + 'buttonSelector' => 'button#' . $button_unique_id, + ), + JSON_HEX_TAG | JSON_UNESCAPED_SLASHES + ) ) ); exit; From 723d110ea07323f5062e2dea7c0d8596b9847863 Mon Sep 17 00:00:00 2001 From: tin Date: Mon, 7 Sep 2026 13:44:33 +0700 Subject: [PATCH 3/3] Admin: default the dismiss handler destructure; const in installer script If wp_json_encode() were to fail, the emitted call would run with no argument and throw a TypeError when destructuring. Defaulting to an empty object avoids the error. Also declare the installer focus helper variable with const instead of a leaking var now that the block is formatted as part of the migration. --- src/wp-admin/async-upload.php | 2 +- src/wp-admin/install.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/async-upload.php b/src/wp-admin/async-upload.php index ba983b6c163f3..c406cc5f5894f 100644 --- a/src/wp-admin/async-upload.php +++ b/src/wp-admin/async-upload.php @@ -146,7 +146,7 @@ ); $js_function = <<<'JS' - ( { speakMessage, buttonSelector } ) => { + ( { speakMessage, buttonSelector } = {} ) => { _.delay( function () { wp.a11y.speak( speakMessage ); }, 1500 ); diff --git a/src/wp-admin/install.php b/src/wp-admin/install.php index c07fc16194add..4fd4c9a7f594b 100644 --- a/src/wp-admin/install.php +++ b/src/wp-admin/install.php @@ -472,7 +472,7 @@ function display_setup_form( $error = null ) { if ( ! wp_is_mobile() ) { wp_print_inline_script_tag( <<<'JS' - var t = document.getElementById( 'weblog_title' ); + const t = document.getElementById( 'weblog_title' ); if ( t ) { t.focus(); }