PluginProbe
Translate and boost SEO – Automatic AI translation – wpLingua / 2.16.8
Translate and boost SEO – Automatic AI translation – wpLingua v2.16.8
2.16.8 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 All 113 releases
← All changes | inc/dom/translate-node-texts.php +57 -57 2.16.12.16.8 View file →
@@ -1,57 +1,57 @@
1 -<?php
2 -
3 -// If this file is called directly, abort.
4 -if ( ! defined( 'WPINC' ) ) {
5 - die;
6 -}
7 -
8 -
9 -/**
10 - * Translate nodes text in dom for translated pages
11 - *
12 - * @param object $dom
13 - * @param array $args
14 - * @return object
15 - */
16 -function wplng_dom_translate_nodes_texts( $dom, $args ) {
17 -
18 - wplng_args_setup( $args );
19 -
20 - if ( empty( $args['translations'] )
21 - || $args['load'] === 'progress'
22 - ) {
23 - return $dom;
24 - }
25 -
26 - $selector = 'text';
27 -
28 - if ( $args['mode'] === 'editor'
29 - || $args['mode'] === 'list'
30 - ) {
31 - $selector = 'head text';
32 - }
33 -
34 - $node_text_excluded = wplng_data_excluded_node_text();
35 -
36 - foreach ( $dom->find( $selector ) as $element ) {
37 -
38 - if ( in_array( $element->parent->tag, $node_text_excluded ) ) {
39 - continue;
40 - }
41 -
42 - $text = wplng_text_esc( $element->innertext );
43 -
44 - if ( ! wplng_text_is_translatable( $text ) ) {
45 - continue;
46 - }
47 -
48 - $translated_text = wplng_get_translated_text_from_translations(
49 - $element->innertext,
50 - $args['translations']
51 - );
52 -
53 - $element->innertext = esc_html( $translated_text );
54 - }
55 -
56 - return $dom;
57 -}
1 +<?php
2 +
3 +// If this file is called directly, abort.
4 +if ( ! defined( 'WPINC' ) ) {
5 + die;
6 +}
7 +
8 +
9 +/**
10 + * Translate nodes text in dom for translated pages
11 + *
12 + * @param object $dom
13 + * @param array $args
14 + * @return object
15 + */
16 +function wplng_dom_translate_nodes_texts( $dom, $args ) {
17 +
18 + wplng_args_setup( $args );
19 +
20 + if ( empty( $args['translations'] )
21 + || $args['load'] === 'progress'
22 + ) {
23 + return $dom;
24 + }
25 +
26 + $selector = 'text';
27 +
28 + if ( $args['mode'] === 'editor'
29 + || $args['mode'] === 'list'
30 + ) {
31 + $selector = 'head text';
32 + }
33 +
34 + $node_text_excluded = wplng_data_excluded_node_text();
35 +
36 + foreach ( $dom->find( $selector ) as $element ) {
37 +
38 + if ( in_array( $element->parent->tag, $node_text_excluded ) ) {
39 + continue;
40 + }
41 +
42 + $text = wplng_text_esc( $element->innertext );
43 +
44 + if ( ! wplng_text_is_translatable( $text ) ) {
45 + continue;
46 + }
47 +
48 + $translated_text = wplng_get_translated_text_from_translations(
49 + $element->innertext,
50 + $args['translations']
51 + );
52 +
53 + $element->innertext = esc_html( $translated_text );
54 + }
55 +
56 + return $dom;
57 +}