Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/accelera.../includes/vendor/tool/Dom
File: ElementDump.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace AmpProject\Dom;
[2] Fix | Delete
[3] Fix | Delete
use DOMAttr;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Dump an element with its attributes.
[7] Fix | Delete
*
[8] Fix | Delete
* This is meant for quick identification of an element and does not dump the child element or other inner content
[9] Fix | Delete
* from that element.
[10] Fix | Delete
*
[11] Fix | Delete
* @package ampproject/amp-toolbox
[12] Fix | Delete
*/
[13] Fix | Delete
final class ElementDump
[14] Fix | Delete
{
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Element to dump.
[18] Fix | Delete
*
[19] Fix | Delete
* @var Element
[20] Fix | Delete
*/
[21] Fix | Delete
private $element;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Maximum length to truncate attributes and textContent to.
[25] Fix | Delete
*
[26] Fix | Delete
* Defaults to 120.
[27] Fix | Delete
*
[28] Fix | Delete
* @var int
[29] Fix | Delete
*/
[30] Fix | Delete
private $truncate;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Instantiate an ElementDump object.
[34] Fix | Delete
*
[35] Fix | Delete
* The object is meant to be cast to a string to do its magic.
[36] Fix | Delete
*
[37] Fix | Delete
* @param Element $element Element to dump.
[38] Fix | Delete
* @param int $truncate Optional. Maximum length to truncate attributes and textContent to. Defaults to 120.
[39] Fix | Delete
*/
[40] Fix | Delete
public function __construct(Element $element, $truncate = 120)
[41] Fix | Delete
{
[42] Fix | Delete
$this->element = $element;
[43] Fix | Delete
$this->truncate = $truncate;
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Dump the provided element into a string.
[48] Fix | Delete
*
[49] Fix | Delete
* @return string Dump of the element.
[50] Fix | Delete
*/
[51] Fix | Delete
public function __toString()
[52] Fix | Delete
{
[53] Fix | Delete
$attributes = $this->maybeTruncate(
[54] Fix | Delete
array_reduce(
[55] Fix | Delete
iterator_to_array($this->element->attributes, true),
[56] Fix | Delete
static function ($text, DOMAttr $attribute) {
[57] Fix | Delete
return $text . " {$attribute->nodeName}=\"{$attribute->value}\"";
[58] Fix | Delete
},
[59] Fix | Delete
''
[60] Fix | Delete
)
[61] Fix | Delete
);
[62] Fix | Delete
[63] Fix | Delete
$textContent = $this->maybeTruncate($this->element->textContent);
[64] Fix | Delete
[65] Fix | Delete
return sprintf(
[66] Fix | Delete
'<%1$s%2$s>%3$s</%1$s>',
[67] Fix | Delete
$this->element->tagName,
[68] Fix | Delete
$attributes,
[69] Fix | Delete
$textContent
[70] Fix | Delete
);
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Truncate the provided text if needed.
[75] Fix | Delete
*
[76] Fix | Delete
* @param string $text Text to truncate.
[77] Fix | Delete
* @return string Potentially truncated text.
[78] Fix | Delete
*/
[79] Fix | Delete
private function maybeTruncate($text)
[80] Fix | Delete
{
[81] Fix | Delete
if ($this->truncate <= 0) {
[82] Fix | Delete
return $text;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
// Not checking for both mb_* functions, as we assume that if one mb_* function exists, the extension is
[86] Fix | Delete
// available and all mb_* functions will exist.
[87] Fix | Delete
if (function_exists('mb_strlen')) {
[88] Fix | Delete
if (mb_strlen($text) > $this->truncate) {
[89] Fix | Delete
return mb_substr($text, 0, $this->truncate - 1) . '…';
[90] Fix | Delete
}
[91] Fix | Delete
} elseif (strlen($text) > $this->truncate) {
[92] Fix | Delete
// Fall back to regular string functions, knowing that this might potentially miscalculate and/or split
[93] Fix | Delete
// multi-byte chars. We do so as we assume a site with special character encoding needs will have the
[94] Fix | Delete
// multi-byte extension loaded anyway.
[95] Fix | Delete
return substr($text, 0, $this->truncate - 1) . '…';
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
return $text;
[99] Fix | Delete
}
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function