Current path: home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d4/app/Handlers/
?? Go up: /home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d4/app
<?php
namespace KS_PAC_DCFH\Handlers;
use DOMDocument;
if (!defined('ABSPATH')) {
exit;
}
class DOM_Handler
{
private static $_instance;
public static function instance(): self
{
if (self::$_instance === null) {
self::$_instance = new self();
}
return self::$_instance;
}
public static function dom($html): DOMDocument
{
$charset = 'utf-8';
$dom = new DOMDocument('1.0', $charset);
libxml_use_internal_errors(true);
if (function_exists('mb_encode_numericentity')) {
$html = mb_encode_numericentity($html, [0x80, 0x10FFFF, 0, 0x1FFFFF], $charset);
} elseif (function_exists('mb_convert_encoding')) {
$html = mb_convert_encoding($html, 'HTML-ENTITIES', $charset);
} else {
//$html = htmlentities($html, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
if (!seems_utf8($html)) {
$html = utf8_encode($html);
}
}
$dom->loadHTML($html, LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
libxml_clear_errors();
return $dom;
}
}