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

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