Opened 23 months ago
Closed 21 months ago
#57265 closed enhancement (wontfix)
Strip tags from post title in WP List Table
Reported by: | audrasjb | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | has-screenshots has-patch 2nd-opinion close |
Focuses: | administration | Cc: |
Description
When post titles are copied or imported from other sources, it's pretty common that HTML tags like strong
, em
, sup
, sub
, (etc.) are used.
Currently, those HTML tags are displayed in all WP List Table screens.
It would be nice to strip all HTML tags from being displayed in the post title column of these screens.
Unexpectedly, I couldn't find any existing ticket about this issue, so I opened a new one, but historians are welcome to close this one in favor of any existing ticket :)
This issue was raised by @webaxones in the French WordPress slack team.
Attachments (4)
Change History (16)
#3
@
23 months ago
+1
While we could skip escaping certain formatting HTML tags, truncation would mess this up (<strong>Title and...
= page is now bold).
Therefore, stripping the tags as proposed seems the safer option here.
#4
@
23 months ago
Maybe superscripts and subscripts could be displayed?
<?php strip_tags($title, ['sup', 'sub']); ?>
#5
@
21 months ago
- Milestone changed from Awaiting Review to 6.2
Yes, I think we can keep sub and superscript.
Moving for 6.2 consideration.
This ticket was mentioned in PR #3852 on WordPress/wordpress-develop by @audrasjb.
21 months ago
#6
- Keywords has-patch added
Fixes: https://core.trac.wordpress.org/ticket/57265
Please note that this is a first iteration around this change.
Tests and comments welcome :)
#7
@
21 months ago
- Keywords changes-requested added
Thanks @audrasjb for ticket and PR. I also face a similar issue often.
I left one comment on PR. Please have a look.
#8
@
21 months ago
This looks much cleaner -- thanks, @audrasjb!
Test Report
Patch tested: https://github.com/WordPress/wordpress-develop/pull/3852 (after removal of $allowable_tags
) 👍🏻
Environment
- Hardware: MacBook Pro Apple M1 Pro
- OS: macOS 12.6.2
- Browser: Safari 16.2
- Server: nginx/1.23.3
- PHP: 7.4.33
- WordPress: 6.2-alpha-54642-src
Actual Results
- ✅ Tags are stripped from displayed titles in post list table.
Supplemental Artifacts
Titles tested below include tags typed manually in the post title field (the last three), as well as titles copied from styled text in a Google Doc (the first five).
Before Patch | After Patch |
---|---|
#9
@
21 months ago
- Keywords 2nd-opinion added; changes-requested removed
Hello there,
I submitted this proposal for more advice in the French WP Slack Team, and I get a bunch of helpful thoughts, which can be summarized as follows:
If we strip tags from title, we would lose the information that a title contains HTML tags, which can be useful for debugging unwanted tags (after an import, or after a bad copy-paste for example).
Even on the accessibility side of the topic, while one could say that it's not a great experience for assistive technology users to have these tags fully spelled out, it might be helpful to know that a title contains HTML tags.
Thanks to @chaton666, @petitphp, @webaxones, @maigret, @nicomollet for sharing their thoughts :)
#10
@
21 months ago
We are having a bit of a related discussion here:
https://github.com/WordPress/gutenberg/issues/38637
Stripping the tags out of the list table but not the actual titles will further obscure this issue where markup is included in the post title but is not editable.
If we must support markup in the post title there needs to be some kind of code/text view to edit the full contents of the post title. Right now the only work around is to cut and paste into external editors, and the list view is one of the only places you can actually discover this issue.
+1 -- I agree that this is odd behavior. Adding another example here, showing how pasting directly from Google Docs can impact the displayed post title.