This commit is contained in:
emmymayo
2025-02-05 23:15:46 +01:00
commit 7269c99357
16995 changed files with 3389680 additions and 0 deletions
@@ -0,0 +1,27 @@
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
namespace MailPoet\Util\pQuery;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\pQuery\DomNode as pQueryDomNode;
class DomNode extends pQueryDomNode {
public $childClass = DomNode::class;
public $parserClass = Html5Parser::class;
public function getInnerText() {
return html_entity_decode($this->toString(true, true, 1), ENT_NOQUOTES, 'UTF-8');
}
public function getOuterText() {
return html_entity_decode($this->toString(), ENT_NOQUOTES, 'UTF-8');
}
public function query($query = '*') {
$select = $this->select($query);
$result = new pQuery((array)$select);
return $result;
}
}
@@ -0,0 +1,13 @@
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
namespace MailPoet\Util\pQuery;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\pQuery\Html5Parser as pQueryHtml5Parser;
class Html5Parser extends pQueryHtml5Parser {
/** @var string|DomNode */
public $root = DomNode::class;
}
@@ -0,0 +1 @@
<?php
@@ -0,0 +1,23 @@
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
namespace MailPoet\Util\pQuery;
if (!defined('ABSPATH')) exit;
use MailPoetVendor\pQuery\pQuery as pQuerypQuery;
// extend pQuery class to use UTF-8 encoding when getting elements' inner/outer text
// phpcs:ignore Squiz.Classes.ValidClassName
class pQuery extends pQuerypQuery {
public static function parseStr($html): DomNode {
$parser = new Html5Parser($html);
if (!$parser->root instanceof DomNode) {
// this condition shouldn't happen it is here only for PHPStan
throw new \Exception('Renderer is not configured correctly');
}
return $parser->root;
}
}