PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 2.12.2
Translate and Go multilingual – Automatic AI translation – wpLingua v2.12.2
2.16.7 2.16.6 2.16.5 2.16.4 2.16.3 2.16.2 2.16.1 2.16.0 2.15.2 2.15.1 2.15.0 2.14.3 2.14.2 2.14.1 2.14.0 2.13.1 2.13.0 2.12.3 2.12.2 2.12.1 trunk 1.0.3 1.0.4 1.0.5 1.1.0 All 112 releases
wplingua / inc / admin / option-page-settings.php

option-page-settings.php in Translate and Go multilingual – Automatic AI translation – wpLingua 2.12.2, at inc/admin/option-page-settings.php

666 lines 27.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If this file is called directly, abort.
4 if ( ! defined( 'WPINC' ) ) {
5 die;
6 }
7
8
9 /**
10 * Print HTML Option page : wpLingua Settings
11 *
12 * @return void
13 */
14 function wplng_option_page_settings() {
15
16 /**
17 * Try to get API key data from API
18 * (From cache if API can not be called
19 */
20
21 $api_data = wplng_get_api_data( true );
22
23 /**
24 * Show register screen if empty API data
25 */
26
27 if ( empty( $api_data ) ) {
28 wplng_option_page_register();
29 return;
30 }
31
32 ?>
33
34 <h1 class="wplng-option-page-title"><span class="dashicons dashicons-translation"></span> <?php esc_html_e( 'wpLingua - General settings', 'wplingua' ); ?></h1>
35
36 <div class="wrap">
37 <hr class="wp-header-end">
38 <?php
39
40 $is_first = wplng_settings_part_first_use();
41 $form_css = '';
42
43 if ( $is_first ) {
44 $form_css = 'display: none !important;';
45 }
46
47 ?>
48 <form
49 method="post"
50 action="options.php"
51 id="wplng-option-settings-form"
52 style="<?php echo esc_attr( $form_css ); ?>"
53 >
54 <?php
55 settings_fields( 'wplng_settings' );
56 do_settings_sections( 'wplng_settings' );
57 ?>
58
59 <table class="form-table wplng-form-table">
60 <tr>
61 <th scope="row"><span class="dashicons dashicons-location"></span> <?php esc_html_e( 'Website language', 'wplingua' ); ?></th>
62 <td>
63 <?php wplng_settings_part_language_website(); ?>
64 </td>
65 </tr>
66 <tr>
67 <th scope="row"><span class="dashicons dashicons-location-alt"></span> <?php esc_html_e( 'Translated languages', 'wplingua' ); ?></th>
68 <td>
69 <?php wplng_settings_part_languages_target(); ?>
70 </td>
71 </tr>
72 <tr>
73 <th scope="row"><span class="dashicons dashicons-admin-settings"></span> <?php esc_html_e( 'Features', 'wplingua' ); ?></th>
74 <td>
75 <fieldset>
76 <?php wplng_settings_part_features_api(); ?>
77 <br><br><hr>
78 <?php wplng_settings_part_features_seo(); ?>
79 <br><br><hr>
80 <?php wplng_settings_part_features_more(); ?>
81 </fieldset>
82 </td>
83 </tr>
84 <tr>
85 <th scope="row"><span class="dashicons dashicons-admin-network"></span> <?php _e( 'API Key', 'wplingua' ); ?></th>
86 <td>
87 <?php wplng_settings_part_api_key(); ?>
88 </td>
89 </tr>
90 <tr class="wplng-tr-submit">
91 <th scope="row"><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'Save', 'wplingua' ); ?></th>
92 <td>
93 <?php submit_button(); ?>
94 </td>
95 </tr>
96 </table>
97 </form>
98 </div>
99 <?php
100 }
101
102
103 /**
104 * Print HTML subsection of Option page : wpLingua Settings - First use
105 *
106 * @return void
107 */
108 function wplng_settings_part_first_use() {
109
110 if ( ! empty( get_option( 'wplng_website_language' ) )
111 || 'all' === wplng_get_api_language_website()
112 ) {
113 return false;
114 }
115
116 update_option(
117 'wplng_website_language',
118 wplng_get_api_language_website()
119 );
120
121 $data = wplng_get_api_data();
122
123 // Set option for target language
124
125 if ( empty( $data['languages_target'][0] )
126 || count( $data['languages_target'] ) !== 1
127 ) {
128 return false;
129 }
130
131 $language_target = wplng_get_language_by_id(
132 $data['languages_target'][0]
133 );
134
135 if ( ! empty( $language_target ) ) {
136
137 global $wplng_languages_target_simplified;
138 $wplng_languages_target_simplified = array( $language_target );
139
140 update_option(
141 'wplng_target_languages',
142 wp_json_encode(
143 array( $language_target )
144 )
145 );
146
147 update_option( 'wplng_flags_style', 'rectangular' );
148
149 } else {
150 return false;
151 }
152
153 // Enable default feature
154 update_option( 'wplng_sitemap_xml', 1 );
155 update_option( 'wplng_hreflang', 1 );
156 update_option( 'wplng_load_in_progress', 1 );
157
158 // Get URL for first registered language of front page
159 $url_front_page_translated = wplng_url_translate(
160 get_home_url(),
161 $language_target['id']
162 );
163
164 $url_front_page_load = add_query_arg(
165 array(
166 'wplng-load' => 'disabled',
167 'nocache' => (string) time() . (string) rand( 100, 999 ),
168 ),
169 $url_front_page_translated
170 );
171
172 ?>
173 <div class="wplng-notice notice notice-info" id="wplng-notice-first-loading-loading" data-wplng-url-first-load="<?php echo esc_url( $url_front_page_load ); ?>">
174 <h2><span class="dashicons dashicons-update wplng-spin"></span> <?php esc_html_e( 'Your website is being translated and will be ready soon.', 'wplingua' ); ?></h2>
175 <p><?php esc_html_e( 'In just a few seconds, your website will be multilingual, and search engines will be able to index these new pages. wpLingua detects all the texts on your pages and offers you a first automatically generated translation. All translations are editable: open the visual editor from the administration bar and edit them simply by clicking on the texts on your website.', 'wplingua' ); ?></p>
176 <p><strong><?php esc_html_e( 'Translation progress: ', 'wplingua' ); ?> <span id="wplng-notice-first-loading-loading-percent">1 %</span></strong></p>
177 </div>
178
179 <div class="wplng-notice notice notice-success is-dismissible" id="wplng-notice-first-loading-loaded" style="display: none;">
180 <h2>
181 🎉 <?php esc_html_e( 'Your website is now multilingual!', 'wplingua' ); ?>
182 <br>
183 <?php esc_html_e( 'You can start visiting the translated version.', 'wplingua' ); ?>
184 </h2>
185 <p><?php esc_html_e( 'The first time a translated page is loaded, the translations are automatically generated and saved in the database. This may take some time (on first generation only) depending on the size of your content. This is why we advise you to browse your entire website for the first time in order to generate all the multilingual versions.', 'wplingua' ); ?></p>
186 <p><?php esc_html_e( 'All translations are editable: open the visual editor from the administration bar and edit them simply by clicking on the texts on your website.', 'wplingua' ); ?></p>
187
188 <a href="<?php echo esc_url( $url_front_page_translated ); ?>" target="_blank" class="button button-primary">
189 <?php esc_html_e( 'Visit your multilingual website', 'wplingua' ); ?>
190 </a>
191 </div>
192 <?php
193
194 return true;
195 }
196
197
198 /**
199 * Print HTML subsection of Option page : wpLingua Settings - Website language
200 *
201 * @return void
202 */
203 function wplng_settings_part_language_website() {
204
205 $api_language_website = wplng_get_api_language_website();
206
207 if ( 'all' !== $api_language_website ) {
208 echo '<fieldset style="display: none;">';
209 } else {
210 echo '<fieldset>';
211 }
212
213 echo '<label for="wplng_website_language" class="wplng-fe-50">';
214 echo '<strong>';
215 esc_html_e( 'Original website language: ', 'wplingua' );
216 echo ' </strong>';
217 echo '</label>';
218
219 echo '<select id="wplng_website_language" name="wplng_website_language" class="wplng-fe-50">';
220 $website_language_saved = true;
221 if ( empty( wplng_get_language_website_id() ) ) {
222 $website_language_saved = false;
223 } else {
224
225 $website_language_id = wplng_get_language_website_id();
226 $website_language = wplng_get_language_by_id( $website_language_id );
227
228 if ( ! empty( $website_language['id'] )
229 && ! empty( $website_language['name'] )
230 ) {
231 echo '<option value="' . esc_attr( $website_language['id'] ) . '">';
232 echo esc_html( $website_language['name'] );
233 echo '</option>';
234 } else {
235 $website_language_saved = false;
236 }
237 }
238
239 if ( ! $website_language_saved ) {
240 echo '<option value="">';
241 esc_html_e( 'Please choose an option', 'wplingua' );
242 echo '</option>';
243 }
244
245 echo '</select>';
246 echo '<hr>';
247 echo '</fieldset>';
248
249 if ( 'all' !== $api_language_website ) {
250 echo '<p>';
251 echo '<strong>';
252 esc_html_e( 'Original website language, defined by API key: ', 'wplingua' );
253 echo ' </strong>';
254 echo '<span';
255 echo ' title="' . esc_attr__( 'Click to expand', 'wplingua' ) . '"';
256 echo ' wplng-help-box="#wplng-hb-language-website"';
257 echo '></span>';
258 echo ' </p>';
259
260 echo '<div class="wplng-help-box" id="wplng-hb-language-website">';
261 echo '<p>';
262 echo esc_html__( 'This is the language of your website, defined by the associated API key. Make sure your website language is also correctly set in WordPress options (Settings ➔ General ➔ Website Language).', 'wplingua' );
263 echo '<hr>';
264 echo esc_html__( 'If you have mistakenly selected the wrong language, you can delete the API key in the site options below and request a new API key.', 'wplingua' );
265 echo '</p>';
266 echo '</div>';
267 }
268 ?>
269
270 <div id="wplng-flags-radio-original-website-custom"><?php _e( 'Custom', 'wplingua' ); ?></div>
271
272 <div id="wplng-website-language-box">
273
274 <div class="wplng-website-language-displayed">
275 <div id="wplng-website-language" class="wplng-website-language-left">
276 <img src="<?php echo esc_url( wplng_get_language_website_flag() ); ?>" id="wplng-website-flag"><?php echo esc_html( $website_language['name'] ); ?>
277 </div>
278 <div class="wplng-target-language-right">
279 <a href="javascript:void(0);" id="wplng-website-lang-update-flag"><?php esc_html_e( 'Edit', 'wplingua' ); ?></a>
280 </div>
281 </div>
282
283 <div id="wplng-flag-website-container">
284 <p><strong><?php esc_html_e( 'Flag to use for this language: ', 'wplingua' ); ?></strong></p>
285 <p><span id="wplng-flags-radio-original-website"></span></p>
286
287 <div id="wplng-website-flag-container">
288 <hr>
289 <p>
290 <strong><?php esc_html_e( 'Custom flag URL for this language: ', 'wplingua' ); ?></strong>
291 </p>
292 <input type="url" name="wplng_website_flag" id="wplng_website_flag" value="<?php echo esc_url( wplng_get_language_website_flag() ); ?>"/>
293 </div>
294 </div>
295
296 </div>
297 <?php
298 }
299
300
301 /**
302 * Print HTML subsection of Option page : wpLingua Settings - Languages target
303 *
304 * @return void
305 */
306 function wplng_settings_part_languages_target() {
307
308 $languages_target = wplng_get_languages_target_simplified();
309
310 ?>
311 <fieldset id="fieldset-add-target-language">
312
313 <div id="wplng_add_new_target_language_message" style="display: none !important;"><?php esc_html_e( 'Important: space out the addition of new languages ​​by at least ten days and browse your site for the first time in the added languages. This promotes better indexing by search engines, reduces the load on your server and minimizes the risk of slowdowns on your site.', 'wplingua' ); ?></div>
314
315 <p class="wplng-fe-50">
316 <label for="wplng_add_new_target_language">
317 <strong><?php esc_html_e( 'Add new target Language: ', 'wplingua' ); ?></strong>
318 </label>
319 </p>
320
321 <p class="wplng-fe-50">
322 <select id="wplng_add_new_target_language" name="wplng_add_new_target_language"></select>
323 <a class="button button-primary wplng-icon-button" id="wplng-target-lang-add" title="<?php esc_html_e( 'Add language', 'wplingua' ); ?>" href="javascript:void(0);">
324 <span class="dashicons dashicons-insert"></span>
325 </a>
326 </p>
327 </fieldset>
328
329 <hr id="wplng-languages-target-separator">
330
331 <div id="wplng-target-language-template">
332 <div class="wplng-target-language">
333
334 <div class="wplng-target-language-displayed">
335 <div class="wplng-target-language-left">
336 [FLAG][NAME]<span class="wplng-private-label"> <?php esc_html_e( '(Private)', 'wplingua' ); ?></span>
337 </div>
338
339 <div class="wplng-target-language-right">
340 <a href="javascript:void(0);" class="wplng-target-lang-move-up" wplng-target-lang="[LANG]" title="<?php esc_attr_e( 'Move up', 'wplingua' ); ?>"><span class="dashicons dashicons-arrow-up-alt2"></span></a>
341 <a href="javascript:void(0);" class="wplng-target-lang-move-down" wplng-target-lang="[LANG]" title="<?php esc_attr_e( 'Move down', 'wplingua' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></a>
342 <a href="javascript:void(0);" class="wplng-target-lang-update-flag" wplng-target-lang="[LANG]"><?php esc_html_e( 'Edit', 'wplingua' ); ?></a>
343 <a href="javascript:void(0);" class="wplng-target-lang-remove" wplng-target-lang="[LANG]"><?php esc_html_e( 'Remove', 'wplingua' ); ?></a>
344 </div>
345 </div>
346
347 <div class="wplng-flag-target-container" wplng-target-lang="[LANG]">
348 <p><strong><?php esc_html_e( 'Flag to use for this language: ', 'wplingua' ); ?></strong></p>
349 <p><span class="wplng-subflags-radio-target-website">[FLAGS_OPTIONS]</span></p>
350 <div class="wplng-subflag-target-custom" wplng-target-lang="[LANG]">
351 <hr>
352 <p><strong><?php esc_html_e( 'Custom flag URL for this language: ', 'wplingua' ); ?></strong></p>
353 [INPUT]
354 </div>
355 <hr>
356 <fieldset>
357 [PRIVATE_INPUT]<label for="wplng-language-private-[LANG]"><strong><?php _e( 'Make this language private', 'wplingua' ); ?></strong></label>
358 <p><?php _e( 'Private languages will only be visible to logged-in users with editing rights. This option allows administrators to pre-generate and correct translations before they are accessible to the public.', 'wplingua' ); ?></p>
359 </fieldset>
360 </div>
361 </div>
362 </div>
363
364 <div id="wplng-target-languages-container">
365 <p><strong><?php esc_html_e( 'Target languages enabled: ', 'wplingua' ); ?></strong></p>
366 <div id="wplng-target-languages-list"></div>
367 <textarea name="wplng_target_languages" id="wplng_target_languages"><?php echo esc_textarea( wp_json_encode( $languages_target, true ) ); ?></textarea>
368 </div>
369
370 <hr>
371
372 <p><?php esc_html_e( 'Access more target languages by upgrading your API key.', 'wplingua' ); ?></strong>
373 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-language-adding"></span></p>
374
375 <div class="wplng-help-box" id="wplng-hb-language-adding">
376 <p>
377 <?php
378
379 echo '<strong>';
380 echo esc_html__( 'Available languages: ', 'wplingua' );
381 echo '</strong>';
382 echo '<br>';
383
384 $languages_all = wplng_get_languages_all();
385 $last_language_key = count( $languages_all ) - 1;
386
387 foreach ( $languages_all as $key => $language ) {
388 echo $language['name'];
389 if ( $key !== $last_language_key ) {
390 echo '&nbsp;- ';
391 }
392 }
393 ?>
394 </p>
395
396 <hr>
397
398 <p>
399 <a href="https://wplingua.com/pricing/" target="_blank">
400 <?php esc_attr_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
401 </a>
402 </p>
403 </div>
404 <?php
405 }
406
407
408 /**
409 * Print HTML subsection of Option page : wpLingua Settings - API feature
410 *
411 * @return void
412 */
413 function wplng_settings_part_features_api() {
414
415 $api_features = wplng_get_api_feature();
416
417 ?>
418 <p><strong><?php esc_html_e( 'API translation features: ', 'wplingua' ); ?></strong></p>
419 <hr>
420 <p><?php esc_html_e( 'The options below require extended access to the wpLingua API to be functional on your website.', 'wplingua' ); ?></p>
421 <hr>
422 <fieldset>
423 <input type="checkbox" id="wplng_commercial_use" name="wplng_commercial_use" value="1" <?php checked( 1, in_array( 'commercial', $api_features ), true ); ?> disabled="disabled"/>
424 <label for="wplng_commercial_use">PREMIUM - <?php esc_html_e( 'Use wpLingua on commercial website', 'wplingua' ); ?></label>
425 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-commercial"></span>
426 </fieldset>
427
428 <div class="wplng-help-box" id="wplng-hb-feature-commercial">
429 <p><?php esc_html_e( 'Use of the free wpLingua API keys is reserved for personal blogs and non-profit websites; paid subscriptions are available for companies and commercial websites.', 'wplingua' ); ?></p>
430 <hr>
431 <p>
432 <a href="https://wplingua.com/pricing/" target="_blank">
433 <?php esc_attr_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
434 </a>
435 </p>
436 </div>
437
438 <fieldset>
439 <input type="checkbox" id="wplng_translate_search" name="wplng_translate_search" value="1" <?php checked( 1, get_option( 'wplng_translate_search' ) && in_array( 'search', $api_features ), true ); ?> <?php disabled( false, in_array( 'search', $api_features ), true ); ?>/>
440 <label for="wplng_translate_search">PREMIUM - <?php esc_html_e( 'Search from translated languages', 'wplingua' ); ?></label>
441 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-search"></span>
442 </fieldset>
443
444 <div class="wplng-help-box" id="wplng-hb-feature-search">
445 <p><?php esc_html_e( 'Enable visitors to search on your website in their own language.', 'wplingua' ); ?></p>
446 <hr>
447 <p><?php esc_html_e( 'Example: if your website is translated from English to French and you have a post named "Hello". When a French visitor searches for the term "Bonjour" on the website, this feature will translate it on the fly to "Hello" before launching the search. This will allow WordPress to find the post named "Hello" when your visitor has searched for "Bonjour".', 'wplingua' ); ?></p>
448 <hr>
449 <p>
450 <a href="https://wplingua.com/pricing/" target="_blank">
451 <?php esc_attr_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
452 </a>
453 </p>
454
455 </div>
456 <?php
457 }
458
459
460 /**
461 * Print HTML subsection of Option page : wpLingua Settings - Plugin feature
462 *
463 * @return void
464 */
465 function wplng_settings_part_features_seo() {
466
467 ?>
468 <p><strong><?php esc_html_e( 'SEO features: ', 'wplingua' ); ?></strong></p>
469
470 <hr>
471
472 <fieldset>
473 <input type="checkbox" id="wplng_hreflang" name="wplng_hreflang" value="1" <?php checked( 1, get_option( 'wplng_hreflang', 1 ), true ); ?>/>
474 <label for="wplng_hreflang"><?php esc_html_e( 'Add hreflang tags to translated pages', 'wplingua' ); ?></label>
475 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-hreflang"></span>
476 </fieldset>
477
478 <div class="wplng-help-box" id="wplng-hb-feature-hreflang">
479 <p><?php esc_html_e( 'This option automatically adds hreflang tags to your pages that are available in multiple languages.', 'wplingua' ); ?></p>
480 <hr>
481 <p><?php esc_html_e( 'Hreflang tags are HTML metadata used to indicate the URLs of each language version of a page. They are not visible to visitors, but they allow search engines (Google, Bing, etc.) to identify the multilingual structure of the site and display the correct version according to the user\'s language.', 'wplingua' ); ?></p>
482 </div>
483
484 <fieldset>
485 <input type="checkbox" id="wplng_sitemap_xml" name="wplng_sitemap_xml" value="1" <?php checked( 1, get_option( 'wplng_sitemap_xml', 1 ), true ); ?>/>
486 <label for="wplng_sitemap_xml"><?php esc_html_e( 'Enable multilingual XML Sitemap', 'wplingua' ); ?></label>
487 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-sitemap-xml"></span>
488 </fieldset>
489
490 <div class="wplng-help-box" id="wplng-hb-feature-sitemap-xml">
491 <p><?php esc_html_e( 'This option automatically adds your wpLingua translated pages into your XML Sitemap files.', 'wplingua' ); ?></p>
492 <hr>
493 <p><?php esc_html_e( 'An XML Sitemap is used by search engines (Google, Bing, etc.) to better discover and index the pages of your website. By default, only the default language pages are included. With this option enabled, all translated versions of your content will also be listed.', 'wplingua' ); ?></p>
494 <p><?php esc_html_e( 'This greatly improves SEO visibility, ensuring that search engines can easily find and index your content in every language.', 'wplingua' ); ?></p>
495 <hr>
496 <p><?php esc_html_e( 'wpLingua uses a universal method that intercepts and extends sitemap. It works with the native WordPress sitemap and with popular SEO plugins such as Yoast SEO, Rank Math, All in One SEO, SEOPress, etc.', 'wplingua' ); ?></p>
497 </div>
498
499 <div class="wplng-beta-hidden" style="display: none;">
500 <fieldset>
501 <input type="checkbox" id="wplng_sitemap_xsl_override" name="wplng_sitemap_xsl_override" value="1" <?php checked( 1, get_option( 'wplng_sitemap_xsl_override', false ), true ); ?>/>
502 <label for="wplng_sitemap_xsl_override">BETA - <?php esc_html_e( 'Use wpLingua display for XML Sitemap', 'wplingua' ); ?></label>
503 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-sitemap-xsl"></span>
504 </fieldset>
505
506 <div class="wplng-help-box" id="wplng-hb-feature-sitemap-xsl">
507 <p><?php esc_html_e( 'This option replaces the default XML Sitemap stylesheet with wpLingua\'s custom display.', 'wplingua' ); ?></p>
508 <hr>
509 <p><?php esc_html_e( 'When enabled, the XML Sitemap will use a wpLingua-designed stylesheet that visually displays all translated URLs directly under each original URL. This makes it easy to verify that all language versions are correctly included in your sitemap.', 'wplingua' ); ?></p>
510 <hr>
511 <p><?php esc_html_e( 'Note: This only affects how the sitemap is displayed in your browser. The actual XML data sent to search engines remains unchanged and fully compatible with all SEO standards.', 'wplingua' ); ?></p>
512 <p><?php esc_html_e( 'This option has no effect when using All In One SEO, as this plugin handles the display of translated links itself.', 'wplingua' ); ?></p>
513 </div>
514 </div>
515
516 <?php
517 }
518
519
520 /**
521 * Print HTML subsection of Option page : wpLingua Settings - Plugin feature
522 *
523 * @return void
524 */
525 function wplng_settings_part_features_more() {
526
527 ?>
528 <p><strong><?php esc_html_e( 'More features: ', 'wplingua' ); ?></strong></p>
529
530 <hr>
531
532 <fieldset>
533 <input type="checkbox" id="wplng_load_in_progress" name="wplng_load_in_progress" value="1" <?php checked( 1, get_option( 'wplng_load_in_progress' ), true ); ?>/>
534 <label for="wplng_load_in_progress"><?php esc_html_e( 'Translation progress bar for editors', 'wplingua' ); ?></label>
535 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-load-in-progress"></span>
536 </fieldset>
537
538 <div class="wplng-help-box" id="wplng-hb-feature-load-in-progress">
539 <p><?php esc_html_e( 'Enable progress bar: Smooth translations loading for editors', 'wplingua' ); ?></p>
540 <hr>
541 <p><?php esc_html_e( 'Activate a progress bar when a page requires the generation of more than 10 new string translations. This feature only applies to connected editors.', 'wplingua' ); ?></p>
542 </div>
543
544 <input type="checkbox" id="wplng_browser_language_redirect_checkbox" name="wplng_browser_language_redirect_checkbox" value="1"/>
545 <label for="wplng_browser_language_redirect_checkbox"><?php esc_html_e( 'Enable redirection based on the web browser\'s language', 'wplingua' ); ?></label>
546 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-browser-language-redirect"></span>
547
548 <div class="wplng-help-box" id="wplng-hb-feature-browser-language-redirect">
549 <p><?php esc_html_e( 'This option automatically redirects visitors to the translated version of your site that matches their browser language when they land on the main homepage. It can improve user experience by showing content in the right language immediately, but depending on your setup, it may introduce side effects.', 'wplingua' ); ?></p>
550 <hr>
551 <p><strong><?php esc_html_e( 'Disabled (recommended):', 'wplingua' ); ?></strong></p>
552 <p><?php esc_html_e( 'No redirection is applied. Every visitor always sees the default homepage, regardless of their browser language. This is the safest option and ensures maximum compatibility with caching systems, SEO, and shared links. Recommended if you are unsure which option to choose.', 'wplingua' ); ?></p>
553 <hr>
554 <p><strong><?php esc_html_e( 'JS only:', 'wplingua' ); ?></strong></p>
555 <p><?php esc_html_e( 'The redirect is handled with JavaScript, after the default homepage has loaded. This method works in almost all cases and avoids issues with caching plugins. However, it may cause a short flicker effect: users will briefly see the default page before being redirected to the translated version.', 'wplingua' ); ?></p>
556 <hr>
557 <p><strong><?php esc_html_e( 'PHP and JS:', 'wplingua' ); ?></strong></p>
558 <p><?php esc_html_e( 'The redirect is performed server-side with PHP, which makes it faster and more seamless for visitors. In addition, a cookie is set via JavaScript to remember the user’s preferred language for future visits. While this provides the smoothest experience, it can sometimes conflict with caching systems (static pages, CDN, aggressive cache settings) and may cause incorrect redirects in certain setups.', 'wplingua' ); ?></p>
559 </div>
560
561 <fieldset id="wplng-browser-language-fieldset">
562 <?php
563
564 $wbrowser_language_redirect = get_option( 'wplng_browser_language_redirect', 'disable' );
565
566 if ( $wbrowser_language_redirect !== 'disable'
567 && $wbrowser_language_redirect !== 'js_only'
568 && $wbrowser_language_redirect !== 'php_js'
569 ) {
570 $wbrowser_language_redirect = 'disable';
571 }
572
573 ?>
574 <label>
575 <input type="radio" name="wplng_browser_language_redirect" value="disable" <?php checked( $wbrowser_language_redirect, 'disable' ); ?> />
576 <?php esc_html_e( 'Disable (recommended)', 'wplingua' ); ?>
577 </label>
578
579 <br>
580
581 <label>
582 <input type="radio" name="wplng_browser_language_redirect" value="js_only" <?php checked( $wbrowser_language_redirect, 'js_only' ); ?> />
583 <?php esc_html_e( 'Enable with JS only', 'wplingua' ); ?>
584 </label>
585
586 <br>
587
588 <label>
589 <input type="radio" name="wplng_browser_language_redirect" value="php_js" <?php checked( $wbrowser_language_redirect, 'php_js' ); ?> />
590 <?php esc_html_e( 'Enable with PHP and JS', 'wplingua' ); ?>
591 </label>
592 </fieldset>
593
594 <?php
595 }
596
597
598 /**
599 * Print HTML subsection of Option page : wpLingua Settings - API Key
600 *
601 * @return void
602 */
603 function wplng_settings_part_api_key() {
604
605 $data = wplng_get_api_data();
606
607 ?>
608 <fieldset>
609 <p><label for="wplng_api_key"><strong><?php esc_html_e( 'Website API key: ', 'wplingua' ); ?></strong></label></p>
610
611 <hr>
612
613 <p>
614 <?php esc_html_e( 'The API key connects the website to wpLingua\'s online services and automatic translation generators.', 'wplingua' ); ?>
615 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-api-key"></span>
616 </p>
617
618 <div class="wplng-help-box" id="wplng-hb-api-key">
619 <p>
620 <?php esc_html_e( 'A wpLingua API key consists of 42 characters (uppercase, lowercase and numbers). It is emailed to you when you request it using the form provided when you install the plugin. You must keep this key secret and only communicate it to wplingua.com services.', 'wplingua' ); ?>
621 </p>
622 <hr>
623 <p>
624 <a href="https://wplingua.com/pricing/" target="_blank">
625 <?php esc_attr_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
626 </a>
627 </p>
628 </div>
629
630 <hr>
631
632 <input type="text" id="wplng-api-key-fake" value="●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●" disabled></input>
633
634 <input type="text" name="wplng_api_key" id="wplng_api_key" value="<?php echo esc_attr( wplng_get_api_key() ); ?>" style="display: none;"></input>
635
636 <a class="button button-primary wplng-icon-button" id="wplng-api-key-show" href="javascript:void(0);" title="<?php esc_html_e( 'Show API key', 'wplingua' ); ?>"><span class="dashicons dashicons-visibility"></span></a>
637
638 <a class="button button-primary wplng-icon-button" id="wplng-api-key-hide" href="javascript:void(0);" title="<?php esc_html_e( 'Hide API key', 'wplingua' ); ?>" style="display: none;"><span class="dashicons dashicons-hidden"></span></a>
639 </fieldset>
640
641 <?php if ( ! empty( $data['status'] ) ) : ?>
642
643 <hr>
644 <p class="wplng-fe-50"><?php esc_html_e( 'API key status: ', 'wplingua' ); ?></p>
645
646 <?php if ( 'FREE' === $data['status'] ) : ?>
647 <p class="wplng-fe-50" style="text-align: right;"><span class="dashicons dashicons-saved"></span> FREE</p>
648 <?php elseif ( 'PREMIUM' === $data['status'] ) : ?>
649 <p class="wplng-fe-50" style="text-align: right;"><span class="dashicons dashicons-superhero-alt"></span> PREMIUM</p>
650 <?php elseif ( 'VIP' === $data['status'] ) : ?>
651 <p class="wplng-fe-50" style="text-align: right;"><span class="dashicons dashicons-star-empty"></span> VIP</p>
652 <?php endif; ?>
653
654
655 <?php endif; ?>
656
657 <?php if ( ! empty( $data['expiration'] ) ) : ?>
658
659 <p class="wplng-fe-50"><?php esc_html_e( 'Premium expiration: ', 'wplingua' ); ?></p>
660 <p class="wplng-fe-50" style="text-align: right;"><?php echo esc_html( $data['expiration'] ); ?></p>
661
662 <?php endif; ?>
663
664 <?php
665 }
666