Opened 6 weeks ago
Closed 5 weeks ago
#64196 closed defect (bug) (fixed)
Command Palette: Refactor enqueue function to remove regex.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | General | Keywords: | has-patch needs-testing |
| Focuses: | Cc: |
Description
The wp_enqueue_command_palette_assets() function uses REGEX to remove all HTML tags and their contents from the menu items, so that it only display text.
It was using REGEX for it, and can be replaced with the Tag Processor.
Attachments (1)
Change History (18)
This ticket was mentioned in PR #10461 on WordPress/wordpress-develop by @cbravobernal.
6 weeks ago
#1
- Keywords has-patch added
#2
@
6 weeks ago
- Owner set to davidbaumwald
- Resolution set to fixed
- Status changed from new to closed
In 61126:
#3
@
6 weeks ago
- Resolution fixed deleted
- Status changed from closed to reopened
Small initialization bug. Follow-up commit incoming.
#6
@
6 weeks ago
I don't think we can simply replace REGEX with HTML_Tag_Processor. The menu may contain the 0 that are visually hidden. See https://github.com/WordPress/gutenberg/pull/71476#discussion_r2318390285 for more details.
#9
@
6 weeks ago
I'll revert the commits as soon as possible. Thanks @wildworks for pointing it out and @tusharaddweb for confirming.
#11
@
6 weeks ago
If the issue is removing content inside of the HTML tags we can still do that. In reading the PCRE pattern and the comment above it, I misunderstood the purpose of the existing code. Thanks for highlighting that @wildworks.
The fix is not much different than the proposed HTML API code. All we have to do is track depth based on opening and closing tags, or use WP_HTML_Processor and rely on its get_depth() report.
That will still resolve a number of issues with the PCRE approach, including misparses, handling HTML void elements like HR, and leaving potentially-encoded labels in place instead of decoding them.
#12
@
5 weeks ago
Tested this locally and found Theme : 0
Kindly refer below screenshot:-
https://postimg.cc/DW6F8JLL
#13
@
5 weeks ago
The fix is not much different than the proposed HTML API code. All we have to do is track depth based on opening and closing tags, or use
WP_HTML_Processorand rely on itsget_depth()report.
@dmsnell Thank you for telling me this! I'll try this approach tomorrow.
I might address this feedback in the same pull request as well: #64177
#14
@
5 weeks ago
I have submitted a PR: https://github.com/WordPress/wordpress-develop/pull/10480/
This PR addresses both this ticket and #64177.
Refactors the code on the command palette enqueue function to strip the HTML by using the Tag Processor instead of a couple of regex functions.
Proposed by @dmsnell . Props to him.
Trac ticket: https://core.trac.wordpress.org/ticket/64196