Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use Tag processor instead of regex in command pallete enqueue function
  • Loading branch information
cbravobernal committed Nov 4, 2025
commit 304a010c7abeb9030df7668f1fcf4414ff8decbe
17 changes: 11 additions & 6 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3442,9 +3442,11 @@ function wp_enqueue_command_palette_assets() {
}

// Remove all HTML tags and their contents.
$menu_label = $menu_item[0];
while ( preg_match( '/<[^>]*>/', $menu_label ) ) {
$menu_label = preg_replace( '/<[^>]*>.*?<\/[^>]*>|<[^>]*\/>|<[^>]*>/s', '', $menu_label );
$processor = new WP_HTML_Tag_Processor( $menu_item[0] );
while ( $processor->next_token() ) {
if ( '#text' === $processor->get_token_name() ) {
$menu_label .= $processor->get_modifiable_text();
}
}
$menu_label = trim( $menu_label );
$menu_url = '';
Expand All @@ -3471,9 +3473,12 @@ function wp_enqueue_command_palette_assets() {
}

// Remove all HTML tags and their contents.
$submenu_label = $submenu_item[0];
while ( preg_match( '/<[^>]*>/', $submenu_label ) ) {
$submenu_label = preg_replace( '/<[^>]*>.*?<\/[^>]*>|<[^>]*\/>|<[^>]*>/s', '', $submenu_label );
$processor = new WP_HTML_Tag_Processor( $submenu_item[0] );
$submenu_label = '';
while ( $processor->next_token() ) {
if ( '#text' === $processor->get_token_name() ) {
$submenu_label .= $processor->get_modifiable_text();
}
}
$submenu_label = trim( $submenu_label );
$submenu_url = '';
Expand Down
Loading