# wplingua/2.13.0/inc/dom/translate-attr-html.php

Translate and Go multilingual – Automatic AI translation – wpLingua, version 2.13.0. 55 lines.

- Page: https://pluginprobe.com/plugins/wplingua/2.13.0/code/inc/dom/translate-attr-html.php
- Raw: https://pluginprobe.com/plugins/wplingua/2.13.0/raw/inc/dom/translate-attr-html.php
- Modified: 2026-05-21T00:12:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wplingua/2.13.0/code/inc/dom/translate-attr-html.php#L10-L20`.

```php
<?php

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}


/**
 * Translate HTML in attributes in dom for translated pages
 *
 * @param object $dom
 * @param array  $args
 * @return object
 */
function wplng_dom_translate_html_attr( $dom, $args ) {

	wplng_args_setup( $args );

	if ( empty( $args['translations'] ) ) {
		return $dom;
	}

	$attr_html_to_translate = wplng_data_attr_html_to_translate();

	foreach ( $attr_html_to_translate as $attr ) {
		foreach ( $dom->find( $attr['selector'] ) as $element ) {

			if ( empty( $element->attr[ $attr['attr'] ] ) ) {
				continue;
			}

			$html = wplng_text_esc( $element->attr[ $attr['attr'] ] );

			if ( empty( $html ) ) {
				continue;
			}

			$html = wp_specialchars_decode(
				$html,
				ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401
			);

			$html = wplng_translate_html(
				$html,
				$args
			);

			$element->attr[ $attr['attr'] ] = esc_attr( $html );
		}
	}

	return $dom;
}

```
