mirror of
https://github.com/discourse/wp-discourse.git
synced 2025-10-03 08:59:21 +08:00
Remove html and body tags that are added to the DOM Document
This commit is contained in:
parent
9ff609617e
commit
0a1f7b5580
1 changed files with 6 additions and 1 deletions
|
@ -107,6 +107,11 @@ class TemplateFunctions {
|
|||
// Restore the previous value of libxml_use_internal_errors.
|
||||
libxml_use_internal_errors( $use_internal_errors );
|
||||
|
||||
return $doc->saveHTML( $doc->documentElement );
|
||||
$parsed = $doc->saveHTML( $doc->documentElement );
|
||||
|
||||
// Remove DOCTYPE, html, and body tags that have been added to the DOMDocument.
|
||||
$parsed = preg_replace( '~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $parsed );
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue