[wp-trac] [WordPress Trac] #23236: Add functions to format attributes

WordPress Trac noreply at wordpress.org
Thu May 16 04:13:50 UTC 2013


#23236: Add functions to format attributes
-----------------------------+------------------------------
 Reporter:  ryanve           |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Formatting       |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  needs-patch      |
-----------------------------+------------------------------

Comment (by ryanve):

 I added [https://github.com/airve/phat/blob/master/wphat.php wphat.php] in
 the [https://github.com/airve/phat phat repo] called  where I'm working on
 this. I think it'll be better to name the functions `wp_attr` and
 `wp_attr_parse` b/c both can handle 1+ attributes.

 How do we want to encode complex (array|object) attributes?
 [https://github.com/airve/phat/blob/4835480c3c925023199eef65b22ded9866f50b66/wphat.php#LC113
 Currently] it checks for the ~10 attributes that take tokens (`[class]`,
 `[media]`, [http://dev.w3.org/html5/spec-author-
 view/index.html#attributes-1 etc.]) and implode them with the correct
 glue. Otherwise it uses `json_encode`. Should we skip the check and go
 with the simple approach of using `json_encode` for any complex value? In
 either case I'll include a `'complex_attr_value'` filter.

 I avoided `esc_attr` b/c it breaks JSON and b/c it double-encodes
 entities.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23236#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list