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

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

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