Make WordPress Core


Ignore:
Timestamp:
03/12/2026 05:23:14 AM (3 months ago)
Author:
westonruter
Message:

Toolbar: Show command palette admin bar item on mobile.

  • The keyboard shortcut is hidden in favor of a search icon on mobile.
  • The background color of the KBD element is made transparent on non-mobile.
  • The admin bar item is skipped from being added if the wp-core-commands script is not enqueued.

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

Follow-up to r61912.

Props sabernhardt, westonruter, ellatrix, mukesh27.
See #64672.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/admin-bar.php

    r61912 r61979  
    946946 */
    947947function wp_admin_bar_command_palette_menu( WP_Admin_Bar $wp_admin_bar ): void {
    948     if ( ! is_admin() ) {
     948    if ( ! is_admin() || ! wp_script_is( 'wp-core-commands', 'enqueued' ) ) {
    949949        return;
    950950    }
     
    955955        : _x( 'Ctrl+K', 'keyboard shortcut to open the command palette' );
    956956    $title          = sprintf(
    957         '<span class="ab-label"><kbd>%s</kbd><span class="screen-reader-text"> %s</span></span>',
     957        '<span class="ab-icon" aria-hidden="true"></span><span class="ab-label"><kbd>%s</kbd><span class="screen-reader-text"> %s</span></span>',
    958958        $shortcut_label,
    959959        /* translators: Hidden accessibility text. */
Note: See TracChangeset for help on using the changeset viewer.