Opened 6 months ago
Last modified 3 weeks ago
#62721 new defect (bug)
Bundled themes: replace strip_tags() with the more comprehensive wp_strip_all_tags()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Bundled Theme | Keywords: | has-patch |
Focuses: | coding-standards | Cc: |
Description
There is a PHPCS error i.e.
strip_tags() is discouraged. Use the more comprehensive wp_strip_all_tags() instead.
Attachments (2)
Change History (7)
#1
@
6 months ago
- Component changed from Bundled Theme to Themes
- Keywords needs-testing added
Thank you for the patch, however this feels like it's not for bundled themes as not on a theme specifically. Patches for bundled themes are meant to be specific to a theme and in your patch I do see for example wider fixes. This is absolutely ok but I am going to mark this for wider review.
If you could provide steps for testing and anything you found in testing that would also be great to ease those coming to this ticket, thank you.
#2
@
6 months ago
- Keywords close 2nd-opinion added; has-patch needs-testing removed
#57579 already covers the broader scope of replacing most strip_tags()
calls.
However, this ticket might be worth keeping open separately if it focuses on the calls within the bundled themes' image attachment templates and/or ephemera widget classes.
This ticket was mentioned in PR #8537 on WordPress/wordpress-develop by @sabernhardt.
3 months ago
#3
- Keywords has-patch added
- Removes
title
attribute from the parent link in Twenty Ten's image template, and removes the related$post_title
variable. - Replaces
strip_tags()
withwp_strip_all_tags()
in image templates for Twenty Eleven, Twenty Twelve and Twenty Thirteen. Thetitle
attribute remains in these themes to avoid changing the translatable strings. - Replaces
strip_tags()
withwp_strip_all_tags()
in ephemera widgets for Twenty Eleven and Twenty Fourteen.
#4
@
3 months ago
- Component changed from Themes to Bundled Theme
- Keywords close 2nd-opinion removed
- Milestone changed from Awaiting Review to Future Release
- Summary changed from strip_tags() is discouraged. Use the more comprehensive wp_strip_all_tags() instead. to Bundled themes: replace strip_tags() with the more comprehensive wp_strip_all_tags()
@sabernhardt commented on PR #8537:
3 weeks ago
#5
I should acknowledge that removing a translatable string could affect child themes. I think the risk is low with the unnecessary title
attribute text in Twenty Ten, but it might result in losing the translation if:
- a child theme has the old string in one of its template files (most likely the
loop-attachment
template, and then the attachment pages would need to be enabled) and - the site is set to one of 33 non-English languages with approved translations of the "Go to" string
I'm not sure I like the code below, but it could retain the string in the file for translation without assigning the obsolete variable:
// Ignore legacy title attribute string, but keep it for backward compatibility. if ( false ) { /* translators: %s: Post title. */ $post_title = sprintf( __( 'Go to %s', 'twentyten' ), wp_strip_all_tags( get_the_title( $post->post_parent ) ) ); }
Of course, keeping the title attribute and switching to wp_strip_all_tags()
is another option (as this PR does for three other themes). The 'Go to' title
attribute was not removed as part of Trac 57199, though it is basically redundant.
Patch for this issue