[wp-trac] [WordPress Trac] #29892: get_available_languages() can alternately too and not enough permissive

WordPress Trac noreply at wordpress.org
Wed Oct 8 15:03:47 UTC 2014


#29892: get_available_languages() can alternately too and not enough permissive
----------------------------+-----------------------------
 Reporter:  imath           |      Owner:
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  4.0
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 Since 4.0, it's possible to switch site languages from the language
 dropdown in options-general.php. This is a great feature.

 But i think there can be cases when get_available_languages() is too
 permissive and others not enough.

 1/ Too permissive
 If for some reason, a theme or plugin language file is added at the root
 of {{{WP_LANG_DIR}}}, then the theme or plugin language file will be
 listed in the dropdown because it names does not start with 'continents-
 cities' or 'ms-' or 'admin-'. It can be confusing for the site admin.

 2/ Not enough (might be an edge case)
 {{{get_available_languages()}}} accepts a {{{$dir}}} param. So although
 it's not used in core, i guess plugins/themes can use this function to
 list language files of a given directory. In this case, if one of the file
 starts with 'continents-cities' or 'ms-' or 'admin-' then it won't be
 listed.

 The attached patch is suggesting a way to be sure only site language files
 will be listed if the $dir param is null or == {{{WP_LANG_DIR}}} else to
 list all language files.

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


More information about the wp-trac mailing list