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

692 lines 28.5 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 class="wplng-flex-container">
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 class="wplng-flex-container">
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><hr>
78 <?php wplng_settings_part_features_seo(); ?>
79 <br><hr>
80 <?php wplng_settings_part_features_more(); ?>
81 </fieldset>
82 </td>
83 </tr>
84 <tr class="wplng-flex-container">
85 <th scope="row"><span class="dashicons dashicons-admin-network"></span> <?php esc_html_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 esc_html_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 '<div class="wplng-flex-row">';
214 echo '<div class="wplng-flex-item">';
215 echo '<label for="wplng_website_language">';
216 echo '<strong>';
217 esc_html_e( 'Original website language: ', 'wplingua' );
218 echo ' </strong>';
219 echo '</label>';
220 echo '</div>'; // End .wplng-flex-item
221
222 echo '<div class="wplng-flex-item">';
223 echo '<select id="wplng_website_language" name="wplng_website_language" class="wplng-width-full">';
224 $website_language_saved = true;
225 if ( empty( wplng_get_language_website_id() ) ) {
226 $website_language_saved = false;
227 } else {
228
229 $website_language_id = wplng_get_language_website_id();
230 $website_language = wplng_get_language_by_id( $website_language_id );
231
232 if ( ! empty( $website_language['id'] )
233 && ! empty( $website_language['name'] )
234 ) {
235 echo '<option value="' . esc_attr( $website_language['id'] ) . '">';
236 echo esc_html( $website_language['name'] );
237 echo '</option>';
238 } else {
239 $website_language_saved = false;
240 }
241 }
242
243 if ( ! $website_language_saved ) {
244 echo '<option value="">';
245 esc_html_e( 'Please choose an option', 'wplingua' );
246 echo '</option>';
247 }
248
249 echo '</select>';
250 echo '</div>'; // End .wplng-flex-item
251 echo '</div>'; // End .wplng-flex-row
252 echo '<hr>';
253 echo '</fieldset>';
254
255 if ( 'all' !== $api_language_website ) {
256 echo '<p>';
257 echo '<strong>';
258 esc_html_e( 'Original website language, defined by API key: ', 'wplingua' );
259 echo ' </strong>';
260 echo '<span';
261 echo ' title="' . esc_attr__( 'Click to expand', 'wplingua' ) . '"';
262 echo ' wplng-help-box="#wplng-hb-language-website"';
263 echo '></span>';
264 echo ' </p>';
265
266 echo '<div class="wplng-help-box" id="wplng-hb-language-website">';
267 echo '<p>';
268 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' );
269 echo '<hr>';
270 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' );
271 echo '</p>';
272 echo '</div>';
273 }
274 ?>
275
276 <div id="wplng-flags-radio-original-website-custom"><?php esc_html_e( 'Custom', 'wplingua' ); ?></div>
277
278 <div id="wplng-website-language-box">
279
280 <div class="wplng-website-language-displayed">
281 <div id="wplng-website-language" class="wplng-website-language-left">
282 <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'] ) : ''; ?>
283 </div>
284 <div class="wplng-target-language-right">
285 <a href="javascript:void(0);" id="wplng-website-lang-update-flag"><?php esc_html_e( 'Edit', 'wplingua' ); ?></a>
286 </div>
287 </div>
288
289 <div id="wplng-flag-website-container">
290 <p><strong><?php esc_html_e( 'Flag to use for this language: ', 'wplingua' ); ?></strong></p>
291 <p><span id="wplng-flags-radio-original-website"></span></p>
292
293 <div id="wplng-website-flag-container">
294 <hr>
295 <p>
296 <strong><?php esc_html_e( 'Custom flag URL for this language: ', 'wplingua' ); ?></strong>
297 </p>
298 <input type="url" name="wplng_website_flag" id="wplng_website_flag" value="<?php echo esc_url( wplng_get_language_website_flag() ); ?>"/>
299 </div>
300 </div>
301
302 </div>
303 <?php
304 }
305
306
307 /**
308 * Print HTML subsection of Option page : wpLingua Settings - Languages target
309 *
310 * @return void
311 */
312 function wplng_settings_part_languages_target() {
313
314 $languages_target = wplng_get_languages_target_simplified();
315
316 ?>
317 <fieldset id="fieldset-add-target-language" class="wplng-flex-row">
318
319 <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>
320
321 <div class="wplng-flex-item">
322 <label for="wplng_add_new_target_language">
323 <strong><?php esc_html_e( 'Add new target Language: ', 'wplingua' ); ?></strong>
324 </label>
325 </div>
326
327
328 <div class="wplng-flex-item">
329 <select id="wplng_add_new_target_language" name="wplng_add_new_target_language"></select>
330 <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);">
331 <span class="dashicons dashicons-insert"></span>
332 </a>
333 </div>
334 </fieldset>
335
336 <hr id="wplng-languages-target-separator">
337
338 <div id="wplng-target-language-template">
339 <div class="wplng-target-language">
340
341 <div class="wplng-target-language-displayed">
342 <div class="wplng-target-language-left">
343 [FLAG][NAME]<span class="wplng-private-label"> <?php esc_html_e( '(Private)', 'wplingua' ); ?></span>
344 </div>
345
346 <div class="wplng-target-language-right">
347 <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>
348 <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>
349 <a href="javascript:void(0);" class="wplng-target-lang-update-flag" wplng-target-lang="[LANG]"><?php esc_html_e( 'Edit', 'wplingua' ); ?></a>
350 <a href="javascript:void(0);" class="wplng-target-lang-remove" wplng-target-lang="[LANG]"><?php esc_html_e( 'Remove', 'wplingua' ); ?></a>
351 </div>
352 </div>
353
354 <div class="wplng-flag-target-container" wplng-target-lang="[LANG]">
355 <p><strong><?php esc_html_e( 'Flag to use for this language: ', 'wplingua' ); ?></strong></p>
356 <p><span class="wplng-subflags-radio-target-website">[FLAGS_OPTIONS]</span></p>
357 <div class="wplng-subflag-target-custom" wplng-target-lang="[LANG]">
358 <hr>
359 <p><strong><?php esc_html_e( 'Custom flag URL for this language: ', 'wplingua' ); ?></strong></p>
360 [INPUT]
361 </div>
362 <hr>
363 <fieldset>
364 [PRIVATE_INPUT]<label for="wplng-language-private-[LANG]"><strong><?php esc_html_e( 'Make this language private', 'wplingua' ); ?></strong></label>
365 <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>
366 </fieldset>
367 </div>
368 </div>
369 </div>
370
371 <div id="wplng-target-languages-container">
372 <p><strong><?php esc_html_e( 'Target languages enabled: ', 'wplingua' ); ?></strong></p>
373 <div id="wplng-target-languages-list"></div>
374 <textarea name="wplng_target_languages" id="wplng_target_languages"><?php echo esc_textarea( wp_json_encode( $languages_target, true ) ); ?></textarea>
375 </div>
376
377 <hr>
378
379 <div>
380 <?php esc_html_e( 'Access more target languages by upgrading your API key.', 'wplingua' ); ?>
381 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-language-adding"></span>
382 </div>
383
384 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-language-adding">
385 <p>
386 <?php
387
388 echo '<strong>';
389 echo esc_html__( 'Available languages: ', 'wplingua' );
390 echo '</strong>';
391 echo '<br>';
392
393 $languages_all = wplng_get_languages_all();
394 $last_language_key = count( $languages_all ) - 1;
395
396 foreach ( $languages_all as $key => $language ) {
397 echo esc_html( $language['name'] );
398 if ( $key !== $last_language_key ) {
399 echo '&nbsp;- ';
400 }
401 }
402 ?>
403 </p>
404
405 <hr>
406
407 <p>
408 <a href="https://wplingua.com/pricing/" target="_blank">
409 <?php esc_html_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
410 </a>
411 </p>
412 </div>
413 <?php
414 }
415
416
417 /**
418 * Print HTML subsection of Option page : wpLingua Settings - API feature
419 *
420 * @return void
421 */
422 function wplng_settings_part_features_api() {
423
424 $api_features = wplng_get_api_feature();
425
426 ?>
427 <p><strong><?php esc_html_e( 'API translation features: ', 'wplingua' ); ?></strong></p>
428 <hr>
429 <p><?php esc_html_e( 'The options below require extended access to the wpLingua API to be functional on your website.', 'wplingua' ); ?></p>
430 <hr>
431 <fieldset>
432 <input type="checkbox" id="wplng_commercial_use" name="wplng_commercial_use" value="1" <?php checked( 1, in_array( 'commercial', $api_features ), true ); ?> disabled="disabled"/>
433 <label for="wplng_commercial_use">PREMIUM - <?php esc_html_e( 'Use wpLingua on commercial website', 'wplingua' ); ?></label>
434 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-commercial"></span>
435 </fieldset>
436
437 <div class="wplng-help-box wplng-spacing-bottom" id="wplng-hb-feature-commercial">
438 <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>
439 <hr>
440 <p>
441 <a href="https://wplingua.com/pricing/" target="_blank">
442 <?php esc_html_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
443 </a>
444 </p>
445 </div>
446
447 <fieldset>
448 <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 ); ?>/>
449 <label for="wplng_translate_search">PREMIUM - <?php esc_html_e( 'Search from translated languages', 'wplingua' ); ?></label>
450 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-search"></span>
451 </fieldset>
452
453 <div class="wplng-help-box" id="wplng-hb-feature-search">
454 <p><?php esc_html_e( 'Enable visitors to search on your website in their own language.', 'wplingua' ); ?></p>
455 <hr>
456 <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>
457 <hr>
458 <p>
459 <a href="https://wplingua.com/pricing/" target="_blank">
460 <?php esc_html_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
461 </a>
462 </p>
463
464 </div>
465 <?php
466 }
467
468
469 /**
470 * Print HTML subsection of Option page : wpLingua Settings - Plugin feature
471 *
472 * @return void
473 */
474 function wplng_settings_part_features_seo() {
475
476 ?>
477 <p><strong><?php esc_html_e( 'SEO features: ', 'wplingua' ); ?></strong></p>
478
479 <hr>
480
481 <fieldset>
482 <input type="checkbox" id="wplng_hreflang" name="wplng_hreflang" value="1" <?php checked( 1, get_option( 'wplng_hreflang', 1 ), true ); ?>/>
483 <label for="wplng_hreflang"><?php esc_html_e( 'Add hreflang tags to translated pages', 'wplingua' ); ?></label>
484 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-hreflang"></span>
485 </fieldset>
486
487 <div class="wplng-help-box wplng-spacing-bottom" id="wplng-hb-feature-hreflang">
488 <p><?php esc_html_e( 'This option automatically adds hreflang tags to your pages that are available in multiple languages.', 'wplingua' ); ?></p>
489 <hr>
490 <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>
491 </div>
492
493 <fieldset>
494 <input type="checkbox" id="wplng_sitemap_xml" name="wplng_sitemap_xml" value="1" <?php checked( 1, get_option( 'wplng_sitemap_xml', 1 ), true ); ?>/>
495 <label for="wplng_sitemap_xml"><?php esc_html_e( 'Enable multilingual XML Sitemap', 'wplingua' ); ?></label>
496 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-sitemap-xml"></span>
497 </fieldset>
498
499 <div class="wplng-help-box" id="wplng-hb-feature-sitemap-xml">
500 <p><?php esc_html_e( 'This option automatically adds your wpLingua translated pages into your XML Sitemap files.', 'wplingua' ); ?></p>
501 <hr>
502 <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>
503 <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>
504 <hr>
505 <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>
506 </div>
507
508 <div class="wplng-beta-hidden" style="display: none;">
509 <fieldset>
510 <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 ); ?>/>
511 <label for="wplng_sitemap_xsl_override">BETA - <?php esc_html_e( 'Use wpLingua display for XML Sitemap', 'wplingua' ); ?></label>
512 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-sitemap-xsl"></span>
513 </fieldset>
514
515 <div class="wplng-help-box" id="wplng-hb-feature-sitemap-xsl">
516 <p><?php esc_html_e( 'This option replaces the default XML Sitemap stylesheet with wpLingua\'s custom display.', 'wplingua' ); ?></p>
517 <hr>
518 <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>
519 <hr>
520 <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>
521 <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>
522 </div>
523 </div>
524
525 <?php
526 }
527
528
529 /**
530 * Print HTML subsection of Option page : wpLingua Settings - Plugin feature
531 *
532 * @return void
533 */
534 function wplng_settings_part_features_more() {
535
536 ?>
537 <p><strong><?php esc_html_e( 'More features: ', 'wplingua' ); ?></strong></p>
538
539 <hr>
540
541 <fieldset>
542 <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 ); ?>/>
543 <label for="wplng_load_in_progress"><?php esc_html_e( 'Translation progress bar for editors', 'wplingua' ); ?></label>
544 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-load-in-progress"></span>
545 </fieldset>
546
547 <div class="wplng-help-box wplng-spacing-bottom" id="wplng-hb-feature-load-in-progress">
548 <p><?php esc_html_e( 'Enable progress bar: Smooth translations loading for editors', 'wplingua' ); ?></p>
549 <hr>
550 <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>
551 </div>
552
553 <input type="checkbox" id="wplng_browser_language_redirect_checkbox" name="wplng_browser_language_redirect_checkbox" value="1"/>
554 <label for="wplng_browser_language_redirect_checkbox"><?php esc_html_e( 'Enable redirection based on the web browser\'s language', 'wplingua' ); ?></label>
555 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-feature-browser-language-redirect"></span>
556
557 <div class="wplng-help-box" id="wplng-hb-feature-browser-language-redirect">
558 <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>
559 <hr>
560 <p><strong><?php esc_html_e( 'Disabled (recommended):', 'wplingua' ); ?></strong></p>
561 <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>
562 <hr>
563 <p><strong><?php esc_html_e( 'JS only:', 'wplingua' ); ?></strong></p>
564 <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>
565 <hr>
566 <p><strong><?php esc_html_e( 'PHP and JS:', 'wplingua' ); ?></strong></p>
567 <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>
568 </div>
569
570 <fieldset id="wplng-browser-language-fieldset">
571 <?php
572
573 $wbrowser_language_redirect = get_option( 'wplng_browser_language_redirect', 'disable' );
574
575 if ( $wbrowser_language_redirect !== 'disable'
576 && $wbrowser_language_redirect !== 'js_only'
577 && $wbrowser_language_redirect !== 'php_js'
578 ) {
579 $wbrowser_language_redirect = 'disable';
580 }
581
582 ?>
583 <label>
584 <input type="radio" name="wplng_browser_language_redirect" value="disable" <?php checked( $wbrowser_language_redirect, 'disable' ); ?> />
585 <?php esc_html_e( 'Disable (recommended)', 'wplingua' ); ?>
586 </label>
587
588 <br>
589
590 <label>
591 <input type="radio" name="wplng_browser_language_redirect" value="js_only" <?php checked( $wbrowser_language_redirect, 'js_only' ); ?> />
592 <?php esc_html_e( 'Enable with JS only', 'wplingua' ); ?>
593 </label>
594
595 <br>
596
597 <label>
598 <input type="radio" name="wplng_browser_language_redirect" value="php_js" <?php checked( $wbrowser_language_redirect, 'php_js' ); ?> />
599 <?php esc_html_e( 'Enable with PHP and JS', 'wplingua' ); ?>
600 </label>
601 </fieldset>
602
603 <?php
604 }
605
606
607 /**
608 * Print HTML subsection of Option page : wpLingua Settings - API Key
609 *
610 * @return void
611 */
612 function wplng_settings_part_api_key() {
613
614 $data = wplng_get_api_data();
615
616 ?>
617 <fieldset>
618 <p><label for="wplng_api_key"><strong><?php esc_html_e( 'Website API key: ', 'wplingua' ); ?></strong></label></p>
619
620 <hr>
621
622 <p>
623 <?php esc_html_e( 'The API key connects the website to wpLingua\'s online services and automatic translation generators.', 'wplingua' ); ?>
624 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-api-key"></span>
625 </p>
626
627 <div class="wplng-help-box" id="wplng-hb-api-key">
628 <p>
629 <?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' ); ?>
630 </p>
631 <hr>
632 <p>
633 <a href="https://wplingua.com/pricing/" target="_blank">
634 <?php esc_html_e( 'wplingua.com : Upgrade your API key', 'wplingua' ); ?>
635 </a>
636 </p>
637 </div>
638
639 <hr>
640
641 <input type="text" id="wplng-api-key-fake" value="●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●" disabled></input>
642
643 <input type="text" name="wplng_api_key" id="wplng_api_key" value="<?php echo esc_attr( wplng_get_api_key() ); ?>" style="display: none;"></input>
644
645 <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>
646
647 <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>
648 </fieldset>
649
650 <?php if ( ! empty( $data['status'] ) ) : ?>
651
652 <hr>
653 <div class="wplng-flex-row">
654
655 <div class="wplng-flex-item">
656 <p><?php esc_html_e( 'API key status: ', 'wplingua' ); ?></p>
657 </div>
658
659 <div class="wplng-flex-item">
660 <?php if ( 'FREE' === $data['status'] ) : ?>
661 <p style="text-align: right;"><span class="dashicons dashicons-saved"></span> FREE</p>
662 <?php elseif ( 'PREMIUM' === $data['status'] ) : ?>
663 <p style="text-align: right;"><span class="dashicons dashicons-superhero-alt"></span> PREMIUM</p>
664 <?php elseif ( 'VIP' === $data['status'] ) : ?>
665 <p style="text-align: right;"><span class="dashicons dashicons-star-empty"></span> VIP</p>
666 <?php endif; ?>
667 </div>
668
669 </div>
670
671 <?php endif; ?>
672
673 <?php if ( ! empty( $data['expiration'] ) ) : ?>
674
675 <hr>
676 <div class="wplng-flex-row">
677
678 <div class="wplng-flex-item">
679 <p><?php esc_html_e( 'Premium expiration: ', 'wplingua' ); ?></p>
680 </div>
681
682 <div class="wplng-flex-item">
683 <p style="text-align: right;"><?php echo esc_html( $data['expiration'] ); ?></p>
684 </div>
685
686 </div>
687
688 <?php endif; ?>
689
690 <?php
691 }
692