Toolbar: Improvements to changes in [62282].

This updates the JavaScript based regular expression to be case-insensitive, which matches the corresponding PHP pattern.

A defensive check has alos been added to avoid a `TypeError` if the admin bar is manipulated in a way that changes the path of the targeted element.

Follow up to [62282].

Props westonruter.
Fixes #65121.
Built from https://develop.svn.wordpress.org/trunk@62320


git-svn-id: http://core.svn.wordpress.org/trunk@61600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj
2026-05-07 16:37:43 +00:00
parent 579974ea91
commit 97af967f02
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -971,8 +971,12 @@ function wp_admin_bar_command_palette_menu( WP_Admin_Bar $wp_admin_bar ): void {
*/
$function = <<<'JS'
( applePattern, appleOSLabel ) => {
if ( ( new RegExp( applePattern ) ).test( navigator.userAgent ) ) {
document.querySelector( '#wp-admin-bar-command-palette .ab-label kbd' ).textContent = appleOSLabel;
if ( ! ( new RegExp( applePattern, 'i' ) ).test( navigator.userAgent ) ) {
return;
}
const kbd = document.querySelector( '#wp-admin-bar-command-palette .ab-label kbd' );
if ( kbd ) {
kbd.textContent = appleOSLabel;
}
}
JS;
+1 -1
View File
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.1-alpha-62317';
$wp_version = '7.1-alpha-62320';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.