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

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