PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 2.16.7
Translate and Go multilingual – Automatic AI translation – wpLingua v2.16.7
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.16.7, at inc/admin/option-page-settings.php

695 lines 28.7 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 $is_first = wplng_settings_part_first_use();
33 $form_css = '';
34
35 if ( $is_first ) {
36 $form_css = 'display: none !important;';
37 }
38
39 ?>
40
41
42 <div class="wrap">
43
44 <header id="wplng-option-page-header">
45 <h1 class="wplng-option-page-title"><span class="dashicons dashicons-translation"></span> <?php esc_html_e( 'wpLingua - General settings', 'wplingua' ); ?></h1>
46 <?php echo wplng_option_page_settings_menu( $is_first ); ?>
47 </header>
48
49 <hr class="wp-header-end">
50
51 <form
52 method="post"
53 action="options.php"
54 id="wplng-option-settings-form"
55 style="<?php echo esc_attr( $form_css ); ?>"
56 >
57 <?php
58 settings_fields( 'wplng_settings' );
59 do_settings_sections( 'wplng_settings' );
60 ?>
61
62 <table class="form-table wplng-form-table">
63 <tr>
64 <th scope="row"><span class="dashicons dashicons-location"></span> <?php esc_html_e( 'Website language', 'wplingua' ); ?></th>
65 <td class="wplng-flex-container">
66 <?php wplng_settings_part_language_website(); ?>
67 </td>
68 </tr>
69 <tr>
70 <th scope="row"><span class="dashicons dashicons-location-alt"></span> <?php esc_html_e( 'Translated languages', 'wplingua' ); ?></th>
71 <td class="wplng-flex-container">
72 <?php wplng_settings_part_languages_target(); ?>
73 </td>
74 </tr>
75 <tr>
76 <th scope="row"><span class="dashicons dashicons-admin-settings"></span> <?php esc_html_e( 'Features', 'wplingua' ); ?></th>
77 <td>
78 <fieldset>
79 <?php wplng_settings_part_features_api(); ?>
80 <br><hr>
81 <?php wplng_settings_part_features_seo(); ?>
82 <br><hr>
83 <?php wplng_settings_part_features_more(); ?>
84 </fieldset>
85 </td>
86 </tr>
87 <tr class="wplng-flex-container">
88 <th scope="row"><span class="dashicons dashicons-admin-network"></span> <?php esc_html_e( 'API Key', 'wplingua' ); ?></th>
89 <td>
90 <?php wplng_settings_part_api_key(); ?>
91 </td>
92 </tr>
93 <tr class="wplng-tr-submit">
94 <th scope="row"><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Save', 'wplingua' ); ?></th>
95 <td>
96 <?php submit_button(); ?>
97 </td>
98 </tr>
99 </table>
100 </form>
101 </div>
102 <?php
103 }
104
105
106 /**
107 * Print HTML subsection of Option page : wpLingua Settings - First use
108 *
109 * @return void
110 */
111 function wplng_settings_part_first_use() {
112
113 if ( ! empty( get_option( 'wplng_website_language' ) )
114 || 'all' === wplng_get_api_language_website()
115 ) {
116 return false;
117 }
118
119 update_option(
120 'wplng_website_language',
121 wplng_get_api_language_website()
122 );
123
124 $data = wplng_get_api_data();
125
126 // Set option for target language
127
128 if ( empty( $data['languages_target'][0] )
129 || count( $data['languages_target'] ) !== 1
130 ) {
131 return false;
132 }
133
134 $language_target = wplng_get_language_by_id(
135 $data['languages_target'][0]
136 );
137
138 if ( ! empty( $language_target ) ) {
139
140 global $wplng_languages_target_simplified;
141 $wplng_languages_target_simplified = array( $language_target );
142
143 update_option(
144 'wplng_target_languages',
145 wp_json_encode(
146 array( $language_target )
147 )
148 );
149
150 update_option( 'wplng_flags_style', 'rectangular' );
151
152 } else {
153 return false;
154 }
155
156 // Enable default feature
157 update_option( 'wplng_sitemap_xml', 1 );
158 update_option( 'wplng_hreflang', 1 );
159 update_option( 'wplng_load_in_progress', 1 );
160
161 // Get URL for first registered language of front page
162 $url_front_page_translated = wplng_url_translate(
163 get_home_url(),
164 $language_target['id']
165 );
166
167 $url_front_page_load = add_query_arg(
168 array(
169 'wplng-load' => 'disabled',
170 'nocache' => (string) time() . (string) rand( 100, 999 ),
171 ),
172 $url_front_page_translated
173 );
174
175 ?>
176 <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 ); ?>">
177 <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>
178 <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>
179 <p><strong><?php esc_html_e( 'Translation progress: ', 'wplingua' ); ?> <span id="wplng-notice-first-loading-loading-percent">1 %</span></strong></p>
180 </div>
181
182 <div class="wplng-notice notice notice-success is-dismissible" id="wplng-notice-first-loading-loaded" style="display: none;">
183 <h2>
184 🎉 <?php esc_html_e( 'Your website is now multilingual!', 'wplingua' ); ?>
185 <br>
186 <?php esc_html_e( 'You can start visiting the translated version.', 'wplingua' ); ?>
187 </h2>
188 <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>
189 <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>
190
191 <a href="<?php echo esc_url( $url_front_page_translated ); ?>" target="_blank" rel="noopener noreferrer" class="button button-primary">
192 <?php esc_html_e( 'Visit your multilingual website', 'wplingua' ); ?>
193 </a>
194 </div>
195 <?php
196
197 return true;
198 }
199
200
201 /**
202 * Print HTML subsection of Option page : wpLingua Settings - Website language
203 *
204 * @return void
205 */
206 function wplng_settings_part_language_website() {
207
208 $api_language_website = wplng_get_api_language_website();
209
210 if ( 'all' !== $api_language_website ) {
211 echo '<fieldset style="display: none;">';
212 } else {
213 echo '<fieldset>';
214 }
215
216 echo '<div class="wplng-flex-row">';
217 echo '<div class="wplng-flex-item">';
218 echo '<label for="wplng_website_language">';
219 echo '<strong>';
220 esc_html_e( 'Original website language: ', 'wplingua' );
221 echo ' </strong>';
222 echo '</label>';
223 echo '</div>'; // End .wplng-flex-item
224
225 echo '<div class="wplng-flex-item">';
226 echo '<select id="wplng_website_language" name="wplng_website_language" class="wplng-width-full">';
227 $website_language_saved = true;
228 if ( empty( wplng_get_language_website_id() ) ) {
229 $website_language_saved = false;
230 } else {
231
232 $website_language_id = wplng_get_language_website_id();
233 $website_language = wplng_get_language_by_id( $website_language_id );
234
235 if ( ! empty( $website_language['id'] )
236 && ! empty( $website_language['name'] )
237 ) {
238 echo '<option value="' . esc_attr( $website_language['id'] ) . '">';
239 echo esc_html( $website_language['name'] );
240 echo '</option>';
241 } else {
242 $website_language_saved = false;
243 }
244 }
245
246 if ( ! $website_language_saved ) {
247 echo '<option value="">';
248 esc_html_e( 'Please choose an option', 'wplingua' );
249 echo '</option>';
250 }
251
252 echo '</select>';
253 echo '</div>'; // End .wplng-flex-item
254 echo '</div>'; // End .wplng-flex-row
255 echo '<hr>';
256 echo '</fieldset>';
257
258 if ( 'all' !== $api_language_website ) {
259 echo '<p>';
260 echo '<strong>';
261 esc_html_e( 'Original website language, defined by API key: ', 'wplingua' );
262 echo ' </strong>';
263 echo '<span';
264 echo ' title="' . esc_attr__( 'Click to expand', 'wplingua' ) . '"';
265 echo ' wplng-help-box="#wplng-hb-language-website"';
266 echo '></span>';
267 echo ' </p>';
268
269 echo '<div class="wplng-help-box" id="wplng-hb-language-website">';
270 echo '<p>';
271 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' );
272 echo '<hr>';
273 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' );
274 echo '</p>';
275 echo '</div>';
276 }
277 ?>
278
279 <div id="wplng-flags-radio-original-website-custom"><?php esc_html_e( 'Custom', 'wplingua' ); ?></div>
280
281 <div id="wplng-website-language-box">
282
283 <div class="wplng-website-language-displayed">
284 <div id="wplng-website-language" class="wplng-website-language-left">
285 <img src="<?php echo esc_url( wplng_get_language_website_flag() ); ?>" id="wplng-website-flag"><?php echo isset( $website_language['name'] ) ? esc_html( $website_language['name'] ) : ''; ?>
286 </div>
287 <div class="wplng-target-language-right">
288 <a href="javascript:void(0);" id="wplng-website-lang-update-flag"><?php esc_html_e( 'Edit', 'wplingua' ); ?></a>
289 </div>
290 </div>
291
292 <div id="wplng-flag-website-container">
293 <p><strong><?php esc_html_e( 'Flag to use for this language: ', 'wplingua' ); ?></strong></p>
294 <p><span id="wplng-flags-radio-original-website"></span></p>
295
296 <div id="wplng-website-flag-container">
297 <hr>
298 <p>
299 <strong><?php esc_html_e( 'Custom flag URL for this language: ', 'wplingua' ); ?></strong>
300 </p>
301 <input type="url" name="wplng_website_flag" id="wplng_website_flag" value="<?php echo esc_url( wplng_get_language_website_flag() ); ?>"/>
302 </div>
303 </div>
304
305 </div>
306 <?php
307 }
308
309
310 /**
311 * Print HTML subsection of Option page : wpLingua Settings - Languages target
312 *
313 * @return void
314 */
315 function wplng_settings_part_languages_target() {
316
317 $languages_target = wplng_get_languages_target_simplified();
318
319 ?>
320 <fieldset id="fieldset-add-target-language" class="wplng-flex-row">
321
322 <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>
323
324 <div class="wplng-flex-item">
325 <label for="wplng_add_new_target_language">
326 <strong><?php esc_html_e( 'Add new target Language: ', 'wplingua' ); ?></strong>
327 </label>
328 </div>
329
330
331 <div class="wplng-flex-item">
332 <select id="wplng_add_new_target_language" name="wplng_add_new_target_language"></select>
333 <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);">
334 <span class="dashicons dashicons-insert"></span>
335 </a>
336 </div>
337 </fieldset>
338
339 <hr id="wplng-languages-target-separator">
340
341 <div id="wplng-target-language-template">
342 <div class="wplng-target-language">
343
344 <div class="wplng-target-language-displayed">
345 <div class="wplng-target-language-left">
346 [FLAG][NAME]<span class="wplng-private-label"> <?php esc_html_e( '(Private)', 'wplingua' ); ?></span>
347 </div>
348
349 <div class="wplng-target-language-right">
350 <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>
351 <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>
352 <a href="javascript:void(0);" class="wplng-target-lang-update-flag" wplng-target-lang="[LANG]"><?php esc_html_e( 'Edit', 'wplingua' ); ?></a>
353 <a href="javascript:void(0);" class="wplng-target-lang-remove" wplng-target-lang="[LANG]"><?php esc_html_e( 'Remove', 'wplingua' ); ?></a>
354 </div>
355 </div>
356
357 <div class="wplng-flag-target-container" wplng-target-lang="[LANG]">
358 <p><strong><?php esc_html_e( 'Flag to use for this language: ', 'wplingua' ); ?></strong></p>
359 <p><span class="wplng-subflags-radio-target-website">[FLAGS_OPTIONS]</span></p>
360 <div class="wplng-subflag-target-custom" wplng-target-lang="[LANG]">
361 <hr>
362 <p><strong><?php esc_html_e( 'Custom flag URL for this language: ', 'wplingua' ); ?></strong></p>
363 [INPUT]
364 </div>
365 <hr>
366 <fieldset>
367 [PRIVATE_INPUT]<label for="wplng-language-private-[LANG]"><strong><?php esc_html_e( 'Make this language private', 'wplingua' ); ?></strong></label>
368 <p><?php esc_html_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>
369 </fieldset>
370 </div>
371 </div>
372 </div>
373
374 <div id="wplng-target-languages-container">
375 <p><strong><?php esc_html_e( 'Target languages enabled: ', 'wplingua' ); ?></strong></p>
376 <div id="wplng-target-languages-list"></div>
377 <textarea name="wplng_target_languages" id="wplng_target_languages"><?php echo esc_textarea( wp_json_encode( $languages_target, true ) ); ?></textarea>
378 </div>
379
380 <hr>
381
382 <div>
383 <?php esc_html_e( 'Access more target languages by upgrading your API key.', 'wplingua' ); ?>
384 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-language-adding"></span>
385 </div>
386
387 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-language-adding">
388 <p>
389 <?php
390
391 echo '<strong>';
392 echo esc_html__( 'Available languages: ', 'wplingua' );
393 echo '</strong>';
394 echo '<br>';
395
396 $languages_all = wplng_get_languages_all();
397 $last_language_key = count( $languages_all ) - 1;
398
399 foreach ( $languages_all as $key => $language ) {
400 echo esc_html( $language['name'] );
401 if ( $key !== $last_language_key ) {
402 echo '&nbsp;- ';
403 }
404 }
405 ?>
406 </p>
407
408 <hr>
409
410 <p>
411 <a href="https://wplingua.com/pricing/" target="_blank" rel="noopener noreferrer">
412 <?php esc_html_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
413 </a>
414 </p>
415 </div>
416 <?php
417 }
418
419
420 /**
421 * Print HTML subsection of Option page : wpLingua Settings - API feature
422 *
423 * @return void
424 */
425 function wplng_settings_part_features_api() {
426
427 $api_features = wplng_get_api_feature();
428
429 ?>
430 <p><strong><?php esc_html_e( 'API translation features: ', 'wplingua' ); ?></strong></p>
431 <hr>
432 <p><?php esc_html_e( 'The options below require extended access to the wpLingua API to be functional on your website.', 'wplingua' ); ?></p>
433 <hr>
434 <fieldset>
435 <input type="checkbox" id="wplng_commercial_use" name="wplng_commercial_use" value="1" <?php checked( 1, in_array( 'commercial', $api_features ), true ); ?> disabled="disabled"/>
436 <label for="wplng_commercial_use">PREMIUM - <?php esc_html_e( 'Use wpLingua on commercial website', 'wplingua' ); ?></label>
437 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-commercial"></span>
438 </fieldset>
439
440 <div class="wplng-help-box wplng-spacing-bottom" id="wplng-hb-feature-commercial">
441 <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>
442 <hr>
443 <p>
444 <a href="https://wplingua.com/pricing/" target="_blank" rel="noopener noreferrer">
445 <?php esc_html_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
446 </a>
447 </p>
448 </div>
449
450 <fieldset>
451 <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 ); ?>/>
452 <label for="wplng_translate_search">PREMIUM - <?php esc_html_e( 'Search from translated languages', 'wplingua' ); ?></label>
453 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-search"></span>
454 </fieldset>
455
456 <div class="wplng-help-box" id="wplng-hb-feature-search">
457 <p><?php esc_html_e( 'Enable visitors to search on your website in their own language.', 'wplingua' ); ?></p>
458 <hr>
459 <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>
460 <hr>
461 <p>
462 <a href="https://wplingua.com/pricing/" target="_blank" rel="noopener noreferrer">
463 <?php esc_html_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
464 </a>
465 </p>
466
467 </div>
468 <?php
469 }
470
471
472 /**
473 * Print HTML subsection of Option page : wpLingua Settings - Plugin feature
474 *
475 * @return void
476 */
477 function wplng_settings_part_features_seo() {
478
479 ?>
480 <p><strong><?php esc_html_e( 'SEO features: ', 'wplingua' ); ?></strong></p>
481
482 <hr>
483
484 <fieldset>
485 <input type="checkbox" id="wplng_hreflang" name="wplng_hreflang" value="1" <?php checked( 1, get_option( 'wplng_hreflang', 1 ), true ); ?>/>
486 <label for="wplng_hreflang"><?php esc_html_e( 'Add hreflang tags to translated pages', 'wplingua' ); ?></label>
487 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-hreflang"></span>
488 </fieldset>
489
490 <div class="wplng-help-box wplng-spacing-bottom" id="wplng-hb-feature-hreflang">
491 <p><?php esc_html_e( 'This option automatically adds hreflang tags to your pages that are available in multiple languages.', 'wplingua' ); ?></p>
492 <hr>
493 <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>
494 </div>
495
496 <fieldset>
497 <input type="checkbox" id="wplng_sitemap_xml" name="wplng_sitemap_xml" value="1" <?php checked( 1, get_option( 'wplng_sitemap_xml', 1 ), true ); ?>/>
498 <label for="wplng_sitemap_xml"><?php esc_html_e( 'Enable multilingual XML Sitemap', 'wplingua' ); ?></label>
499 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-sitemap-xml"></span>
500 </fieldset>
501
502 <div class="wplng-help-box" id="wplng-hb-feature-sitemap-xml">
503 <p><?php esc_html_e( 'This option automatically adds your wpLingua translated pages into your XML Sitemap files.', 'wplingua' ); ?></p>
504 <hr>
505 <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>
506 <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>
507 <hr>
508 <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>
509 </div>
510
511 <div class="wplng-beta-hidden" style="display: none;">
512 <fieldset>
513 <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 ); ?>/>
514 <label for="wplng_sitemap_xsl_override">BETA - <?php esc_html_e( 'Use wpLingua display for XML Sitemap', 'wplingua' ); ?></label>
515 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-sitemap-xsl"></span>
516 </fieldset>
517
518 <div class="wplng-help-box" id="wplng-hb-feature-sitemap-xsl">
519 <p><?php esc_html_e( 'This option replaces the default XML Sitemap stylesheet with wpLingua\'s custom display.', 'wplingua' ); ?></p>
520 <hr>
521 <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>
522 <hr>
523 <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>
524 <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>
525 </div>
526 </div>
527
528 <?php
529 }
530
531
532 /**
533 * Print HTML subsection of Option page : wpLingua Settings - Plugin feature
534 *
535 * @return void
536 */
537 function wplng_settings_part_features_more() {
538
539 ?>
540 <p><strong><?php esc_html_e( 'More features: ', 'wplingua' ); ?></strong></p>
541
542 <hr>
543
544 <fieldset>
545 <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 ); ?>/>
546 <label for="wplng_load_in_progress"><?php esc_html_e( 'Translation progress bar for editors', 'wplingua' ); ?></label>
547 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-load-in-progress"></span>
548 </fieldset>
549
550 <div class="wplng-help-box wplng-spacing-bottom" id="wplng-hb-feature-load-in-progress">
551 <p><?php esc_html_e( 'Enable progress bar: Smooth translations loading for editors', 'wplingua' ); ?></p>
552 <hr>
553 <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>
554 </div>
555
556 <input type="checkbox" id="wplng_browser_language_redirect_checkbox" name="wplng_browser_language_redirect_checkbox" value="1"/>
557 <label for="wplng_browser_language_redirect_checkbox"><?php esc_html_e( 'Enable redirection based on the web browser\'s language', 'wplingua' ); ?></label>
558 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-browser-language-redirect"></span>
559
560 <div class="wplng-help-box" id="wplng-hb-feature-browser-language-redirect">
561 <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>
562 <hr>
563 <p><strong><?php esc_html_e( 'Disabled (recommended):', 'wplingua' ); ?></strong></p>
564 <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>
565 <hr>
566 <p><strong><?php esc_html_e( 'JS only:', 'wplingua' ); ?></strong></p>
567 <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>
568 <hr>
569 <p><strong><?php esc_html_e( 'PHP and JS:', 'wplingua' ); ?></strong></p>
570 <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>
571 </div>
572
573 <fieldset id="wplng-browser-language-fieldset">
574 <?php
575
576 $wbrowser_language_redirect = get_option( 'wplng_browser_language_redirect', 'disable' );
577
578 if ( $wbrowser_language_redirect !== 'disable'
579 && $wbrowser_language_redirect !== 'js_only'
580 && $wbrowser_language_redirect !== 'php_js'
581 ) {
582 $wbrowser_language_redirect = 'disable';
583 }
584
585 ?>
586 <label>
587 <input type="radio" name="wplng_browser_language_redirect" value="disable" <?php checked( $wbrowser_language_redirect, 'disable' ); ?> />
588 <?php esc_html_e( 'Disable (recommended)', 'wplingua' ); ?>
589 </label>
590
591 <br>
592
593 <label>
594 <input type="radio" name="wplng_browser_language_redirect" value="js_only" <?php checked( $wbrowser_language_redirect, 'js_only' ); ?> />
595 <?php esc_html_e( 'Enable with JS only', 'wplingua' ); ?>
596 </label>
597
598 <br>
599
600 <label>
601 <input type="radio" name="wplng_browser_language_redirect" value="php_js" <?php checked( $wbrowser_language_redirect, 'php_js' ); ?> />
602 <?php esc_html_e( 'Enable with PHP and JS', 'wplingua' ); ?>
603 </label>
604 </fieldset>
605
606 <?php
607 }
608
609
610 /**
611 * Print HTML subsection of Option page : wpLingua Settings - API Key
612 *
613 * @return void
614 */
615 function wplng_settings_part_api_key() {
616
617 $data = wplng_get_api_data();
618
619 ?>
620 <fieldset>
621 <p><label for="wplng_api_key"><strong><?php esc_html_e( 'Website API key: ', 'wplingua' ); ?></strong></label></p>
622
623 <hr>
624
625 <p>
626 <?php esc_html_e( 'The API key connects the website to wpLingua\'s online services and automatic translation generators.', 'wplingua' ); ?>
627 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-api-key"></span>
628 </p>
629
630 <div class="wplng-help-box" id="wplng-hb-api-key">
631 <p>
632 <?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' ); ?>
633 </p>
634 <hr>
635 <p>
636 <a href="https://wplingua.com/pricing/" target="_blank" rel="noopener noreferrer">
637 <?php esc_html_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
638 </a>
639 </p>
640 </div>
641
642 <hr>
643
644 <input type="text" id="wplng-api-key-fake" value="●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●" disabled></input>
645
646 <input type="text" name="wplng_api_key" id="wplng_api_key" value="<?php echo esc_attr( wplng_get_api_key() ); ?>" style="display: none;"></input>
647
648 <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>
649
650 <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>
651 </fieldset>
652
653 <?php if ( ! empty( $data['status'] ) ) : ?>
654
655 <hr>
656 <div class="wplng-flex-row">
657
658 <div class="wplng-flex-item">
659 <p><?php esc_html_e( 'API key status: ', 'wplingua' ); ?></p>
660 </div>
661
662 <div class="wplng-flex-item">
663 <?php if ( 'FREE' === $data['status'] ) : ?>
664 <p style="text-align: right;"><span class="dashicons dashicons-saved"></span> FREE</p>
665 <?php elseif ( 'PREMIUM' === $data['status'] ) : ?>
666 <p style="text-align: right;"><span class="dashicons dashicons-superhero-alt"></span> PREMIUM</p>
667 <?php elseif ( 'VIP' === $data['status'] ) : ?>
668 <p style="text-align: right;"><span class="dashicons dashicons-star-empty"></span> VIP</p>
669 <?php endif; ?>
670 </div>
671
672 </div>
673
674 <?php endif; ?>
675
676 <?php if ( ! empty( $data['expiration'] ) ) : ?>
677
678 <hr>
679 <div class="wplng-flex-row">
680
681 <div class="wplng-flex-item">
682 <p><?php esc_html_e( 'Premium expiration: ', 'wplingua' ); ?></p>
683 </div>
684
685 <div class="wplng-flex-item">
686 <p style="text-align: right;"><?php echo esc_html( $data['expiration'] ); ?></p>
687 </div>
688
689 </div>
690
691 <?php endif; ?>
692
693 <?php
694 }
695