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 / dom / replace-attr-lang.php

replace-attr-lang.php in Translate and Go multilingual – Automatic AI translation – wpLingua 2.13.1, at inc/dom/replace-attr-lang.php

45 lines 822 B
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 * Modify the lang attribute in dom for translated pages
11 *
12 * @param object $dom
13 * @param array $args
14 * @return object
15 */
16 function wplng_dom_replace_attr_lang( $dom, $args ) {
17
18 wplng_args_setup( $args );
19
20 /**
21 * Replace languages IDs in attributes
22 */
23
24 $attr_lang_id_to_replace = wplng_data_attr_lang_id_to_replace();
25
26 foreach ( $attr_lang_id_to_replace as $attr ) {
27 foreach ( $dom->find( $attr['selector'] ) as $element ) {
28
29 if ( empty( $element->attr[ $attr['attr'] ] ) ) {
30 continue;
31 }
32
33 $lang_id = $element->attr[ $attr['attr'] ];
34
35 if ( ! wplng_str_is_locale_id( $lang_id ) ) {
36 continue;
37 }
38
39 $element->attr[ $attr['attr'] ] = esc_attr( $args['language_target'] );
40 }
41 }
42
43 return $dom;
44 }
45