Skip to content

Commit df07b73

Browse files
committed
Relocate script before adding node.
1 parent a56e520 commit df07b73

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

src/wp-includes/admin-bar.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -961,18 +961,6 @@ function wp_admin_bar_command_palette_menu( WP_Admin_Bar $wp_admin_bar ): void {
961961
/* translators: Hidden accessibility text. */
962962
__( 'Open command palette' ),
963963
);
964-
$wp_admin_bar->add_node(
965-
array(
966-
'id' => 'command-palette',
967-
'title' => $title,
968-
'href' => '#',
969-
'meta' => array(
970-
'class' => 'hide-if-no-js',
971-
'onclick' => 'wp.data.dispatch( "core/commands" ).open(); return false;',
972-
),
973-
)
974-
);
975-
976964
/*
977965
* The script is added as an inline script to avoid an additional dependency.
978966
*
@@ -1001,7 +989,17 @@ function wp_admin_bar_command_palette_menu( WP_Admin_Bar $wp_admin_bar ): void {
1001989
})
1002990
JS;
1003991
$script .= '(' . wp_json_encode( $shortcut_labels ) . ');';
1004-
wp_add_inline_script( 'admin-bar', $script );
992+
$wp_admin_bar->add_node(
993+
array(
994+
'id' => 'command-palette',
995+
'title' => $title,
996+
'href' => '#',
997+
'meta' => array(
998+
'class' => 'hide-if-no-js',
999+
'onclick' => 'wp.data.dispatch( "core/commands" ).open(); return false;',
1000+
),
1001+
)
1002+
);
10051003
}
10061004

10071005
/**

0 commit comments

Comments
 (0)