wp_strip_all_tags

函数


wp_strip_all_tags ( $string, $remove_breaks = false )
参数
  • (string)
    $string
    String containing HTML tags
    Required:
  • (bool)
    $remove_breaks
    Optional. Whether to remove left over line breaks and white space chars
    Required:
    Default: false
返回值
  • (string) The processed string.
定义位置
  • wp-includes/formatting.php
    , line 5394
引入
2.9.0
弃用

Properly strips all HTML tags including script and style

This differs from strip_tags() because it removes the contents of
the “ and “ tags. E.g. `strip_tags( ‘something’ )`
will return ‘something’. wp_strip_all_tags will return ”

function wp_strip_all_tags( $string, $remove_breaks = false ) {
	$string = preg_replace( '@]*?>.*?1>@si', '', $string );
	$string = strip_tags( $string );

	if ( $remove_breaks ) {
		$string = preg_replace( '/[rnt ]+/', ' ', $string );
	}

	return trim( $string );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。