[wp-trac] [WordPress Trac] #50867: An API which encourages automatic escaping of HTML

WordPress Trac noreply at wordpress.org
Fri Aug 7 03:36:41 UTC 2020


#50867: An API which encourages automatic escaping of HTML
-------------------------------------------------+-------------------------
 Reporter:  noisysocks                           |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  General                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-unit-tests needs-    |     Focuses:
  docs dev-feedback 2nd-opinion                  |
-------------------------------------------------+-------------------------

Comment (by talldanwp):

 > To better illustrate this proposal, I rewrote
 render_block_core_navigation_link using wp_el. You can see how that looks
 here
 >
 > https://github.com/WordPress/gutenberg/compare/try/refactor-navigation-
 link-render_callback

 From that, I think `wp_classnames` has definite merit, that part of the
 code is much easier to read.

 `wp_el` is a little harder to read in my opinion, mostly because of the
 amount of indentation, but I still think it's an improvement over the
 original concatenated string.

 One of the worst parts I find about assembling HTML using current
 techniques is having to match up opening and closing tags, particularly
 when there's some conditional logic involved around those tags. It's too
 easy to make a mistake and end up with invalid HTML.

 I like that the proposal here doesn't suffer from that problem that tags
 are implicitly closed by the function.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50867#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list