[wp-trac] [WordPress Trac] #64128: html5_script_support variable is misleading

WordPress Trac noreply at wordpress.org
Tue Oct 21 15:29:47 UTC 2025


#64128: html5_script_support variable is misleading
---------------------------+-----------------------------
 Reporter:  jamieburchell  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  General        |    Version:  6.8.3
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 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 ) );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64128>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list