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 | admin/admin.php +67 -187 3.02.9 View file →
@@ -82,18 +82,18 @@
82 82 'bogo_manage_language_packs', 'bogo', 'bogo_tools_page',
83 83 'dashicons-translation', 73 ); // between Users (70) and Tools (75)
84 84
85 85 $tools = add_submenu_page( 'bogo',
86 - __( 'Language Packs', 'bogo' ),
87 - __( 'Language Packs', 'bogo' ),
86 + __( 'Installed Languages', 'bogo' ),
87 + __( 'Installed Languages', 'bogo' ),
88 88 'bogo_manage_language_packs', 'bogo', 'bogo_tools_page' );
89 89
90 90 add_action( 'load-' . $tools, 'bogo_load_tools_page' );
91 91
92 92 $texts = add_submenu_page( 'bogo',
93 - __( 'Terms Translation', 'bogo' ),
94 - __( 'Terms Translation', 'bogo' ),
95 - 'bogo_edit_terms_translation', 'bogo-texts', 'bogo_texts_page' );
93 + __( 'Translatable Text Strings', 'bogo' ),
94 + __( 'Text Translation', 'bogo' ),
95 + 'bogo_edit_text_translation', 'bogo-texts', 'bogo_texts_page' );
96 96
97 97 add_action( 'load-' . $texts, 'bogo_load_texts_page' );
98 98 }
99 99
@@ -124,35 +124,8 @@
124 124 wp_safe_redirect( $redirect_to );
125 125 exit();
126 126 }
127 127
128 - if ( 'set_site_lang' == $action ) {
129 - check_admin_referer( 'bogo-tools' );
130 -
131 - if ( ! current_user_can( 'bogo_manage_language_packs' ) ) {
132 - wp_die( __( "You are not allowed to manage translations.", 'bogo' ) );
133 - }
134 -
135 - $locale = isset( $_GET['locale'] ) ? $_GET['locale'] : null;
136 -
137 - if ( 'en_US' == $locale || ! bogo_is_available_locale( $locale ) ) {
138 - $locale = '';
139 - }
140 -
141 - if ( update_option( 'WPLANG', $locale ) ) {
142 - $redirect_to = add_query_arg(
143 - array( 'locale' => $locale, 'message' => 'site_lang_success' ),
144 - menu_page_url( 'bogo', false ) );
145 - } else {
146 - $redirect_to = add_query_arg(
147 - array( 'locale' => $locale, 'message' => 'site_lang_failed' ),
148 - menu_page_url( 'bogo', false ) );
149 - }
150 -
151 - wp_safe_redirect( $redirect_to );
152 - exit();
153 - }
154 -
155 128 if ( 'delete_translation' == $action ) {
156 129 check_admin_referer( 'bogo-tools' );
157 130
158 131 if ( ! current_user_can( 'bogo_manage_language_packs' ) ) {
@@ -207,27 +180,28 @@
207 180
208 181 if ( 'save' == $action ) {
209 182 check_admin_referer( 'bogo-edit-text-translation' );
210 183
211 - $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : null;
212 -
213 - if ( ! current_user_can( 'bogo_edit_terms_translation' ) ) {
184 + if ( ! current_user_can( 'bogo_edit_text_translation' ) ) {
214 185 wp_die( __( "You are not allowed to edit translations.", 'bogo' ) );
215 186 }
216 187
217 - $entries = array();
188 + $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : null;
218 189
219 - foreach ( $_POST as $p_key => $p_val ) {
220 - if ( in_array( $p_key, array( 'action', 'locale', 'submit' ) )
221 - || substr( $p_key, 0, 1 ) == '_' ) {
222 - continue;
223 - }
190 + $blogname =
191 + isset( $_POST['blogname'] ) ? $_POST['blogname'] : '';
192 + $blogdescription =
193 + isset( $_POST['blogdescription'] ) ? $_POST['blogdescription'] : '';
224 194
225 - $entries[] = array(
226 - 'singular' => $p_key,
227 - 'translations' => array( $p_val ),
228 - 'context' => preg_replace( '/:.*$/', '', $p_key ) );
229 - }
195 + $entries = array(
196 + array(
197 + 'singular' => 'blogname',
198 + 'translations' => array( $blogname ),
199 + 'context' => 'blogname' ),
200 + array(
201 + 'singular' => 'blogdescription',
202 + 'translations' => array( $blogdescription ),
203 + 'context' => 'blogdescription' ) );
230 204
231 205 if ( Bogo_POMO::export( $locale, $entries ) ) {
232 206 $message = 'translation_saved';
233 207 } else {
@@ -243,9 +217,9 @@
243 217 }
244 218 }
245 219
246 220 function bogo_tools_page() {
247 - $enus_deactivated = bogo_is_enus_deactivated();
221 + $enus_deactivated = bogo_get_prop( 'enus_deactivated' );
248 222 $can_install = wp_can_install_language_pack();
249 223
250 224 $default_locale = bogo_get_default_locale();
251 225 $available_locales = bogo_available_locales();
@@ -252,24 +226,24 @@
252 226
253 227 ?>
254 228 <div class="wrap">
255 229
256 -<h1><?php echo esc_html( __( 'Language Packs', 'bogo' ) ); ?></h1>
230 +<h1><?php echo esc_html( __( 'Available Languages', 'bogo' ) ); ?></h1>
257 231
258 232 <?php bogo_admin_notice(); ?>
259 233
260 234 <table id="bogo-languages-table" class="widefat">
261 235 <thead>
262 - <tr><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr>
236 + <tr><th></th><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr>
263 237 </thead>
264 238 <tfoot>
265 - <tr><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr>
239 + <tr><th></th><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr>
266 240 </tfoot>
267 241 <tbody id="translations">
268 - <tr class="active" id="language-1"><td>
242 + <tr class="active"><th>1</th><td>
269 243 <strong><?php echo esc_html( bogo_get_language( $default_locale ) ); ?></strong>
270 244 [<?php echo esc_html( $default_locale ); ?>]
271 - <div class="status"><?php echo esc_html( __( 'Site Language', 'bogo' ) ); ?></div>
245 + <div class="status"><span class="status"><?php echo esc_html( __( 'Site Default Language', 'bogo' ) ); ?></span></div>
272 246 </td></tr>
273 247
274 248 <?php
275 249 $count = 1;
@@ -281,17 +255,14 @@
281 255
282 256 $count += 1;
283 257 $class = 'active';
284 258
285 - if ( ! $language = bogo_get_language( $locale ) ) {
286 - $language = $locale;
287 - }
288 -
289 259 if ( 'en_US' == $locale ) {
290 260 $status = $enus_deactivated
291 - ? __( 'Inactive', 'bogo' ) : __( 'Active', 'bogo' );
261 + ? esc_html( __( 'Inactive', 'bogo' ) )
262 + : esc_html( __( 'Active', 'bogo' ) );
292 263 } else {
293 - $status = __( 'Installed', 'bogo' );
264 + $status = esc_html( __( 'Installed', 'bogo' ) );
294 265 }
295 266
296 267 if ( 'en_US' == $locale ) {
297 268 if ( $enus_deactivated ) {
@@ -300,30 +271,17 @@
300 271 array( 'action' => 'activate_enus' ),
301 272 $activate_link );
302 273 $activate_link = wp_nonce_url( $activate_link, 'bogo-tools' );
303 274 $activate_link = sprintf(
304 - '<a href="%1$s" class="activate" aria-label="%3$s">%2$s</a>',
275 + '<a href="%1$s" class="activate">%2$s</a>',
305 276 $activate_link,
306 - esc_html( __( 'Activate', 'bogo' ) ),
307 - esc_attr(
308 - sprintf( __( 'Activate %s language pack', 'bogo' ), $language ) ) );
277 + esc_html( __( 'Activate', 'bogo' ) ) );
309 278
310 - $row_actions = array( $activate_link );
311 -
279 + $status = sprintf(
280 + '<div class="status"><span class="status">%s</span> | %s</div>',
281 + $status, $activate_link );
312 282 $class = '';
313 283 } else {
314 - $sitelang_link = menu_page_url( 'bogo', false );
315 - $sitelang_link = add_query_arg(
316 - array( 'action' => 'set_site_lang', 'locale' => $locale ),
317 - $sitelang_link );
318 - $sitelang_link = wp_nonce_url( $sitelang_link, 'bogo-tools' );
319 - $sitelang_link = sprintf(
320 - '<a href="%1$s" class="sitelang" aria-label="%3$s">%2$s</a>',
321 - $sitelang_link,
322 - esc_html( __( 'Set as Site Language', 'bogo' ) ),
323 - esc_attr(
324 - sprintf( __( 'Set %s as Site Language', 'bogo' ), $language ) ) );
325 -
326 284 $deactivate_link = menu_page_url( 'bogo', false );
327 285 $deactivate_link = add_query_arg(
328 286 array( 'action' => 'deactivate_enus' ),
329 287 $deactivate_link );
@@ -328,29 +286,17 @@
328 286 array( 'action' => 'deactivate_enus' ),
329 287 $deactivate_link );
330 288 $deactivate_link = wp_nonce_url( $deactivate_link, 'bogo-tools' );
331 289 $deactivate_link = sprintf(
332 - '<a href="%1$s" class="deactivate" aria-label="%3$s">%2$s</a>',
290 + '<a href="%1$s" class="deactivate">%2$s</a>',
333 291 $deactivate_link,
334 - esc_html( __( 'Deactivate', 'bogo' ) ),
335 - esc_attr( sprintf(
336 - __( 'Deactivate %s language pack', 'bogo' ), $language ) ) );
292 + esc_html( __( 'Deactivate', 'bogo' ) ) );
337 293
338 - $row_actions = array( $sitelang_link, $deactivate_link );
294 + $status = sprintf(
295 + '<div class="status"><span class="status">%s</span> | %s</div>',
296 + $status, $deactivate_link );
339 297 }
340 298 } elseif ( $can_install ) {
341 - $sitelang_link = menu_page_url( 'bogo', false );
342 - $sitelang_link = add_query_arg(
343 - array( 'action' => 'set_site_lang', 'locale' => $locale ),
344 - $sitelang_link );
345 - $sitelang_link = wp_nonce_url( $sitelang_link, 'bogo-tools' );
346 - $sitelang_link = sprintf(
347 - '<a href="%1$s" class="sitelang" aria-label="%3$s">%2$s</a>',
348 - $sitelang_link,
349 - esc_html( __( 'Set as Site Language', 'bogo' ) ),
350 - esc_attr(
351 - sprintf( __( 'Set %s as Site Language', 'bogo' ), $language ) ) );
352 -
353 299 $delete_link = menu_page_url( 'bogo', false );
354 300 $delete_link = add_query_arg(
355 301 array( 'action' => 'delete_translation', 'locale' => $locale ),
356 302 $delete_link );
@@ -355,26 +301,30 @@
355 301 array( 'action' => 'delete_translation', 'locale' => $locale ),
356 302 $delete_link );
357 303 $delete_link = wp_nonce_url( $delete_link, 'bogo-tools' );
358 304
359 - $delete_confirm = sprintf( __( "You are about to delete %s language pack.\n 'Cancel' to stop, 'OK' to delete.", 'bogo' ), $language );
305 + if ( ! $delete_language = bogo_get_language( $locale ) ) {
306 + $delete_language = $locale;
307 + }
360 308
361 - $delete_link = sprintf( '<a href="%1$s" class="delete" onclick="if (confirm(\'%3$s\')){return true;} return false;" aria-label="%4$s">%2$s</a>',
309 + $delete_confirm = sprintf( __( "You are about to delete %s language pack.\n 'Cancel' to stop, 'OK' to delete.", 'bogo' ), $delete_language );
310 +
311 + $delete_link = sprintf( '<a href="%1$s" class="delete" onclick="if (confirm(\'%3$s\')){return true;} return false;">%2$s</a>',
362 312 $delete_link,
363 313 esc_html( __( 'Delete', 'bogo' ) ),
364 - esc_js( $delete_confirm ),
365 - esc_attr(
366 - sprintf( __( 'Delete %s language pack', 'bogo' ), $language ) ) );
314 + esc_js( $delete_confirm ) );
367 315
368 - $row_actions = array( $sitelang_link, $delete_link );
316 + $status = sprintf(
317 + '<div class="status"><span class="status">%s</span> | %s</div>',
318 + $status, $delete_link );
369 319 }
370 320 ?>
371 - <tr class="<?php echo esc_attr( $class ); ?>" id="language-<?php echo absint( $count ); ?>">
321 + <tr class="<?php echo esc_attr( $class ); ?>">
322 + <th><?php echo $count; ?></th>
372 323 <td>
373 324 <strong><?php echo esc_html( bogo_get_language( $locale ) ); ?></strong>
374 325 [<?php echo esc_html( $locale ); ?>]
375 - <div class="status"><?php echo esc_html( $status ); ?></div>
376 - <div class="row-actions"><?php echo implode( ' | ', $row_actions ); ?></div>
326 + <?php echo $status; ?>
377 327 </td>
378 328 </tr>
379 329 <?php
380 330 }
@@ -393,22 +343,16 @@
393 343 $install_link = add_query_arg(
394 344 array( 'action' => 'install_translation', 'locale' => $locale ),
395 345 $install_link );
396 346 $install_link = wp_nonce_url( $install_link, 'bogo-tools' );
397 - $install_link = sprintf( '<a href="%1$s" class="install" aria-label="%3$s">%2$s</a>',
398 - $install_link,
399 - esc_html( __( 'Install', 'bogo' ) ),
400 - esc_attr(
401 - sprintf( __( 'Install %s language pack', 'bogo' ),
402 - bogo_get_language( $locale ) ) ) );
403 -
404 - $row_actions = array( $install_link );
347 + $install_link = sprintf( '<a href="%1$s" class="install">%2$s</a>',
348 + $install_link, esc_html( __( 'Install', 'bogo' ) ) );
405 349 }
406 350 ?>
407 - <tr id="language-<?php echo absint( $count ); ?>"><td>
351 + <tr><th><?php echo $count; ?></th><td>
408 352 <strong><?php echo esc_html( bogo_get_language( $locale ) ); ?></strong>
409 353 [<?php echo esc_html( $locale ); ?>]
410 - <div class="row-actions"><?php echo implode( ' | ', $row_actions ); ?></div>
354 + <?php echo $install_link; ?>
411 355 </td></tr>
412 356 <?php
413 357 }
414 358 ?>
@@ -421,17 +365,14 @@
421 365 }
422 366
423 367 function bogo_texts_page() {
424 368 $locale_to_edit = isset( $_GET['locale'] ) ? $_GET['locale'] : '';
369 + Bogo_POMO::import( $locale_to_edit );
425 370
426 - if ( ! Bogo_POMO::import( $locale_to_edit ) ) {
427 - Bogo_POMO::reset();
428 - }
429 -
430 371 ?>
431 372 <div class="wrap">
432 373
433 -<h1><?php echo esc_html( __( 'Terms Translation', 'bogo' ) ); ?></h1>
374 +<h1><?php echo esc_html( __( 'Translatable Text Strings', 'bogo' ) ); ?></h1>
434 375
435 376 <?php bogo_admin_notice(); ?>
436 377
437 378 <form action="" method="post" id="bogo-translatable-text-strings">
@@ -441,12 +382,9 @@
441 382 <p>
442 383 <select name="locale" id="select-locale">
443 384 <option value=""><?php echo esc_html( __( '-- Select Language to Edit --', 'bogo' ) ); ?></option>
444 385 <?php
445 - $available_locales = bogo_available_locales(
446 - array( 'current_user_can_access' => true ) );
447 -
448 - foreach ( $available_locales as $locale ) {
386 + foreach ( bogo_available_locales() as $locale ) {
449 387 echo sprintf( '<option value="%1$s"%3$s>%2$s</option>',
450 388 esc_attr( $locale ),
451 389 esc_html( bogo_get_language( $locale ) ),
452 390 $locale == $locale_to_edit ? ' selected="selected"' : '' );
@@ -454,78 +392,24 @@
454 392 ?>
455 393 </select>
456 394 </p>
457 395
458 -<?php
459 - if ( bogo_is_available_locale( $locale_to_edit ) ) :
460 - $strings = array(
461 - array(
462 - 'name' => 'blogname',
463 - 'original' => get_option( 'blogname' ),
464 - 'translated' => bogo_translate( 'blogname',
465 - 'blogname', get_option( 'blogname' ) ),
466 - 'context' => __( 'Site Title', 'bogo' ) ),
467 - array(
468 - 'name' => 'blogdescription',
469 - 'original' => get_option( 'blogdescription' ),
470 - 'translated' => bogo_translate( 'blogdescription',
471 - 'blogdescription', get_option( 'blogdescription' ) ),
472 - 'context' => __( 'Tagline', 'bogo' ) ) );
473 -
474 - remove_filter( 'get_term', 'bogo_get_term_filter' );
475 -
476 - foreach ( (array) get_taxonomies( array(), 'objects' ) as $taxonomy ) {
477 - $tax_labels = get_taxonomy_labels( $taxonomy );
478 - $terms = get_terms( array(
479 - 'taxonomy' => $taxonomy->name,
480 - 'orderby' => 'slug',
481 - 'hide_empty' => false ) );
482 -
483 - foreach ( (array) $terms as $term ) {
484 - $name = sprintf( '%s:%d', $taxonomy->name, $term->term_id );
485 - $strings[] = array(
486 - 'name' => $name,
487 - 'original' => $term->name,
488 - 'translated' => bogo_translate( $name,
489 - $taxonomy->name, $term->name ),
490 - 'context' => $tax_labels->name );
491 - }
492 - }
493 -?>
494 -<table class="wp-list-table widefat fixed striped" id="bogo-translation-table">
495 -<thead>
396 +<?php if ( bogo_is_available_locale( $locale_to_edit ) ) : ?>
397 +<table class="form-table">
398 +<tbody>
496 399 <tr>
497 - <th scope="col"><?php echo esc_html( __( 'Original', 'bogo' ) ); ?></th>
498 - <th scope="col"><?php echo esc_html( __( 'Translation', 'bogo' ) ); ?></th>
499 - <th scope="col" style="width: 20%;"><?php echo esc_html( __( 'Context', 'bogo' ) ); ?></th>
400 + <th scope="row"><label for="blogname"><?php echo esc_html( __( 'Site Title' ) ); ?></label></th>
401 + <td><input name="blogname" type="text" id="blogname" value="<?php echo esc_attr( bogo_translate( 'blogname', 'blogname', get_option( 'blogname' ) ) ); ?>" class="regular-text" /></td>
500 402 </tr>
501 -</thead>
502 -<tfoot>
503 403 <tr>
504 - <th scope="col"><?php echo esc_html( __( 'Original', 'bogo' ) ); ?></th>
505 - <th scope="col"><?php echo esc_html( __( 'Translation', 'bogo' ) ); ?></th>
506 - <th scope="col"><?php echo esc_html( __( 'Context', 'bogo' ) ); ?></th>
404 + <th scope="row"><label for="blogdescription"><?php echo esc_html( __( 'Tagline' ) ); ?></label></th>
405 + <td><input name="blogdescription" type="text" id="blogdescription" value="<?php echo esc_attr( bogo_translate( 'blogdescription', 'blogdescription', get_option( 'blogdescription' ) ) ); ?>" class="regular-text" /></td>
507 406 </tr>
508 -</tfoot>
509 -<tbody>
510 -<?php
511 - foreach( $strings as $string ) :
512 -?>
513 - <tr>
514 - <td><?php echo esc_html( $string['original'] ); ?></td>
515 - <td><input name="<?php echo esc_attr( $string['name'] ); ?>" type="text" id="<?php echo esc_attr( $string['name'] ); ?>" value="<?php echo esc_attr( $string['translated'] ); ?>" class="large-text" /></td>
516 - <td><?php echo esc_html( $string['context'] ); ?></td>
517 - </tr>
518 -<?php
519 - endforeach;
520 -?>
521 407 </tbody>
522 408 </table>
523 409
524 410 <?php submit_button(); ?>
525 -<?php
526 - endif;
527 -?>
411 +<?php endif; ?>
528 412 </form>
529 413 </div>
530 414 <?php
531 415 }
@@ -538,12 +422,8 @@
538 422 if ( 'install_success' == $reason ) {
539 423 $message = __( "Translation installed successfully.", 'bogo' );
540 424 } elseif ( 'install_failed' == $reason ) {
541 425 $message = __( "Translation install failed.", 'bogo' );
542 - } elseif ( 'site_lang_success' == $reason ) {
543 - $message = __( "Site language set successfully.", 'bogo' );
544 - } elseif ( 'site_lang_failed' == $reason ) {
545 - $message = __( "Setting site language failed.", 'bogo' );
546 426 } elseif ( 'delete_success' == $reason ) {
547 427 $message = __( "Translation uninstalled successfully.", 'bogo' );
548 428 } elseif ( 'delete_failed' == $reason ) {
549 429 $message = __( "Translation uninstall failed.", 'bogo' );