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-switcher.php

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

642 lines 22.4 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 Switcher
11 *
12 * @return void
13 */
14 function wplng_option_page_switcher() {
15
16 $insert = wplng_get_switcher_insert();
17 $theme = wplng_get_switcher_theme();
18 $style = wplng_get_switcher_style();
19 $name_format = wplng_get_switcher_name_format();
20 $flags_style = wplng_get_switcher_flags_style();
21 $custom_css = get_option( 'wplng_custom_css' );
22
23 $switcher_html = wplng_get_switcher_html(
24 array( 'class' => 'switcher-preview' )
25 );
26
27 if ( empty( $custom_css ) || ! is_string( $custom_css ) ) {
28 $custom_css = '';
29 } else {
30 $custom_css = wp_strip_all_tags( $custom_css );
31 }
32
33 ?>
34
35 <div class="wrap">
36
37 <header id="wplng-option-page-header">
38 <h1 class="wplng-option-page-title"><span class="dashicons dashicons-translation"></span> <?php esc_html_e( 'wpLingua - Switcher settings', 'wplingua' ); ?></h1>
39 <?php echo wplng_option_page_settings_menu(); ?>
40 </header>
41
42 <hr class="wp-header-end">
43
44 <form method="post" action="options.php">
45 <?php
46 settings_fields( 'wplng_switcher' );
47 do_settings_sections( 'wplng_switcher' );
48 ?>
49 <table class="form-table wplng-form-table">
50
51 <?php if ( empty( $switcher_html ) ) : ?>
52 <div class="wplng-notice notice notice-error">
53 <p>
54 <strong><?php esc_html_e( 'No target language selected.', 'wplingua' ); ?></strong>
55 </p>
56 </div>
57 <?php else : ?>
58 <tr>
59 <th scope="row"><span class="dashicons dashicons-visibility"></span> <?php esc_html_e( 'Preview', 'wplingua' ); ?></th>
60 <td id="wplng-switcher-preview-container">
61 <div class="wplng-switcher-preview">
62 <?php echo $switcher_html; ?>
63 </div>
64 </td>
65 </tr>
66 <?php endif; ?>
67
68 <tr>
69 <th scope="row"><span class="dashicons dashicons-admin-appearance"></span> <?php esc_html_e( 'Design', 'wplingua' ); ?></th>
70 <td class="wplng-flex-container">
71 <fieldset class="wplng-flex-row">
72
73 <div class="wplng-flex-item">
74 <label for="wplng_style">
75 <strong><?php esc_html_e( 'Layout: ', 'wplingua' ); ?></strong>
76 </label>
77 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-layout"></span>
78 </div>
79
80 <div class="wplng-flex-item">
81 <select id="wplng_style" name="wplng_style" class="wplng-width-full">
82 <?php
83
84 $style_options = wplng_data_switcher_valid_style();
85
86 foreach ( $style_options as $option_value => $option_name ) {
87 if ( $style === $option_value ) {
88 echo '<option value="' . esc_attr( $option_value ) . '" selected>';
89 } else {
90 echo '<option value="' . esc_attr( $option_value ) . '">';
91 }
92 echo esc_html( $option_name );
93 echo '</option>';
94 }
95
96 ?>
97 </select>
98 </div>
99
100 </fieldset>
101
102 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-layout">
103 <p>
104 <?php esc_html_e( 'This option allow you to define the layout of the languages ​​in the switcher.', 'wplingua' ); ?>
105 </p>
106 <hr>
107 <ul>
108 <li>
109 <strong><?php esc_html_e( 'Inline list: ', 'wplingua' ); ?></strong>
110 <?php esc_html_e( 'the languages ​​are lined up next to each other.', 'wplingua' ); ?>
111 </li>
112 <li>
113 <strong><?php esc_html_e( 'Block: ', 'wplingua' ); ?></strong>
114 <?php esc_html_e( 'the languages ​​are placed in columns, one under the other.', 'wplingua' ); ?>
115 </li>
116 <li>
117 <strong><?php esc_html_e( 'Dropdown: ', 'wplingua' ); ?></strong>
118 <?php esc_html_e( 'the languages ​​appear in a drop-down menu; this is recommended when your website offers several languages.', 'wplingua' ); ?>
119 </li>
120 </ul>
121 </div>
122
123 <hr>
124
125 <fieldset class="wplng-flex-row">
126
127 <div class="wplng-flex-item">
128 <label for="wplng_name_format">
129 <strong><?php esc_html_e( 'Displayed names: ', 'wplingua' ); ?></strong>
130 </label>
131 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-name-format"></span>
132 </div>
133
134 <div class="wplng-flex-item">
135 <select id="wplng_name_format" name="wplng_name_format" class="wplng-width-full">
136 <?php
137
138 $name_format_options = wplng_data_switcher_valid_name_format();
139
140 foreach ( $name_format_options as $option_value => $option_name ) {
141 if ( $name_format === $option_value ) {
142 echo '<option value="' . esc_attr( $option_value ) . '" selected>';
143 } else {
144 echo '<option value="' . esc_attr( $option_value ) . '">';
145 }
146 echo esc_html( $option_name );
147 echo '</option>';
148 }
149
150 ?>
151 </select>
152 </div>
153
154 </fieldset>
155
156 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-name-format">
157 <p>
158 <?php esc_html_e( 'This option allow you to choose how the languages names should be written in the switcher.', 'wplingua' ); ?>
159 </p>
160
161 <hr>
162
163 <ul>
164 <li>
165 <strong><?php esc_html_e( 'Translated names: ', 'wplingua' ); ?></strong>
166 <?php esc_html_e( 'the name of the languages ​​is translated into the current language displayed.', 'wplingua' ); ?>
167 </li>
168 <li>
169 <strong><?php esc_html_e( 'Original name: ', 'wplingua' ); ?></strong>
170 <?php esc_html_e( 'each language retains its name in its own language (English, Français, 日本語, Português, Español, etc.).', 'wplingua' ); ?>
171 </li>
172 <li>
173 <strong><?php esc_html_e( 'Language ID: ', 'wplingua' ); ?></strong>
174 <?php esc_html_e( 'language names use language ID (FR, EN, DE, RU, etc.).', 'wplingua' ); ?>
175 </li>
176 <li>
177 <strong><?php esc_html_e( 'No display: ', 'wplingua' ); ?></strong>
178 <?php esc_html_e( 'no text, only flags are displayed.', 'wplingua' ); ?>
179 </li>
180 </ul>
181 </div>
182
183 <hr>
184
185 <fieldset class="wplng-flex-row">
186
187 <div class="wplng-flex-item">
188 <label for="wplng_flags_style">
189 <strong><?php esc_html_e( 'Flags style: ', 'wplingua' ); ?></strong>
190 </label>
191 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-flags-style"></span>
192 </div>
193
194 <div class="wplng-flex-item">
195 <select id="wplng_flags_style" name="wplng_flags_style" class="wplng-width-full">
196 <?php
197
198 $flags_style_options = wplng_data_switcher_valid_flags_style();
199
200 foreach ( $flags_style_options as $option_value => $option_name ) {
201 if ( $flags_style === $option_value ) {
202 echo '<option value="' . esc_attr( $option_value ) . '" selected>';
203 } else {
204 echo '<option value="' . esc_attr( $option_value ) . '">';
205 }
206 echo esc_html( $option_name );
207 echo '</option>';
208 }
209
210 ?>
211 </select>
212 </div>
213 </fieldset>
214
215 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-flags-style">
216 <p><?php esc_html_e( 'This option allow you to choose the appearance of the flags in the switcher. ', 'wplingua' ); ?></p>
217
218 <hr>
219
220 <ul>
221 <li>
222 <strong><?php esc_html_e( 'Circle: ', 'wplingua' ); ?></strong>
223 <?php esc_html_e( 'display round flags.', 'wplingua' ); ?>
224 </li>
225 <li>
226 <strong><?php esc_html_e( 'Rectangular: ', 'wplingua' ); ?></strong>
227 <?php esc_html_e( 'display rectangular flags.', 'wplingua' ); ?>
228 </li>
229 <li>
230 <strong><?php esc_html_e( 'Wave: ', 'wplingua' ); ?></strong>
231 <?php esc_html_e( 'display wavy flags.', 'wplingua' ); ?>
232 </li>
233 <li>
234 <strong><?php esc_html_e( 'No display: ', 'wplingua' ); ?></strong>
235 <?php esc_html_e( 'no display any flags, only the language name will be displayed.', 'wplingua' ); ?>
236 </li>
237 </ul>
238
239 <hr>
240
241 <p><?php esc_html_e( 'You can also change the country flag or set a custom flag from wpLingua ➔ General settings. For example, you can set the flag of Mexico for Spanish instead of the flag of Spain.', 'wplingua' ); ?></p>
242
243 </div>
244
245 <hr>
246
247 <fieldset class="wplng-flex-row">
248
249 <div class="wplng-flex-item">
250 <label for="wplng_theme">
251 <strong><?php esc_html_e( 'Color theme: ', 'wplingua' ); ?></strong>
252 </label>
253 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-theme"></span>
254 </div>
255
256 <div class="wplng-flex-item">
257 <select id="wplng_theme" name="wplng_theme" class="wplng-width-full">
258 <?php
259
260 $theme_options = wplng_data_switcher_valid_theme();
261
262 foreach ( $theme_options as $option_value => $option_name ) {
263 if ( $theme === $option_value ) {
264 echo '<option value="' . esc_attr( $option_value ) . '" selected>';
265 } else {
266 echo '<option value="' . esc_attr( $option_value ) . '">';
267 }
268 echo esc_html( $option_name );
269 echo '</option>';
270 }
271
272 ?>
273 </select>
274 </div>
275 </fieldset>
276
277 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-theme">
278 <p>
279 <?php esc_html_e( 'This option allows you to choose the color and border styles of the languages switcher.', 'wplingua' ); ?>
280 </p>
281
282 <hr>
283
284 <p>
285 <?php esc_html_e( 'The color options offer 5 themes: ', 'wplingua' ); ?>
286 </p>
287
288 <ul>
289 <li>
290 <strong><?php esc_html_e( 'Light: ', 'wplingua' ); ?></strong>
291 <?php esc_html_e( 'white color in the background of the switcher.', 'wplingua' ); ?>
292 </li>
293 <li>
294 <strong><?php esc_html_e( 'Grey: ', 'wplingua' ); ?></strong>
295 <?php esc_html_e( 'grey background color.', 'wplingua' ); ?>
296 </li>
297 <li>
298 <strong><?php esc_html_e( 'Dark: ', 'wplingua' ); ?></strong>
299 <?php esc_html_e( 'black background color.', 'wplingua' ); ?>
300 </li>
301 <li>
302 <strong><?php esc_html_e( 'Blur Black: ', 'wplingua' ); ?></strong>
303 <?php esc_html_e( 'transparent and blurred background color with black text and borders.', 'wplingua' ); ?>
304 </li>
305 <li>
306 <strong><?php esc_html_e( 'Blur White: ', 'wplingua' ); ?></strong>
307 <?php esc_html_e( 'transparent and blurred background color with white text and borders.', 'wplingua' ); ?>
308 </li>
309 </ul>
310
311 <hr>
312
313 <p>
314 <?php esc_html_e( 'Each theme is then broken down by shape and border style:', 'wplingua' ); ?>
315 </p>
316
317 <ul>
318 <li>
319 <strong><?php esc_html_e( 'Double – Smooth: ', 'wplingua' ); ?></strong>
320 <?php esc_html_e( 'the switcher will be framed by a double border with rounded corners.', 'wplingua' ); ?>
321 </li>
322 <li>
323 <strong><?php esc_html_e( 'Double – Square: ', 'wplingua' ); ?></strong>
324 <?php esc_html_e( 'double border with square corners.', 'wplingua' ); ?>
325 </li>
326 <li>
327 <strong><?php esc_html_e( 'Simple – Smooth: ', 'wplingua' ); ?></strong>
328 <?php esc_html_e( 'single border with rounded corners.', 'wplingua' ); ?>
329 </li>
330 <li>
331 <strong><?php esc_html_e( 'Simple – Square: ', 'wplingua' ); ?></strong>
332 <?php esc_html_e( 'single border with square corners.', 'wplingua' ); ?>
333 </li>
334 </ul>
335
336 </div>
337
338 </td>
339 </tr>
340
341 <tr>
342 <th scope="row"><span class="dashicons dashicons-media-code"></span> <?php esc_html_e( 'Custom CSS', 'wplingua' ); ?></th>
343 <td>
344 <p><strong><?php esc_html_e( 'Set custom CSS: ', 'wplingua' ); ?></strong></p>
345 <hr>
346 <p>
347 <?php esc_html_e( 'The field below allows you to add custom CSS code that will run on all pages.', 'wplingua' ); ?>
348 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-css"></span>
349 </p>
350 <div class="wplng-help-box" id="wplng-hb-css">
351 <p>
352 <?php echo wp_kses( __( 'First of all, note that the CSS class <code>.switcher-content</code> allows you to act on the entire block of the language switcher while the class <code>.wplng-langague</code> allows you to act on the languages ​​themselves.', 'wplingua' ), array( 'code' => array() ) ); ?>
353 </p>
354
355 <?php
356 echo '<pre>';
357 echo '.wplng-switcher.theme-light-double-square .switcher-content {' . PHP_EOL;
358 echo ' background-color: #5e33d9;' . PHP_EOL;
359 echo ' border: 1px solid #5e33d9;' . PHP_EOL;
360 echo '}';
361 echo '</pre>';
362 ?>
363
364 <hr>
365
366 <p>
367 <?php esc_html_e( 'To change the background and border colors of languages, here is the CSS:', 'wplingua' ); ?>
368 </p>
369
370 <?php
371 echo '<pre>';
372 echo '.wplng-switcher.theme-light-double-square .switcher-content .wplng-language {' . PHP_EOL;
373 echo ' border: 1px solid #5e33d9;' . PHP_EOL;
374 echo ' color: #5e33d9;' . PHP_EOL;
375 echo '}';
376 echo '</pre>';
377 ?>
378
379 <hr>
380
381 <p>
382 <a href="https://wplingua.com/documentation/user/how-to-customize-the-language-switcher/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'More example on wplingua.com', 'wplingua' ); ?></a>
383 </p>
384 </div>
385
386 <fieldset>
387 <textarea name="wplng_custom_css" id="wplng_custom_css" spellcheck="false"><?php echo esc_textarea( $custom_css ); ?></textarea>
388 </fieldset>
389 </td>
390 </tr>
391
392 <tr>
393 <th scope="row"><span class="dashicons dashicons-admin-post"></span> <?php esc_html_e( 'Insertion', 'wplingua' ); ?></th>
394 <td class="wplng-flex-container">
395
396 <fieldset class="wplng-flex-row">
397
398 <div class="wplng-flex-item">
399 <p>
400 <label for="wplng_insert">
401 <strong><?php esc_html_e( 'Automatic insert: ', 'wplingua' ); ?></strong>
402 </label>
403 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-insert-automatic"></span>
404 </p>
405 </div>
406
407 <div class="wplng-flex-item">
408 <select id="wplng_insert" name="wplng_insert" class="wplng-width-full">
409 <?php
410
411 $insert_options = wplng_data_switcher_valid_insert();
412
413 foreach ( $insert_options as $option_value => $option_name ) {
414 if ( $insert === $option_value ) {
415 echo '<option value="' . esc_attr( $option_value ) . '" selected>';
416 } else {
417 echo '<option value="' . esc_attr( $option_value ) . '">';
418 }
419 echo esc_html( $option_name );
420 echo '</option>';
421 }
422
423 ?>
424 </select>
425 </div>
426
427 </fieldset>
428
429 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-insert-automatic">
430 <p><?php esc_html_e( 'Choose a predefined location: ', 'wplingua' ); ?></p>
431
432 <ul>
433 <li>
434 <strong><?php esc_html_e( 'Bottom right: ', 'wplingua' ); ?></strong>
435 <?php esc_html_e( 'the switcher is placed at the bottom right of the screen.', 'wplingua' ); ?>
436 </li>
437 <li>
438 <strong><?php esc_html_e( 'Bottom Center: ', 'wplingua' ); ?></strong>
439 <?php esc_html_e( 'bottom center of the screen.', 'wplingua' ); ?>
440 </li>
441 <li>
442 <strong><?php esc_html_e( 'Bottom left: ', 'wplingua' ); ?></strong>
443 <?php esc_html_e( 'bottom left of the screen.', 'wplingua' ); ?>
444 </li>
445 <li>
446 <strong><?php esc_html_e( 'None: ', 'wplingua' ); ?></strong>
447 <?php esc_html_e( 'the switcher is not inserted automatically.', 'wplingua' ); ?>
448 </li>
449 </ul>
450
451 </div>
452
453 <hr>
454
455 <fieldset class="wplng-flex-row">
456
457 <div class="wplng-flex-item">
458 <p>
459 <strong><?php esc_html_e( 'Shortcode switcher: ', 'wplingua' ); ?></strong>
460 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-insert-shortcode"></span>
461 </p>
462 </div>
463
464 <div class="wplng-flex-item">
465 <code class="wplng-width-full wplng-tag-code">[wplng_switcher]</code>
466 </div>
467
468 </fieldset>
469
470 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-insert-shortcode">
471 <p><?php esc_html_e( 'If you want to insert the language switcher only in certain places on your website, you can use the shortcode provided for this purpose. Note that in this case, the previous option should be "None". This method is ideal for placing the switcher where you want it, whether you are using a Gutenberg block-based theme (FSE), a classic theme or even a page or theme builder like Divi, Elementor...', 'wplingua' ); ?></p>
472 <hr>
473 <p><?php esc_html_e( 'You can add parameters to the language selector shortcode, for example: ', 'wplingua' ); ?></p>
474 <pre>[wplng_switcher style="dropdown" theme="dark-simple-smooth"]</pre>
475 <hr>
476 <p><?php esc_html_e( 'Here is a list of all available settings: ', 'wplingua' ); ?></p>
477 <pre>[wplng_switcher style="list|block|dropdown" flags="circle|rectangular|wave|none" title="original|name|id|none" class="you-css-class" theme="light-double-smooth|light-double-square|light-simple-smooth|light-simple-square|grey-double-smooth|grey-double-square|grey-simple-smooth|grey-simple-square|dark-double-smooth|dark-double-square|dark-simple-smooth|dark-simple-square|blurblack-double-smooth|blurblack-double-square|blurblack-simple-smooth|blurblack-simple-square|blurwhite-double-smooth|blurwhite-double-square|blurwhite-simple-smooth|blurwhite-simple-square"]</pre>
478 <hr>
479 <p><?php esc_html_e( 'If a setting is not specified, the value entered on the language switcher options page will be used.', 'wplingua' ); ?></p>
480 </div>
481
482 <hr>
483
484 <div class="wplng-flex-row">
485
486 <div class="wplng-flex-item">
487 <p>
488 <strong><?php esc_html_e( 'Gutenberg & FSE: ', 'wplingua' ); ?></strong>
489 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-insert-block"></span>
490 </p>
491 </div>
492
493 <div class="wplng-flex-item">
494 <p><?php esc_html_e( 'Block wpLingua Switcher', 'wplingua' ); ?></p>
495 </div>
496
497 </div>
498
499 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-insert-block">
500 <p><?php esc_html_e( 'Block based themes, wpLingua offers a dedicated Gutenberg block. You can insert the switcher wherever you want, whether in the content or via the overall site editor.', 'wplingua' ); ?></p>
501 </div>
502
503 <hr>
504
505 <div class="wplng-flex-row">
506
507 <div class="wplng-flex-item">
508 <p>
509 <strong><?php esc_html_e( 'Switcher in menu: ', 'wplingua' ); ?> </strong>
510 <span title="<?php esc_attr_e( 'Click to expand', 'wplingua' ); ?>" wplng-help-box="#wplng-hb-insert-menu"></span>
511 </p>
512 </div>
513
514 <div class="wplng-flex-item">
515 <p>
516 <?php
517
518 $support_menus = ! empty( get_nav_menu_locations() );
519
520 if ( $support_menus ) {
521 echo '<a';
522 echo ' href="' . esc_url( get_admin_url() . 'nav-menus.php' ) . '"';
523 echo ' target="_blank"';
524 echo ' rel="noopener noreferrer"';
525 echo '>';
526 }
527
528 esc_html_e( 'Appearance ➔ Menus', 'wplingua' );
529
530 if ( $support_menus ) {
531 echo '</a>';
532 }
533
534 ?>
535 </p>
536 </div>
537
538 </div>
539
540 <div class="wplng-help-box wplng-spacing-top" id="wplng-hb-insert-menu">
541 <p><?php esc_html_e( 'If the active theme manages menus (classic theme), it is possible to add a language switcher. The design of these language switchers will be defined by the theme. Go to the Appearance ➔ Menu tab to add the wpLingua switcher as a menu item. It is also possible to add it as a sub-element.', 'wplingua' ); ?></p>
542 </div>
543
544 </td>
545 </tr>
546 <tr class="wplng-tr-submit">
547 <th scope="row"><span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Save', 'wplingua' ); ?></th>
548 <td>
549 <?php submit_button(); ?>
550 </td>
551 </tr>
552 </table>
553 </form>
554 </div>
555 <?php
556 }
557
558
559 /**
560 * Print HTML subsection of Option page : wpLingua Switcher - Flags style
561 *
562 * @param string $old_flags_style Flag URL
563 * @param string $new_flags_style Flag URL
564 * @return void
565 */
566 function wplng_options_switcher_update_flags_style( $old_flags_style, $new_flags_style ) {
567
568 if ( $old_flags_style === $new_flags_style ) {
569 return;
570 }
571
572 if ( 'none' === $new_flags_style ) {
573 $new_flags_style = 'rectangular';
574 }
575
576 if ( 'none' === $old_flags_style ) {
577 $old_flags_style = 'rectangular';
578 }
579
580 /**
581 * Replace flag URL for website language
582 */
583
584 $website_flag = wplng_get_language_website_flag();
585
586 $website_flag = str_replace(
587 '/wplingua/assets/images/' . $old_flags_style . '/',
588 '/wplingua/assets/images/' . $new_flags_style . '/',
589 $website_flag
590 );
591
592 $website_flag = sanitize_url( $website_flag );
593
594 update_option( 'wplng_website_flag', $website_flag );
595
596 /**
597 * Replace flag URL for target languages
598 */
599
600 $target_languages_json = get_option( 'wplng_target_languages' );
601
602 if ( empty( $target_languages_json ) ) {
603 return;
604 }
605
606 $target_languages = json_decode(
607 $target_languages_json,
608 true
609 );
610
611 if ( empty( $target_languages ) || ! is_array( $target_languages ) ) {
612 return;
613 }
614
615 foreach ( $target_languages as $key => $target_language ) {
616 if ( ! empty( $target_language['flag'] )
617 && is_string( $target_language['flag'] )
618 ) {
619
620 $old_src = sanitize_url( $target_language['flag'] );
621
622 $new_src = str_replace(
623 '/' . $old_flags_style . '/',
624 '/' . $new_flags_style . '/',
625 $old_src
626 );
627
628 $new_src = sanitize_url( $new_src );
629
630 $target_languages[ $key ]['flag'] = $new_src;
631 }
632 }
633
634 update_option(
635 'wplng_target_languages',
636 wp_json_encode(
637 $target_languages,
638 JSON_UNESCAPED_SLASHES
639 )
640 );
641 }
642