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/translator/html.php +97 -97 2.16.02.16.8 View file →
@@ -1,97 +1,97 @@
1 -<?php
2 -
3 -// If this file is called directly, abort.
4 -if ( ! defined( 'WPINC' ) ) {
5 - die;
6 -}
7 -
8 -
9 -/**
10 - * wpLingua translate : Get translated HTML
11 - *
12 - * @param string $html
13 - * @param array $args
14 - * @return string
15 - */
16 -function wplng_translate_html( $html, $args = array() ) {
17 -
18 - if ( empty( $html ) ) {
19 - return $html;
20 - }
21 -
22 - /**
23 - * Create the dom element
24 - */
25 -
26 - $dom = wplng_sdh_str_get_html( $html );
27 -
28 - if ( empty( $dom ) ) {
29 - return $html;
30 - }
31 -
32 - /**
33 - * Replace excluded HTML part by tag
34 - */
35 -
36 - $excluded_elements = array();
37 -
38 - $dom = wplng_dom_exclusions_put_tags( $dom, $excluded_elements );
39 -
40 - /**
41 - * Update args and get all texts in HTML if needed
42 - */
43 -
44 - wplng_args_setup( $args );
45 -
46 - if ( empty( $args['translations'] ) ) {
47 - $texts = wplng_parse_html( $dom );
48 - wplng_args_update_from_texts( $args, $texts );
49 - }
50 -
51 - /**
52 - * Update the dom
53 - */
54 -
55 - // Setup translated page (dir, attribute lang, class, links)
56 - $dom = wplng_dom_replace_attr_dir( $dom, $args );
57 - $dom = wplng_dom_replace_attr_lang( $dom, $args );
58 - $dom = wplng_dom_replace_body_class( $dom, $args );
59 - $dom = wplng_dom_replace_links( $dom, $args );
60 -
61 - // Translate texts
62 - $dom = wplng_dom_translate_nodes_texts( $dom, $args );
63 - $dom = wplng_dom_translate_attr_texts( $dom, $args );
64 -
65 - // Translate HTML, JS and JSON
66 - $dom = wplng_dom_translate_html_attr( $dom, $args );
67 - $dom = wplng_dom_translate_json_attr( $dom, $args );
68 - $dom = wplng_dom_translate_script( $dom, $args );
69 -
70 - // Load editor or list mode if needed
71 - $dom = wplng_dom_mode_editor( $dom, $args );
72 - $dom = wplng_dom_mode_list( $dom, $args );
73 -
74 - // Load bar if needed (progress or overload)
75 - $dom = wplng_dom_load_progress( $dom, $args );
76 - $dom = wplng_dom_load_overload( $dom, $args );
77 -
78 - /**
79 - * Replace exclude tags by HTML
80 - */
81 -
82 - $dom = wplng_dom_exclusions_replace_tags( $dom, $excluded_elements );
83 -
84 - /**
85 - * Dom is ready: check, apply filter and return
86 - */
87 -
88 - $html = $dom->save();
89 -
90 - $html = str_replace( '_wplingua_no_translate_', '', $html );
91 -
92 - if ( empty( $html ) ) {
93 - return '';
94 - }
95 -
96 - return $html;
97 -}
1 +<?php
2 +
3 +// If this file is called directly, abort.
4 +if ( ! defined( 'WPINC' ) ) {
5 + die;
6 +}
7 +
8 +
9 +/**
10 + * wpLingua translate : Get translated HTML
11 + *
12 + * @param string $html
13 + * @param array $args
14 + * @return string
15 + */
16 +function wplng_translate_html( $html, $args = array() ) {
17 +
18 + if ( empty( $html ) ) {
19 + return $html;
20 + }
21 +
22 + /**
23 + * Create the dom element
24 + */
25 +
26 + $dom = wplng_sdh_str_get_html( $html );
27 +
28 + if ( empty( $dom ) ) {
29 + return $html;
30 + }
31 +
32 + /**
33 + * Replace excluded HTML part by tag
34 + */
35 +
36 + $excluded_elements = array();
37 +
38 + $dom = wplng_dom_exclusions_put_tags( $dom, $excluded_elements );
39 +
40 + /**
41 + * Update args and get all texts in HTML if needed
42 + */
43 +
44 + wplng_args_setup( $args );
45 +
46 + if ( empty( $args['translations'] ) ) {
47 + $texts = wplng_parse_html( $dom );
48 + wplng_args_update_from_texts( $args, $texts );
49 + }
50 +
51 + /**
52 + * Update the dom
53 + */
54 +
55 + // Setup translated page (dir, attribute lang, class, links)
56 + $dom = wplng_dom_replace_attr_dir( $dom, $args );
57 + $dom = wplng_dom_replace_attr_lang( $dom, $args );
58 + $dom = wplng_dom_replace_body_class( $dom, $args );
59 + $dom = wplng_dom_replace_links( $dom, $args );
60 +
61 + // Translate texts
62 + $dom = wplng_dom_translate_nodes_texts( $dom, $args );
63 + $dom = wplng_dom_translate_attr_texts( $dom, $args );
64 +
65 + // Translate HTML, JS and JSON
66 + $dom = wplng_dom_translate_html_attr( $dom, $args );
67 + $dom = wplng_dom_translate_json_attr( $dom, $args );
68 + $dom = wplng_dom_translate_script( $dom, $args );
69 +
70 + // Load editor or list mode if needed
71 + $dom = wplng_dom_mode_editor( $dom, $args );
72 + $dom = wplng_dom_mode_list( $dom, $args );
73 +
74 + // Load bar if needed (progress or overload)
75 + $dom = wplng_dom_load_progress( $dom, $args );
76 + $dom = wplng_dom_load_overload( $dom, $args );
77 +
78 + /**
79 + * Replace exclude tags by HTML
80 + */
81 +
82 + $dom = wplng_dom_exclusions_replace_tags( $dom, $excluded_elements );
83 +
84 + /**
85 + * Dom is ready: check, apply filter and return
86 + */
87 +
88 + $html = $dom->save();
89 +
90 + $html = str_replace( '_wplingua_no_translate_', '', $html );
91 +
92 + if ( empty( $html ) ) {
93 + return '';
94 + }
95 +
96 + return $html;
97 +}