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/clone/wp-conte.../plugins/wordpres.../src/helpers/schema
File: html-helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Helpers\Schema;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Class HTML_Helper.
[5] Fix | Delete
*/
[6] Fix | Delete
class HTML_Helper {
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Sanitizes a HTML string by stripping all tags except headings, breaks, lists, links, paragraphs and formatting.
[10] Fix | Delete
*
[11] Fix | Delete
* @param string $html The original HTML.
[12] Fix | Delete
*
[13] Fix | Delete
* @return string The sanitized HTML.
[14] Fix | Delete
*/
[15] Fix | Delete
public function sanitize( $html ) {
[16] Fix | Delete
if ( ! $this->is_non_empty_string_or_stringable( $html ) ) {
[17] Fix | Delete
if ( \is_int( $html ) || \is_float( $html ) ) {
[18] Fix | Delete
return (string) $html;
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
return '';
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
return \strip_tags( $html, '<h1><h2><h3><h4><h5><h6><br><ol><ul><li><a><p><b><strong><i><em>' );
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Strips the tags in a smart way.
[29] Fix | Delete
*
[30] Fix | Delete
* @param string $html The original HTML.
[31] Fix | Delete
*
[32] Fix | Delete
* @return string The sanitized HTML.
[33] Fix | Delete
*/
[34] Fix | Delete
public function smart_strip_tags( $html ) {
[35] Fix | Delete
if ( ! $this->is_non_empty_string_or_stringable( $html ) ) {
[36] Fix | Delete
if ( \is_int( $html ) || \is_float( $html ) ) {
[37] Fix | Delete
return (string) $html;
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
return '';
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
// Replace all new lines with spaces.
[44] Fix | Delete
$html = \preg_replace( '/(\r|\n)/', ' ', $html );
[45] Fix | Delete
[46] Fix | Delete
// Replace <br> tags with spaces.
[47] Fix | Delete
$html = \preg_replace( '/<br(\s*)?\/?>/i', ' ', $html );
[48] Fix | Delete
[49] Fix | Delete
// Replace closing </p> and other tags with the same tag with a space after it, so we don't end up connecting words when we remove them later.
[50] Fix | Delete
$html = \preg_replace( '/<\/(p|div|h\d)>/i', '</$1> ', $html );
[51] Fix | Delete
[52] Fix | Delete
// Replace list items with list identifiers so it still looks natural.
[53] Fix | Delete
$html = \preg_replace( '/(<li[^>]*>)/i', '$1• ', $html );
[54] Fix | Delete
[55] Fix | Delete
// Strip tags.
[56] Fix | Delete
$html = \wp_strip_all_tags( $html );
[57] Fix | Delete
[58] Fix | Delete
// Replace multiple spaces with one space.
[59] Fix | Delete
$html = \preg_replace( '!\s+!', ' ', $html );
[60] Fix | Delete
[61] Fix | Delete
return \trim( $html );
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Verifies that the received input is either a string or stringable object.
[66] Fix | Delete
*
[67] Fix | Delete
* @param string $html The original HTML.
[68] Fix | Delete
*
[69] Fix | Delete
* @return bool
[70] Fix | Delete
*/
[71] Fix | Delete
private function is_non_empty_string_or_stringable( $html ) {
[72] Fix | Delete
return ( \is_string( $html ) || ( \is_object( $html ) && \method_exists( $html, '__toString' ) ) ) && ! empty( $html );
[73] Fix | Delete
}
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function