Yoast\WP\SEO\Helpers\Schema
HTML_Helper::smart_strip_tags()
Strips the tags in a smart way.
Метод класса: HTML_Helper{}
Хуков нет.
Возвращает
Строку
. The sanitized HTML.
Использование
$HTML_Helper = new HTML_Helper(); $HTML_Helper->smart_strip_tags( $html );
- $html(строка) (обязательный)
- The original HTML.
Код HTML_Helper::smart_strip_tags() HTML Helper::smart strip tags Yoast 25.0
public function smart_strip_tags( $html ) { if ( ! $this->is_non_empty_string_or_stringable( $html ) ) { if ( \is_int( $html ) || \is_float( $html ) ) { return (string) $html; } return ''; } // Replace all new lines with spaces. $html = \preg_replace( '/(\r|\n)/', ' ', $html ); // Replace <br> tags with spaces. $html = \preg_replace( '/<br(\s*)?\/?>/i', ' ', $html ); // 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. $html = \preg_replace( '/<\/(p|div|h\d)>/i', '</$1> ', $html ); // Replace list items with list identifiers so it still looks natural. $html = \preg_replace( '/(<li[^>]*>)/i', '$1• ', $html ); // Strip tags. $html = \wp_strip_all_tags( $html ); // Replace multiple spaces with one space. $html = \preg_replace( '!\s+!', ' ', $html ); return \trim( $html ); }