[wp-trac] [WordPress Trac] #32192: Add HTML attribute builder helper function

WordPress Trac noreply at wordpress.org
Wed Apr 29 20:01:32 UTC 2015


#32192: Add HTML attribute builder helper function
-------------------------+-----------------------------
 Reporter:  paulwilde    |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  4.2.1
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 I've seen (and wrote) a lot of plugins which manually build out each HTML
 attribute as a loop, escaping each value and then removing any attribute
 that has no value. Wouldn't it be nice if there was a function that does
 all that for you?

 This patch introduces a new function {{{html_attributes}}} which accepts
 an array and builds out a string of attributes whilst sanitising the
 values and removing any empty attributes.

 I've also updated any uses in core removing the logic and using the
 function instead. There's probably a few instances still left to update,
 but this is a good start.

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


More information about the wp-trac mailing list