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