diff --git a/.changelogs/fix_mb_convert_encoding.yml b/.changelogs/fix_mb_convert_encoding.yml new file mode 100644 index 0000000000..10c2614e32 --- /dev/null +++ b/.changelogs/fix_mb_convert_encoding.yml @@ -0,0 +1,5 @@ +significance: minor +type: fixed +links: + - "#2672" +entry: Removes use of deprecated mb_convert_encoding(). diff --git a/includes/class-llms-dom-document.php b/includes/class-llms-dom-document.php index d47f0719cf..8f54e64d78 100644 --- a/includes/class-llms-dom-document.php +++ b/includes/class-llms-dom-document.php @@ -126,14 +126,16 @@ public function dom() { } /** - * Load the HTML string in the DOMDocument using mb_convert_econding + * Load the HTML string in the DOMDocument using mb_encode_numericentity * * @since 4.13.0 + * @since [version] Use `mb_encode_numericentity()` instead of deprecated `mb_convert_encoding()` with 'HTML-ENTITIES'. * * @return void */ private function load_with_mb_convert_encoding() { - if ( ! $this->dom->loadHTML( mb_convert_encoding( $this->source, 'HTML-ENTITIES', 'UTF-8' ) ) ) { + $html = mb_encode_numericentity( $this->source, array( 0x80, 0x10FFFF, 0, 0x1FFFFF ), 'UTF-8' ); + if ( ! $this->dom->loadHTML( $html ) ) { $this->error = new WP_Error( 'llms-dom-document-error', __( 'DOMDocument XML Error encountered.', 'lifterlms' ), libxml_get_errors() ); } }