| @@ -1,54 +1,54 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -// If this file is called directly, abort. | |
| 4 | -if ( ! defined( 'WPINC' ) ) { | |
| 5 | - die; | |
| 6 | -} | |
| 7 | - | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * Translate HTML in attributes in dom for translated pages | |
| 11 | - * | |
| 12 | - * @param object $dom | |
| 13 | - * @param array $args | |
| 14 | - * @return object | |
| 15 | - */ | |
| 16 | -function wplng_dom_translate_html_attr( $dom, $args ) { | |
| 17 | - | |
| 18 | - wplng_args_setup( $args ); | |
| 19 | - | |
| 20 | - if ( empty( $args['translations'] ) ) { | |
| 21 | - return $dom; | |
| 22 | - } | |
| 23 | - | |
| 24 | - $attr_html_to_translate = wplng_data_attr_html_to_translate(); | |
| 25 | - | |
| 26 | - foreach ( $attr_html_to_translate as $attr ) { | |
| 27 | - foreach ( $dom->find( $attr['selector'] ) as $element ) { | |
| 28 | - | |
| 29 | - if ( empty( $element->attr[ $attr['attr'] ] ) ) { | |
| 30 | - continue; | |
| 31 | - } | |
| 32 | - | |
| 33 | - $html = wplng_text_esc( $element->attr[ $attr['attr'] ] ); | |
| 34 | - | |
| 35 | - if ( empty( $html ) ) { | |
| 36 | - continue; | |
| 37 | - } | |
| 38 | - | |
| 39 | - $html = wp_specialchars_decode( | |
| 40 | - $html, | |
| 41 | - ENT_QUOTES | ENT_HTML5 | |
| 42 | - ); | |
| 43 | - | |
| 44 | - $html = wplng_translate_html( | |
| 45 | - $html, | |
| 46 | - $args | |
| 47 | - ); | |
| 48 | - | |
| 49 | - $element->attr[ $attr['attr'] ] = esc_attr( $html ); | |
| 50 | - } | |
| 51 | - } | |
| 52 | - | |
| 53 | - return $dom; | |
| 54 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +// If this file is called directly, abort. | |
| 4 | +if ( ! defined( 'WPINC' ) ) { | |
| 5 | + die; | |
| 6 | +} | |
| 7 | + | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * Translate HTML in attributes in dom for translated pages | |
| 11 | + * | |
| 12 | + * @param object $dom | |
| 13 | + * @param array $args | |
| 14 | + * @return object | |
| 15 | + */ | |
| 16 | +function wplng_dom_translate_html_attr( $dom, $args ) { | |
| 17 | + | |
| 18 | + wplng_args_setup( $args ); | |
| 19 | + | |
| 20 | + if ( empty( $args['translations'] ) ) { | |
| 21 | + return $dom; | |
| 22 | + } | |
| 23 | + | |
| 24 | + $attr_html_to_translate = wplng_data_attr_html_to_translate(); | |
| 25 | + | |
| 26 | + foreach ( $attr_html_to_translate as $attr ) { | |
| 27 | + foreach ( $dom->find( $attr['selector'] ) as $element ) { | |
| 28 | + | |
| 29 | + if ( empty( $element->attr[ $attr['attr'] ] ) ) { | |
| 30 | + continue; | |
| 31 | + } | |
| 32 | + | |
| 33 | + $html = wplng_text_esc( $element->attr[ $attr['attr'] ] ); | |
| 34 | + | |
| 35 | + if ( empty( $html ) ) { | |
| 36 | + continue; | |
| 37 | + } | |
| 38 | + | |
| 39 | + $html = wp_specialchars_decode( | |
| 40 | + $html, | |
| 41 | + ENT_QUOTES | ENT_HTML5 | |
| 42 | + ); | |
| 43 | + | |
| 44 | + $html = wplng_translate_html( | |
| 45 | + $html, | |
| 46 | + $args | |
| 47 | + ); | |
| 48 | + | |
| 49 | + $element->attr[ $attr['attr'] ] = esc_attr( $html ); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + return $dom; | |
| 54 | +} | |