Preferred Languages - Version 1.0.0

Version Description

  • Initial release.
Download this release

Release Info

Developer swissspidy
Plugin Icon Preferred Languages
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

LICENSE ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
css/preferred-languages-rtl.css ADDED
@@ -0,0 +1 @@
 
1
+ .active-locales-list,.inactive-locales-list{width:25em;margin-left:1em;clear:both;float:right}.active-locales-list{height:98px;overflow-y:scroll;margin-top:0;background:#fff;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);border:1px solid #ddd;color:#32373c;box-sizing:border-box}.active-locales-list.empty-list{background:hsla(0,0%,100%,.5);border-color:hsla(0,0%,87%,.75);box-shadow:inset 0 1px 2px rgba(0,0,0,.04);color:rgba(51,51,51,.5);display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center}.active-locales-list li{width:100%;height:28px;line-height:28px;margin:0;padding:0 8px 0 0;cursor:pointer}.active-locales-list li:hover{background:rgba(0,0,0,.07)}.active-locales-list li[aria-selected=true]{background:rgba(0,0,0,.15)}#active-locales-list-empty-message{background:transparent;text-align:center;height:auto;cursor:default}.inactive-locales{clear:both}.inactive-locales select{width:100%}
css/preferred-languages.css ADDED
@@ -0,0 +1 @@
 
1
+ .active-locales-list,.inactive-locales-list{width:25em;margin-right:1em;clear:both;float:left}.active-locales-list{height:98px;overflow-y:scroll;margin-top:0;background:#fff;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);border:1px solid #ddd;color:#32373c;box-sizing:border-box}.active-locales-list.empty-list{background:hsla(0,0%,100%,.5);border-color:hsla(0,0%,87%,.75);box-shadow:inset 0 1px 2px rgba(0,0,0,.04);color:rgba(51,51,51,.5);display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center}.active-locales-list li{width:100%;height:28px;line-height:28px;margin:0;padding:0 0 0 8px;cursor:pointer}.active-locales-list li:hover{background:rgba(0,0,0,.07)}.active-locales-list li[aria-selected=true]{background:rgba(0,0,0,.15)}#active-locales-list-empty-message{background:transparent;text-align:center;height:auto;cursor:default}.inactive-locales{clear:both}.inactive-locales select{width:100%}
css/src/preferred-languages.css ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .active-locales-list,
2
+ .inactive-locales-list {
3
+ width: 25em;
4
+ margin-right: 1em;
5
+ clear: both;
6
+ float: left;
7
+ }
8
+
9
+ .active-locales-list {
10
+ height: 98px;
11
+ overflow-y: scroll;
12
+ margin-top: 0;
13
+ background: #fff;
14
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
15
+ border: 1px solid #ddd;
16
+ color: #32373c;
17
+ box-sizing: border-box;
18
+ }
19
+
20
+ .active-locales-list.empty-list {
21
+ background: rgba(255, 255, 255, 0.5);
22
+ border-color: rgba(222, 222, 222, 0.75);
23
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
24
+ color: rgba(51, 51, 51, 0.5);
25
+ display: flex;
26
+ align-items: center;
27
+ }
28
+
29
+ .active-locales-list li {
30
+ width: 100%;
31
+ height: 28px;
32
+ line-height: 28px;
33
+ margin: 0;
34
+ padding: 0 0 0 8px;
35
+ cursor: pointer;
36
+ }
37
+
38
+ .active-locales-list li:hover {
39
+ background: rgba(0, 0, 0, 0.07);
40
+ }
41
+
42
+ .active-locales-list li[aria-selected="true"] {
43
+ background: rgba(0, 0, 0, 0.15);
44
+ }
45
+
46
+ #active-locales-list-empty-message {
47
+ background: transparent;
48
+ text-align: center;
49
+ height: auto;
50
+ cursor: default;
51
+ }
52
+
53
+ .inactive-locales {
54
+ clear: both;
55
+ }
56
+
57
+ .inactive-locales select {
58
+ width: 100%;
59
+ }
inc/default-filters.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_action( 'init', 'preferred_languages_register_setting' );
4
+ add_action( 'init', 'preferred_languages_register_meta' );
5
+ add_action( 'init', 'preferred_languages_register_scripts' );
6
+
7
+ add_action( 'admin_init', 'preferred_languages_settings_field' );
8
+
9
+ add_action( 'personal_options', 'preferred_languages_personal_options' );
10
+ add_action( 'personal_options_update', 'preferred_languages_update_user_option' );
11
+ add_action( 'edit_user_profile_update', 'preferred_languages_update_user_option' );
12
+
13
+ add_filter( 'update_option_preferred_languages', 'preferred_languages_download_language_packs', 10, 2 );
14
+ add_filter( 'get_user_metadata', 'preferred_languages_filter_user_locale', 10, 3 );
15
+ add_filter( 'locale', 'preferred_languages_filter_locale' );
16
+ add_filter( 'load_textdomain_mofile', 'preferred_languages_load_textdomain_mofile', 10 );
17
+
18
+
19
+
20
+
inc/functions.php ADDED
@@ -0,0 +1,429 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Registers the option for the preferred languages.
5
+ *
6
+ * @since 1.0.0
7
+ */
8
+ function preferred_languages_register_setting() {
9
+ register_setting(
10
+ 'general',
11
+ 'preferred_languages',
12
+ array(
13
+ 'sanitize_callback' => 'preferred_languages_sanitize_list',
14
+ 'default' => '',
15
+ 'show_in_rest' => true,
16
+ 'type' => 'string',
17
+ 'description' => __( 'List of preferred locales.', 'preferred-languages' ),
18
+ )
19
+ );
20
+ }
21
+
22
+ /**
23
+ * Registers the user meta key for the preferred languages.
24
+ *
25
+ * @since 1.0.0
26
+ */
27
+ function preferred_languages_register_meta() {
28
+ register_meta( 'user', 'preferred_languages', array(
29
+ 'type' => 'string',
30
+ 'description' => 'List of preferred languages',
31
+ 'single' => true,
32
+ 'sanitize_callback' => 'preferred_languages_sanitize_list',
33
+ 'show_in_rest' => true,
34
+ ) );
35
+ }
36
+
37
+ /**
38
+ * Updates the user's set of preferred languages.
39
+ *
40
+ * @since 1.0.0
41
+ *
42
+ * @param int $user_id The user ID.
43
+ */
44
+ function preferred_languages_update_user_option( $user_id ) {
45
+ if ( isset( $_POST['preferred_languages'] ) ) {
46
+ update_user_meta( $user_id, 'preferred_languages', $_POST['preferred_languages'] );
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Returns the list of preferred languages.
52
+ *
53
+ * If in the admin area, this returns the data for the current user.
54
+ * Else the site settings are used.
55
+ *
56
+ * @since 1.0.0
57
+ *
58
+ * @return array Preferred languages.
59
+ */
60
+ function preferred_languages_get_list() {
61
+ $preferred_languages = array();
62
+
63
+ if ( is_admin() ) {
64
+ $preferred_languages = get_user_meta( get_current_user_id(), 'preferred_languages', true );
65
+ $preferred_languages = array_filter( explode( ',', $preferred_languages ) );
66
+ }
67
+
68
+ // Fall back to site setting.
69
+ if ( empty( $preferred_languages ) ) {
70
+ $preferred_languages = get_option( 'preferred_languages', '' );
71
+ $preferred_languages = array_filter( explode( ',', $preferred_languages ) );
72
+ }
73
+
74
+ return $preferred_languages;
75
+ }
76
+
77
+ /**
78
+ * Downloads language packs upon updating the option.
79
+ *
80
+ * @since 1.0.0
81
+ *
82
+ * @param string $old_value The old option value.
83
+ * @param string $value The new option value.
84
+ */
85
+ function preferred_languages_download_language_packs( $old_value, $value ) {
86
+ if ( is_multisite() && ! is_super_admin() ) {
87
+ return;
88
+ }
89
+
90
+ // Handle translation install.
91
+ require_once ABSPATH . 'wp-admin/includes/translation-install.php';
92
+
93
+ if ( ! wp_can_install_language_pack() ) {
94
+ return;
95
+ }
96
+
97
+ $locales = $value;
98
+ $locales = explode( ',', $locales );
99
+
100
+ $installed_languages = array();
101
+
102
+ foreach ( $locales as $locale ) {
103
+ $language = wp_download_language_pack( $locale );
104
+ if ( $language ) {
105
+ $installed_languages[] = $language;
106
+ }
107
+ }
108
+
109
+ remove_filter( 'update_option_preferred_languages', 'preferred_languages_download_language_packs' );
110
+
111
+ // Only store actually installed languages in option.
112
+ update_option( 'preferred_languages', implode( ',', $installed_languages ) );
113
+
114
+ add_filter( 'update_option_preferred_languages', 'preferred_languages_download_language_packs', 10, 2 );
115
+
116
+ // Reload translations after save.
117
+ $preferred_languages_list = preferred_languages_get_list();
118
+ load_default_textdomain( reset( $preferred_languages_list ) );
119
+ }
120
+
121
+ /**
122
+ * Sanitizes the preferred languages option.
123
+ *
124
+ * @since 1.0.0
125
+ *
126
+ * @param string $preferred_languages Comma separated list of preferred languages.
127
+ *
128
+ * @return string Sanitized list.
129
+ */
130
+ function preferred_languages_sanitize_list( $preferred_languages ) {
131
+ $locales = array_map( 'sanitize_text_field', explode( ',', $preferred_languages ) );
132
+
133
+ return implode( ',', $locales );
134
+ }
135
+
136
+ /**
137
+ * Filters calls to get_locale() to use the preferred languages setting.
138
+ *
139
+ * @since 1.0.0
140
+ *
141
+ * @param string $locale The current locale.
142
+ *
143
+ * @return string
144
+ */
145
+ function preferred_languages_filter_locale( $locale ) {
146
+ $preferred_languages = preferred_languages_get_list();
147
+
148
+ if ( empty( $preferred_languages ) ) {
149
+ return $locale;
150
+ }
151
+
152
+ return reset( $preferred_languages );
153
+ }
154
+
155
+ /**
156
+ * Filters calls to get_user_locale() to use the preferred languages setting.
157
+ *
158
+ * @since 1.0.0
159
+ *
160
+ * @param null|array|string $value The value get_metadata() should return - a single metadata value,
161
+ * or an array of values.
162
+ * @param int $object_id Object ID.
163
+ * @param string $meta_key Meta key.
164
+ *
165
+ * @return null|array|string The meta value.
166
+ */
167
+ function preferred_languages_filter_user_locale( $value, $object_id, $meta_key ) {
168
+ if ( 'locale' !== $meta_key ) {
169
+ return $value;
170
+ }
171
+
172
+ $preferred_languages = get_user_meta( $object_id, 'preferred_languages', true );
173
+ $preferred_languages = array_filter( explode( ',', $preferred_languages ) );
174
+
175
+ if ( ! empty( $preferred_languages ) ) {
176
+ return reset( $preferred_languages );
177
+ }
178
+
179
+ return $value;
180
+ }
181
+
182
+ /**
183
+ * Filters load_textdomain() calls to respect the list of preferred languages.
184
+ *
185
+ * @since 1.0.0
186
+ *
187
+ * @param string $mofile Path to the MO file.
188
+ *
189
+ * @return string The modified MO file path.
190
+ */
191
+ function preferred_languages_load_textdomain_mofile( $mofile ) {
192
+ $preferred_locales = preferred_languages_get_list();
193
+
194
+ if ( empty( $preferred_locales ) || is_readable( $mofile ) ) {
195
+ return $mofile;
196
+ }
197
+
198
+ $current_locale = get_locale();
199
+
200
+ foreach ( $preferred_locales as $locale ) {
201
+ $preferred_mofile = str_replace( $current_locale, $locale, $mofile );
202
+
203
+ if ( is_readable( $preferred_mofile ) ) {
204
+ return $preferred_mofile;
205
+ }
206
+ }
207
+
208
+ return $mofile;
209
+ }
210
+
211
+ /**
212
+ * Registers the needed scripts and styles.
213
+ *
214
+ * @since 1.0.0
215
+ */
216
+ function preferred_languages_register_scripts() {
217
+ $suffix = SCRIPT_DEBUG ? '' : '.min';
218
+
219
+ wp_register_script(
220
+ 'preferred-languages',
221
+ plugin_dir_url( dirname( __FILE__ ) ) . 'js/preferred-languages' . $suffix . '.js',
222
+ array(
223
+ 'jquery',
224
+ 'jquery-ui-sortable',
225
+ 'wp-a11y',
226
+ ),
227
+ '20171001',
228
+ true
229
+ );
230
+
231
+ wp_localize_script(
232
+ 'preferred-languages',
233
+ 'preferredLanguages',
234
+ array(
235
+ 'l10n' => array(
236
+ 'localeAdded' => __( 'Locale added to list' ),
237
+ 'localeRemoved' => __( 'Locale removed from list' ),
238
+ 'movedUp' => __( 'Locale moved up' ),
239
+ 'movedDown' => __( 'Locale moved down' ),
240
+ ),
241
+ )
242
+ );
243
+
244
+ $rtl_suffix = is_rtl() ? '-rtl' : '';
245
+
246
+ wp_enqueue_style(
247
+ 'preferred-languages',
248
+ plugin_dir_url( dirname( __FILE__ ) ) . 'css/preferred-languages' . $rtl_suffix . '.css',
249
+ array(),
250
+ '20171001',
251
+ 'screen'
252
+ );
253
+ }
254
+
255
+ /**
256
+ * Adds a settings field for the preferred languages option.
257
+ *
258
+ * @since 1.0.0
259
+ */
260
+ function preferred_languages_settings_field() {
261
+ add_settings_field(
262
+ 'preferred_languages',
263
+ '<span id="preferred-languages-label">' . __( 'Site Language', 'preferred-languages' ) . '<span/>',
264
+ 'preferred_languages_display_form',
265
+ 'general',
266
+ 'default',
267
+ array(
268
+ 'selected' => array_filter( explode( ',', get_option( 'preferred_languages', '' ) ) ),
269
+ )
270
+ );
271
+ }
272
+
273
+ /**
274
+ * Adds a settings field for the preferred languages option to the user profile.
275
+ *
276
+ * @since 1.0.0
277
+ *
278
+ * @param WP_User $user The current WP_User object.
279
+ */
280
+ function preferred_languages_personal_options( $user ) {
281
+ $languages = get_available_languages();
282
+
283
+ if ( ! $languages ) {
284
+ return;
285
+ }
286
+ ?>
287
+ <tr class="user-preferred-languages-wrap">
288
+ <th scope="row">
289
+ <span id="preferred-languages-label"><?php _e( 'Language' ); ?></span>
290
+ </th>
291
+ <td>
292
+ <?php
293
+ preferred_languages_display_form( array(
294
+ 'selected' => array_filter( explode( ',', get_user_option( 'preferred_languages', $user->ID ) ) ),
295
+ 'show_available_translations' => false,
296
+ 'show_option_site_default' => true,
297
+ ) );
298
+ ?>
299
+ </td>
300
+ </tr>
301
+ <?php
302
+ }
303
+
304
+ /**
305
+ * Displays the actual form to select the preferred languages.
306
+ *
307
+ * @since 1.0.0
308
+ *
309
+ * @param array $args Optional. Arguments to pass to the form.
310
+ */
311
+ function preferred_languages_display_form( $args = array() ) {
312
+ wp_enqueue_script( 'preferred-languages' );
313
+
314
+ $args = wp_parse_args( $args, array(
315
+ 'selected' => array(),
316
+ 'show_available_translations' => true,
317
+ 'show_option_site_default' => false,
318
+ ) );
319
+
320
+ require_once ABSPATH . 'wp-admin/includes/translation-install.php';
321
+ $translations = wp_get_available_translations();
322
+
323
+ $languages = get_available_languages();
324
+
325
+ $preferred_languages = array();
326
+
327
+ foreach ( $args['selected'] as $locale ) {
328
+ if ( isset( $translations[ $locale ] ) ) {
329
+ $translation = $translations[ $locale ];
330
+
331
+ $preferred_languages[] = array(
332
+ 'language' => $translation['language'],
333
+ 'native_name' => $translation['native_name'],
334
+ 'lang' => current( $translation['iso'] ),
335
+ );
336
+ } else if ( 'en_US' !== $locale ) {
337
+ $preferred_languages[] = array(
338
+ 'language' => $locale,
339
+ 'native_name' => $locale,
340
+ 'lang' => '',
341
+ );
342
+ }
343
+ }
344
+ ?>
345
+ <div class="preferred-languages">
346
+ <p><?php _e( 'Choose languages for displaying WordPress in, in order of preference.', 'preferred-languages' ); ?></p>
347
+ <div class="active-locales">
348
+ <ul
349
+ role="listbox"
350
+ aria-labelledby="preferred-languages-label"
351
+ tabindex="0"
352
+ aria-activedescendant="<?php echo empty( $preferred_languages ) ? '' : esc_attr( get_locale() ); ?>"
353
+ id="preferred_languages"
354
+ class="active-locales-list <?php echo empty( $preferred_languages ) ? 'empty-list' : ''; ?>">
355
+ <?php foreach ( $preferred_languages as $language ) : ?>
356
+ <li
357
+ role="option"
358
+ aria-selected="<?php echo (string) ( get_locale() === $language['language'] ); ?>"
359
+ id="<?php echo esc_attr( $language['language'] ); ?>"
360
+ class="active-locale">
361
+ <?php echo esc_html( $language['native_name'] ); ?>
362
+ </li>
363
+ <?php endforeach; ?>
364
+ <li class="<?php echo ! empty( $preferred_languages ) ? 'hidden' : ''; ?>" id="active-locales-list-empty-message">
365
+ <?php _e( 'Nothing set.', 'preferred-languages' ); ?>
366
+ <br>
367
+ <?php
368
+ if ( true === $args['show_option_site_default'] ) {
369
+ _e( 'Falling back to Site Default.', 'preferred-languages' );
370
+ } else {
371
+ /* translators: %s: English (United States) */
372
+ printf( __( 'Falling back to %s.', 'preferred-languages' ), 'English (United States)' );
373
+ }
374
+ ?>
375
+ </li>
376
+ </ul>
377
+ <input type="hidden" name="preferred_languages" value="<?php echo esc_attr( implode( ',', $args['selected'] ) ); ?>"/>
378
+ <div class="active-locales-controls">
379
+ <ul>
380
+ <li>
381
+ <button
382
+ aria-keyshortcuts="Alt+ArrowUp"
383
+ aria-disabled="false"
384
+ type="button"
385
+ class="button locales-move-up">
386
+ <?php _e( 'Move Up', 'preferred-languages' ); ?>
387
+ </button>
388
+ </li>
389
+ <li>
390
+ <button
391
+ aria-keyshortcuts="Alt+ArrowDown"
392
+ aria-disabled="false"
393
+ type="button"
394
+ class="button locales-move-down">
395
+ <?php _e( 'Move Down', 'preferred-languages' ); ?>
396
+ </button>
397
+ </li>
398
+ <li>
399
+ <button
400
+ aria-keyshortcuts="Alt+Delete"
401
+ aria-disabled="false"
402
+ type="button"
403
+ class="button locales-remove">
404
+ <?php _e( 'Remove', 'preferred-languages' ); ?>
405
+ </button>
406
+ </li>
407
+ </ul>
408
+ </div>
409
+ </div>
410
+ </div>
411
+ <div class="inactive-locales">
412
+ <label class="screen-reader-text" for="preferred-languages-inactive-locales"><?php _e( 'Inactive Locales', 'preferred-languages' ); ?></label>
413
+ <div class="inactive-locales-list">
414
+ <?php
415
+ wp_dropdown_languages( array(
416
+ 'id' => 'preferred-languages-inactive-locales',
417
+ 'name' => 'preferred-languages-inactive-locales',
418
+ 'languages' => $languages,
419
+ 'translations' => $translations,
420
+ 'show_available_translations' => $args['show_available_translations'],
421
+ ) );
422
+ ?>
423
+ </div>
424
+ <div class="inactive-locales-controls">
425
+ <button type="button" class="button locales-add" data-action="add"><?php _e( 'Add', 'preferred-languages' ); ?></button>
426
+ </div>
427
+ </div>
428
+ <?php
429
+ }
js/preferred-languages.js ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ (function (wp, settings, $) {
4
+ var $activeLocales = $('.active-locales-list');
5
+ var $activeLocalesControls = $('.active-locales-controls');
6
+ var $inactiveLocales = $('.inactive-locales-list');
7
+ var $inactiveLocalesControls = $('.inactive-locales-controls');
8
+ var $selectedLocale = $activeLocales.find('li[aria-selected="true"]');
9
+ var $inputField = $('input[name="preferred_languages"]');
10
+
11
+ /**
12
+ * Changes the move button states.
13
+ *
14
+ * @since 1.0.0
15
+ *
16
+ * @param {jQuery} activeLocale Active locale element.
17
+ */
18
+ function changeButtonState(activeLocale) {
19
+ var activeLocalesList = $activeLocales.find('.active-locale');
20
+
21
+ $activeLocalesControls.find('.locales-move-up').attr('disabled', $activeLocales.hasClass('empty-list') || activeLocalesList.first().is(activeLocale));
22
+ $activeLocalesControls.find('.locales-move-down').attr('disabled', $activeLocales.hasClass('empty-list') || activeLocalesList.last().is(activeLocale));
23
+ $activeLocalesControls.find('.locales-remove').attr('disabled', $activeLocales.hasClass('empty-list'));
24
+ }
25
+
26
+ /**
27
+ * Toggles a locale.
28
+ *
29
+ * @since 1.0.0
30
+ *
31
+ * @param {jQuery} locale Locale element.
32
+ */
33
+ function toggleLocale(locale) {
34
+ var selected = locale.attr('aria-selected');
35
+ var newState = !!selected;
36
+
37
+ // It's already the current locale, so nothing to do here.
38
+ if (true === selected) {
39
+ return;
40
+ }
41
+
42
+ $selectedLocale.attr('aria-selected', false);
43
+
44
+ locale.attr('aria-selected', newState);
45
+
46
+ if (true === newState) {
47
+ $selectedLocale = locale;
48
+
49
+ $activeLocales.attr('aria-activedescendant', $selectedLocale.attr('id'));
50
+ }
51
+
52
+ changeButtonState(locale);
53
+ }
54
+
55
+ /**
56
+ * Updates the preferred languages input field after a change.
57
+ *
58
+ * @since 1.0.0
59
+ */
60
+ function updateHiddenInput() {
61
+ var _this = this;
62
+
63
+ var locales = [];
64
+
65
+ $activeLocales.children('.active-locale').each(function () {
66
+ locales.push($(_this).attr('id'));
67
+ });
68
+
69
+ $inputField.val(locales.join(','));
70
+ }
71
+
72
+ /**
73
+ * Moves a locale up in the list.
74
+ *
75
+ * @since 1.0.0
76
+ */
77
+ function moveLocaleUp() {
78
+
79
+ // 1. Change position if possible.
80
+ $selectedLocale.insertBefore($selectedLocale.prev());
81
+
82
+ // 2. Update hidden input field.
83
+ updateHiddenInput();
84
+
85
+ // 3. Update buttons.
86
+ changeButtonState($selectedLocale);
87
+
88
+ // 4. Announce to assistive technologies.
89
+ wp.a11y.speak(settings.l10n.movedUp);
90
+ }
91
+
92
+ /**
93
+ * Moves a locale down in the list.
94
+ *
95
+ * @since 1.0.0
96
+ */
97
+ function moveLocaleDown() {
98
+
99
+ // 1. Change position if possible.
100
+ $selectedLocale.insertAfter($selectedLocale.next());
101
+
102
+ // 2. Update hidden input field.
103
+ updateHiddenInput();
104
+
105
+ // 3. Update buttons.
106
+ changeButtonState($selectedLocale);
107
+
108
+ // 4. Announce to assistive technologies.
109
+ wp.a11y.speak(settings.l10n.movedDown);
110
+ }
111
+
112
+ /**
113
+ * Displays a message in case the list of active locales is empty.
114
+ *
115
+ * @since 1.0.0
116
+ */
117
+ function showEmptyListMessage() {
118
+ $activeLocales.addClass('empty-list');
119
+ $activeLocales.attr('aria-activedescendant', '');
120
+ $activeLocales.find('#active-locales-list-empty-message').removeClass('hidden');
121
+ }
122
+
123
+ /**
124
+ * Hides the empty list of locales message.
125
+ *
126
+ * @since 1.0.0
127
+ */
128
+ function hideEmptyListMessage() {
129
+ $activeLocales.removeClass('empty-list');
130
+ $activeLocales.find('#active-locales-list-empty-message').addClass('hidden');
131
+ }
132
+
133
+ /**
134
+ * Removes an active locale from the list.
135
+ *
136
+ * @since 1.0.0
137
+ */
138
+ function removeActiveLocale() {
139
+ var locale = $selectedLocale.attr('id');
140
+ var $successor = void 0;
141
+
142
+ $successor = $selectedLocale.prev(':visible');
143
+
144
+ if (0 === $successor.length) {
145
+ $successor = $selectedLocale.next(':visible');
146
+ }
147
+
148
+ // 1. Remove selected locale.
149
+ $selectedLocale.remove();
150
+
151
+ // 2. Make another locale the current one.
152
+ if ($successor.length > 0) {
153
+ toggleLocale($successor);
154
+ } else {
155
+ showEmptyListMessage();
156
+ }
157
+
158
+ // 3. Update buttons.
159
+ changeButtonState($selectedLocale);
160
+
161
+ // 4. Update hidden input field.
162
+ updateHiddenInput();
163
+
164
+ // 5. Make visible in dropdown again.
165
+ $inactiveLocales.find('select option[value="' + locale + '"]').removeClass('hidden');
166
+
167
+ // 6. Announce to assistive technologies.
168
+ wp.a11y.speak(settings.l10n.localeRemoved);
169
+ }
170
+
171
+ /**
172
+ * Makes an inactive locale active.
173
+ *
174
+ * @since 1.0.0
175
+ *
176
+ * @param {jQuery} option The locale element.
177
+ */
178
+ function makeLocaleActive(option) {
179
+ var $newLocale = $('<li/>', { 'id': option.val(), text: option.text(), 'aria-selected': false, 'class': 'active-locale' });
180
+ var $successor = void 0;
181
+
182
+ $successor = option.prev(':not(.hidden)');
183
+
184
+ if (0 === $successor.length) {
185
+ $successor = option.next(':not(.hidden)');
186
+ }
187
+
188
+ if (0 === $successor.length) {
189
+ $successor = $inactiveLocales.find('option').first();
190
+ }
191
+
192
+ // 1. Change selected value in dropdown.
193
+ $successor.attr('selected', true);
194
+ $inactiveLocalesControls.val($successor.val());
195
+
196
+ // 2. Hide from dropdown.
197
+ option.removeAttr('selected').addClass('hidden');
198
+
199
+ // It's already in the list of active locales, stop here.
200
+ if ($activeLocales.find('#' + option.val()).length > 0) {
201
+ return;
202
+ }
203
+
204
+ // 3. Hide empty list message if present.
205
+ if ($activeLocales.hasClass('empty-list')) {
206
+ hideEmptyListMessage();
207
+ }
208
+
209
+ // 4. Add to list.
210
+ $activeLocales.append($newLocale);
211
+
212
+ toggleLocale($newLocale);
213
+
214
+ // 5. Scroll into view.
215
+ $activeLocales.animate({
216
+ scrollTop: $newLocale.offset().top - $activeLocales.offset().top + $activeLocales.scrollTop()
217
+ });
218
+
219
+ // 5. Update hidden input field.
220
+ updateHiddenInput();
221
+
222
+ // 6. Announce to assistive technologies.
223
+ wp.a11y.speak(settings.l10n.localeAdded);
224
+ }
225
+
226
+ // Hide original language settings.
227
+ $('.user-language-wrap').remove();
228
+ $('#WPLANG').parent().parent().remove();
229
+
230
+ // Remove en_US as an option from the dropdown.
231
+ $inactiveLocales.find('[lang="en"]').remove();
232
+
233
+ // Change initial button state.
234
+ changeButtonState($selectedLocale);
235
+
236
+ // Initially hide already active locales from dropdown.
237
+ if ($inputField.val().length) {
238
+ $.each($inputField.val().split(','), function (index, value) {
239
+ makeLocaleActive($inactiveLocales.find('[value="' + value + '"]'));
240
+ });
241
+ }
242
+
243
+ // Enabling sorting locales using drag and drop.
244
+ $activeLocales.sortable({
245
+ axis: 'y',
246
+ cursor: 'move',
247
+ items: ':not(#active-locales-list-empty-message)'
248
+ });
249
+
250
+ // Arrow key handler.
251
+ $activeLocales.on('keydown', function (e) {
252
+
253
+ // Up.
254
+ if (38 === e.which) {
255
+ if (e.altKey) {
256
+ moveLocaleUp();
257
+ } else {
258
+ $selectedLocale.prev().length && toggleLocale($selectedLocale.prev());
259
+ }
260
+
261
+ e.preventDefault();
262
+ }
263
+
264
+ // Down.
265
+ if (40 === e.which) {
266
+ if (e.altKey) {
267
+ moveLocaleDown();
268
+ } else {
269
+ $selectedLocale.next().length && toggleLocale($selectedLocale.next());
270
+ }
271
+
272
+ e.preventDefault();
273
+ }
274
+
275
+ // Backspace.
276
+ if (8 === e.which) {
277
+ removeActiveLocale();
278
+ e.preventDefault();
279
+ }
280
+ });
281
+
282
+ // Add new locale to list.
283
+ $inactiveLocalesControls.find('.locales-add').on('click', function () {
284
+ makeLocaleActive($inactiveLocales.find('select option:selected'));
285
+ });
286
+
287
+ // Select a locale.
288
+ $activeLocales.on('click', '.active-locale', function (e) {
289
+ toggleLocale($(e.currentTarget));
290
+ });
291
+
292
+ $activeLocalesControls.find('.locales-move-up').on('click', moveLocaleUp);
293
+
294
+ $activeLocalesControls.find('.locales-move-down').on('click', moveLocaleDown);
295
+
296
+ // Remove locale from list.
297
+ $activeLocalesControls.find('.locales-remove').on('click', removeActiveLocale);
298
+ })(wp, preferredLanguages, jQuery);
js/preferred-languages.min.js ADDED
@@ -0,0 +1 @@
 
1
+ "use strict";(function(wp,settings,$){var $activeLocales=$(".active-locales-list");var $activeLocalesControls=$(".active-locales-controls");var $inactiveLocales=$(".inactive-locales-list");var $inactiveLocalesControls=$(".inactive-locales-controls");var $selectedLocale=$activeLocales.find('li[aria-selected="true"]');var $inputField=$('input[name="preferred_languages"]');function changeButtonState(activeLocale){var activeLocalesList=$activeLocales.find(".active-locale");$activeLocalesControls.find(".locales-move-up").attr("disabled",$activeLocales.hasClass("empty-list")||activeLocalesList.first().is(activeLocale));$activeLocalesControls.find(".locales-move-down").attr("disabled",$activeLocales.hasClass("empty-list")||activeLocalesList.last().is(activeLocale));$activeLocalesControls.find(".locales-remove").attr("disabled",$activeLocales.hasClass("empty-list"))}function toggleLocale(locale){var selected=locale.attr("aria-selected");var newState=!!selected;if(true===selected){return}$selectedLocale.attr("aria-selected",false);locale.attr("aria-selected",newState);if(true===newState){$selectedLocale=locale;$activeLocales.attr("aria-activedescendant",$selectedLocale.attr("id"))}changeButtonState(locale)}function updateHiddenInput(){var _this=this;var locales=[];$activeLocales.children(".active-locale").each(function(){locales.push($(_this).attr("id"))});$inputField.val(locales.join(","))}function moveLocaleUp(){$selectedLocale.insertBefore($selectedLocale.prev());updateHiddenInput();changeButtonState($selectedLocale);wp.a11y.speak(settings.l10n.movedUp)}function moveLocaleDown(){$selectedLocale.insertAfter($selectedLocale.next());updateHiddenInput();changeButtonState($selectedLocale);wp.a11y.speak(settings.l10n.movedDown)}function showEmptyListMessage(){$activeLocales.addClass("empty-list");$activeLocales.attr("aria-activedescendant","");$activeLocales.find("#active-locales-list-empty-message").removeClass("hidden")}function hideEmptyListMessage(){$activeLocales.removeClass("empty-list");$activeLocales.find("#active-locales-list-empty-message").addClass("hidden")}function removeActiveLocale(){var locale=$selectedLocale.attr("id");var $successor=void 0;$successor=$selectedLocale.prev(":visible");if(0===$successor.length){$successor=$selectedLocale.next(":visible")}$selectedLocale.remove();if($successor.length>0){toggleLocale($successor)}else{showEmptyListMessage()}changeButtonState($selectedLocale);updateHiddenInput();$inactiveLocales.find('select option[value="'+locale+'"]').removeClass("hidden");wp.a11y.speak(settings.l10n.localeRemoved)}function makeLocaleActive(option){var $newLocale=$("<li/>",{id:option.val(),text:option.text(),"aria-selected":false,class:"active-locale"});var $successor=void 0;$successor=option.prev(":not(.hidden)");if(0===$successor.length){$successor=option.next(":not(.hidden)")}if(0===$successor.length){$successor=$inactiveLocales.find("option").first()}$successor.attr("selected",true);$inactiveLocalesControls.val($successor.val());option.removeAttr("selected").addClass("hidden");if($activeLocales.find("#"+option.val()).length>0){return}if($activeLocales.hasClass("empty-list")){hideEmptyListMessage()}$activeLocales.append($newLocale);toggleLocale($newLocale);$activeLocales.animate({scrollTop:$newLocale.offset().top-$activeLocales.offset().top+$activeLocales.scrollTop()});updateHiddenInput();wp.a11y.speak(settings.l10n.localeAdded)}$(".user-language-wrap").remove();$("#WPLANG").parent().parent().remove();$inactiveLocales.find('[lang="en"]').remove();changeButtonState($selectedLocale);if($inputField.val().length){$.each($inputField.val().split(","),function(index,value){makeLocaleActive($inactiveLocales.find('[value="'+value+'"]'))})}$activeLocales.sortable({axis:"y",cursor:"move",items:":not(#active-locales-list-empty-message)"});$activeLocales.on("keydown",function(e){if(38===e.which){if(e.altKey){moveLocaleUp()}else{$selectedLocale.prev().length&&toggleLocale($selectedLocale.prev())}e.preventDefault()}if(40===e.which){if(e.altKey){moveLocaleDown()}else{$selectedLocale.next().length&&toggleLocale($selectedLocale.next())}e.preventDefault()}if(8===e.which){removeActiveLocale();e.preventDefault()}});$inactiveLocalesControls.find(".locales-add").on("click",function(){makeLocaleActive($inactiveLocales.find("select option:selected"))});$activeLocales.on("click",".active-locale",function(e){toggleLocale($(e.currentTarget))});$activeLocalesControls.find(".locales-move-up").on("click",moveLocaleUp);$activeLocalesControls.find(".locales-move-down").on("click",moveLocaleDown);$activeLocalesControls.find(".locales-remove").on("click",removeActiveLocale)})(wp,preferredLanguages,jQuery);
js/src/preferred-languages.js ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( ( ( wp, settings, $ ) => {
2
+ const $activeLocales = $( '.active-locales-list' );
3
+ const $activeLocalesControls = $( '.active-locales-controls' );
4
+ const $inactiveLocales = $( '.inactive-locales-list' );
5
+ const $inactiveLocalesControls = $( '.inactive-locales-controls' );
6
+ let $selectedLocale = $activeLocales.find( 'li[aria-selected="true"]' );
7
+ const $inputField = $( 'input[name="preferred_languages"]' );
8
+
9
+ /**
10
+ * Changes the move button states.
11
+ *
12
+ * @since 1.0.0
13
+ *
14
+ * @param {jQuery} activeLocale Active locale element.
15
+ */
16
+ function changeButtonState( activeLocale ) {
17
+ const activeLocalesList = $activeLocales.find( '.active-locale' );
18
+
19
+ $activeLocalesControls.find( '.locales-move-up' ).attr(
20
+ 'disabled',
21
+ $activeLocales.hasClass( 'empty-list' ) || activeLocalesList.first().is( activeLocale )
22
+ );
23
+ $activeLocalesControls.find( '.locales-move-down' ).attr(
24
+ 'disabled',
25
+ $activeLocales.hasClass( 'empty-list' ) || activeLocalesList.last().is( activeLocale )
26
+ );
27
+ $activeLocalesControls.find( '.locales-remove' ).attr(
28
+ 'disabled',
29
+ $activeLocales.hasClass( 'empty-list' )
30
+ );
31
+ }
32
+
33
+ /**
34
+ * Toggles a locale.
35
+ *
36
+ * @since 1.0.0
37
+ *
38
+ * @param {jQuery} locale Locale element.
39
+ */
40
+ function toggleLocale( locale ) {
41
+ const selected = locale.attr( 'aria-selected' );
42
+ const newState = !! selected;
43
+
44
+ // It's already the current locale, so nothing to do here.
45
+ if ( true === selected ) {
46
+ return;
47
+ }
48
+
49
+ $selectedLocale.attr( 'aria-selected', false );
50
+
51
+ locale.attr( 'aria-selected', newState );
52
+
53
+ if ( true === newState ) {
54
+ $selectedLocale = locale;
55
+
56
+ $activeLocales.attr( 'aria-activedescendant', $selectedLocale.attr( 'id' ) );
57
+ }
58
+
59
+ changeButtonState( locale );
60
+ }
61
+
62
+ /**
63
+ * Updates the preferred languages input field after a change.
64
+ *
65
+ * @since 1.0.0
66
+ */
67
+ function updateHiddenInput() {
68
+ const locales = [];
69
+
70
+ $activeLocales.children( '.active-locale' ).each( () => {
71
+ locales.push( $( this ).attr( 'id' ) );
72
+ } );
73
+
74
+ $inputField.val( locales.join( ',' ) );
75
+ }
76
+
77
+ /**
78
+ * Moves a locale up in the list.
79
+ *
80
+ * @since 1.0.0
81
+ */
82
+ function moveLocaleUp() {
83
+
84
+ // 1. Change position if possible.
85
+ $selectedLocale.insertBefore( $selectedLocale.prev() );
86
+
87
+ // 2. Update hidden input field.
88
+ updateHiddenInput();
89
+
90
+ // 3. Update buttons.
91
+ changeButtonState( $selectedLocale );
92
+
93
+ // 4. Announce to assistive technologies.
94
+ wp.a11y.speak( settings.l10n.movedUp );
95
+ }
96
+
97
+ /**
98
+ * Moves a locale down in the list.
99
+ *
100
+ * @since 1.0.0
101
+ */
102
+ function moveLocaleDown() {
103
+
104
+ // 1. Change position if possible.
105
+ $selectedLocale.insertAfter( $selectedLocale.next() );
106
+
107
+ // 2. Update hidden input field.
108
+ updateHiddenInput();
109
+
110
+ // 3. Update buttons.
111
+ changeButtonState( $selectedLocale );
112
+
113
+ // 4. Announce to assistive technologies.
114
+ wp.a11y.speak( settings.l10n.movedDown );
115
+ }
116
+
117
+ /**
118
+ * Displays a message in case the list of active locales is empty.
119
+ *
120
+ * @since 1.0.0
121
+ */
122
+ function showEmptyListMessage() {
123
+ $activeLocales.addClass( 'empty-list' );
124
+ $activeLocales.attr( 'aria-activedescendant', '' );
125
+ $activeLocales.find( '#active-locales-list-empty-message' ).removeClass( 'hidden' );
126
+ }
127
+
128
+ /**
129
+ * Hides the empty list of locales message.
130
+ *
131
+ * @since 1.0.0
132
+ */
133
+ function hideEmptyListMessage() {
134
+ $activeLocales.removeClass( 'empty-list' );
135
+ $activeLocales.find( '#active-locales-list-empty-message' ).addClass( 'hidden' );
136
+ }
137
+
138
+ /**
139
+ * Removes an active locale from the list.
140
+ *
141
+ * @since 1.0.0
142
+ */
143
+ function removeActiveLocale() {
144
+ let locale = $selectedLocale.attr( 'id' );
145
+ let $successor;
146
+
147
+ $successor = $selectedLocale.prev( ':visible' );
148
+
149
+ if ( 0 === $successor.length ) {
150
+ $successor = $selectedLocale.next( ':visible' );
151
+ }
152
+
153
+ // 1. Remove selected locale.
154
+ $selectedLocale.remove();
155
+
156
+ // 2. Make another locale the current one.
157
+ if ( $successor.length > 0 ) {
158
+ toggleLocale( $successor );
159
+ } else {
160
+ showEmptyListMessage();
161
+ }
162
+
163
+ // 3. Update buttons.
164
+ changeButtonState( $selectedLocale );
165
+
166
+ // 4. Update hidden input field.
167
+ updateHiddenInput();
168
+
169
+ // 5. Make visible in dropdown again.
170
+ $inactiveLocales.find( `select option[value="${locale}"]` ).removeClass( 'hidden' );
171
+
172
+ // 6. Announce to assistive technologies.
173
+ wp.a11y.speak( settings.l10n.localeRemoved );
174
+ }
175
+
176
+ /**
177
+ * Makes an inactive locale active.
178
+ *
179
+ * @since 1.0.0
180
+ *
181
+ * @param {jQuery} option The locale element.
182
+ */
183
+ function makeLocaleActive( option ) {
184
+ const $newLocale = $( '<li/>', { 'id': option.val(), text: option.text(), 'aria-selected': false, 'class': 'active-locale' } );
185
+ let $successor;
186
+
187
+ $successor = option.prev( ':not(.hidden)' );
188
+
189
+ if ( 0 === $successor.length ) {
190
+ $successor = option.next( ':not(.hidden)' );
191
+ }
192
+
193
+ if ( 0 === $successor.length ) {
194
+ $successor = $inactiveLocales.find( 'option' ).first();
195
+ }
196
+
197
+ // 1. Change selected value in dropdown.
198
+ $successor.attr( 'selected', true );
199
+ $inactiveLocalesControls.val( $successor.val() );
200
+
201
+ // 2. Hide from dropdown.
202
+ option.removeAttr( 'selected' ).addClass( 'hidden' );
203
+
204
+ // It's already in the list of active locales, stop here.
205
+ if ( $activeLocales.find( `#${option.val()}` ).length > 0 ) {
206
+ return;
207
+ }
208
+
209
+ // 3. Hide empty list message if present.
210
+ if ( $activeLocales.hasClass( 'empty-list' ) ) {
211
+ hideEmptyListMessage();
212
+ }
213
+
214
+ // 4. Add to list.
215
+ $activeLocales.append( $newLocale );
216
+
217
+ toggleLocale( $newLocale );
218
+
219
+ // 5. Scroll into view.
220
+ $activeLocales.animate({
221
+ scrollTop: $newLocale.offset().top - $activeLocales.offset().top + $activeLocales.scrollTop()
222
+ });
223
+
224
+ // 5. Update hidden input field.
225
+ updateHiddenInput();
226
+
227
+ // 6. Announce to assistive technologies.
228
+ wp.a11y.speak( settings.l10n.localeAdded );
229
+ }
230
+
231
+ // Hide original language settings.
232
+ $( '.user-language-wrap' ).remove();
233
+ $( '#WPLANG' ).parent().parent().remove();
234
+
235
+ // Remove en_US as an option from the dropdown.
236
+ $inactiveLocales.find( '[lang="en"]' ).remove();
237
+
238
+ // Change initial button state.
239
+ changeButtonState( $selectedLocale );
240
+
241
+ // Initially hide already active locales from dropdown.
242
+ if ( $inputField.val().length ) {
243
+ $.each( $inputField.val().split( ',' ), ( index, value ) => {
244
+ makeLocaleActive( $inactiveLocales.find( `[value="${value}"]` ) );
245
+ } );
246
+ }
247
+
248
+ // Enabling sorting locales using drag and drop.
249
+ $activeLocales.sortable({
250
+ axis: 'y',
251
+ cursor: 'move',
252
+ items: ':not(#active-locales-list-empty-message)'
253
+ });
254
+
255
+ // Arrow key handler.
256
+ $activeLocales.on( 'keydown', e => {
257
+
258
+ // Up.
259
+ if ( 38 === e.which ) {
260
+ if ( e.altKey ) {
261
+ moveLocaleUp();
262
+ } else {
263
+ $selectedLocale.prev().length && toggleLocale( $selectedLocale.prev() );
264
+ }
265
+
266
+ e.preventDefault();
267
+ }
268
+
269
+ // Down.
270
+ if ( 40 === e.which ) {
271
+ if ( e.altKey ) {
272
+ moveLocaleDown();
273
+ } else {
274
+ $selectedLocale.next().length && toggleLocale( $selectedLocale.next() );
275
+ }
276
+
277
+ e.preventDefault();
278
+ }
279
+
280
+ // Backspace.
281
+ if ( 8 === e.which ) {
282
+ removeActiveLocale();
283
+ e.preventDefault();
284
+ }
285
+ } );
286
+
287
+ // Add new locale to list.
288
+ $inactiveLocalesControls.find( '.locales-add' ).on( 'click', () => {
289
+ makeLocaleActive( $inactiveLocales.find( 'select option:selected' ) );
290
+ } );
291
+
292
+ // Select a locale.
293
+ $activeLocales.on( 'click', '.active-locale', ( e ) => {
294
+ toggleLocale( $( e.currentTarget ) );
295
+ } );
296
+
297
+ $activeLocalesControls.find( '.locales-move-up' ).on( 'click', moveLocaleUp );
298
+
299
+ $activeLocalesControls.find( '.locales-move-down' ).on( 'click', moveLocaleDown );
300
+
301
+ // Remove locale from list.
302
+ $activeLocalesControls.find( '.locales-remove' ).on( 'click', removeActiveLocale );
303
+ } ) )( wp, preferredLanguages, jQuery );
preferred-languages.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Preferred Languages
4
+ * Plugin URI: https://github.com/swissspidy/preferred-languages/
5
+ * Description: Choose languages for displaying WordPress in, in order of preference.
6
+ * Version: 1.0.0
7
+ * Author: Pascal Birchler
8
+ * Author URI: https://pascalbirchler.com
9
+ * License: GPL-2.0+
10
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11
+ * Text Domain: preferred-languages
12
+ * Domain Path: /languages
13
+ *
14
+ * Copyright (c) 2017 Pascal Birchler (email: swissspidy@chat.wordpress.org)
15
+ *
16
+ * This program is free software; you can redistribute it and/or modify
17
+ * it under the terms of the GNU General Public License, version 2 or, at
18
+ * your discretion, any later version, as published by the Free
19
+ * Software Foundation.
20
+ *
21
+ * This program is distributed in the hope that it will be useful,
22
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ * GNU General Public License for more details.
25
+ *
26
+ * You should have received a copy of the GNU General Public License
27
+ * along with this program; if not, write to the Free Software
28
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29
+ */
30
+
31
+ require_once( dirname( __FILE__ ) . '/inc/functions.php' );
32
+ require_once( dirname( __FILE__ ) . '/inc/default-filters.php' );
33
+
34
+
readme.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Preferred Languages ===
2
+ Contributors: swissspidy
3
+ Tags: internationalization, i18n, localization, l10n, language, locale, translation
4
+ Requires at least: 4.7
5
+ Tested up to: 4.7
6
+ Stable tag: 1.0.0
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Choose languages for displaying WordPress in, in order of preference.
11
+
12
+ == Description ==
13
+
14
+ Thanks to language packs it's easier than ever before to change the main language of your site. However, in some cases a single locale is not enough. When WordPress can't find a translation for the active locale, it falls back to the original English strings. That’s a poor user experience for many non-English speakers.
15
+
16
+ This feature project aims to change that by letting users choos multiple languages for displaying WordPress in. That way you can set some sort of "fallback chain" where WordPress tries to load translations in your preferred order.
17
+
18
+ == Installation ==
19
+
20
+ 1. Upload the plugin files to the `/wp-content/plugins/preferred-languages` directory, or install the plugin through the WordPress plugins screen directly.
21
+ 1. Activate the plugin through the 'Plugins' screen in WordPress
22
+ 1. Choose your preferred languages through 'Settings' -> 'General' or your user profile.
23
+
24
+ == Screenshots ==
25
+
26
+ 1. The new language section in 'Settings' -> 'General'
27
+ 2. The new language section in your user profile.
28
+
29
+ == Changelog ==
30
+
31
+ = 1.0.0 =
32
+ * Initial release.
uninstall.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined( 'WP_UNINSTALL_PLUGIN' ) or die;
4
+
5
+ delete_option( 'preferred_languages' );
6
+ delete_metadata( 'user', null, 'preferred_languages', '', true );