[wp-trac] [WordPress Trac] #32008: Wrapper method for esc_attr

WordPress Trac noreply at wordpress.org
Fri May 1 20:14:19 UTC 2015


#32008: Wrapper method for esc_attr
------------------------------------------------+------------------
 Reporter:  welcher                             |       Owner:
     Type:  enhancement                         |      Status:  new
 Priority:  normal                              |   Milestone:  4.3
Component:  General                             |     Version:  4.2
 Severity:  normal                              |  Resolution:
 Keywords:  has-patch dev-feedback 2nd-opinion  |     Focuses:
------------------------------------------------+------------------

Comment (by jorbin):

 Replying to [comment:5 dd32]:
 > Personally I'm leaning away from adding it.
 > * `esc_{type}_e()` is shorter than `echo esc_{type}( __() )` which is
 why it exists
 > * `echo_esc_{type}()` isn't any shorter than `echo esc_{type}()` and the
 extra brackets from above are not needed
 > * `e_esc_{type}()` or `esc_{type}_echo` is too much like
 `esc_{type}_e()`, and seems like it'll cause confusion even further
 > * I don't really like dropping the esc prefix in cases like
 `echo_attr()`, as it's less obvious what the function does, and easy to
 confuse with `echo attr()` in code review
 >
 > Is auto-complete by an IDE really worth it here? it's the difference
 between `echo_` and `echo esc` having to be typed for triggering the auto
 complete..

 I think you are right, auto-complete by an IDE isn't really that much of a
 benifit. However, this is one area that WordPress functions lack
 consistency. In many places we have echo and return variants (as pointed
 out above, it's often with the return variant being prefixed with `get_`.

 That said, `e_esc_{type}` is confusing and way to close to `esc_{type}_e`.
 We don't use `e_` anywhere else in the codebase while we do use `_e` and
 the context is going to be different.  A prefix that is the exact inverse
 of a suffix shouldn't have a completely different context (behavior change
 vs. translation).

 I'm tempted to close this as maybelater unless a quality name can be
 decided upon. We can always revisit this if/when a better name has been
 decided.

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


More information about the wp-trac mailing list