#64128 closed defect (bug) (fixed)
html5_script_support variable is misleading
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | 5.7 |
| Component: | Script Loader | Keywords: | has-patch |
| Focuses: | Cc: |
Description
The $html5_script_support variable used in wp_sanitize_script_attributes() is misleading.
It reads that if the theme supports HTML5 script, use the longform attribute version foo="foo", otherwise only the attribute name. While technically the function returns the correct string due to its placement in the ternary operator, its meaning is backwards.
I believe that the variable should be:
$html5_script_support = is_admin() || current_theme_supports( 'html5', 'script' );
and used thus:
$attributes_string .= $html5_script_support ? ' ' . esc_attr( $attribute_name ) : sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_name ) );
Change History (8)
#1
@
8 months ago
#2
@
8 months ago
- Owner set to westonruter
- Status changed from new to accepted
@jamieburchell do you want to add a patch for your suggestion?
This ticket was mentioned in PR #10383 on WordPress/wordpress-develop by @jamieburchell.
8 months ago
#3
- Keywords has-patch added
The $html5_script_support variable used in wp_sanitize_script_attributes() is misleading.
It reads that if the theme supports HTML5 script, use the longform attribute version foo="foo", otherwise only the attribute name. While technically the function returns the correct string due to its placement in the ternary operator, its meaning is backwards. This patch addresses this.
Trac ticket: https://core.trac.wordpress.org/ticket/64128
Not entirely sure of the purpose of the
is_admin()check, but this logic may need to be changed to$html5_script_support = ! is_admin() && current_theme_supports( 'html5', 'script' );