PluginProbe
Bogo / 2.9
Bogo v2.9
3.9.3 trunk 1.0 1.1 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5 2.6 2.6.1 2.7 2.8 2.8.1 2.9 3.0 3.0.1 All 52 releases
← All changes | includes/functions.php +24 -40 3.02.9 View file →
@@ -77,9 +77,9 @@
77 77 'ja' => __( 'Japanese', 'bogo' ),
78 78 'jv_ID' => __( 'Javanese', 'bogo' ),
79 79 'ka_GE' => __( 'Georgian', 'bogo' ),
80 80 'kk' => __( 'Kazakh', 'bogo' ),
81 - 'km' => __( 'Khmer', 'bogo' ),
81 + 'km_KH' => __( 'Khmer', 'bogo' ),
82 82 'kn' => __( 'Kannada', 'bogo' ),
83 83 'ko_KR' => __( 'Korean', 'bogo' ),
84 84 'li' => __( 'Limburgish', 'bogo' ),
85 85 'lo' => __( 'Lao', 'bogo' ),
@@ -176,20 +176,14 @@
176 176 return false;
177 177 }
178 178
179 179 function bogo_get_default_locale() {
180 - static $locale = '';
181 -
182 - if ( ! empty( $locale ) ) {
183 - return $locale;
184 - }
185 -
186 180 if ( defined( 'WPLANG' ) ) {
187 181 $locale = WPLANG;
188 182 }
189 183
190 184 if ( is_multisite() ) {
191 - if ( wp_installing()
185 + if ( defined( 'WP_INSTALLING' )
192 186 || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) {
193 187 $ms_locale = get_site_option( 'WPLANG' );
194 188 }
195 189
@@ -203,13 +197,13 @@
203 197 $locale = $db_locale;
204 198 }
205 199 }
206 200
207 - if ( ! empty( $locale ) ) {
208 - return $locale;
201 + if ( empty( $locale ) ) {
202 + $locale = 'en_US';
209 203 }
210 204
211 - return 'en_US';
205 + return $locale;
212 206 }
213 207
214 208 function bogo_is_default_locale( $locale ) {
215 209 $default_locale = bogo_get_default_locale();
@@ -216,16 +210,8 @@
216 210
217 211 return ! empty( $locale ) && $locale == bogo_get_default_locale();
218 212 }
219 213
220 -function bogo_is_enus_deactivated() {
221 - if ( bogo_is_default_locale( 'en_US' ) ) {
222 - return false;
223 - }
224 -
225 - return (bool) bogo_get_prop( 'enus_deactivated' );
226 -}
227 -
228 214 function bogo_available_locales( $args = '' ) {
229 215 $defaults = array(
230 216 'exclude' => array(),
231 217 'exclude_enus_if_inactive' => false,
@@ -232,39 +218,37 @@
232 218 'current_user_can_access' => false );
233 219
234 220 $args = wp_parse_args( $args, $defaults );
235 221
236 - static $installed_locales = array();
222 + $installed_locales = get_available_languages();
223 + $installed_locales[] = bogo_get_default_locale();
237 224
238 - if ( empty( $installed_locales ) ) {
239 - $installed_locales = get_available_languages();
240 - $installed_locales[] = bogo_get_default_locale();
225 + $exclude_enus = $args['exclude_enus_if_inactive']
226 + && bogo_get_prop( 'enus_deactivated' );
227 +
228 + if ( ! $exclude_enus ) {
241 229 $installed_locales[] = 'en_US';
242 230 }
243 231
244 - $available_locales = $installed_locales;
232 + $installed_locales = array_unique( $installed_locales );
233 + $installed_locales = array_filter( $installed_locales );
245 234
246 - if ( $args['current_user_can_access']
247 - && ! current_user_can( 'bogo_access_all_locales' ) ) {
248 - $user_accessible_locales = bogo_get_user_accessible_locales(
249 - get_current_user_id() );
235 + $available_locales = array();
250 236
251 - $available_locales = array_intersect( $available_locales,
252 - (array) $user_accessible_locales );
253 - }
237 + foreach ( $installed_locales as $locale ) {
238 + if ( in_array( $locale, (array) $args['exclude'] ) ) {
239 + continue;
240 + }
254 241
255 - if ( ! empty( $args['exclude'] ) ) {
256 - $available_locales = array_diff( $available_locales,
257 - (array) $args['exclude'] );
258 - }
242 + if ( $args['current_user_can_access']
243 + && ! current_user_can( 'bogo_access_locale', $locale ) ) {
244 + continue;
245 + }
259 246
260 - if ( $args['exclude_enus_if_inactive']
261 - && bogo_is_enus_deactivated() ) {
262 - $available_locales = array_diff( $available_locales,
263 - array( 'en_US' ) );
247 + $available_locales[] = $locale;
264 248 }
265 249
266 - return array_unique( array_filter( $available_locales ) );
250 + return $available_locales;
267 251 }
268 252
269 253 function bogo_available_languages( $args = '' ) {
270 254 $defaults = array(