PluginProbe
Bogo / 2.6
Bogo v2.6
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 +89 -329 3.0.12.6 View file →
@@ -4,46 +4,21 @@
4 4 require_once BOGO_PLUGIN_DIR . '/admin/includes/post.php';
5 5 require_once BOGO_PLUGIN_DIR . '/admin/includes/nav-menu.php';
6 6 require_once BOGO_PLUGIN_DIR . '/admin/includes/widgets.php';
7 7
8 -add_action( 'admin_init', 'bogo_upgrade' );
9 -
10 -function bogo_upgrade() {
11 - $old_ver = bogo_get_prop( 'version' );
12 - $new_ver = BOGO_VERSION;
13 -
14 - if ( $old_ver != $new_ver ) {
15 - require_once BOGO_PLUGIN_DIR . '/admin/includes/upgrade.php';
16 - do_action( 'bogo_upgrade', $new_ver, $old_ver );
17 - bogo_set_prop( 'version', $new_ver );
18 - }
19 -}
20 -
21 8 add_action( 'admin_enqueue_scripts', 'bogo_admin_enqueue_scripts' );
22 9
23 10 function bogo_admin_enqueue_scripts( $hook_suffix ) {
24 - wp_enqueue_style( 'bogo-admin',
25 - plugins_url( 'admin/includes/css/admin.css', BOGO_PLUGIN_BASENAME ),
26 - array(), BOGO_VERSION, 'all' );
11 + if ( false !== strpos( $hook_suffix, 'bogo-tools' )
12 + || 'widgets.php' == $hook_suffix
13 + || 'user-edit.php' == $hook_suffix ) {
14 + wp_enqueue_style( 'bogo-admin',
15 + plugins_url( 'admin/includes/css/admin.css', BOGO_PLUGIN_BASENAME ),
16 + array(), BOGO_VERSION, 'all' );
27 17
28 - if ( is_rtl() ) {
29 - wp_enqueue_style( 'bogo-admin-rtl',
30 - plugins_url( 'admin/includes/css/admin-rtl.css', BOGO_PLUGIN_BASENAME ),
31 - array(), BOGO_VERSION, 'all' );
18 + return;
32 19 }
33 20
34 - wp_enqueue_script( 'bogo-admin',
35 - plugins_url( 'admin/includes/js/admin.js', BOGO_PLUGIN_BASENAME ),
36 - array( 'jquery' ), BOGO_VERSION, true );
37 -
38 - $local_args = array(
39 - 'saveAlert' => __(
40 - "The changes you made will be lost if you navigate away from this page.",
41 - 'bogo' ),
42 - 'rest_api' => array(
43 - 'url' => trailingslashit( rest_url( 'bogo/v1' ) ),
44 - 'nonce' => wp_create_nonce( 'wp_rest' ) ) );
45 -
46 21 if ( 'nav-menus.php' == $hook_suffix ) {
47 22 $nav_menu_id = absint( get_user_option( 'nav_menu_recently_edited' ) );
48 23 $nav_menu_items = wp_get_nav_menu_items( $nav_menu_id );
49 24 $locales = array();
@@ -51,53 +26,51 @@
51 26 foreach ( (array) $nav_menu_items as $item ) {
52 27 $locales[$item->db_id] = $item->bogo_locales;
53 28 }
54 29
55 - $local_args = array_merge( $local_args, array(
30 + $prefix = 'menu-item-bogo-locale';
31 +
32 + wp_enqueue_script( 'bogo-admin',
33 + plugins_url( 'admin/includes/js/admin.js', BOGO_PLUGIN_BASENAME ),
34 + array( 'jquery' ),
35 + BOGO_VERSION, true );
36 +
37 + wp_localize_script( 'bogo-admin', '_bogo', array(
56 38 'availableLanguages' => bogo_available_languages( array(
57 39 'exclude_enus_if_inactive' => true,
58 40 'orderby' => 'value' ) ),
59 41 'locales' => $locales,
60 42 'selectorLegend' => __( 'Displayed on pages in', 'bogo' ),
61 - 'cbPrefix' => 'menu-item-bogo-locale' ) );
43 + 'cbPrefix' => $prefix ) );
44 +
45 + wp_enqueue_style( 'bogo-admin',
46 + plugins_url( 'admin/includes/css/admin.css', BOGO_PLUGIN_BASENAME ),
47 + array(), BOGO_VERSION, 'all' );
48 +
49 + return;
62 50 }
63 51
64 52 if ( 'options-general.php' == $hook_suffix ) {
65 - $local_args = array_merge( $local_args, array(
53 + wp_enqueue_script( 'bogo-admin',
54 + plugins_url( 'admin/includes/js/admin.js', BOGO_PLUGIN_BASENAME ),
55 + array( 'jquery' ),
56 + BOGO_VERSION, true );
57 +
58 + wp_localize_script( 'bogo-admin', '_bogo', array(
66 59 'defaultLocale' => bogo_get_default_locale() ) );
67 - }
68 60
69 - if ( 'post.php' == $hook_suffix && ! empty( $GLOBALS['post'] ) ) {
70 - $post = $GLOBALS['post'];
71 - $local_args = array_merge( $local_args, array(
72 - 'post_id' => $post->ID ) );
61 + return;
73 62 }
74 -
75 - $local_args['pagenow'] = isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '';
76 -
77 - wp_localize_script( 'bogo-admin', '_bogo', $local_args );
78 63 }
79 64
80 65 add_action( 'admin_menu', 'bogo_admin_menu' );
81 66
82 67 function bogo_admin_menu() {
83 - add_menu_page( __( 'Languages', 'bogo' ), __( 'Languages', 'bogo' ),
84 - 'bogo_manage_language_packs', 'bogo', 'bogo_tools_page',
85 - 'dashicons-translation', 73 ); // between Users (70) and Tools (75)
68 + $tools = add_management_page(
69 + __( 'Bogo Tools', 'bogo' ), __( 'Bogo', 'bogo' ),
70 + 'update_core', 'bogo-tools', 'bogo_tools_page' );
86 71
87 - $tools = add_submenu_page( 'bogo',
88 - __( 'Language Packs', 'bogo' ),
89 - __( 'Language Packs', 'bogo' ),
90 - 'bogo_manage_language_packs', 'bogo', 'bogo_tools_page' );
91 -
92 72 add_action( 'load-' . $tools, 'bogo_load_tools_page' );
93 -
94 - $texts = add_submenu_page( 'bogo',
95 - __( 'Terms Translation', 'bogo' ),
96 - __( 'Terms Translation', 'bogo' ),
97 - 'bogo_edit_terms_translation', 'bogo-texts', 'bogo_texts_page' );
98 -
99 - add_action( 'load-' . $texts, 'bogo_load_texts_page' );
100 73 }
101 74
102 75 function bogo_load_tools_page() {
103 76 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
@@ -106,10 +79,10 @@
106 79
107 80 if ( 'install_translation' == $action ) {
108 81 check_admin_referer( 'bogo-tools' );
109 82
110 - if ( ! current_user_can( 'bogo_manage_language_packs' ) ) {
111 - wp_die( __( "You are not allowed to install translations.", 'bogo' ) );
83 + if ( ! current_user_can( 'update_core' ) ) {
84 + wp_die( __( 'You are not allowed to install translations.', 'bogo' ) );
112 85 }
113 86
114 87 $locale = isset( $_GET['locale'] ) ? $_GET['locale'] : null;
115 88
@@ -115,13 +88,13 @@
115 88
116 89 if ( wp_download_language_pack( $locale ) ) {
117 90 $redirect_to = add_query_arg(
118 91 array( 'locale' => $locale, 'message' => 'install_success' ),
119 - menu_page_url( 'bogo', false ) );
92 + menu_page_url( 'bogo-tools', false ) );
120 93 } else {
121 94 $redirect_to = add_query_arg(
122 95 array( 'locale' => $locale, 'message' => 'install_failed' ),
123 - menu_page_url( 'bogo', false ) );
96 + menu_page_url( 'bogo-tools', false ) );
124 97 }
125 98
126 99 wp_safe_redirect( $redirect_to );
127 100 exit();
@@ -126,40 +99,13 @@
126 99 wp_safe_redirect( $redirect_to );
127 100 exit();
128 101 }
129 102
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 103 if ( 'delete_translation' == $action ) {
158 104 check_admin_referer( 'bogo-tools' );
159 105
160 - if ( ! current_user_can( 'bogo_manage_language_packs' ) ) {
161 - wp_die( __( "You are not allowed to delete translations.", 'bogo' ) );
106 + if ( ! current_user_can( 'update_core' ) ) {
107 + wp_die( __( 'You are not allowed to delete translations.', 'bogo' ) );
162 108 }
163 109
164 110 $locale = isset( $_GET['locale'] ) ? $_GET['locale'] : null;
165 111
@@ -165,13 +111,13 @@
165 111
166 112 if ( bogo_delete_language_pack( $locale ) ) {
167 113 $redirect_to = add_query_arg(
168 114 array( 'locale' => $locale, 'message' => 'delete_success' ),
169 - menu_page_url( 'bogo', false ) );
115 + menu_page_url( 'bogo-tools', false ) );
170 116 } else {
171 117 $redirect_to = add_query_arg(
172 118 array( 'locale' => $locale, 'message' => 'delete_failed' ),
173 - menu_page_url( 'bogo', false ) );
119 + menu_page_url( 'bogo-tools', false ) );
174 120 }
175 121
176 122 wp_safe_redirect( $redirect_to );
177 123 exit();
@@ -183,9 +129,9 @@
183 129 bogo_set_prop( 'enus_deactivated', true );
184 130
185 131 $redirect_to = add_query_arg(
186 132 array( 'message' => 'enus_deactivated' ),
187 - menu_page_url( 'bogo', false ) );
133 + menu_page_url( 'bogo-tools', false ) );
188 134
189 135 wp_safe_redirect( $redirect_to );
190 136 exit();
191 137 }
@@ -196,9 +142,9 @@
196 142 bogo_set_prop( 'enus_deactivated', false );
197 143
198 144 $redirect_to = add_query_arg(
199 145 array( 'message' => 'enus_activated' ),
200 - menu_page_url( 'bogo', false ) );
146 + menu_page_url( 'bogo-tools', false ) );
201 147
202 148 wp_safe_redirect( $redirect_to );
203 149 exit();
204 150 }
@@ -203,51 +149,10 @@
203 149 exit();
204 150 }
205 151 }
206 152
207 -function bogo_load_texts_page() {
208 - $action = isset( $_POST['action'] ) ? $_POST['action'] : '';
209 -
210 - if ( 'save' == $action ) {
211 - check_admin_referer( 'bogo-edit-text-translation' );
212 -
213 - $locale = isset( $_POST['locale'] ) ? $_POST['locale'] : null;
214 -
215 - if ( ! current_user_can( 'bogo_edit_terms_translation' ) ) {
216 - wp_die( __( "You are not allowed to edit translations.", 'bogo' ) );
217 - }
218 -
219 - $entries = array();
220 -
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 - }
226 -
227 - $entries[] = array(
228 - 'singular' => $p_key,
229 - 'translations' => array( $p_val ),
230 - 'context' => preg_replace( '/:.*$/', '', $p_key ) );
231 - }
232 -
233 - if ( Bogo_POMO::export( $locale, $entries ) ) {
234 - $message = 'translation_saved';
235 - } else {
236 - $message = 'translation_failed';
237 - }
238 -
239 - $redirect_to = add_query_arg(
240 - array( 'locale' => $locale, 'message' => $message ),
241 - menu_page_url( 'bogo-texts', false ) );
242 -
243 - wp_safe_redirect( $redirect_to );
244 - exit();
245 - }
246 -}
247 -
248 153 function bogo_tools_page() {
249 - $enus_deactivated = bogo_is_enus_deactivated();
154 + $enus_deactivated = bogo_get_prop( 'enus_deactivated' );
250 155 $can_install = wp_can_install_language_pack();
251 156
252 157 $default_locale = bogo_get_default_locale();
253 158 $available_locales = bogo_available_locales();
@@ -254,25 +159,27 @@
254 159
255 160 ?>
256 161 <div class="wrap">
257 162
258 -<h1><?php echo esc_html( __( 'Language Packs', 'bogo' ) ); ?></h1>
163 +<h2><?php echo esc_html( __( 'Bogo Tools', 'bogo' ) ); ?></h2>
259 164
260 165 <?php bogo_admin_notice(); ?>
261 166
167 +<h3 class="title"><?php echo esc_html( __( 'Available Languages', 'bogo' ) ); ?></h3>
168 +
262 169 <table id="bogo-languages-table" class="widefat">
263 170 <thead>
264 - <tr><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr>
171 + <tr><th></th><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr>
265 172 </thead>
266 173 <tfoot>
267 - <tr><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr>
174 + <tr><th></th><th><?php echo esc_html( __( 'Language', 'bogo' ) ); ?></th></tr>
268 175 </tfoot>
269 176 <tbody id="translations">
270 - <tr class="active" id="language-1"><td>
177 + <tr class="active"><th>1</th><td><p>
271 178 <strong><?php echo esc_html( bogo_get_language( $default_locale ) ); ?></strong>
272 179 [<?php echo esc_html( $default_locale ); ?>]
273 - <div class="status"><?php echo esc_html( __( 'Site Language', 'bogo' ) ); ?></div>
274 - </td></tr>
180 + <div class="status"><span class="status"><?php echo esc_html( __( 'Site Default Language', 'bogo' ) ); ?></span></div>
181 + </p></td></tr>
275 182
276 183 <?php
277 184 $count = 1;
278 185
@@ -283,100 +190,77 @@
283 190
284 191 $count += 1;
285 192 $class = 'active';
286 193
287 - if ( ! $language = bogo_get_language( $locale ) ) {
288 - $language = $locale;
289 - }
290 -
291 194 if ( 'en_US' == $locale ) {
292 195 $status = $enus_deactivated
293 - ? __( 'Inactive', 'bogo' ) : __( 'Active', 'bogo' );
196 + ? esc_html( __( 'Inactive', 'bogo' ) )
197 + : esc_html( __( 'Active', 'bogo' ) );
294 198 } else {
295 - $status = __( 'Installed', 'bogo' );
199 + $status = esc_html( __( 'Installed', 'bogo' ) );
296 200 }
297 201
298 202 if ( 'en_US' == $locale ) {
299 203 if ( $enus_deactivated ) {
300 - $activate_link = menu_page_url( 'bogo', false );
204 + $activate_link = menu_page_url( 'bogo-tools', false );
301 205 $activate_link = add_query_arg(
302 206 array( 'action' => 'activate_enus' ),
303 207 $activate_link );
304 208 $activate_link = wp_nonce_url( $activate_link, 'bogo-tools' );
305 209 $activate_link = sprintf(
306 - '<a href="%1$s" class="activate" aria-label="%3$s">%2$s</a>',
210 + '<a href="%1$s" class="activate">%2$s</a>',
307 211 $activate_link,
308 - esc_html( __( 'Activate', 'bogo' ) ),
309 - esc_attr(
310 - sprintf( __( 'Activate %s language pack', 'bogo' ), $language ) ) );
212 + esc_html( __( 'Activate', 'bogo' ) ) );
311 213
312 - $row_actions = array( $activate_link );
313 -
214 + $status = sprintf(
215 + '<div class="status"><span class="status">%s</span> | %s</div>',
216 + $status, $activate_link );
314 217 $class = '';
315 218 } 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 - $deactivate_link = menu_page_url( 'bogo', false );
219 + $deactivate_link = menu_page_url( 'bogo-tools', false );
329 220 $deactivate_link = add_query_arg(
330 221 array( 'action' => 'deactivate_enus' ),
331 222 $deactivate_link );
332 223 $deactivate_link = wp_nonce_url( $deactivate_link, 'bogo-tools' );
333 224 $deactivate_link = sprintf(
334 - '<a href="%1$s" class="deactivate" aria-label="%3$s">%2$s</a>',
225 + '<a href="%1$s" class="deactivate">%2$s</a>',
335 226 $deactivate_link,
336 - esc_html( __( 'Deactivate', 'bogo' ) ),
337 - esc_attr( sprintf(
338 - __( 'Deactivate %s language pack', 'bogo' ), $language ) ) );
227 + esc_html( __( 'Deactivate', 'bogo' ) ) );
339 228
340 - $row_actions = array( $sitelang_link, $deactivate_link );
229 + $status = sprintf(
230 + '<div class="status"><span class="status">%s</span> | %s</div>',
231 + $status, $deactivate_link );
341 232 }
342 233 } 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 - $delete_link = menu_page_url( 'bogo', false );
234 + $delete_link = menu_page_url( 'bogo-tools', false );
356 235 $delete_link = add_query_arg(
357 236 array( 'action' => 'delete_translation', 'locale' => $locale ),
358 237 $delete_link );
359 238 $delete_link = wp_nonce_url( $delete_link, 'bogo-tools' );
360 239
361 - $delete_confirm = sprintf( __( "You are about to delete %s language pack.\n 'Cancel' to stop, 'OK' to delete.", 'bogo' ), $language );
240 + if ( ! $delete_language = bogo_get_language( $locale ) ) {
241 + $delete_language = $locale;
242 + }
362 243
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>',
244 + $delete_confirm = sprintf( __( "You are about to delete %s language pack.\n 'Cancel' to stop, 'OK' to delete.", 'bogo' ), $delete_language );
245 +
246 + $delete_link = sprintf( '<a href="%1$s" class="delete" onclick="if (confirm(\'%3$s\')){return true;} return false;">%2$s</a>',
364 247 $delete_link,
365 248 esc_html( __( 'Delete', 'bogo' ) ),
366 - esc_js( $delete_confirm ),
367 - esc_attr(
368 - sprintf( __( 'Delete %s language pack', 'bogo' ), $language ) ) );
249 + esc_js( $delete_confirm ) );
369 250
370 - $row_actions = array( $sitelang_link, $delete_link );
251 + $status = sprintf(
252 + '<div class="status"><span class="status">%s</span> | %s</div>',
253 + $status, $delete_link );
371 254 }
372 255 ?>
373 - <tr class="<?php echo esc_attr( $class ); ?>" id="language-<?php echo absint( $count ); ?>">
374 - <td>
256 + <tr class="<?php echo esc_attr( $class ); ?>">
257 + <th><?php echo $count; ?></th>
258 + <td><p>
375 259 <strong><?php echo esc_html( bogo_get_language( $locale ) ); ?></strong>
376 260 [<?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>
261 + <?php echo $status; ?>
262 + </p>
379 263 </td>
380 264 </tr>
381 265 <?php
382 266 }
@@ -390,28 +274,22 @@
390 274
391 275 $install_link = '';
392 276
393 277 if ( $can_install ) {
394 - $install_link = menu_page_url( 'bogo', false );
278 + $install_link = menu_page_url( 'bogo-tools', false );
395 279 $install_link = add_query_arg(
396 280 array( 'action' => 'install_translation', 'locale' => $locale ),
397 281 $install_link );
398 282 $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 );
283 + $install_link = sprintf( '<a href="%1$s" class="install">%2$s</a>',
284 + $install_link, esc_html( __( 'Install', 'bogo' ) ) );
407 285 }
408 286 ?>
409 - <tr id="language-<?php echo absint( $count ); ?>"><td>
287 + <tr><th><?php echo $count; ?></th><td><p>
410 288 <strong><?php echo esc_html( bogo_get_language( $locale ) ); ?></strong>
411 289 [<?php echo esc_html( $locale ); ?>]
412 - <div class="row-actions"><?php echo implode( ' | ', $row_actions ); ?></div>
413 - </td></tr>
290 + <?php echo $install_link; ?>
291 + </p></td></tr>
414 292 <?php
415 293 }
416 294 ?>
417 295
@@ -421,118 +299,8 @@
421 299 </div>
422 300 <?php
423 301 }
424 302
425 -function bogo_texts_page() {
426 - $locale_to_edit = isset( $_GET['locale'] ) ? $_GET['locale'] : '';
427 -
428 - if ( ! Bogo_POMO::import( $locale_to_edit ) ) {
429 - Bogo_POMO::reset();
430 - }
431 -
432 -?>
433 -<div class="wrap">
434 -
435 -<h1><?php echo esc_html( __( 'Terms Translation', 'bogo' ) ); ?></h1>
436 -
437 -<?php bogo_admin_notice(); ?>
438 -
439 -<form action="" method="post" id="bogo-translatable-text-strings">
440 -<input type="hidden" name="action" value="save" />
441 -<?php wp_nonce_field( 'bogo-edit-text-translation' ); ?>
442 -
443 -<p>
444 -<select name="locale" id="select-locale">
445 - <option value=""><?php echo esc_html( __( '-- Select Language to Edit --', 'bogo' ) ); ?></option>
446 -<?php
447 - $available_locales = bogo_available_locales(
448 - array( 'current_user_can_access' => true ) );
449 -
450 - foreach ( $available_locales as $locale ) {
451 - echo sprintf( '<option value="%1$s"%3$s>%2$s</option>',
452 - esc_attr( $locale ),
453 - esc_html( bogo_get_language( $locale ) ),
454 - $locale == $locale_to_edit ? ' selected="selected"' : '' );
455 - }
456 -?>
457 -</select>
458 -</p>
459 -
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>
498 - <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>
502 - </tr>
503 -</thead>
504 -<tfoot>
505 - <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>
509 - </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 -</tbody>
524 -</table>
525 -
526 -<?php submit_button(); ?>
527 -<?php
528 - endif;
529 -?>
530 -</form>
531 -</div>
532 -<?php
533 -}
534 -
535 303 function bogo_admin_notice( $reason = '' ) {
536 304 if ( empty( $reason ) && isset( $_GET['message'] ) ) {
537 305 $reason = $_GET['message'];
538 306 }
@@ -540,12 +308,8 @@
540 308 if ( 'install_success' == $reason ) {
541 309 $message = __( "Translation installed successfully.", 'bogo' );
542 310 } elseif ( 'install_failed' == $reason ) {
543 311 $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 312 } elseif ( 'delete_success' == $reason ) {
549 313 $message = __( "Translation uninstalled successfully.", 'bogo' );
550 314 } elseif ( 'delete_failed' == $reason ) {
551 315 $message = __( "Translation uninstall failed.", 'bogo' );
@@ -552,17 +316,13 @@
552 316 } elseif ( 'enus_deactivated' == $reason ) {
553 317 $message = __( "English (United States) deactivated.", 'bogo' );
554 318 } elseif ( 'enus_activated' == $reason ) {
555 319 $message = __( "English (United States) activated.", 'bogo' );
556 - } elseif ( 'translation_saved' == $reason ) {
557 - $message = __( "Translation saved.", 'bogo' );
558 - } elseif ( 'translation_failed' == $reason ) {
559 - $message = __( "Saving translation failed.", 'bogo' );
560 320 } else {
561 321 return false;
562 322 }
563 323
564 - if ( '_failed' == substr( $reason, -7 ) ) {
324 + if ( 'install_failed' == $reason || 'delete_failed' == $reason ) {
565 325 echo sprintf(
566 326 '<div class="error notice notice-error is-dismissible"><p>%s</p></div>',
567 327 esc_html( $message ) );
568 328 } else {