Skip to content

Commit 756809f

Browse files
committed
Command Palette: Revert Use HTLM_Tag_Processor to get the menu label when enqueueing assets.
Reverts [61126] and [61127], which introduced a bug where the command palette is not stripping numbers. `HTML_Tag_Processor` cannot replace the REGEX yet. Unprops cbravobernal. Follow-up to [61126], [61127]. Props wildworks, tusharaddweb. See #64196. git-svn-id: https://develop.svn.wordpress.org/trunk@61142 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2dc09c2 commit 756809f

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/wp-includes/script-loader.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3442,12 +3442,9 @@ function wp_enqueue_command_palette_assets() {
34423442
}
34433443

34443444
// Remove all HTML tags and their contents.
3445-
$processor = new WP_HTML_Tag_Processor( $menu_item[0] );
3446-
$menu_label = '';
3447-
while ( $processor->next_token() ) {
3448-
if ( '#text' === $processor->get_token_name() ) {
3449-
$menu_label .= $processor->get_modifiable_text();
3450-
}
3445+
$menu_label = $menu_item[0];
3446+
while ( preg_match( '/<[^>]*>/', $menu_label ) ) {
3447+
$menu_label = preg_replace( '/<[^>]*>.*?<\/[^>]*>|<[^>]*\/>|<[^>]*>/s', '', $menu_label );
34513448
}
34523449
$menu_label = trim( $menu_label );
34533450
$menu_url = '';
@@ -3474,12 +3471,9 @@ function wp_enqueue_command_palette_assets() {
34743471
}
34753472

34763473
// Remove all HTML tags and their contents.
3477-
$processor = new WP_HTML_Tag_Processor( $submenu_item[0] );
3478-
$submenu_label = '';
3479-
while ( $processor->next_token() ) {
3480-
if ( '#text' === $processor->get_token_name() ) {
3481-
$submenu_label .= $processor->get_modifiable_text();
3482-
}
3474+
$submenu_label = $submenu_item[0];
3475+
while ( preg_match( '/<[^>]*>/', $submenu_label ) ) {
3476+
$submenu_label = preg_replace( '/<[^>]*>.*?<\/[^>]*>|<[^>]*\/>|<[^>]*>/s', '', $submenu_label );
34833477
}
34843478
$submenu_label = trim( $submenu_label );
34853479
$submenu_url = '';

0 commit comments

Comments
 (0)