[wp-trac] [WordPress Trac] #40829: Improve wp_dropdown_languages() so it doesn't print out empty attributes

WordPress Trac noreply at wordpress.org
Sat May 20 20:41:03 UTC 2017


#40829: Improve wp_dropdown_languages() so it doesn't print out empty attributes
-----------------------------------+------------------------------
 Reporter:  afercia                |       Owner:
     Type:  defect (bug)           |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  I18N                   |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------------------
Changes (by johnjamesjacoby):

 * keywords:   => has-patch 2nd-opinion


Comment:

 [https://core.trac.wordpress.org/attachment/ticket/40829/40829.diff
 40829.diff] proposes the following changes:

 * Set `id` and `name` to `locale` by default instead of empty, to
 circumvent the issue proposed here. This also promotes the use of `locale`
 for future usages by core and plugins.
 * Bail early if ID or name are intentionally forced to be empty.
 * Move the beginning of the `$output` string creation to the end of the
 function with the other concatenation
 * Switch `$args` replacement to use the `$r` variable approach, as per
 most other `wp_parse_args()` usages in core. This prevents stomping the
 original `$args` array, in the event a filter is introduced into this
 function later.
 * Add some more inline documentation where blocks of code perform separate
 things.

 Tests are passing. No further changes are needed to any usages of
 `wp_dropdown_languages()`.

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


More information about the wp-trac mailing list