Version Description
This release fixes a bug that prevented saving changes in some cases.
Download this release
Release Info
Developer | swissspidy |
Plugin | Preferred Languages |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- css/preferred-languages-rtl.css +1 -1
- css/preferred-languages.css +1 -1
- css/src/preferred-languages.css +0 -59
- inc/functions.php +2 -2
- js/preferred-languages.js +2 -4
- js/preferred-languages.min.js +1 -1
- js/src/preferred-languages.js +0 -303
- preferred-languages.php +1 -1
- readme.txt +17 -9
css/preferred-languages-rtl.css
CHANGED
@@ -1 +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%}
|
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{box-sizing:border-box;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
CHANGED
@@ -1 +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%}
|
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{box-sizing:border-box;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
DELETED
@@ -1,59 +0,0 @@
|
|
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/functions.php
CHANGED
@@ -224,7 +224,7 @@ function preferred_languages_register_scripts() {
|
|
224 |
'jquery-ui-sortable',
|
225 |
'wp-a11y',
|
226 |
),
|
227 |
-
'
|
228 |
true
|
229 |
);
|
230 |
|
@@ -247,7 +247,7 @@ function preferred_languages_register_scripts() {
|
|
247 |
'preferred-languages',
|
248 |
plugin_dir_url( dirname( __FILE__ ) ) . 'css/preferred-languages' . $rtl_suffix . '.css',
|
249 |
array(),
|
250 |
-
'
|
251 |
'screen'
|
252 |
);
|
253 |
}
|
224 |
'jquery-ui-sortable',
|
225 |
'wp-a11y',
|
226 |
),
|
227 |
+
'20171002',
|
228 |
true
|
229 |
);
|
230 |
|
247 |
'preferred-languages',
|
248 |
plugin_dir_url( dirname( __FILE__ ) ) . 'css/preferred-languages' . $rtl_suffix . '.css',
|
249 |
array(),
|
250 |
+
'20171002',
|
251 |
'screen'
|
252 |
);
|
253 |
}
|
js/preferred-languages.js
CHANGED
@@ -58,12 +58,10 @@
|
|
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($(
|
67 |
});
|
68 |
|
69 |
$inputField.val(locales.join(','));
|
58 |
* @since 1.0.0
|
59 |
*/
|
60 |
function updateHiddenInput() {
|
|
|
|
|
61 |
var locales = [];
|
62 |
|
63 |
+
$activeLocales.children('.active-locale').each(function (index, el) {
|
64 |
+
locales.push($(el).attr('id'));
|
65 |
});
|
66 |
|
67 |
$inputField.val(locales.join(','));
|
js/preferred-languages.min.js
CHANGED
@@ -1 +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
|
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 locales=[];$activeLocales.children(".active-locale").each(function(index,el){locales.push($(el).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
DELETED
@@ -1,303 +0,0 @@
|
|
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
CHANGED
@@ -3,7 +3,7 @@
|
|
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.
|
7 |
* Author: Pascal Birchler
|
8 |
* Author URI: https://pascalbirchler.com
|
9 |
* License: GPL-2.0+
|
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.1
|
7 |
* Author: Pascal Birchler
|
8 |
* Author URI: https://pascalbirchler.com
|
9 |
* License: GPL-2.0+
|
readme.txt
CHANGED
@@ -2,8 +2,9 @@
|
|
2 |
Contributors: swissspidy
|
3 |
Tags: internationalization, i18n, localization, l10n, language, locale, translation
|
4 |
Requires at least: 4.7
|
5 |
-
Tested up to: 4.
|
6 |
-
|
|
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -13,20 +14,27 @@ Choose languages for displaying WordPress in, in order of preference.
|
|
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
|
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.
|
2 |
Contributors: swissspidy
|
3 |
Tags: internationalization, i18n, localization, l10n, language, locale, translation
|
4 |
Requires at least: 4.7
|
5 |
+
Tested up to: 4.8
|
6 |
+
Requires PHP: 5.2
|
7 |
+
Stable tag: 1.0.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
14 |
|
15 |
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.
|
16 |
|
17 |
+
This feature project aims to change that by letting users choose 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
== Screenshots ==
|
20 |
|
21 |
1. The new language section in 'Settings' -> 'General'
|
22 |
2. The new language section in your user profile.
|
23 |
|
24 |
+
== Upgrade Notice ==
|
25 |
+
|
26 |
+
= 1.0.1 =
|
27 |
+
|
28 |
+
This release fixes a bug that prevented saving changes in some cases.
|
29 |
+
|
30 |
+
= 1.0.0 =
|
31 |
+
|
32 |
+
Initial release.
|
33 |
+
|
34 |
== Changelog ==
|
35 |
|
36 |
+
= 1.0.1 =
|
37 |
+
* Fixed: Fixed a bug that prevented saving changes.
|
38 |
+
|
39 |
= 1.0.0 =
|
40 |
* Initial release.
|